Commit Graph
10 Commits
Author SHA1 Message Date
DongHyeonka aedd32841f fix(cache-storage): 정책 변경과 손상 뒤에도 다음 배포가 pointer를 덮어쓴다 (0929/02-01)
문제: active pointer를 읽을 때 rollback 목록 길이를 현재
retainedPreviousReleaseCount와 비교한다. 3에서 1로 줄이는 정상 설정
변경이나 pointer JSON 손상 뒤에는 읽기가 CORRUPT_DATA가 되고, 조회·
활성화·정리·inspect가 모두 여기서 멈춘다. control cache를 지우는 API가
없어 사용자가 사이트 데이터를 지우기 전까지 오프라인 캐시가 꺼진 채로
남고, cleanup이 막혀 배포마다 release cache가 쌓인다. 이번 라운드에도
Node와 실제 Cache API 3엔진에서 재현됐다.

고른 방법(지난 리뷰 4.1절의 (나)+(다)):
- (다) isActivePointer는 목록 길이를 현재 값이 아니라 정책이 허용하는
  최댓값(5, MAX_RETAINED_PREVIOUS_RELEASE_COUNT)과만 비교한다. 정책
  검증과 같은 상수를 쓴다. 다음 activation이 이미 하던 slice로 목록을
  현재 값으로 자른다.
- (나) activateRelease는 이전 pointer 읽기가 CORRUPT_DATA면 없는
  것으로 보고, 전체 재검증을 통과한 후보로 rollback 목록 없이
  덮어쓴다. 일시 오류(UNAVAILABLE 등)는 지금처럼 활성화를 멈춘다.

버린 대안:
- 현상 유지 + "사이트 데이터 삭제" 안내. 운영자가 원인을 알 수 없고
  캐시가 계속 쌓인다.
- control을 지우는 admin API. 포트가 늘고 호출자가 언제 불러야 하는지
  알아야 한다.
- (다)만 적용. 정책 변경은 풀리지만 JSON 손상은 풀리지 않는다.

위험·한계:
- 지키던 성질은 그대로다. 검증한 후보만 활성화하고(재검증은 pointer
  읽기 전에 끝난다), 조회는 manifest digest가 맞는 바이트만 돌려준다.
  읽을 수 있는 pointer가 가리키는 캐시는 cleanup이 지우지 않는다.
  손상 pointer 상태의 조회와 cleanup은 다음 activation까지 여전히
  CORRUPT_DATA다.
- 덮어쓰면 손상 pointer의 rollback 목록을 잃는다. 원래 읽을 수 없던
  값이다. 덮어쓴 뒤 cleanup이 구버전 탭이 쓰던 캐시를 지울 수 있다.
  그 탭의 조회는 네트워크로 떨어진다. Service Worker drain(VD-15)을
  구현하면 이 규칙을 다시 본다(지난 리뷰 4.1절 7).
- 리뷰가 "가능하면"으로 적은 3엔진 browser spec(E-2)은 추가하지
  않았다. 단위 테스트(MemoryCacheStorage)로만 확인했다.
- service-worker-pwa 레시피 번들 9,665 → 9,716 / 10,000 gzip bytes.

검증:
- RED(수정 전): public-response-cache-repair.test.ts 새 2건 실패.
  retained 3 → 1 뒤 조회가 { ok: false }(기대 ok:true), 잘린 pointer
  뒤 다음 배포의 activate가 { ok: false }.
- GREEN: 같은 파일 8건 통과. 일시 오류 가드 테스트 1건을 함께 넣었다.
  activate가 모든 pointer 실패를 무시하도록 바꾼 변이를 이 테스트가
  잡는다(1건 실패 확인 뒤 되돌림).
- 회귀: public-response-cache 단위 3파일 40건 통과. tsc app·test·
  service-worker·recipes 통과. 바꾼 파일 eslint 통과.
  verify-documentation-readiness PASS_SCOPED. check-optional-recipes
  (source) PASS.

Refs: docs/reviews/2026-09-29-maturity-review/02-adapters-browser-files-cache.md
2026-11-01 23:14:48 +09:00
DongHyeonka 8ad11c0b64 fix(browser-files): preview와 download의 dispose가 자기 lease만 푼다 (02-01)
문제: runtime은 object URL lease registry 하나를 preview와 download에
같이 넘긴다. 두 쪽의 dispose()가 모두 registry 전체의 dispose()를
불러, 누가 만든 lease인지 구분하지 않고 전부 revoke한다.
runtime.previews.dispose()를 부르면 30초 grace 중인 download blob
URL까지 바로 revoke된다(E-9). 브라우저가 아직 blob을 읽기 전이면 그
download가 실패할 수 있다. 반대로 download의 dispose()는 다른 화면의
preview URL을 끊는다. registry 주석은 이 dispose를 "route teardown"
에서 쓰라고 읽혔다.

고른 방법(리뷰 5.2절의 (나)): 한도는 같이 쓰고 해제 권한만 나눈다.
registry에 scope()를 두어 소비자마다 자기가 만든 lease 집합을
들고, scope의 dispose()는 그것만 release한다. preview와 download
adapter는 각자 scope로 lease를 만든다. registry 전체 dispose()는
runtime.dispose()만 부른다. 포트 시그니처는 그대로이고,
TransientPreviewPort.dispose()에 효과 범위를 주석으로 적었다. 설계
문서 3.5절에 해제 권한과 route 정리 방법을 적고, 바뀐 줄 번호를
맞췄다.

버린 대안:
- 포트 주석만 고친다(가). 함정이 코드에 그대로 남는다.
- 소비자마다 registry를 나눈다(다). 해제 범위는 맞지만 탭 전체의
  합계 바이트 상한이 두 곳으로 갈라진다.
- TransientPreviewPort에서 dispose()를 뺀다(라). 공개 포트 변경이라
  이번 범위(포트는 추가만)를 넘는다. (나)와 함께 할 수 있어 남겨 둔다.

위험·한계:
- previews.dispose() 뒤 그 runtime의 preview가 계속 UNAVAILABLE인
  것(영향 ②)과, previews.dispose()가 다른 화면의 preview lease까지
  푸는 것(영향 ①, 같은 소비자 안)은 그대로다. 문서에 route 정리는
  lease마다 release()로 하라고 적었다. 완전히 막으려면 (라)가 필요하다.
- scope가 들고 있는 release 함수 집합만큼 메모리가 조금 는다. lease
  release 때 집합에서 빠지므로 lease 수 상한(기본 16)을 넘지 않는다.
- file-transfer 레시피 번들이 55,856 → 55,937 gzip bytes가 되어 예산
  55,900을 넘었다. 다음 백 단위 규칙대로 56,000으로 올렸다.

검증:
- RED(수정 전): browser-file-runtime.test.ts 새 1건 "expected
  [ 'blob:runtime-download' ] to deeply equal []"(previews.dispose()가
  download URL을 revoke). browser-file-download.test.ts 새 1건
  "expected [ 'blob:shared-1', 'blob:shared-2' ] to deeply equal
  [ 'blob:shared-2' ]"(download dispose()가 다른 소비자의 lease를
  revoke).
- GREEN: browser-file 단위 5파일 64건 통과. runtime dispose가 모든
  lease를 즉시 revoke하는 기존 테스트도 통과.
- 회귀: browser-file·presigned·json-schema 단위 10파일 168건 통과.
  tsc app·test·recipes 통과. 바꾼 파일 eslint 통과. check-architecture
  (exec 전용 shim) 통과, check-adapter-inventory 통과,
  verify-documentation-readiness PASS_SCOPED,
  check-optional-recipes(source) file-transfer 55937/56000.

Refs: docs/reviews/2026-11-01-maturity-review/02-adapters-browser-files-cache.md
2026-11-01 23:14:47 +09:00
DongHyeonkaandClaude Opus 5.5 0b41cb38af fix(browser-files): report exhausted object URL leases as retryable (02-04)
Preview and download share one lease registry and download leases stay for a
30 s grace, so running out of slots clears on its own. Only a Blob above the
single-lease ceiling stays LIMIT_EXCEEDED without retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:08:33 +09:00
DongHyeonkaandClaude Opus 5.5 c8e4794860 docs(browser-files): dispose the file runtime on logout or account switch (02-03)
The runtime does not know the session, so File refs, preview leases and
downloads of the previous user outlived a logout. Section 3.5 and the recipe
lifecycle now say to dispose it, via a scope reset participant if needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:03:13 +09:00
DongHyeonkaandClaude Opus 5.5 4d8ceade21 fix(storage): match the OPFS runbook to the adapter and drop the dead EFFECT_UNKNOWN branch (05-09)
The runbook named failure codes the adapter stopped using and promised a
resume and a quarantine reconcile never does. It now states the put's own
code with RECONCILE, the skipped and failed row counts, and what reconcile
really does per phase. The worker never sent EFFECT_UNKNOWN and the client
refused it, so the cleanup effect type and its two adapter branches go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 22:44:51 +09:00
DongHyeonkaandClaude Opus 5.5 510cd80a5c fix(storage): keep a put's own failure code when compensation fails (Q-6.5-9)
When a put failed before commit and the compensating ABORT_PUT or the
journal rollback did not complete, the coordinator returned a generic
CONFLICT / OBJECT_RECONCILE (or the rollback's own code). A user cancel or
a full disk reached the caller as a bare conflict.

compensatePreparedPut now takes the put's failure and returns it. If the
compensation completes, the failure is returned as before. If it does not,
the journal row is still left for reconciliation, and the failure keeps its
code, operation and retryable flag; only recovery becomes RECONCILE. The
architecture doc's compensation rule says the same.

Verified: new tests in tests/unit/opfs-byte-store.test.ts were RED (5
cases: failed cleanup, unknown cleanup effect, caller cancel, failed
rollback, FILES_READY failure) and are GREEN; the successful-compensation
case pins the unchanged path. All gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:30:26 +09:00
DongHyeonkaandClaude Opus 5.5 f8587e8b6f docs(storage): state that revision and generation restart after delete (Q-6.5-8)
Decision D-13 keeps the storage schema as is: IndexedDB `remove` deletes
the row without a tombstone and an OPFS delete removes the logical object
row, so a recreated key starts again at revision 1 / generation 1.

The IndexedDB write receipt's `revision` and the durable object
descriptor's `generation` now say so in the port comments, and the storage
architecture doc says it in the IndexedDB record section and the OPFS
journal rules: callers must not treat `(key, revision)` or
`(objectId, generation)` as unique across the key's lifetime, and should
compare a value they own (or the integrity root digest) when it matters.

Documentation only. verify:documentation and all gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:30:26 +09:00
donghyeon-ka ec7f20e2ee refactor: 프론트엔드 리펙토링 2026-09-18 22:05:42 +09:00
DongHyeonkaandClaude Opus 5 618da9abf5 fix: preserve OPFS recovery authority during cleanup
Repair the compensating half of the OPFS put saga.

The coordinator now owns a single abortPreparedPut() driven by a
composition-owned bounded signal instead of the caller's already aborted one,
and the worker client no longer issues a duplicate fire-and-forget abort.
Journal rows and budget reservations are released only after the physical
effect is confirmed CLEANED or ALREADY_CLEAN; a timeout, malformed response or
EFFECT_UNKNOWN keeps PREPARING/FILES_READY and returns OBJECT_RECONCILE.

New writes carry a transaction-unique physicalGenerationId through the staging
receipt, manifest path and prepared object, so a late compensation deletes only
its own transaction's directory even when a newer transaction legitimately
reuses the same logical generation. v1 paths, receipts and prepared objects stay
readable through the rollback window.

Abort and cleanup hold the origin mutation lease through physical deletion and
staging removal. A transaction that never reached staging returns ALREADY_CLEAN
without waiting for the lease, which would otherwise deadlock against the BEGIN
it is cancelling.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 23:21:58 +09:00
donghyeon-ka 6c52cdb916 feat: 기능 추가 과정중 2026-07-30 15:58:20 +09:00