- cursor pagination re-serialized every accumulated item on each page
(O(pages x total)) and used items.push(...page.items), which throws
RangeError for a large page, so loadAll rejected instead of returning
a Result. Each page is now measured once and summed (errs high by at
most one byte per page), the item count is checked before copying,
and items are appended one by one.
- conditional-validator-store accepted `W/"` as a weak ETag because its
opening quote also satisfied endsWith('"'). The closing quote must now
come after the opening one.
- browser-rpc-runtime's validTransportFailure had no callers, duplicated
decodeTransportFailure and read properties directly, which RPC-RR-04
forbids. Deleted (approved for this template).
Verified: new tests failed RED (18 serialized items instead of 6 because
the accumulated array was passed each time, RangeError for a 1,000,000
item page, `W/"` installed) and pass now. All lane gates pass except the
known removal-fixture test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three gaps in the unary/stream runtime:
- A KEYED_COMMAND/NON_REPLAYABLE unary that failed after the transport
was invoked (timeout, throw, UNAVAILABLE, ...) came back retryable
with action "retry", although the server may have applied it. Every
failure of a COMMAND after send now carries effect MAYBE_APPLIED
(retryable false, contact-support). Pre-send rejections and queries
are unchanged.
- A retry did not re-check the scope generation, so after a logout the
previous user's command could be sent again. Each retry now checks
safeIsCurrent first and ends with SCOPE_GENERATION_CHANGED.
- A stream whose consumer aborted but never called return() stayed
suspended at a yield; its finally never ran and the operation stayed
RPC_STREAM_DRAINING for good. The lease is now released (cancel +
positive-close subscription) from the stream's own abort listener;
finally triggers the same path through its abort.
Verified: five new tests failed RED (no effect, second attempt sent,
cancel never called) and pass now; a pin that pre-send command failures
and query failures stay effect-free passes before and after. All lane
gates pass except the known removal-fixture test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TanStack 5 invalidateQueries resolves only after the active refetches
finish. The coordinator awaited each namespace in a for loop, so one
invalidation (and lease.release(), which waits on it) took the sum of
every namespace's refetch time. The namespaces now run through
Promise.allSettled; each rejected one is still reported once as
"invalidate".
Verified: new test holds the first namespace's refetch open and failed
RED (second invalidateQueries never started); it now passes and checks
that a failure is reported once. All lane gates pass except the known
removal-fixture test; provider-guardian-transaction timed out once under
load and passed on rerun.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retried command reported only its last attempt's effect. An IDEMPOTENT
command whose first attempt was lost (network error or 429) and whose
retry got a NOT_APPLIED problem ended as "not applied, retry", although
the first attempt may have applied. A 5xx with an HTML or empty body is
MAYBE_APPLIED for a command, yet the executor still replayed it.
The executor now records what each retried attempt settled on and joins
it into the final outcome's effect. An admission whose own certainty is
MAYBE_APPLIED (or APPLIED_CONFIRMED) is not retried; a 429 still is,
because its admission reason is RATE_LIMITED rather than an effect
verdict. The logical accumulator is not reused because it is raised at
dispatch and cannot tell a rejected attempt from a lost one.
Verified: three new tests (lost response then 400, 429 then 400, 504
empty body) failed RED with NOT_APPLIED / a second attempt and now pass.
All lane gates pass except the known removal-fixture test; two component
tests timed out once under load and passed on rerun.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The executor decided the terminal outcome of an ended wait in six places
(credentials, lease, dispatch, transport backoff, admission, retry
backoff). The two backoff copies only checked the caller, so a scope
fence during a retry sleep ended as TRANSPORT_FAILURE{TIMEOUT} and the
user saw "timed out, retry" after logging out.
All six sites now call one terminalOutcomeFor(phase) helper: the caller
cancels, the deadline times out, a scope fence during a wait is
ABORTED_BY_SCOPE and during admission stays the SCOPE_FENCED violation.
Verified: a new owner x phase table in http-execution-v3.test.ts pins
the 16 existing combinations and failed RED only for the two backoff
scope-fence cases (TIMEOUT instead of ABORTED_BY_SCOPE). All lane gates
pass except the known removal-fixture test (missing artifacts/).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
createBrowserCrossContextInvalidationFromHost returned undefined without any
diagnostic when the cache epoch was invalid or secure random was missing, and
bootstrap built the epoch as `release.${releaseId}`, so any release ID with
`+`, `/`, `@` or over the length limit silently turned cross-tab
invalidation off.
- The host factory now reports OPEN/FAILED/NONE with the new reasons
INVALID_CACHE_EPOCH or SECURE_RANDOM_UNAVAILABLE before returning
undefined (the zero-topic build still probes nothing and reports nothing).
- New crossContextCacheEpochForRelease() derives `release.<fnv1a-64 hex>`
from the release ID; bootstrap uses it (one call-site change in
src/bootstrap/runtime-adapters.ts).
- The observation reason union gains two members (additive); the ops runbook
lists them.
Verified: two new unit tests failed before (no observation; missing epoch
helper) and pass now. Lane gates, reference-feature and V3 integration tests,
and check:diagnostics pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NativeInputFilePicker installed the window-focus fallback on every select,
even in engines that dispatch a native `cancel`. A provider that returns
focus first and dispatches `change` only after fetching the file (Android
cloud providers) was reported as DISMISSED after the grace window. The picker
now remembers that it observed a native `cancel` and stops installing the
focus fallback for later selections.
Verified: new unit test (cancel seen, then focus + fallback timer + late
change) returned DISMISSED before and SELECTED now. Lane gates pass
(tests/component/router.test.tsx timed out once under full-gate load and
passed on rerun).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
matchActiveExact re-read, re-normalized and re-hashed the whole release
marker (up to maxEntriesPerRelease assets) on every lookup, then scanned the
asset list linearly. The adapter now keeps the last verified marker keyed by
candidate cache name + manifest digest (the digest binds every asset field)
with a Map of assets by key. Eviction is still detected through keys(), and
every served body is still hashed. Control JSON is read by collecting chunks
instead of preallocating the 2 MiB budget.
Verified: new unit test pins lookup results across two releases and eviction,
and asserts the second lookup does no marker read and no marker digest (RED
before: 3 marker reads). Cache unit tests and all lane gates pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
web-push/codec-primitives.ts now owns OPAQUE_ID/validOpaqueId, isRecord,
hasExactKeys, exactRecord, validAuthority, base64UrlDecode and (to share the
alphabet) base64UrlEncode. push-codec,
push-registration-gateway, push-association-fence-store,
push-subscription-adapter and service-worker-runtime import them instead of
carrying their own copies (the fence store's control/association key checks
now use exactRecord/hasExactKeys with the same key lists). The duplicate-key
JSON scan in push-codec.ts is untouched (realtime lane, T76).
Where the copies differed, the stricter validated behavior is kept:
- validAuthority: the fence store's null guard. The gateway's copy threw a
TypeError for a null authority, so register()/reconcile() rejected instead
of returning INVALID_INPUT; they now return INVALID_INPUT (the only change a
caller can observe; characterization test was RED before the merge).
Non-record values (arrays) are also refused.
- base64UrlDecode: the gateway's decoder, which refuses a lone trailing
character (length % 4 == 1). The window adapter's copy accepted it when the
spare bits were zero; its only caller pre-checks an 87-char VAPID key, so
that difference was not reachable. `>>` vs `>>>` gave identical bytes.
- OPAQUE_ID, isRecord/hasExactKeys/exactRecord were already identical.
Page controller: PageControllerDependencies gains optional `document`; the
6-hour update check reads it (falling back to the global document), and
bootstrap/register-service-worker.ts now passes host.document through.
New adapter file: INVENTORY.md row 126 + renumber, total 137/137; detail row in
docs/reviews/adapters/05-service-worker-and-web-push.md.
Verified: characterization tests pinned the caller-visible behavior of every
copy before the merge (spare-bit keys, VAPID key, null authority in fence
store and gateway, array/extra-key backend answers, opaque ids); all pass
after, plus direct base64UrlDecode tests and an encode round-trip against
Node's base64url for lengths 0..66. Document injection test was RED
(update() ran while the injected document was hidden), green after. Gates:
check:architecture, types app/test/service-worker, lint, test:unit (only
pre-existing removal-fixture failure), test:component,
check:realtime-boundaries, check:adapter-inventory.
Realtime reference bundle (check:optional-recipes:source, already over budget
at b953142): 40139 -> 40097 gzip bytes after T89+T90.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D-14. A click whose data or authority was refused (EXPIRED, association or
release mismatch, unreadable fence, unknown route) closed the notification and
opened nothing, so the user's tap was silently dropped. The click adapter now
opens `<origin>/` with no handoff message in that case; the refusal is still
the returned result and the terminal observation (FAILED + reason) carries the
root window's native-effect certainty. NATIVE_FAILURE (browser refused the
target window), ABORTED and a deadline-aborted signal are not retried.
The bounded openWindow step (certainty phases + late-effect observation) is
now one helper, openWindowBounded, used by both the route open and the root
open; observeLateEffect moved to the adapter scope. No behavior change for
the route path. Net effect on the realtime reference bundle stays negative
together with T90 (see T90).
The silent push drop stays by design and is now documented with its costs
(Chrome's "updated in the background" notice, WebKit revoking subscriptions
after repeated silent pushes) in
docs/architecture/realtime-events-web-push-and-bounded-polling.md 8.4/8.5.
Verified: RED first (expired and release-mismatch clicks: openWindow never
called), then green; a guard test pins that a null target window is not
retried with the root. Gates: check:architecture, types app/test/service-worker,
lint, test:unit (only pre-existing removal-fixture failure), test:component,
check:realtime-boundaries, check:adapter-inventory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page and the worker both used clientDrainMs (30s). A tab that drained at
29.999s let the worker call skipWaiting() and commit after the page had
already resolved CLIENT_DRAIN_TIMEOUT, so the requesting tab never reloaded.
The page now waits clientDrainMs + activationReplySlackMs (new additive
SERVICE_WORKER_BOUNDS field, 5s).
Verified: RED first with the real page/worker seam (last drain at 29.999s,
skipWaiting 50ms): page resolved CLIENT_DRAIN_TIMEOUT; green after.
Gates: check:architecture, types app/test/service-worker, lint, test:unit
(only pre-existing removal-fixture failure), test:component.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
onActivate wrote the activation marker first, so a quota failure on
currentCache.put threw before the stale-cache delete loop and space never came
back. Stale owned caches are now deleted first (each delete failure is counted
as not deleted instead of aborting the loop), and a failed marker write is
swallowed: activation stands, the only loss is that the next release cannot
use this cache as its previous-release fallback.
Verified: RED first (onActivate rejected with QuotaExceededError and deleted
nothing), then green with order [delete stale, marker]. Gates:
check:architecture, types app/test/service-worker, lint, test:unit (only
pre-existing removal-fixture failure), test:component.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The static cache name is the asset-set digest, so a worker built with the same
assets (same VITE_BUILD_ID, new worker code) installs into the cache the active
worker serves from. A failed install then deleted that serving cache and its
activation marker. installStaticAssets now checks caches.keys() first and rolls
back (including the deferred post-deadline delete) only a cache this install
created. Rewriting an existing cache only puts identical sha256-verified bytes.
InstallDependencies.caches gains an optional keys(); without it the old
behavior (always roll back) is kept.
Verified: RED first (existing-candidate test saw one delete), then green; a
second test pins that a newly created candidate is still deleted. Gates:
check:architecture, types app/test/service-worker, lint, test:unit (only
pre-existing removal-fixture failure), test:component.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fetch listener only called respondWith for URLs in the current manifest,
so the previous-cache fallback (T29) never ran for the one case it exists for:
a tab of the previous build lazy-loading a chunk the new release no longer
lists. classifyFetch now returns PREVIOUS_RELEASE_FALLBACK for a same-origin,
non-navigate GET whose path is a content-hashed name (HASHED_STATIC_ASSET_NAME)
and that is not in the manifest; the runtime answers it only from the marked
previous release cache, otherwise the entry falls back to the network. The
decision is a synchronous runtime.intercepts() so respondWith is still called
only for requests the worker may answer. Runtime config and release manifest
stay network-only even though `-manifest.json` matches the hash pattern.
Verified: RED first (3 new tests failed: runtime onFetch returned null, entry
did not call respondWith), then green. New entry tests cover old chunk from
previous cache, previous miss -> network, and no interception for navigate,
POST, API, cross-origin, unhashed same-origin and release-manifest.json.
Gates: check:architecture, types app/test/service-worker, lint, test:unit
(only pre-existing removal-fixture failure), test:component.
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>
Two small holes in the IndexedDB kernel (src/adapters/platform/):
- runIndexedDbTransaction: a `fail(x)` after `succeed()` kept the success
candidate, so the abort it triggered was reported as an anonymous
NATIVE_EXCEPTION and `x` was lost. `fail` now replaces a success
candidate; an earlier failure still wins.
- openIndexedDbDatabase: when the open had already settled (caller abort,
terminal BLOCKED, blocked deadline, close) before `onupgradeneeded`
fired, the upgrade still ran and committed the migration. The handler now
aborts the versionchange transaction when the open is already settled.
Tests that encoded the old behavior were updated in this commit:
tests/unit/indexeddb-transaction.test.ts ("an abort after succeed...")
expected NATIVE_EXCEPTION and now expects the caller's failure, and
tests/unit/indexeddb-runtime.test.ts ("times out a blocked upgrade...")
expected the late upgrade to commit and its connection to be closed; it now
expects no schema commit. Both fail without the fix.
Verified: new tests (fail after succeed on a real fake DB does not commit,
first failure still wins, late upgrade after caller abort and after
BLOCKED is aborted without running the upgrade callback) were RED and are
GREEN. All gates pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a put failed before commit and the compensating ABORT_PUT or the
journal rollback did not complete, the coordinator returned a generic
CONFLICT / OBJECT_RECONCILE (or the rollback's own code). A user cancel or
a full disk reached the caller as a bare conflict.
compensatePreparedPut now takes the put's failure and returns it. If the
compensation completes, the failure is returned as before. If it does not,
the journal row is still left for reconciliation, and the failure keeps its
code, operation and retryable flag; only recovery becomes RECONCILE. The
architecture doc's compensation rule says the same.
Verified: new tests in tests/unit/opfs-byte-store.test.ts were RED (5
cases: failed cleanup, unknown cleanup effect, caller cancel, failed
rollback, FILES_READY failure) and are GREEN; the successful-compensation
case pins the unchanged path. All gates pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runtime and maintenance each carried their own Stored* row types,
isStored* validators, record size formula, countBucket and failureOf, and
the dataset binding check had a third, hand-written budget validator. A
field added to one copy would make the other judge a healthy row corrupt.
indexeddb-records.ts now holds the row types, the validators, the budget
key and measureRecordBytes (payload + 512-byte envelope + UTF-16 key). Each
call site keeps its own failure code for a bad measurement (runtime
INVALID_INPUT, maintenance MIGRATION_FAILED), and only the binding check
still bounds a stored budget by hardBudgetBytes. The one validator
difference (maintenance's retention check did not re-validate the key it
compared against) is unobservable: it always passes a validated record key.
Verified: characterization tests added first in
tests/unit/indexeddb-maintenance.test.ts pin the size formula in both
writers, the per-site failure codes for NaN/negative/oversized sizes, and
the hardBudgetBytes bound at open (runtime and maintenance fail with
POLICY_REJECTED one byte over, open at the limit). They passed before and
after the refactor. INVENTORY.md (137/137) and the storage detail table
list the new file. All gates pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
openObject used to send VERIFY_OBJECT, which read and hashed every chunk,
and then streamed the object with READ_CHUNK, which read and hashed every
chunk again. A large object did twice the I/O before the first byte and
could exceed the RPC timeout during the pre-check.
VERIFY_OBJECT now takes an optional `manifestOnly` flag. openObject sends
it, so the pre-check only compares the stored manifest with the caller's
copy. Integrity is kept on the stream: READ_CHUNK still hashes each chunk,
and at the last chunk it also checks the chunk list against the root digest
before releasing the bytes, so a stream never ends as a success on an
unverified object. An empty object has no chunk to read, so its root digest
is still checked at open. verifyObject (reconcile) keeps the full check.
Verified: new tests in tests/unit/opfs-worker-runtime.test.ts were RED
(open read each chunk; a corrupted chunk or forged root failed at open) and
are GREEN (open reads no chunk bytes, each chunk is read once, a corrupted
chunk and a forged root digest fail the stream, empty objects are checked
at open, verifyObject still detects a corrupted chunk). All gates pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first R-0 pass prefixed only the tsc/vite/test entry points. 36 more
package scripts run node entry files that import src and therefore the
gitignored index, including ci:gate (the CI runner) and check:ci, so they
still failed on a fresh checkout.
- prefix those scripts with the index generator
- update the CI contract's canonical check:artifact-schemas command
- the guard test now walks relative imports from every node entry and
fails if a script reaches src/.generated without rendering it first
Verified from a fresh state: check:registries, check:ci, check:i18n,
check:design-system, check:diagnostics, check:realtime-boundaries,
check:artifact-schemas, verify:compatibility, ci:gate FE-GATE-001 pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reconcile() re-registered every native subscription the server reported
ABSENT. After an offline logout whose unsubscribe() failed, the fence is
rotated to the next account with a REVOKED association while the native
subscription survives; the next account's boot reconcile then
registered it without that account's opt-in.
When the server answers ABSENT, reconcile() now re-registers only if the
local association is ACTIVE (the server lost it). For REVOKED or
UNASSOCIATED it runs the existing guarded cleanupNative() (captured
subscription, unchanged fence, owned notification close, bounded) and
returns PUSH_UNAVAILABLE with BACKEND_ASSOCIATION_MISSING, or
NATIVE_UNSUBSCRIBE_AMBIGUOUS when cleanup could not complete.
Pinned first: "re-registers when the local association is ACTIVE (crash
recovery)" passed before and after the change.
RED before fix (resolved PUSH_READY, i.e. the next account was signed
up): "unsubscribes instead of registering when the local association is
REVOKED" and "... is UNASSOCIATED".
Gates: check:architecture, check:types:{app,test,service-worker,recipes,
node,web-worker}, lint, test:component pass. test:unit passes except the
pre-existing removal-fixture.test.ts case that needs generated release
evidence under artifacts/ (absent in a fresh worktree; unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fetch listener called respondWith() for every request, so every
navigation, API call and cross-origin request went through
onFetch -> fetch(request) inside the worker, even when only WEB_PUSH was
selected.
The listener now decides synchronously and calls respondWith() only for
a non-navigation GET whose URL is in runtime.manifestUrls; everything
else returns without touching the event. The fetch listener is only
registered when PWA_STATIC_ASSETS is selected, so a push-only worker is
not booted for fetches at all.
RED before fix:
- "service worker entry fetch interception (R-6.6) > answers only
same-origin GETs for manifest assets": respondWith was called for a
navigation.
- "... > registers no fetch listener without the static asset handler":
a fetch listener was registered.
The test loads the real entry module against stubbed worker globals and
build-time constants.
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Static install compared content-type by exact match, so a server
answering `.js` with `application/javascript` failed every install with
CONTENT_TYPE_INVALID. It also compared Content-Length with the decoded
byte count, so any gzip/br response (whose Content-Length is the
encoded size) failed with BYTES_MISMATCH.
- A response type and a manifest type that are both JavaScript MIME
essences (WHATWG MIME Sniffing list) now match.
- With a content-encoding header, the declared Content-Length is not
compared. The streamed decoded byte count and sha256 checks are
unchanged.
RED before fix (both REJECTED):
- installs JavaScript served under a JavaScript MIME synonym (R-6.5)
- does not compare an encoded Content-Length with the decoded size (R-6.5)
Guard: "still checks the decoded byte count of an encoded response"
(BYTES_MISMATCH).
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
register() resolves while the first worker is still installing. With no
active or waiting worker, start() fell through to ACTIVE, and kept doing
so on every visit even when the install failed.
When there is no active worker, start() now waits for the installing
worker to reach `activated` or `redundant`, bounded by the worker's own
install deadline (installDeadlineMs) and by stop(). Activated -> the
existing RELOAD_TO_ENABLE path (no clients.claim()); redundant ->
FAILED INSTALL_FAILED; deadline -> FAILED INSTALL_TIMEOUT; no worker at
all -> FAILED INSTALL_FAILED. start() is fire-and-forget after mount,
so the wait does not block rendering.
Test fixture: pageContainer gains an `installing` option backed by a
statechange-capable fake worker.
RED before fix (both resolved ACTIVE immediately):
- does not report a first install as ACTIVE while it is installing (R-6.4)
- reports a failed first install instead of ACTIVE (R-6.4)
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
onActivate keeps one previous release cache, but onFetch only ever read
the current one, so the retained cache was never used.
On a current-cache miss, onFetch now looks up the owned non-current cache
with the highest activation marker (same rule onActivate uses; extracted
as highestMarkedCache) and serves a valid 200 hit from it. Per D-7 this
only applies to content-hashed file names; any other URL goes to the
network as before. The hashed-name rule moves to
HASHED_STATIC_ASSET_NAME in src/contracts/service-worker.ts and the
build generator imports it, so the generator and the worker share one
definition.
Scope note: the fallback runs inside onFetch's VERIFIED_CACHE_FIRST
branch, i.e. for URLs in the current manifest. Old-build chunks that are
not in the current manifest stay network-only (R-6.6 limits interception
to manifest URLs).
RED before fix: "serves a hashed asset missing from the current cache
from the previous release cache (R-6.3)" got null. Guard test "never
answers a non-hashed URL from the previous release cache (D-7)" added.
Gates: check:architecture, check:types:{app,node,test,service-worker},
lint, test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tabs that did not request an activation only observe()d
ACTIVATED_RELOAD_REQUIRED, and the host contract had no way to tell the
app. Worse, the worker targeted that broadcast at the requester's build,
so a tab on another build dropped it as TARGET_BUILD_MISMATCH. A waiting
worker produced by the periodic registration.update() was never reported
either.
- ServiceWorkerRuntimeHost gains optional onReloadRequired/onUpdateWaiting
(additive; existing host implementations still type-check).
- The page controller notifies reload subscribers when an expected worker
source sends ACTIVATED_RELOAD_REQUIRED, and watches `updatefound` +
`statechange` to announce an update that reached `installed` while an
active worker exists (a first install is never announced). Listeners
are removed on stop(); a throwing subscriber is isolated.
- Worker post-commit/reject notifications are untargeted; the requester
still pairs by nonce.
- Test fixtures: registration and workers are now EventTarget-backed.
RED before fix (listener called 0 times):
- announces an update that finished installing as waiting (R-6.3)
- page ↔ worker activation seam > tells a tab that did not ask that a
reload is required (R-6.3)
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The waiting worker sent CLIENT_DRAIN_REQUEST with
`targetBuildId: requesterBuildId`, so a tab on any other build dropped
it as TARGET_BUILD_MISMATCH, and the worker also ignored replies whose
`sourceBuildId` differed from the requester's. With a build N tab and a
reloaded build N+1 tab open, every activation ran into the 30s
CLIENT_DRAIN_TIMEOUT.
The drain request is now untargeted and replies are paired only by the
worker's own buildId (reply target), the nonce and the exact client id.
The unused requesterBuildId field and parameter are removed.
RED before fix: "page ↔ worker activation seam > drains tabs of another
build and completes the activation (R-6.2)" resolved CLIENT_DRAIN_TIMEOUT.
The test wires two page controllers (builds N and N+1) to one worker
runtime with async postMessage in both directions.
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page's activation listener checked the reply source and
`registration.waiting` before looking at nonce/kind. After skipWaiting()
the registration can already show the worker as active, so a genuine
ACCEPTED/RELOAD_REQUIRED became PROTOCOL_MISMATCH, and any unrelated
message (SYNC_WAKE_OBSERVED, CACHE_RESET_RESULT) from another source
ended a pending activation the same way (first half of 6.6-10).
Replies are now filtered by nonce and reply kind first. ACCEPTED and
RELOAD_REQUIRED (post-commit) are success when the worker is still the
waiting one or is already the active one; REJECTED still requires it to
be waiting. Source identity is still enforced.
RED before fix (both returned PROTOCOL_MISMATCH):
- accepts a post-commit reply after the waiting worker was promoted (R-6.1)
- ignores unrelated worker messages while an activation is pending (R-6.1)
Gates: check:architecture, check:types:{app,test,service-worker}, lint,
test:component pass. test:unit passes except the pre-existing
removal-fixture.test.ts case that needs generated release evidence
under artifacts/ (absent in a fresh worktree; unrelated to this diff).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prepared objects were validated in three places with different rules. The
worker required integrity.chunkSizeBytes, chunk sizes, chunk count and
object size to match the current runtime policy; the journal checked the
object against itself; the page only checked the shape. Changing
chunkSizeBytes (allowed by opfs-policy) made every existing object fail:
open returned INTEGRITY_FAILED, FILES_READY reconcile failed CORRUPT_DATA
(and, had cleanup succeeded, would have rolled back a valid object), and
COMMITTED reconcile failed INVALID_INPUT at FINALIZE_PUT.
The journal's policy-free rules move to opfs-prepared-object.ts, the one
definition of isPreparedObject (and of the physical schema check). The
worker's VERIFY_OBJECT, READ_CHUNK, FINALIZE_PUT and FILES_READY receipt
paths and the page's FINISH_PUT parse use it, so a stored object is
checked against its own manifest. The current policy still governs new
writes only: validateObjectWriteInput, BEGIN_PUT's chunk size check and
APPEND_CHUNK's size and count limits are unchanged. stableJson keeps its
two copies; they differ in how a non-finite number fails and unifying
them would change error mapping.
Verified: new test "R-5.5 stored objects are checked against their own
chunk size" writes an object with 64 KiB chunks, then reconciles and opens
it through a 128 KiB runtime. Before the fix reconcile failed CORRUPT_DATA
and open failed INTEGRITY_FAILED; now reconcile commits without rollback,
the bytes read back, and a new put uses 128 KiB chunks. A new journal test
pins that a 4 MiB-chunk object round-trips and an inconsistent one is
still rejected (passes before and after). Inventory and the storage
detail review list the new file.
Gates: check:architecture, check:types:app/test/web-worker, lint,
test:component pass; test:unit passes except removal-fixture.test.ts
(needs gitignored release artifacts absent from a fresh worktree);
check:adapter-inventory accepts the new row but still reports two rows
already missing at f0d3953 (http/platform-error-mapping.ts,
telemetry/feature-telemetry.ts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SESSION_END, LOGOUT and ACCOUNT_DELETION purges validated every row they
were about to delete and checked the dataset budget counters on each step.
One unreadable record, a record without a valid sidecar, a bad receipt or
a budget counter off by one aborted the batch with CORRUPT_DATA, and the
next batch restarted and hit the same row, so the partition's personal
data never left the device.
The partition purge now deletes by key without making row validity a
precondition. Rows that fail validation are counted and reported as one
CORRUPT_DATA observation per batch through the existing observe channel.
Per-row budget arithmetic is removed; the transaction that finds every
store empty resets the budget row to zero, which also heals a drifted
counter. Between batches the budget can only read high (blocks writes,
never admits). The purge still opens only the partition's own database,
whose name is derived from the partition token. RETENTION_SWEEP is
unchanged and still fails closed on corrupt rows.
Verified: new test "R-5.4 completes a LOGOUT/ACCOUNT_DELETION purge past
corrupt rows" seeds a corrupt record, an invalid sidecar, an invalid
orphan sidecar, an invalid receipt and a drifted budget. Before the fix
the first batch failed CORRUPT_DATA; now the purge reaches COMPLETE, all
rows are gone, the budget is zero, a CORRUPT_DATA observation is emitted,
and a second partition routed through the same factory keeps its row.
Gates: check:architecture, check:types:app/test/web-worker, lint,
test:component pass; test:unit passes except removal-fixture.test.ts,
which needs gitignored release artifacts absent from a fresh worktree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A put holds the origin-wide OPFS mutation lock from BEGIN to FINISH, and
every other BEGIN_PUT, REMOVE_OBJECT, FINALIZE_PUT, cleanup and GC request
queues on it. The page started each request's 60s RPC timer at post time,
so a second put or a remove queued behind an upload longer than 60s failed
UNAVAILABLE while the worker kept waiting and later ran it anyway.
Per D-3 the lock scope is unchanged. The worker now acquires the lock
through one wrapper built on the platform abortable-operation kernel that
bounds the wait by a new policy value, mutationLockWaitTimeoutMs (default
10 min, validated 1s..1h); a request still queued at the bound leaves the
queue and fails BLOCKED, retryable, and a lease granted after the wait
ended is released at once. The page gives requests that can queue on the
lock (listed once in the protocol as OPFS_LOCK_WAITING_REQUEST_KINDS) a
timer of rpcTimeoutMs + mutationLockWaitTimeoutMs, so queue time never
eats the request's own 60s. Other requests keep rpcTimeoutMs.
Verified: new tests "R-5.3 lock waiting is not counted against the RPC
timeout" use an exclusive FIFO lease manager and the real client and
runtime. Before the fix a put and a remove queued behind a stalled put
settled as failures at 60s, and at the policy bound they reported
UNAVAILABLE instead of BLOCKED. Now they wait, then complete once the
lock frees, or fail BLOCKED at the bound with the queue emptied.
Gates: check:architecture, check:types:app/test/web-worker, lint,
test:component pass; the hand-rolled abort ratchet in
check:adapter-inventory stays at 21; test:unit passes except
removal-fixture.test.ts, which needs gitignored release artifacts absent
from a fresh worktree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
writeImmutableChunk returned early when a chunk with the same digest
already existed, so the chunk kept its old lastModified. Orphan GC decides
"not referenced" from the page journal and deletes in the worker; another
tab's GC holding a stale answer could delete a day-old chunk right after
this put reused it and left staging, and the committed object then failed
INTEGRITY_FAILED on open.
A dedup hit now rewrites the identical bytes through the atomic writable
path, which refreshes lastModified so DELETE_ORPHAN_CHUNK's grace check
skips it. Readers of the committed chunk see either copy, never a partial
file. The mutation lock scope is unchanged.
Verified: new test "R-5.2 a dedup-reused chunk is protected by the grace
period again" ages a committed chunk, reuses it from a second put and
finalizes. Before the fix LIST_ORPHAN_CANDIDATES still returned the reused
digest; now it is neither listed nor deleted and the second object
verifies.
Gates: check:architecture, check:types:app/test/web-worker, lint,
test:component pass; test:unit passes except removal-fixture.test.ts,
which needs gitignored release artifacts absent from a fresh worktree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LIST_ORPHAN_CANDIDATES returned at most 100 old chunks in directory order,
committed ones included, and had no way to continue. Once more than 100
day-old committed chunks existed, every reconcile got the same referenced
page, deleted nothing and reported DEADLINE_REACHED; real orphans behind it
leaked quota forever.
The request now takes an optional afterDigest cursor. The worker walks
prefix directories and chunk names in ascending digest order and returns
only digests after the cursor. The coordinator pages on with the last
digest of each page until no more are available or its deadline hits.
The gateway method gets the cursor as a new trailing optional parameter.
Deletion safety checks (journal reference, staging receipts, grace period)
are unchanged.
Verified: new test "R-5.1 orphan GC pages past referenced chunks" wires the
real worker runtime, client gateway and coordinator. Before the fix it
failed with inspected 100, deleted 0, DEADLINE_REACHED; now both orphans
(lowest and highest digest) are deleted and all 150 referenced chunks
remain. The existing listOrphanCandidates call-arity assertion now expects
the extra undefined cursor argument.
Gates: check:architecture, check:types:app/test/web-worker, lint,
test:component pass; test:unit passes except removal-fixture.test.ts,
which needs gitignored release artifacts absent from a fresh worktree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared credential admission (V2 and V3) only rejected CR/LF. A token
with NUL, a non-Latin-1 character or another control character passed,
then Fetch rejected it after V3 had marked the attempt dispatched: a query
burned its retry budget and a command ended MAYBE_APPLIED with
NETWORK_FAILURE. The external session adapter also merged header names
that differ only in case, silently keeping the last value.
- admitCredentialHeaders: the value must match [\x20-\x7E\xA0-\xFF]+ (a
ByteString without C0/C1 controls); the size limit is now the string
length, which is the wire byte count for a ByteString. Failure stays
CREDENTIAL_HEADER_VALUE_INVALID, i.e. AUTH_INTEGRATION_FAILURE before
dispatch.
- checkFinalInvariants: builds `new Headers(headers)` first; any value
Fetch would reject fails as HEADER_VALUE_INVALID (new additive member of
FinalInvariantFailure) with zero fetch calls.
- validateCredentialPatch: rejects case-only duplicate header names.
RED before fix: http-execution-v3-live-authority.test.ts "rejects a NUL /
non-Latin-1 credential value before dispatch" (got TRANSPORT_FAILURE, fetch
called), http-contract-bridge.test.ts "rejects a NUL/non-Latin-1/tab/DEL/C1
control value ..." and "fails before dispatch when Fetch would reject a
header value", auth-session-adapter.test.ts "rejects credential headers
that differ only in case instead of merging them". Pinned: "admits an
ordinary bearer token", CR/LF rejection, existing "Bearer ok"/"Bearer
token" integration paths.
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component, test:integration, test:contract, test:platform,
test:reference-feature pass. test:unit passes except removal-fixture.test.ts
(needs generated artifacts/ release evidence absent in a fresh worktree;
unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A gateway 502/503/504 (or 408/425) with an HTML, empty or broken body
ended as CONTRACT_VIOLATION without response metadata, so httpStatus and
http_status_group were lost, and the feature binding turned it into a
non-retryable "contact support" failure. Request-side violations
(FINAL_REQUEST_INVARIANT_FAILED, MISSING/UNEXPECTED_IDEMPOTENCY_KEY) fell
through to ENVELOPE_MISMATCH, a server-response error.
- V3: violations raised while admitting an error-status response now carry
the response `metadata` (additive optional field on CONTRACT_VIOLATION).
The observation status reads `metadata` from any outcome that has it, so
telemetry keeps http_status_group (this also gives a server 401 "4xx").
- Binding: a violation whose status is 5xx/408/425 becomes SERVER_FAILURE
with httpStatus (retryable, action "retry" unless the effect is uncertain).
Other violations keep their kind and now include httpStatus when known.
Request-side violations map to VALIDATION_REJECTED.
RED before fix: http-execution-v3.test.ts "ends a 502/503/504/408 response
as a retryable server failure with its status" (observation status
undefined, binding kind CONTENT_TYPE_MISMATCH/SCHEMA_MISMATCH/...),
feature-http-binding.test.ts "does not report the request-side violation
... as a server envelope mismatch" (got ENVELOPE_MISMATCH).
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component, test:integration, test:contract, test:platform,
test:reference-feature pass (reference-page "mounts list and detail keys"
timed out once under load avg ~50 and passed on rerun). test:unit passes
except removal-fixture.test.ts (needs generated artifacts/ release
evidence absent in a fresh worktree; unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
V3 returned the same UNAUTHENTICATED outcome for "no credential, nothing
sent" and for a server 401, and the composition root called
onUnauthenticated() for both. With the demo owner that overwrote a
recovery-pending session with "unauthenticated", and the demo setState
notified even when the value did not change, which fed the scope-fence loop.
- V3: the server-401 UNAUTHENTICATED outcome now carries its response
`metadata` (additive optional field). The pre-dispatch one does not.
- runtime-adapters: onUnauthenticated() only when metadata is present.
- demo session: setState is a no-op for the current value.
RED before fix: reference-runtime-composition.test.ts "does not report a
request refused before dispatch as a sign-out" (state became
"unauthenticated"), auth-session-adapter.test.ts "does not notify when the
demo state is set to its current value" (1 notification),
http-execution-v3.test.ts "tells a missing credential apart from a server
401" (no metadata). Pinned: "still signs out when the server answers 401".
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component, test:integration, test:reference-feature, test:contract
pass. test:unit passes except removal-fixture.test.ts (needs generated
artifacts/ release evidence absent in a fresh worktree; unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every session notification aborted in-flight requests, bumped the generation
and cleared the cache, even when nothing changed. A repeated sign-out or a
token-refresh notification wiped the cache, and with V3 calling
onUnauthenticated() on a logged-out query it could loop.
The scope runtime now reads (getState, getSubject) and skips a notification
that leaves both unchanged. An identity it cannot prove unchanged still
fences: a session without getState (old behavior), a throwing owner, or an
authenticated session with no subject. A FAILED scope still retries its
reset on any notification.
To make the subject observable, SessionGateway gets an optional
`getSubject?(): string | null` and ExternalSessionOwner an optional
`readSubject?()` (additive; existing owners keep fencing on every
authenticated notification).
RED before fix: tests/unit/server-state-scope-runtime.test.ts "does not
fence, abort or clear on a repeated sign-out" / "... on a token refresh for
the same subject" saw FENCED. Pinned (passing before and after): "still
fences when the state changes / the subject changes / an authenticated
session cannot name its subject", "retries a failed reset ...".
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component, test:integration, test:reference-feature pass. test:unit
passes except removal-fixture.test.ts (needs generated artifacts/ release
evidence absent in a fresh worktree; unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A path value of "." or ".." survives encodeURIComponent unchanged, and URL
resolution (V3 `new URL`, V2 `pathname =` assignment) then collapses it into
a parent path that still sits under the base URL, so `URL_ORIGIN_ESCAPED`
never fired. `/members/{m}` with m=".." pointed at the project instead.
The V3 bridge now returns PATH_VALUE_INVALID and the V2 request builder
returns PATH_PARAMETER_INVALID for exactly those two values.
RED before fix: tests/unit/http-contract-bridge.test.ts "rejects the dot
segment ..." and tests/unit/request-builder.test.ts "rejects the dot segment
..." returned ok/success with a parent URL.
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture.test.ts, which
needs generated artifacts/ release evidence absent in a fresh worktree
(unrelated to this change).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The V3 composition admits operationIds with /^[A-Za-z][A-Za-z0-9_.-]{0,127}$/
(camelCase, up to 128 chars), but telemetry validated operation_id with
/^[A-Z][A-Z0-9_]{0,63}$/, so api.request.failed for a V3 operation such as
`getUser` failed projection as invalid-attribute-value and was dropped.
Diagnostics used the free-form 64-char safe-string pattern instead.
http_status_group had the same split: statusGroup() emits [0-9]xx|none and
diagnostics accepted that, but telemetry only [1-5]xx|none, so a failure
with status 0 or >= 600 was dropped too.
- New src/contracts/operation-id.ts holds isOperationId (the V3 grammar);
the V3 composition, telemetry operation_id and diagnostics operation_id
all use it. The REST v2 and browser RPC registry grammars are subsets.
- isHttpStatusGroup sits next to statusGroup() in diagnostics.ts and is used
by both diagnostics and telemetry.
Other telemetry attribute policies (route_id, error_kind, redaction) are
unchanged.
RED: "shared operationId and status-group grammar" failed before the fix:
getUser, users.v1.get-item and a 128-char id were rejected by telemetry;
"1getUser", "get:user", "get/user" were accepted by diagnostics; and the
statusGroup(0)/statusGroup(999) groups were rejected by telemetry.
Gates: check:architecture, check:types:app/test/node, lint, test:component,
test:runtime-schema, test:contract pass; test:unit passes except the
environment-dependent removal-fixture.test.ts (needs generated
artifacts/release files; unrelated). check:diagnostics,
check:registries:structure, check:types:web-worker/service-worker and
tests/integration, tests/platform/telemetry also pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>