Commit Graph
4 Commits
Author SHA1 Message Date
DongHyeonka 44538819eb fix(adapters): 지난 리뷰에서 남은 adapter 결함과 시험 빈칸을 고친다
문제(2026-09-29·11-01·11-05 리뷰에서 남음·일부로 이월):
- 계속 읽히지 않는 release marker를 같은 manifest stage가 다시 쓰지 않아
  candidate와 rollback 대상이 다시 활성화되지 않는다(1105/02-02).
- 손상된 chunk 참조 행 하나가 orphan GC를 영구히 멈춘다(0929/05-01 ③).
- 롤백 중(옛 릴리스 탭) 승인된 계정 삭제가 새 릴리스가 올린 DB 앞에서
  실패한다(0929/05-05).
- lifecycle proof 정규식이 IndexedDB 16~128, OPFS 16~512로 갈렸다(05-06).
- canonical JSON 사본 셋과 sameScope 사본 둘(05-07).
- 한 origin의 앱 둘이 DB 이름으로 갈리는 근거가 문서에 없다(05-10).
- Web Storage의 TTL 모양·prototype 키·accessor 거절을 시험이 안 본다
  (1101/05-06).
- part buffer copy factor가 1까지 내려가 메모리 상한 식이 거짓이 된다
  (1101/01-03).
- 업링크 하한 64 KiB/s가 정책과 실행기에 따로 있다(0929/01-03).
- 닫힌 runtime의 abort()가 RESUME을 돌려주고 abort() 표가 없다(01-05).
- 로그인 뒤 돌아갈 주소가 router basename을 빼서 /app/ 배포가 앱 밖으로
  나간다(0929/08-08).

고른 방법:
- marker 읽기 실패(abort 말고)는 entry처럼 같은 stage가 덮어쓴다. 지우지
  않는다. 포트 주석의 "or lookup"을 고치고 운영 문서에 한 줄 적는다.
- 손상 참조 행은 참조로 보고 chunk를 남긴 뒤 수를 센다
  (corruptChunkReferences, DEGRADED 관측). 1101 결정 "손상 행은 건너뛰고
  센다"와 같다.
- 상태가 INCOMPATIBLE(새 schema)일 때 승인된 ACCOUNT_DELETION만 DB 전체를
  지운다. LOGOUT은 새 릴리스에 맡긴다.
- kernel에 canonical-json.ts·opaque-authority-proof.ts를 두고 사본이 그것을
  쓴다(실패 code는 호출자가 정한다). proof는 넓은 쪽(512)을 지킨다.
  sameOpfsScope는 OPFS 그룹 안 한 곳이다. INVENTORY 145.
- 05-10은 접두사 옵션 대신 registry가 주는 authorityToken을 앱 경계로
  정하고 문서와 시험으로 고정한다. 옵션은 지우기·유지보수 경로가 같은
  이름을 다시 계산해야 해서, 한 곳에서 빠지면 지웠다고 보고한 데이터가
  남는다.
- PART_BUFFER_COPIES(4) 하한, DEFAULT_MIN_TRANSFER_BYTES_PER_SECOND 한 값.
- 닫힌 runtime의 abort()는 NONE이고, 포트에 abort() recovery 표를 둔다.
- returnTo는 useHref로 만든 문서 경로이고 포트 주석에 기준을 적는다.
버린 대안: marker를 지우고 다시 받기 — 서빙 중인 release를 지운다
(STO-RR-04).

위험·한계: canonical JSON이 이제 cache·realtime에서도 NaN·Infinity를
거절한다(전에는 null로 썼다). Fileserver client(http 그룹)의 같은
64 KiB/s는 다른 그룹이라 이 상수를 import할 수 없고, 그 파일은 그룹 B
PR①이 고치는 파일이라 여기서 건드리지 않았다.

검증: desktop 결과는 PR 본문.

Refs: 1105/02-02, 0929/05-01, 0929/05-05, 0929/05-06, 0929/05-07, 0929/05-10, 1101/05-06, 1101/01-03, 0929/01-03, 0929/01-05, 0929/08-08
2026-11-13 20:17:04 +09:00
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
DongHyeonkaandClaude Opus 5.5 2cbf500fcc perf(cache-storage): one keys() and two body copies per cache lookup (02-07)
A lookup listed the cache names twice and copied the body four times (read
buffer, digest input, stored source, stream). The name list is now shared and
only the read buffer and the per-stream copy remain; WebCrypto copies its
input itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:26:17 +09:00
DongHyeonkaandClaude Opus 5.5 4093ee8fc2 refactor(cache-storage): split the cache and download codecs out of their adapters (Q-6.2-11)
public-response-cache-adapter.ts (1986 lines) and download-delivery-adapter.ts
(1491 lines) mixed the facade with codecs and validators. Moved verbatim:
- cache-storage/public-cache-codec.ts: manifest normalization and canonical
  digest input, marker/active-pointer validation, bounded control JSON,
  owned cache names, CacheValidationFailure -> Result mapping.
- cache-storage/public-cache-response-validation.ts: response admission
  (status, directives, Content-Type, Vary, bounded body, digest).
- browser-files/download-input-validation.ts: request snapshot, input/limit
  checks, presigned and browser-managed capability validation, handoff target.
The adapters drop to 1164 and 1157 lines.

Two non-verbatim edits: validateDownloadInput takes a structural
DownloadInputValidationOptions instead of DownloadDeliveryAdapterOptions (no
import cycle), and readBodyBounded races reads on the kernel
createAbortableOperation instead of its own abort listener. Moving it out of
a primitive-importing file would otherwise have raised the hand-rolled abort
ratchet to 20/19; the abort outcome (ABORTED, reader cancelled) is unchanged.

Verified: characterization tests added first and passing before the move
(cache manifest/response/control-JSON failure codes, lookup abort during a
pending body read; download input validation codes); a line diff confirms the
moved code is verbatim apart from the two edits above. Inventory 139/139,
lane gates, check:browser-file-storage-boundaries pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00