Commit Graph
10 Commits
Author SHA1 Message Date
DongHyeonka 0a74bd42b0 test(browser-files): handoff 실패 lease 반환과 남은 보호 규칙 3개를 고정한다
문제: 이번 리뷰에서도 아래 browser-files 변이가 관련 unit 파일을 모두
통과했다.
- M10(0929/02-05): bounded download의 catch에서 lease?.release()를 지운다.
  handoff가 던지면 만든 blob URL이 runtime dispose까지 남는다.
- N27(1101/02-04 ③): 같은 파일을 다시 inspect할 때 이전 receipt를
  무효화하지 않는다. 다른 정책으로 검사한 옛 receipt로 preview가 열린다.
- N29(1101/02-04 ①): object URL lease의 합계 바이트 상한을 지운다. 기존
  테스트는 개수 상한이 먼저 막아 바이트 상한을 보지 못했다.
- N30(1101/02-04 ⑥): browser-managed handoff의 fragment 거절을 지운다.

고른 방법: 규칙마다 실패하는 테스트 하나. N29는 개수 여유가 있을 때도
바이트가 막는 경우를 기존 상한 테스트 끝에 더했고, N30은 target 규칙
표에 fragment href 한 줄을 더했다.

위험·한계: 테스트만 바꾼다. 1101/02-04의 나머지(N26·N26b는 다음 커밋,
N38 host storageArea, N39 조회 keys() 재확인)는 이 커밋에 없다.

검증: 네 변이를 하나씩 넣고 browser-files 단위 5파일 + tests/recipes를
돌렸다. 모두 새 테스트(또는 늘린 행)가 실패했고 되돌린 뒤 통과. 원래
코드에서 두 파일 47건 통과. check:types:test, eslint 통과.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 0929/02-05, 1101/02-04
2026-11-04 20:59:25 +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 98977df6f4 test(browser-files): isolate five rules another check used to hide (02-08)
Cross-origin handoff, retained byte cap, typed preview Blob, native picker
user activation and first-seen-source GAP each get an input that only that
rule rejects. Removing any of the five lines now fails exactly one test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:29:34 +09:00
DongHyeonkaandClaude Opus 5.5 d76653bfcd fix(browser-files): observe dismissals as DISMISSED instead of SUCCEEDED (02-06)
A cancelled save dialog and a browser handoff were both recorded as
DOWNLOAD SUCCEEDED, so the cancel rate hid inside the handoff success rate.
BrowserDataObservation.outcome gains DISMISSED (additive).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:20: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
DongHyeonkaandClaude Opus 5.5 89e90cc990 fix(browser-files): race deliveries and vault reads on the kernel owner (Q-6.2-7)
download-delivery-adapter and browser-file-vault each carried their own
combineAbortSignals/awaitWithSignal copies. Two gaps followed:
- a presigned lease that resolved after the abort but before the delivery's
  finally was seen by neither compensateLateSource (holder not yet closed) nor
  closeHeldSource (lease never adopted), so it leaked;
- a writable from handle.createWritable() that arrived after the abort was
  never aborted (Chrome keeps a .crswap file).

Each delivery and each vault stream now owns a createAbortableOperation joined
to the caller signal; dispose() closes the live owners. Every await goes
through owner.race, and late leases/writables are compensated by the race.
The hand-rolled abort ratchet drops 21 -> 19.

Verified: two new download tests (same-turn late lease, late writable) failed
before (close 0 times, no abort) and pass now; a new vault characterization
test (caller abort / dispose during a pending read) passes before and after.
All lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
DongHyeonkaandClaude Opus 5.5 de954d2ebf fix(browser-files): stop binding file pickers to the options object (R-2.4)
EnhancedFilePicker and the download adapter captured showOpenFilePicker
and showSaveFilePicker with `.bind(options)`. A Window operation throws
TypeError("Illegal invocation") when `this` is not the Window, so passing
`window.showOpenFilePicker` / `window.showSaveFilePicker` as-is failed on
every call.

Both are now captured with `.bind(undefined)`. They are still captured at
construction, and Web IDL maps an undefined receiver to the global object,
so the native functions can be injected directly.

Verified: "calls an injected window picker without rebinding its
receiver" and "calls an injected window save picker without rebinding its
receiver" use a fake picker that throws "Illegal invocation" unless `this`
is undefined or globalThis. Both failed before the fix (ok:false) and pass
now. check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture, which needs
generated artifacts/release files that a fresh worktree lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:15:58 +09:00
DongHyeonkaandClaude Opus 5.5 54abaec12a fix(browser-files): resolve bounded object URL source inside the result boundary (R-2.1)
boundedObjectUrlHandoff called resolveByteSource outside its try/finally.
When the authorized source open threw or was aborted, deliver() rejected
with an AbortError instead of returning {ok:false, ABORTED}, the observer
saw nothing, and the holder was never latched closed, so a lease that
arrived later was never closed by compensateLateSource.

Source resolution now runs inside the existing try/catch/finally, the same
shape promptAndStream already uses. The explicit closeHeldSource calls on
the early-return paths are covered by the finally.

Verified: "resolves ABORTED and closes a late lease when a bounded source
open is aborted" failed before the fix (promise rejected with AbortError)
and passes now. check:architecture, check:types:app, check:types:test,
lint, test:component pass. test:unit passes except removal-fixture, which
needs generated artifacts/release files that a fresh worktree lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:15:58 +09:00
DongHyeonkaandClaude Opus 5 ba79060a83 fix: execute canonical browser download targets
Replace the boolean browser-managed target validator with
resolveBrowserManagedTarget, which returns the parsed canonical absolute URL,
and hand that exact value to the host. Previously the raw href was passed on,
so a relative target was re-resolved against document.baseURI and a hostile
<base> could send the navigation to an origin the policy never approved.

STO-08 stays UNVERIFIED: the capability spec does not exercise the system
picker, so the receiver-binding hypothesis is neither reproduced nor refuted
and no source change was made for it.

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