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>
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>
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>
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>
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>
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>
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>