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 1dfe86a372 test(browser-files): 손상 데이터·로그아웃 경로의 보호 규칙 5개를 고정한다
문제: 2026-11-03 리뷰 변이 중 아래 5개가 관련 unit 파일을 모두
통과했다. 규칙을 고치는 사람은 테스트가 통과해도 손상·로그아웃 보호가
남았는지 알 수 없다.
- L6 cleanupOwned()가 읽을 수 없는 pointer를 "pointer 없음"으로 보고
  지금 서비스 중인 release까지 지운다.
- L7 stage가 손상된 marker를 고치지 않고 실패한다. REHYDRATE 안내가
  기대는 회복 경로다.
- L4 preview가 파일 resolve 뒤 #disposed를 다시 보지 않는다.
- L5 vault resolveFile이 load 뒤 #disposed를 다시 보지 않는다.
- L1 vault dispose()가 File 참조 Map을 비우지 않는다.
L4·L5는 lease registry가 dispose 뒤에도 lease를 내주기 때문에 소비자
쪽 검사가 유일한 방어선이다.

고른 방법: 규칙마다 실패하는 테스트 하나를 더한다. 리뷰가 L5에
제안한 readRange()는 slice 읽기 뒤에 #disposed를 한 번 더 보므로 L5를
잡지 못한다. 그래서 resolve 직후 소스를 돌려주는 openSource()로
고정했다.

위험·한계: 테스트만 바꾼다. 동작 변경 없음.

검증: 5개 변이를 하나씩 넣고 browser-files 단위 5파일 + tests/recipes,
cache 단위 3파일 + tests/recipes를 돌렸다. L1·L4·L5·L6·L7 모두 새
테스트 하나씩이 실패했고(되돌린 뒤 통과), 원래 코드에서 두 파일 34건
통과. check:types:test, 바꾼 파일 eslint 통과.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-03
2026-11-04 20:20:11 +09:00
DongHyeonka 60b721fd1c fix(browser-files): inspect 중에 놓은 ref에는 receipt를 발급하지 않는다
문제: vault inspect()는 이전 receipt를 무효화한 뒤 파일을 읽으며 두 번
await한다. 그 뒤 #disposed는 다시 보지만 ref가 아직 있는지는 보지 않고
receipt를 발급한다. 그 사이 release(ref)가 record와 receipt를 지우면,
inspect는 사라진 ref에 ok와 receipt를 돌려주고 receipt 기록이 놓은 File을
runtime dispose까지 붙잡는다(activeReferenceCount 0,
activeVerificationCount 1). 지금은 resolveVerifiedFile의 records.has 검사가
preview를 막지만, 그 검사를 지운 변이(L11)를 잡는 테스트가 없었다.

고른 방법: #disposed 재확인 바로 뒤에서 record가 없으면
NOT_FOUND/RESELECT로 끝낸다. resolveFile이 ref를 못 찾을 때와 같은
결과라 호출자가 이미 처리하는 분기다. 리뷰의 최소 개선 방향 그대로다.

위험·한계: 같은 ref에 inspect 두 개가 겹치면 receipt가 둘 생기는 것은
이 변경 범위 밖이다(두 receipt 모두 release·dispose가 지운다). 이 수정
뒤에는 놓은 ref에 receipt가 남는 경로가 없어서, L11 검사는 다시 두 번째
방어선이 된다. 새 테스트는 이 커밋의 검사를 지우면 실패한다.
file-transfer 번들 56,053 → 56,068 / 57,800 gzip B.

검증:
- RED: browser-file-content.test.ts 새 테스트가 inspect ok(기대
  NOT_FOUND)로 실패.
- GREEN: browser-files 단위 5파일 + tests/recipes 85건 통과.
  check:types, 바꾼 파일 eslint, check:optional-recipes:source PASS.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-04
2026-11-04 20:17:50 +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 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 c9be8d65e4 fix(browser-files): return ABORTED instead of a leaked preview lease after a same-turn abort (02-01)
create() checked the signal only before resolving the file, so an abort in
the same turn still produced a lease the caller never released. Each leak
used one of the 16 object URL slots shared with downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 23:57:04 +09:00
DongHyeonkaandClaude Opus 5.5 042427c887 refactor(browser-files): share the media-type, token and limit checks (Q-6.2-12)
The exact media-type regex lived in object-url-lease.ts,
browser-file-policy-registry.ts and the download validation;
safeOpaqueValue (vault) and safeGeneratedToken (download) were the same
regex; and five modules each defined their own positive-safe-integer check
(isPositiveByteLimit included). file-policy.ts now exports one copy of each:
EXACT_MEDIA_TYPE, isSafeGeneratedToken, isPositiveSafeInteger.
ObjectUrlLeaseRegistry.create also loses an inner revoke branch that could
never run (it required a non-empty string inside a "not a non-empty string"
guard).

cache-storage/public-cache-policy.ts keeps its private positiveSafeInteger:
adapters may not import another adapter's module.

Verified: a characterization test (unsafe reference -> UNAVAILABLE, 128-char
token accepted, empty object URL -> no revoke, fractional/zero limits and a
wildcard download media type rejected) passes on the code before and after.
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 d67fe1ab35 perf(browser-files): truncate filenames in one pass and sanitize once (Q-6.2-10)
sanitizeSuggestedFileName dropped one code point at a time and re-encoded the
whole name each round, so a 100k-character server-supplied name took ~10^10
steps. truncateUtf8 now walks the code points once, counting UTF-8 bytes, and
cuts at the longest fitting prefix (trailing whitespace trimmed, as before).
The fallback base name uses the same helper. deliver() also sanitized the
name twice (validation, then again for use); validateDownloadInput now
returns the sanitized name and deliverActive uses it.

Verified: new unit test pins results for ASCII, Hangul, emoji and the
whitespace-trim case, and asserts a 5k-character name needs <10
TextEncoder.encode calls (RED before: 4827). 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 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
donghyeon-ka 6c52cdb916 feat: 기능 추가 과정중 2026-07-30 15:58:20 +09:00