문제: part 발급(BFF)이 401/403으로 거절하면 upload()가
{PERMISSION_DENIED, UPLOAD_PART, retryable:false, RESUME}을 돌려준다.
세션 만료나 권한 회수라서 재인증 전에는 다시 불러도 같은 거절이다.
그런데 RESUME을 믿는 화면은 "다시 시도"를 띄우고, 다시 부르면 파일
전체를 재해시한 뒤 같은 거절을 받는다. 지난 수정(9142390)은 이 경로를
남겼다. object store PUT 403과 code·단계·recovery가 모두 같아서
toUploadAction 한 곳에서 가를 수 없었다.
고른 방법: 실패의 출처를 아는 곳에서 표시한다. runtime의
uploadPartWithRetry 발급 분기만 그 실패가 BFF 발급에서 왔다는 것을
안다. 그 분기에서 PERMISSION_DENIED를 {retryable:false, NONE}으로
만든다. 표시는 별도 필드 대신 기존 recovery 값(NONE)이다. 번역
(toUploadAction)은 NONE을 그대로 두고 retryable:false를 강제한다. 공개
타입은 바뀌지 않는다. 발급 분기는 모든 control plane 구현이 지나는
곳이라 http-control-plane-adapter 말고 다른 구현에도 같은 답이 나온다.
PUT 403은 그대로 RESUME이다. 서명 만료가 보통 원인이고 다음 시도가 새
capability를 받는다(지난 수정의 보존 조건).
버린 대안:
- 백엔드가 code를 나눈다: 두 repo 계약이 바뀌고 다른 백엔드에도 기대야
한다.
- code만 보고 번역에서 추측한다: 두 출처의 code가 같아 불가능하다.
PERMISSION_DENIED를 모두 NONE으로 하면 PUT 403 테스트 2건이 깨진다.
- 실패의 stage(operation) union에 발급 값을 더한다: 공개 타입 변경이라
[계약]이다. 같은 일을 기존 값으로 할 수 있다.
- 내부 표시 필드나 WeakSet: 발급 분기와 번역 사이에서 실패는 공개
BrowserDataFailure로 오간다. 필드를 실으려면 타입 단언이 필요하고,
WeakSet은 객체 동일성에 기대는 숨은 결합이다. 중간에 실패를 다시
만들면 말없이 표시가 사라진다.
- control plane adapter에서 바꾼다: 다른 control plane 구현은 여전히
RESUME을 낸다.
위험·한계:
- BFF 발급 401/403의 recovery가 RESUME → NONE으로 바뀐다. 다운스트림
화면이 이 값으로 분기하므로 CHANGELOG [계약] 한 줄이 필요하다.
- control plane이 발급 거절을 retryable:true로 줘도 이제 재시도하지
않는다. 재인증 전에는 결과가 같기 때문이다.
- 재인증 자체는 앱 세션 계층 몫이라 다루지 않았다.
- 실제 BFF·object store가 아니라 fetch 가짜 서버로 확인했다.
- file-transfer 레시피 번들 56,031 → 56,053 gzip B(예산 56,100).
검증:
- RED(수정 전): resumable-upload-runtime-recovery.test.ts 새 3건 중
BFF 발급 401·403 2건 실패(recovery 기대 NONE, 실제 RESUME). PUT 403
1건은 수정 전에도 RESUME으로 통과(보존 조건 고정).
- GREEN: 같은 파일 37건 통과. 세 경로 모두 retryable:false를 단언한다.
- 변이: 번역에 "PERMISSION_DENIED → NONE"을 넣으면 PUT 403 2건(새
테스트, 기존 01-05 표 테스트)이 실패한다.
- 회귀: resumable-upload·presigned·upload-cancellation·browser-file·
image-cdn 단위 20파일 329건 통과. tsc app·test·recipes 통과. 바꾼
파일 eslint 통과. verify-documentation-readiness PASS_SCOPED.
check-optional-recipes(source) file-transfer 56053/56100.
- 미실행: check:architecture(pnpm 필요).
Refs: docs/reviews/2026-09-29-maturity-review/01-adapters-browser-transfer.md
문제: 포트는 upload() 실패의 recovery가 호출자 행동 하나를 가리킨다고
적는다. 번역은 toUploadAction 한 곳이 하는데 recovery 단어만 본다. 표
밖 값이면 REISSUE_CAPABILITY·RETRY만 RESUME, 나머지는 NONE으로 바꾸고
retryable은 그대로 둔다. 그래서 지난 리뷰 실험 X1의 경로들이 표와 다른
행동을 가리킨다.
- ① 고른 파일이 바뀜(NOT_READABLE/REOPEN): NONE에 retryable:true.
표대로면 RESELECT다.
- ② IndexedDB 일시 오류(UNAVAILABLE/REOPEN, retryable:true): NONE.
다시 부르면 성공한다.
- ③ part 발급 404(서버가 session을 모름): NONE. 다시 부르면 새
session으로 성공한다.
- ⑤ 닫힌 runtime: RESUME. 같은 runtime은 늘 같은 답이다.
- ⑥ session보다 긴 capability(POLICY_REJECTED/REISSUE_CAPABILITY):
RESUME. 서버가 같은 값을 다시 준다.
고른 방법(지난 리뷰 3절 D1의 (a), 번역 기준 보강): 번역은 계속 한 곳에
둔다. 몇 가지 code가 먼저 정한다. POLICY_REJECTED → NONE, file store의
NOT_READABLE/REOPEN → RESELECT, UPLOAD_PART의 NOT_FOUND → RECONCILE.
나머지는 지금처럼 표 안 값은 그대로 두고, 표 밖이면 retryable:true나
REISSUE_CAPABILITY·RETRY일 때 RESUME, 아니면 NONE이다. NONE과 RESELECT는
번역 끝에서 retryable:false로 맞춘다. 닫힌 runtime은 NONE을 돌려준다.
포트 표 주석과 설계 문서 표에 이 규칙을 적었다.
버린 대안:
- 리뷰 예시의 STALE_RESULT → RESELECT. 기존 STALE_RESULT/RECONCILE
경로(resumable-upload-runtime.ts의 재조정)를 깨뜨린다. 지금
STALE_RESULT는 모두 표 안 값을 갖고 있어 규칙이 필요 없다.
- 리뷰 예시의 NOT_READABLE → RESELECT(조건 없이). PUT 중 네트워크 읽기
실패도 NOT_READABLE(REISSUE_CAPABILITY)이라 파일 재선택으로 잘못
보낸다. 그래서 REOPEN(file store가 붙이는 값)일 때만 RESELECT다.
- 출처마다 포트 어휘를 만들게 하는 안(b), action 필드 추가(c). 지난
리뷰가 다른 포트를 틀어지게 하거나 공유 타입을 바꾼다고 기각했다.
위험·한계:
- ④ part 발급(BFF) 401/403은 고치지 않았다. 지금도 RESUME이다. object
store PUT 403(재발급으로 풀리고, 기존 01-05 표 테스트가 RESUME으로
고정)과 code·단계·recovery가 모두 같아 번역 한 곳에서 가를 수 없다.
리뷰 예시("PERMISSION_DENIED는 단계와 무관하게 NONE")와 보존 조건
("기존 7경로 기대값 유지")이 이 경로에서 서로 어긋난다. runtime
호출 지점에서 발급 거절만 따로 표시할지는 소유자 판단이 필요하다.
그래서 이 발견은 부분 충족이다.
- 몇 경로의 recovery 값이 바뀐다(위 ①②③⑤⑥). 기존 테스트 하나
(resumable-upload-runtime-contract.test.ts "rejects a part capability
that outlives its session")의 기대값을 RESUME → NONE으로 바꿨다.
다운스트림 화면이 이 값으로 분기하므로 CHANGELOG [계약] 한 줄이
필요하다. 이번 수정 묶음은 CHANGELOG를 한 번에 쓰므로 여기서는 쓰지
않았다.
- 실제 브라우저 오류 발생은 재현하지 않았다. 단위 harness에서 오류
값을 주입했다.
- file-transfer 레시피 번들이 55,937 → 56,031 gzip bytes가 되어 예산
56,000을 넘었다. 다음 백 단위 규칙대로 56,100으로 올렸다.
검증:
- RED(수정 전): resumable-upload-runtime-recovery.test.ts 새 5건 실패.
① recovery NONE·retryable true(기대 RESELECT·false), ② NONE(기대
RESUME), ③ NONE(기대 RECONCILE), ⑤ RESUME(기대 NONE), ⑥ RESUME(기대
NONE). 수정 전 번역 규칙으로 되돌리면 같은 5건이 실패한다.
- GREEN: 같은 파일 통과. 기존 7경로 표 테스트에 "NONE이면
retryable:false" 단언을 더했고 통과한다.
- 회귀: resumable-upload·presigned·upload-cancellation·browser-file·
image-cdn 단위 20파일 326건 통과. tsc app·test·recipes 통과. 바꾼
파일 eslint 통과. verify-documentation-readiness PASS_SCOPED.
check-architecture(exec 전용 shim) 통과. check-optional-recipes
(source) file-transfer 56031/56100.
Refs: docs/reviews/2026-09-29-maturity-review/01-adapters-browser-transfer.md
문제: resolve()는 통과한 probe 기록(passedProbes)을 slot을 기다리기
전에만 본다. 같은 asset·preset을 동시에 5번 resolve하면 probe가 5번
돈다. probe마다 preset의 encoded 예산까지 no-store로 내려받고
decode하며, 같은 이미지가 probe slot을 차지해 다른 이미지의 probe가
밀린다.
고른 방법: asset·preset별로 "진행 중인 probe 단계"(slot 대기, probe,
통과 기록)를 promise 하나로 둔다. 뒤에 온 호출은 그 단계가 끝나기를
자기 signal로 기다린 뒤 기록된 통과를 재사용한다. probe 자체를
공유하지 않으므로 호출마다 abort가 독립이다. 앞선 probe가 실패하면
기다린 호출이 직접 probe한다(실패는 재사용하지 않는다는 기존 규칙).
X5(동시 5회, maxConcurrentProbes 2)에서 probe가 1회다.
버린 대안:
- 리뷰가 제안한 slot 획득 뒤 재확인. 넣어 보니 X5에서 probe가 3회로
완료 기준(2회 이하)을 못 맞춘다. slot은 원시 probe가 끝날 때
넘겨지는데(TR-RR-07), 통과 기록은 그보다 몇 microtask 뒤에 남는다.
다음 대기자가 기록 전에 깨어난다.
- 진행 중 probe의 결과를 공유(single-flight). 호출자마다 signal이
달라 참조 수를 세야 한다.
- slot 해제를 통과 기록 뒤로 미룬다. 해제 지점이 원시 probe 정착과
wrapper 종료 두 곳으로 갈라진다.
위험·한계:
- 대기 뒤 재사용할 때 만료를 따로 다시 보지 않는다. 통과를 기록한
호출이 기록 직전에 만료를 봤고, 대기자는 같은 task 안에서 이어서
실행된다. 시작할 때의 만료 검사(기존)는 그대로다.
- 앞선 probe가 실패하면 기다리던 호출들이 각자 probe한다(slot 수로
묶임). 실패가 반복되는 이미지는 지금과 같은 수의 probe가 돈다.
- probe 블록을 try/finally로 감싸면서 들여쓰기가 바뀌었다. 로직
변경은 `git show -w`로 보면 짧다.
- file-transfer 레시피 번들이 55,725 → 55,856 gzip bytes가 되어 예산
55,800을 넘었다. 다음 백 단위로 올리는 기존 규칙대로 55,900으로
올렸다.
검증:
- RED(수정 전 코드에 새 테스트): "probes once and lets the other calls
reuse the pass"가 "expected vi.fn() to be called 1 times, but got 5
times"로 실패. 재확인 안(버린 대안)에서는 2회 기대에 3회로 실패.
나머지 새 테스트 2건(앞선 probe 실패 시 대기자가 직접 probe, 대기
중 abort가 진행 중 probe를 끊지 않음)은 새 분기를 고정한다.
- GREEN: image-cdn 단위 3파일 37건 통과.
- 회귀: browser-file·image-cdn·presigned·resumable-upload·json-schema
단위 20파일 323건 통과. tsc app·test·recipes 통과. 바꾼 파일 eslint
통과. check-optional-recipes(source) file-transfer 55856/55900.
Refs: docs/reviews/2026-11-01-maturity-review/01-adapters-browser-transfer.md
문제: part 단계(BFF capability 발급, object store PUT)의 상태표
statusFailure는 상태 코드만 받아 429의 Retry-After를 버린다. 서버가
`429 Retry-After: 5`로 답해도 runtime은 지수 backoff(기본 250·500·
1000ms)로 다시 보내고, 1.75초 안에 요청 8개를 쓴 뒤 retryable 실패를
돌려준다. 설계 문서 두 곳(presigned-transfer-and-image-cdn.md,
server-file-capability-infrastructure.md)은 part 단계도 bounded
Retry-After를 따른다고 적는다. 헤더를 읽는 곳은 control plane
transport뿐이었다.
고른 방법: statusFailure가 Response와 현재 시각을 받아 429·503이면
kernel parseRetryAfterDelay로 retryAfterMs를 채운다. 상한
maxRetryAfterMs는 runtime의 canRetry·waitForRetry가 이미 적용하므로
presigned 계층은 값을 그대로 넘긴다. 상한을 넘으면 재시도하지 않는다
(control plane과 같은 규칙). PresignedUploadPartCapabilityProvider.
issueUploadPart와 PresignedUploadPartPort.put의 반환 타입을
UploadProviderResult로 넓혔다. 기존 구현은 그대로 대입되므로
추가형이다. HTTP control plane 어댑터의 발급 브리지가 실패를 다시
만들면서 retryAfterMs를 버리던 것도 넘기게 했다.
버린 대안:
- 문서를 "part 단계는 Retry-After를 읽지 않는다"로 고친다. 재시도
증폭이 그대로 남는다.
- BFF 응답 본문에 대기 시간을 넣는 별도 계약. 표준 헤더를 두고 서버와
클라이언트를 함께 바꿔야 한다.
- download 경로만 빼고 읽는다. 하나로 합친 상태표(Q-6.1-9)를 다시
둘로 가르게 된다. download 소비자(browser-files 전달 어댑터)는
실패를 다시 만들어 이 값을 읽지 않는다.
위험·한계:
- 다른 origin의 object store가 Access-Control-Expose-Headers에
Retry-After를 넣지 않으면 헤더가 없는 것으로 읽혀 지금처럼 backoff만
쓴다. statusFailure 주석에 적었다.
- part 단계에서 Retry-After가 없거나 형식이 틀린 429는 지금처럼
retryable backoff다. control plane은 이 경우 재시도하지 않는다. 이
차이는 이번에 바꾸지 않았다.
- issueDownload·open 실패에도 retryAfterMs가 실린다. 이 두 포트의
타입(BrowserDataResult)에는 드러나지 않는다.
- file-transfer 레시피 번들이 55,623 → 55,725 gzip bytes가 되어 예산
55,700을 넘었다. 측정값 위 약 100바이트로 반올림하는 기존 규칙
(4b0e44a9)대로 55,800으로 올렸다.
- 포트 반환 타입이 넓어졌으므로 CHANGELOG [계약] 한 줄이 필요하다.
이번 수정 묶음은 CHANGELOG를 한 번에 쓰므로 여기서는 쓰지 않았다.
검증:
- RED(수정 전): resumable-upload-runtime-recovery.test.ts 새 4건 실패.
발급·PUT이 `429 Retry-After: 5`일 때 "expected 0 to be greater than
or equal to 5000"(첫 sleep 0ms). maxRetryAfterMs 1000을 넘을 때
재시도해서 ok:true. resumable-upload-http-control-plane.test.ts 새
1건 실패: 브리지 결과에 retryAfterMs 5000이 없다.
- GREEN: 두 파일 33건 통과.
- 회귀: browser-file·image-cdn·presigned·resumable-upload·
upload-cancellation·json-schema 단위 21파일 322건 통과. tsc app·
test·node·recipes 통과. 바꾼 파일 eslint 통과. check-architecture
(exec 전용 shim, pnpm 미사용) 통과, check-adapter-inventory 통과,
check-optional-recipes(source) PASS file-transfer 55725/55800.
Refs: docs/reviews/2026-11-01-maturity-review/01-adapters-browser-transfer.md
Early returns before resolve (invalid input, pre-aborted signal, byte-length
mismatch) left the capability registered, so maxActiveCapabilities: 1 refused
the next issuance. The public methods now release it once in a finally.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VD-01 decision 3 hands unused diagnostics to tsc and turns off ESLint's
no-unused-vars for TS files, but tsconfig.base.json never enabled the
tsc check (D-19). The flag found 46 unused imports, types and helpers
across 22 files; none of them were read, so removing them changes no
behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The checkpoint store still used the File/Cache table, so a missing store read
as NOT_FOUND and a quota failure as retryable. It now uses
mapIndexedDbException, leaving one IndexedDB exception table in the repo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PRIMARY_REQUIRED resolve() downloaded and decoded the primary candidate on
every call with no concurrency limit. Probes now wait for one of
maxConcurrentProbes slots (default 4) and a passed probe is reused for the
same asset and preset while the capability is valid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The executor and the runtime both recorded UPLOAD_PART, so a part retried once
became one FAILED and two SUCCEEDED records, and no retry bucket existed. PUT
attempts are now PRESIGNED_TRANSFER; the runtime records the part once with
its attempt count as countBucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The policy allows 10,000 parts but a 1 MiB request cap overflows near 5,300,
so the upload failed at complete after every part was sent. Given
maxPartCount, the fetch transport now rejects such a combination at
composition using a worst-case receipt size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resume re-ran the current policy against the stored session, so a build that
lowered maxConcurrency or maxSessionLifetimeMs failed every upload an older
build had started with INTEGRITY_FAILED. Resume now checks the session only
against its checkpoint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only consume() removed a vault entry, so a refused, expired or aborted
transfer held a maxActiveCapabilities slot until expiry and later issuance
failed as LIMIT_EXCEEDED. The executor now revokes on every exit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A server lifetime equal to the client ceiling was refused as soon as the
device clock ran slightly behind, and the error did not read as a clock
problem. Both ceilings now allow maxClockSkewMs (default 60 s), as image-cdn
already does; the doc states the server-side lifetime conditions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ABORT_PENDING and a checkpoint CAS race returned the same failure, and some
recoveries (REISSUE_CAPABILITY, RESTART for a replayed create) named actions
the caller cannot take or that repeat the failure. The port now documents a
five-value recovery table and upload() returns only those values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fixed 30 s attempt deadline never let a 5 MiB part finish below ~1.4 Mbit/s,
and a download had one deadline for its whole body. PUT and download limits
now add bytes / minTransferBytesPerSecond (default 64 KiB/s), and a stalled
download ends at a per-chunk idle limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed checkpoint cleanup after a committed complete returned a failure and
dropped the resourceId, and abort() on ALREADY_COMPLETED returned no id. The
upload now succeeds, abort() reads the id from status first, and the port and
design doc state the in-progress complete contract (429 + Retry-After).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A single object-store refusal ended the whole upload as PERMISSION_DENIED
with retryable:false. The next attempt already issues a fresh capability, so
REISSUE_CAPABILITY PUT failures now retry within maxRetries; BFF issuance
refusals still stop at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kernel already treats an undefined signal or timeoutMs as absent, so the
conditional spreads around them were dead weight.
file-transfer gzip: 54484 -> 54468
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
combineAbortSignals moves verbatim from resumable-upload-runtime.ts to
platform/abortable-operation.ts (AbortSignal.any is not available on the
Safari 16 target). Behavior is unchanged: either input aborts the combined
signal, and release only drops listeners. Adds kernel unit tests for it.
gzip: file-transfer 54499 -> 54484, offline-indexeddb 35854 -> 35856,
service-worker-pwa 9500 -> 9499, realtime 39685 unchanged (net -14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readWithSignal now races reader.read() through createAbortableOperation
instead of its own abort listener, and createAbortScope takes the single
consumer signal its only caller passes instead of looping over an array.
Adds a characterization test for a consumer-only abort during a pending
read (ABORTED, owner signal untouched, body cancelled).
file-transfer gzip: 54546 -> 54500
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resumable-upload fetch transport had its own parser that handed any
non-integer value to Date.parse, so "1.5", "2025-01-01" or an RFC 850 date
became a zero-delay retry. It now uses platform/retry-after.ts, which only
accepts delta-seconds or an IMF-fixdate.
file-transfer gzip: 54406 -> 54546
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The capability-verification deadline, the probe wait and runtime close now
use createAbortableOperation/snapshotAbortTimers instead of three local
helpers and a default scheduler wrapper. Results, error codes and the
scheduler TypeError message are unchanged. Hand-rolled abort ratchet 17 -> 16.
file-transfer gzip: 54562 -> 54406
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- browser-file-picker: the native and enhanced pickers carried two copies of
the same selection observation (#finishObservation / #observe); one
module-level observeSelection replaces both.
- indexeddb-checkpoint-store: read / compareAndSwap / remove /
removeUnreadable each repeated acquire -> transaction -> get -> onerror;
withCheckpointRow does that once and hands the row to the operation, still
inside the same transaction. deleteCheckpointRow shares the delete tail.
- resumable-upload-runtime: the four checkpoint removals that remap to
UPLOAD_RECONCILE go through removeCheckpoint.
- image-cdn-runtime: the verification deadline reuses
combineImageRuntimeAbortSignals instead of a second listener loop; the
verifier-coverage check throws its TypeError from one place; the registry
id pattern is one constant instead of three inline literals.
- presigned executor / capability provider: reuse checkpoint-schema's
SHA256_HEX and isSafeUploadReceiptToken instead of equal local patterns.
file-transfer reference runtime: 54754 -> 54562 gzip bytes (budget 54600).
Other reference runtimes unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory, build,
check:optional-recipes (file-transfer 54562/54600, offline-indexeddb
35854/36000, realtime 39685/40000, service-worker-pwa 9500/10000),
test:recipes, check:types:recipes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- image-header-metadata: `=== undefined` / `?? 0` / `?? null` guards on bytes
and boxes whose index was bounds-checked a few lines earlier (PNG IHDR,
JPEG marker, WebP VP8X/VP8L, AVIF ftyp/meta/iprp/ipma, ascii,
readUint24LittleEndian). A differential fuzz of the old and new parser over
720k valid and mutated PNG/JPEG/WebP/AVIF inputs found no difference.
- incremental-sha256: `?? 0` on in-range Uint32Array reads and `>>> 0` on
Uint32Array stores, which already reduce modulo 2^32. Checked against
node:crypto for 0..1 MiB inputs, one-shot and streamed.
- p256 verifier: the alphabet index can't be negative after the base64url
pattern check, and the decoded signature is already an owned, exactly sized
buffer, so it is no longer copied again.
- browser-image-probe: once the bitmap matches the header dimensions, which
are positive and inside the decode budget, the repeated positivity and
budget checks on the bitmap cannot fail.
file-transfer reference runtime: 54894 -> 54754 gzip bytes. Other reference
runtimes unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- cancelBody / cancelReader move from presigned/http-common.ts into
platform/abortable-operation.ts next to compensateLateHandle; the probe's
own cancelResponseBody/cancelReader copies are dropped and every caller
imports the kernel pair.
- fetch-json-transport uses the kernel operation directly: the FetchAttempt
projection only renamed terminal() (ABORT/TIMEOUT/CLOSED), and only the
CALLER_ABORT case was ever read.
- browser-image-probe uses the kernel operation directly (awaitOwned /
unanswered helpers replace the ProbeAbortScope object), and the body read
goes through the same race instead of the hand-written readOrAbort.
- storage-manager-adapter's inspection wait is the kernel race: a caller
abort ends the wait and a later settlement, including a rejection, is
consumed, exactly as the hand-written listener did. The hand-rolled abort
ratchet drops 19 -> 18 for this file.
file-transfer reference runtime: 55154 -> 54894 gzip bytes.
offline-indexeddb: 35951 -> 35854. service-worker-pwa: 9581 -> 9500.
realtime unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory (hand-rolled abort
wiring 17/18).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Identical private copies lived in both file adapters and in five
browser-transfer modules. One copy each now lives next to isValidByteLength
in the browser-file-storage port (outside every reference-runtime source
root, so it adds no namespace export):
- byteBucket (browser-files/file-observer, presigned/http-common) ->
browserDataByteBucket; both modules re-export it under the old name
- positiveSafeInteger / nonNegativeSafeInteger (checkpoint-schema,
http-control-plane-adapter, runtime-policy, upload-byte-source,
image-cdn-policy, browser-image-probe, file-policy's isPositiveSafeInteger)
-> isPositiveSafeInteger / isNonNegativeSafeInteger
- hasControlCharacters (image-cdn-policy) and
hasForbiddenHeaderValueCharacter (fetch-json-transport) -> hasControlCharacter
Same predicates, same results for every input.
file-transfer reference runtime: 55306 -> 55154 gzip bytes.
offline-indexeddb: 35957 -> 35951. realtime, service-worker-pwa unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reference-runtime measurement exposes every export of every catalog
module through a namespace object, so an export nobody imports still costs
bytes. Made module-private (only used inside their own file, not by src,
tests or scripts):
- download-input-validation.ts: SHA256, snapshotDownloadSource,
validPresignedCapabilityForInput, safeOpaqueId
- checkpoint-schema.ts: RECEIPT_TOKEN, isUploadPartDescriptor,
partMatchesFingerprint
Barrel (index.ts) exports are untouched.
file-transfer reference runtime: 55382 -> 55306 gzip bytes. Other reference
runtimes unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resumable-upload runtime and fetch transport carried private copies of
helpers that already exist once in the same adapter or its port:
- the 18-code failure list -> isBrowserDataFailureCode (same list, same order)
- observeTerminal/transferByteBucket -> observeTransferResult, moved from the
presigned executor into presigned/http-common.ts and also used by the
capability provider
- cancelResponseBody/cancelReader in the fetch transport -> http-common copies
- the loose isAbortSignal guard (transport + runtime) -> one export in
checkpoint-schema.ts
- upload-response-validation's exactKeys -> checkpoint-schema's exactRecord
file-transfer reference runtime: 55704 -> 55382 gzip bytes. Other reference
runtimes unchanged.
Verified: check:architecture, check:types:app, check:types:test, lint,
test:unit, test:component, check:adapter-inventory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
register() took one owned snapshot and stored it, but its duplicate
receipt check read registration.capabilityReceipt from the issuer's object
three more times. A stateful object could show the check a receipt the
vault never stored while the snapshot carried one it already held, so the
same receipt was registered twice. The check now reads the snapshot once.
Verified: RED test "checks a duplicate receipt against the snapshot, not
the issuer's object" (a Proxy registration was accepted) + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resumable-upload-runtime.ts carried the upload flow, retry/deadline, the
server response decoders and eight dependency snapshot wrappers in one
2.3k-line file. Moved without changing behavior:
- runtime-dependencies.ts: the dependency types, snapshotDependencies and
its per-collaborator wrappers, safeNow/safeRandom and the default sleep.
- upload-response-validation.ts: validateSession, validateStatus,
validatePartCapability, the receipt check and the small shared helpers
(exactKeys, sameFingerprint, snapshotReceipts).
The runtime re-exports ResumableUploadRuntimeDependencies, so the public
surface is unchanged. The default sleep now waits on the kernel
createAbortableOperation instead of its own timer/listener pair, so the
moved file does not add a hand-rolled abort offender (ratchet stays 20/21).
INVENTORY and the detail review list the two files.
Verified: new characterization suite resumable-upload-runtime-contract
(invalid collaborators throw at composition, methods captured at
composition, frozen observer copies, throwing clock, default sleep retry
and abort, session/capability/status/receipt rejections) written and green
before the move, still green after + existing runtime suites + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The multipart-to-presigned bridge copied every part with Uint8Array.from
and the presigned executor then snapshotted the same bytes with slice()
before any await. The executor's snapshot is the one the public port
needs, so the bridge now forwards the part buffer as is. The executor
still re-digests its own copy against the part checksum, so a port that
mutated the buffer would fail closed rather than upload other bytes.
partBufferCopyFactor is left at 4; changing a policy default is a
contract migration.
Verified: the bridge test now asserts the port receives the part buffer
itself (failed before: it got a copy) + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The presigned executor and the capability provider each carried a copy of
createAbortScope, readWithSignal, transferFailure, isAbortSignal,
byteBucket, body/reader cancel, Content-Length parsing and statusFailure.
They now import them from presigned/http-common.ts.
Behavior changes:
- statusFailure is one table. The provider used NONE for 401/403 and RETRY
for 429/5xx; it now answers REISSUE_CAPABILITY like the executor. Retry
decisions (retryable) are unchanged. Chosen because capabilities are
single-use and the architecture doc (3.2) and BT-PRE-04 already say a
refusal is recovered by a new capability.
- The download check used Number(Content-Length), which let "5e0", "0x5",
"+5" and "5.0" through; it now uses the strict decimal parser the upload
path and the provider already had.
- The executor's compensateLateResponse had no caller and is deleted.
- The resumable runtime's invokeProviderAttempt now bounds each attempt with
the kernel createAbortableOperation instead of its own listener/timer
race; outcomes (ABORTED on caller abort, retryable UNAVAILABLE on the
deadline) are unchanged.
INVENTORY and the browser-transfer detail review list the new file. The
hand-rolled abort ratchet drops to 20/21; the ceiling constant is left for
the integration step so parallel lanes do not conflict on it.
Verified: RED tests "rejects a download Content-Length that is not a plain
decimal" (5e0 was accepted) and "maps capability endpoint statuses with the
executor's recovery table" (401 was NONE); existing presigned and runtime
suites cover the moved code + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The header parser reads pre-rotation dimensions, but the default
createImageBitmap call applied EXIF/irot orientation, so an orientation
5-8 JPEG or a rotated AVIF decoded with width and height swapped and was
rejected. The default bitmap factory now passes
{ imageOrientation: "none" }. An injected createBitmap is unchanged.
Verified: RED test "decodes with the default bitmap factory without
applying orientation" (options were missing) + all gates. Real-browser
decode of a rotated image is not exercised here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The probe accepts a decode only when it matches the primary candidate's
pixel size exactly. fit inside/outside keep the source ratio, so for any
asset whose ratio differs the preset could only fail with
INTEGRITY_FAILED, and PRIVATE_SIGNED forces the probe. Per D-12 the
registry now rejects PRIMARY_REQUIRED unless fit is cover, contain or
fill; ratio-preserving fits stay allowed on presets without the probe.
README and the architecture doc state the rule.
Verified: RED test "allows a PRIMARY_REQUIRED probe only with an
exact-size fit" (inside/outside were accepted) + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A corrupt row, or one a newer build wrote with an unknown schemaVersion,
failed both upload and abort with CORRUPT_DATA until the whole partition
was deleted. The checkpoint store port gains an optional
removeUnreadable(): in one transaction it deletes the row only if it does
not parse as a checkpoint (a readable row is CONFLICT, an absent row is a
success). Explicit abort calls it on a CORRUPT_DATA read and reports
ORPHANED; the server session is left to expire because the row names no
session. upload() still fails closed on such a row. The port change is
additive (optional method); the architecture doc notes the exception.
Verified: RED tests "removes an unreadable checkpoint row on abort and
reports ORPHANED" (was CORRUPT_DATA) and "removes only an unreadable row
without a revision" (method missing) + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failing range worker only set firstFailure, which the other workers read
on their next loop. An in-flight sibling kept retrying its part until its
own attempt deadline, so the caller got the failure minutes late. The
workers now share a transfer-scoped abort combined with the request signal;
the first failure aborts it, and a sibling's resulting ABORTED never
replaces the failure that won.
Verified: new RED test "aborts in-flight sibling workers as soon as one
part fails" (sibling signal was never aborted before the fix) + all gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Policy validation only checked partSize × copyFactor against
maxInFlightBytes. With the defaults (5 MiB × 4 into 20 MiB) the runtime
silently clamped workers to 1 while createSession still asked the server
for maxConcurrency 3, contrary to the documented rule that
partSize × concurrency × copyFactor over the budget is refused up front.
Per D-2 the default maxConcurrency is now 1 (the value that actually ran)
and maxInFlightBytes stays 20 MiB. Validation multiplies by maxConcurrency,
so a resolved policy always fits its workers in memory; the now-dead
memory clamp in the range-reader worker count is removed and createSession
requests the concurrency the runtime can run.
Verified: RED in tests/unit/resumable-upload-runtime.test.ts --
"has a valid production default policy" (maxConcurrency 4 over a 48-byte
budget did not throw) and "requests the concurrency the default policy can
actually run" (createSession got requestedMaxConcurrency 3) failed before
the fix and pass after. Existing test and browser-spec policy overrides
already satisfy the rule. Gates: check:architecture, check:types:app,
check:types:test, lint, test:component pass; test:unit passes except
removal-fixture.test.ts, which needs untracked artifacts/release/* absent
from a fresh worktree (unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The control plane accepts base64url IDs (/^[A-Za-z0-9_-]{8,512}$/), but the
presigned provider and executor each re-checked session, resource and
idempotency IDs with their own /^[a-z0-9][a-z0-9._:-]{0,255}$/i. IDs that
start with '-'/'_' (about 3% of random base64url IDs) or exceed 256
characters passed session creation and checkpointing, then every part issue
and the final download issue failed as INVALID_INPUT.
checkpoint-schema.ts now defines SAFE_TRANSFER_ID next to SAFE_OPAQUE_ID as
a superset of it; the provider and executor import it instead of keeping
their own regexes. IDs the presigned layer accepted before are still
accepted (no narrowing for non-upload download resource IDs).
Verified: RED "presigned layer accepts every control-plane opaque ID"
(tests/unit/presigned-transfer-upload.test.ts; leading '-', leading '_',
512 chars, for issueUploadPart + PUT and for issueDownload) returned
INVALID_INPUT before the fix and passes after. Gates: check:architecture,
check:types:app, check:types:test, lint, test:component pass; test:unit
passes except removal-fixture.test.ts, which needs untracked
artifacts/release/* absent from a fresh worktree (unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snapshotRequest() threw a TypeError when the source exceeded maxFileBytes
or maxPartCount, and upload() mapped every snapshot error to INVALID_INPUT.
The LIMIT_EXCEEDED branch in executeUpload() re-checked the same policy
and could never run, so a 6 GB file was reported as invalid input.
snapshotRequest() now validates only request shape; executeUpload() owns
the size check and returns LIMIT_EXCEEDED before any control-plane call.
Verified: RED "reports a source over maxFileBytes as LIMIT_EXCEEDED"
(tests/unit/resumable-upload-runtime.test.ts) received INVALID_INPUT before
the fix and passes after. A valid policy already bounds the part count by
maxFileBytes, so the maxPartCount branch is covered by the same check.
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component pass; test:unit passes except removal-fixture.test.ts, which
needs untracked artifacts/release/* absent from a fresh worktree (unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dispose() cached its drain promise. When the cleanup deadline expired it
returned UNAVAILABLE/retryable but kept that promise, so a later dispose()
replayed the same failure even after all work had settled: the checkpoint
store was never closed and lifecycle stayed CLOSING.
The one-shot admission close and the quiescence promise now live in
beginTeardown(); each dispose() races that shared quiescence against a new
deadline, and an expired drain resets so the next call can close the store.
Verified: RED "closes on a later dispose() once work that outlived the
deadline settles" (tests/unit/resumable-upload-runtime-teardown.test.ts)
failed with { ok: false } on the second dispose before the fix and passes
after. Gates: check:architecture, check:types:app, check:types:test, lint,
test:component pass; test:unit passes except removal-fixture.test.ts, which
needs untracked artifacts/release/* absent from a fresh worktree (unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
712 -> 612줄. 연결 수명주기와 트랜잭션 상태기계가 커널로 갔고 CP의 손수
abort 리스너가 0이 됐다. 그래서 abort 래칫을 24에서 23으로 조인다.
보존한 동작 다섯 가지:
- 값 없는 완료는 CORRUPT_DATA/RECONCILE (translate에 NO_VALUE_PRODUCED를
명시 매핑). 빠뜨리면 UNAVAILABLE로 바뀐다
- durability는 undefined를 명시적으로 넘긴다. 커널 기본이나 strict를 쓰면
체크포인트 쓰기가 조용히 느려진다
- nativeFailure 6곳 전부 context.fail. requestFailed로 바꾸면 요청이
실패했는데도 뒤 요청이 커밋된다
- abort()가 throw하면 caller-abort 주장을 철회한다 (커널이 이미 구현)
- blocked 타이머는 주입형 timers
사양이 빠뜨린 함정 하나를 추가로 막았다. bindScope는 succeed()에 해당하는
것이 없어 그대로 옮기면 정상 바인딩이 NO_VALUE_PRODUCED로 보고된다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four browser-capability specs never reached the code they were named for. The
`PRESIGNED_TRANSFER_V1` envelope gained a top-level `protocol` field, and the
fixtures kept answering without it, so every capability was refused before any
object request was made: the download and part-upload success paths were
asserting against an empty transcript rather than exercising a real GET or PUT.
The fixtures now speak the protocol they claim to, and the part-deletion
expectation carries the physical effect the adapter reports.
A refused capability document also answered `recovery: NONE`, telling the
caller there was nothing to be done. The design record fixes this class of
refusal as re-issuable and the vault already answers `REISSUE_CAPABILITY` for
it, so the HTTP decoder disagreed with both. It now agrees.
Lab performance produced no evidence at all. Playwright matches accessible
names by substring, so the navigation entry "플랫폼 구성" also matched the home
page's "플랫폼 구성 보기" call to action; the locator resolved to two links and
the run died on a strict-mode violation before the first measurement. With an
exact match the metrics are collected, and they show the named-interaction
budget is missed on this machine — a real signal that was previously invisible.
The platform overview baseline was captured before the reference routes moved
from `integration-defined` to `session-required` and was never regenerated, so
the only visual gate that could catch a regression on that page was failing for
its own staleness. Regenerated after confirming the diff is exactly that label.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The capability vault checked an issuer's registration and then read it
again to store it, including its nested header rows. A stateful issuer
could show an allowed header set to the forbidden-header check and hand
`Authorization` to the copy, so the vault stored — and the executor sent —
a credential no rule had ever seen. The registration and everything nested
in it is now snapshotted once, and only that snapshot is validated,
frozen and stored.
The upload control plane had the same shape one level down: a `sessionId`
that answered `session_01` to the regex and `../../unsafe` to the result
snapshot reached a success receipt.
Two lifetimes were also unowned. A download source lease that resolved
after the caller's abort never reached the holder, so nothing closed it
and its fetch reader and capability lease outlived the terminal result; a
compensator sharing the holder's close-once latch now closes it exactly
once. And `dispose()` proved quiescence from the wrapper registry alone,
so a provider that ignored its attempt deadline let teardown report a
drained runtime and close the checkpoint store while the provider was
still running. Raw provider promises are now their own registry and the
drain must prove both.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The primitive decided a raced outcome by draining a hard-coded four
microtasks and then asking whether the task had landed. That made the
answer depend on scheduling rather than on what was observed: a caller
abort could fix the terminal owner synchronously and a rejection later in
the same call stack still won the public result, so `race()` disagreed
with `terminal()` and the failure taxonomy a caller received depended on
microtask ordering.
Task settlement and the terminal event now share one settle-once state
machine. Whichever callback actually runs first owns the outcome; a value
that loses is compensated exactly once and a rejection that loses is
absorbed, so neither can surface late.
The three consumers that kept their own copies of these mechanics move
onto it. The Image probe and the Resumable fetch transport attached their
caller listener before installing the timer, so a scheduler that threw
rejected the public `probe()`/`execute()` promise natively and left the
listener on the caller's signal; both now close atomically inside their
own Result vocabulary and start no fetch. `snapshotAbortTimers` binds the
scheduler callables once at construction, so replacing a method after
composition can no longer change how work already in flight is bounded.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
TR-RR-06. dispose() now bounds its drain with a cleanupDeadlineMs from policy
and returns the result, so a non-cooperative mutation lock or provider can no
longer make teardown unbounded and an unproved drain is reported as still
CLOSING instead of closed over. The checkpoint store stays open in that case,
because something can still write to it. An abort is admitted physical work
like an upload, so it joins the tracked set rather than being stepped over.
TR-RR-07. The verification slot belongs to the raw verifier, not the wrapper.
Releasing it when the caller's wait expired let an abandoned verification keep
running while a new one was admitted, so repeated aborts produced more
concurrent physical work than the configured cap allows. The slot is now
released only once the raw tasks settle.
TR-RR-04. A presigned byte source owns a fetch reader and a capability lease and
its port requires close(); the delivery consumer never called it. The closeable
subtype is lost in the FileByteSource projection, so a holder keeps it from the
moment the lease exists and the outermost finally closes it exactly once — on
success, validation failure, writer failure and abort alike.
check:adapter-inventory now also fails if the shared abortable-operation
primitive has no production importers. It was safe to add only once the
presigned subsystems actually migrated onto it; a gate that fails CI for a
documented, unfixed defect reports the wrong thing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TR-RR-05. The shared abortable-operation primitive now distinguishes VALUE,
REJECTED and TERMINAL, so a collaborator's own rejection is no longer forged
into a cancellation and race() always names the same first owner terminal()
reports. The caller signal and scheduler are captured once, so replacing a
method after construction cannot change how an in-flight operation is bounded.
A scheduler that cannot install the deadline is itself terminal: previously it
released the caller listener and left no owner, which made every later abort
invisible. Late values are compensated exactly once.
Both presigned subsystems, which each carried their own copy of these
mechanics, are now projections of that primitive — giving it real production
importers rather than a shared helper nobody used.
TR-RR-01. close() on an active download aborts the scope instead of only
dropping listeners, so a fetch or read already in flight actually stops. The
consumer's stream signal joins the operation's ownership before any I/O begins,
so an already-aborted consumer no longer causes one network request first.
TR-RR-02. The upload abort scope is created before the digest, and the digest
races the caller and the deadline like every other step. A non-settling hash can
no longer hold put() open, and the vault claim and the network call happen only
after the owner is re-checked.
TR-RR-03. A capability registration is a versioned exact union validated at
registration time: the protocol version, HTTPS only, exact own-data fields, a
2xx expected status, and no ambient credential or cookie header — a presigned
URL carries its own authorization, and a session header alongside it would send
the user's credentials to that origin.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TR-RR-08. Object.keys sees only enumerable own string keys, so a symbol or
non-enumerable extra field passed the exactness check unseen and the property
reads that followed invoked whatever accessor the sender installed — escaping
the Result contract as a native rejection out of a public method. Key exactness
is now checked against own property descriptors inside a catch, and each decode
runs within the adapter's failure boundary so a proxy trap becomes a typed
CORRUPT_DATA result.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TR-RR-09. The documented BT-IMG-02 contract requires a private response to
carry no-store and fail closed when any directive that describes cacheability
accompanies it. The probe checked only that no-store was present and public was
absent, and the suite pinned the contradictory "private, no-store" as a success.
Both now follow the recorded contract: only no-store and syntactically valid
unknown extensions are admitted, and public, private, immutable, max-age,
s-maxage, no-cache, must-revalidate and proxy-revalidate each fail closed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
BT-UP-06: close() previously aborted the lifetime and closed the checkpoint
store immediately, so a caller could not wait for an active operation's terminal
settlement and a late provider result could still race the store.
The runtime now tracks every admitted operation until it settles. close() stays
the compatibility facade that closes admission and starts the drain, while
dispose() returns that same single-flight promise: it aborts the operation
registry, awaits actual settlement, and only then closes the checkpoint store
and cancellation channel. lifecycle() exposes OPEN, CLOSING and CLOSED, and a
draining runtime refuses new admission.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
BT-PRE-02: add the top-level PRESIGNED_TRANSFER_V1 protocol literal to the
capability request and response. A missing, V0 or V2 envelope is closed as
POLICY_REJECTED before the vault registers anything. The server negotiates by
request shape; fields are never dual-emitted into a strict decoder, and the
nested PRESIGNED_MULTIPART_V1 binding protocol is unchanged.
BT-PRE-03: aborting a controller does not settle a fetch that ignores its
signal, so both presigned scopes now race the task, cancel a late response body
and survive a throwing scheduler without leaking the external abort listener.
BT-PRE-04: the vault owns its registration invariants, re-checking method,
href/origin/path agreement, embedded credentials, byte bounds, digest shape and
expiry, so a second issuer cannot register a weaker capability of the same type.
BT-PRE-05: decode each path segment once and require it to round-trip through
the canonical uppercase percent encoder, closing %2f, %5c, %252e%252e, mixed-case
escapes and encoded NUL while still admitting valid opaque UTF-8 segments.
BT-UP-02: inject and snapshot the upload transport clock and scheduler, so
Retry-After delta-seconds and HTTP-date resolve against the same captured now
and a clock rollback clamps to zero instead of producing a negative delay.
BT-IMG-01: make the image resolve() lifetime signal required, replacing the
hidden PRIMARY_REQUIRED preset precondition with a type-level one, and add the
negative typecheck fixture and gate that prove it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>