fix: make public cache staging repairable

STO-03: reject at composition any policy that enables Vary variants while
stripping vary from the stored response allowlist, since every stored variant
would collide on the same cache key.

STO-04: extract one verifyReleaseCandidate authority shared by the stage fast
path and activation. A matching release marker is a claim, not evidence, so a
restage now re-verifies each entry, deletes only the owned candidate on a
mismatch and refetches. Abort or an unreadable candidate is never stage success
and never moves the active pointer.

STO-05: split the availability guard. Staging keeps the fetcher requirement
with ONLINE_ONLY recovery; activation, rollback and cleanup need only cache
storage and the mutation lock, so an offline rollback or quota-recovery cleanup
is no longer reported UNSUPPORTED.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-08-13 23:28:22 +09:00
co-authored by Claude Opus 5
parent ba79060a83
commit b893d95b36
5 changed files with 312 additions and 42 deletions
@@ -12,6 +12,26 @@ session/account Query lifecycle, strict query policy와 Web Storage v2 lifecycle
현재 `DESIGNED_NOT_IMPLEMENTED`다. 아래 목표 절차를 현재 runtime의 보장으로
해석하지 않는다.
## Public cache staging repair와 offline activation (STO-03 ~ STO-05)
- release marker는 "staging이 끝났다"는 **주장**이고 모든 entry의 존재·digest
증거가 아니다. 같은 manifest로 `stageRelease`를 다시 호출하면 runtime이
candidate를 재검증하고, browser eviction이나 부분 손상이 발견되면 그 owned
candidate만 삭제한 뒤 network에서 다시 stage한다. marker만 보고 성공을
반환하지 않는다.
- 검증 중 abort나 읽기 불가(UNKNOWN)는 stage 성공이 아니며 active pointer를
건드리지 않는다. candidate를 임의로 삭제하지도 않는다.
- `activateRelease``cleanupOwned`는 network I/O가 없다. fetcher 없이도
동작하므로 offline rollback과 quota recovery cleanup이 `UNSUPPORTED`로 막히지
않는다. 두 operation은 Cache Storage와 mutation lock만 요구하고 실패 시
recovery는 `RETRY`다. `stageRelease`만 fetcher를 요구하며 recovery는
`ONLINE_ONLY`다.
- variant를 사용하는 policy(`allowedVaryHeaderNames` 비어 있지 않음)는 반드시
`allowedResponseHeaderNames``vary`를 포함해야 한다. 아니면 composition이
`TypeError`로 즉시 실패한다. 저장된 variant가 같은 key로 충돌하는 상태를 만들지
않기 위한 cross-field invariant다.
## 1. 변경할 수 없는 복구 원칙
- 서버가 server state와 authorization의 source of truth다.