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>
validateRestOperation only required QUERY to use GET/HEAD and never
checked the semantics/replayPolicy enums. A COMMAND declared as GET
passed, and rest-profiles decides whether CSRF protection applies from the
HTTP method alone, so such a command with a cookie auth profile and csrf
NONE would be sent without CSRF protection. COMMAND now requires
POST/PUT/PATCH/DELETE, and unknown semantics/replayPolicy values are
rejected (same binding browser-rpc and the V3 composition enforce).
High-risk (CSRF) change: a new test re-validates every installed REST v2
operation from installed-feature-contracts (the reference feature's two
GET queries and one POST keyed command) and all pass; the rest-profile,
realtime/bounded-polling, legacy credential and reference-feature suites
that define REST v2 operations also pass.
RED: "REST operation v2 command method and enum rules > rejects a COMMAND
sent as GET/HEAD/OPTIONS/post" and "rejects an unknown semantics/replayPolicy
value" failed with "expected function to throw an error, but it didn't".
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). tests/integration also passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isValidIdempotencyKey only rejected blank values and C0/C1 control
characters. Keys with surrounding whitespace passed and fetch trimmed them
on the wire (two commands could share one key), and non-ASCII keys passed
and made Headers.set throw a TypeError that the client reported as a
retryable NETWORK_UNREACHABLE. The key is now /^[\x21-\x7e]+$/ within the
existing 256-byte bound, the same rule as the realtime HEADER_SAFE_CURSOR.
App-generated keys (randomUUID) and all test fixtures are visible ASCII.
The existing OPT-NET-02 test pinned "키-값" and "ключ" as valid keys; it
encoded the bug and is fixed here: those values plus " order-1 ",
"order-1\t", "key with-space" and a NBSP key are now in the rejected list,
and a UUID key was added to the accepted list.
RED: "OPT-NET-02 shared idempotency key validation > rejects the same values
at intent definition and at admission" failed with '" order-1 ": expected
true to be false' before the fix.
Gates: check:architecture, check:types:app/test/node, lint, test:component,
test:runtime-schema, test:contract pass; test:unit passes except
removal-fixture.test.ts, which needs generated artifacts/release files that
a fresh worktree does not have (unrelated to this change).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
consumeText() walked every code point, appended it to the line string and
called TextEncoder.encode() on it to count UTF-8 bytes, so a 250KB chunk
allocated ~250k arrays on the main thread.
It now finds the next CR/LF with one regex scan, appends the text before it
as one slice and encodes that slice once for its byte count. Byte counts only
grow within a line, so checking the line/incomplete-buffer limits per segment
fails on exactly the same inputs as the per-character check. BOM, pending CR
across reads, CRLF terminator bytes and QUEUE_OVERFLOW ordering are unchanged.
Correctness: existing parser tests pass unchanged. New tests (all green on
the old parser first, as characterization): whole vs byte-by-byte input with
CRLF, CR-only, multi-line data, BOM and a mid-stream U+FEFF, 2/3/4-byte
UTF-8 split across reads; trailing CR blank line dispatched at finish; UTF-8
bytes (not UTF-16 units) counted against line and event limits, also when a
multibyte character is split across reads; a max-size line over 1,000-byte
reads accepted and one byte more rejected; a 248,780-byte chunk of 200
events.
Benchmark (throwaway script, not committed; Node 24.14; 200 events in one
~250KB chunk; machine under load avg 39-54 on 22 cores, so numbers are noisy):
- old/new interleaved in one process, forced GC before each run, median:
ASCII 248,780 B: 294-345 ms -> 4.3-8.2 ms (36-80x)
multibyte 248,180 B (Korean/emoji/accented): 95-130 ms -> 19-26 ms (~5x)
- each parser standalone, sequential runs, average:
ASCII: 664-764 ms -> 0.9-3.7 ms
multibyte: 155-196 ms -> 1.5-6.3 ms
Remaining cost of the new parser is mostly native TextDecoder/TextEncoder
work (profiled); a JS charCode loop for the byte count was not faster.
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 from this fresh worktree
(unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The event consumer projected every RECOVERED disposition to a
RECOVERY_COMMITTED transport outcome. For a SNAPSHOT_ONLY + barrier NONE
stream the coordinator never sets awaitingTransportBarrier, so the transport
closed, the reconnect path called confirmTransportBarrier, and the
coordinator answered PROTOCOL_MISMATCH: one sequence gap ended the stream.
The RECOVERED disposition now carries transportBarrierRequired (optional,
additive field on the RealtimeAcceptDisposition port type; absent keeps the
old "barrier required" behavior). The coordinator fills it from the same
recoveryRequiresTransportBarrier() rule that decides awaitingTransportBarrier,
and the consumer returns CONTINUE when it is false.
Test: "keeps reading after a SNAPSHOT_ONLY recovery that needs no transport
barrier" in event-consumer.test.ts wires the real fetch SSE connection,
consumer, codec and stream coordinator (only the app authority is faked).
RED before the fix: read() ended with RECOVERY_COMMITTED at the gap instead
of EOF. After: the gap recovers to snapshot 3, event 4 still applies, the
stream reads to EOF and no barrier is pending.
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 from this fresh worktree
(unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runRecovery() checked lifecycle === "DRAINING" only on entry. After
`await quiescence` it re-checked closed/abort/scope but not DRAINING, so an
effect that timed out while the recovery waited left the stream DRAINING and
the recovery still called the authority, committed a new resume state and
cleared recoveryRequired while the abandoned effect kept running (the
RT-RR-01/02 case).
The post-quiescence check now also fails with CLOSED/RECOVER when the stream
is DRAINING, without calling the authority.
Test: "fails a recovery whose effect quiescence ends in DRAINING" in
stream-coordinator.test.ts. RED before the fix: the recovery resolved
{ ok: true } (authority called and committed). After: CLOSED, authority not
called, no resume state; once the late effect settles the stream is OPEN and
STALE.
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 from this fresh worktree
(unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reconnectable() in the reconnect coordinator returned false for
PROVIDER_UNAVAILABLE/RATE_LIMITED whenever serverNotBeforeMs was null, even
with retryable:true. The transports send exactly that for WS NETWORK_LOST /
RESTART (1006/1001/1012, error event) and SSE 502/504, and WS can never carry
a hint, so those streams ended instead of reconnecting. The bounded poll
coordinator had the same rule for retryAfterMs.
Both now decide on retryable + kind only; a missing hint falls back to policy
backoff. Transports that require a hint and lack one already report
retryable:false (SSE 429/503 without Retry-After, WS OVERLOADED), which stays
terminal.
Tests: the reconnect and poll tests that pinned the old behavior ("does not
reconnect/retry ... without a server hint") encoded the bug and are rewritten
to expect a policy-backoff retry. New seam tests wire the real
createWebSocketConnection / createFetchSseConnection into the reconnect
coordinator. RED before the fix: "reconnects a WebSocket NETWORK_LOST|RESTART
close that carries no server hint" (1 socket, expected 2), "reconnects SSE
HTTP 502|504 that carries no server hint" (got PROVIDER_UNAVAILABLE
retryable:true instead of the second attempt's FORBIDDEN), "retries retryable
RATE_LIMITED|PROVIDER_UNAVAILABLE without a server hint on policy backoff"
(execute called once). The WS test also closes with OVERLOADED to show
retryable:false stays terminal.
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 from this fresh worktree
(unrelated).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The default policy has allowedVaryHeaderNames: [], so any Vary header was
POLICY_REJECTED. nginx `gzip_vary` and most CDNs send
`Vary: Accept-Encoding` on JS and CSS, so the default policy could not
stage real assets. Accept-Encoding is a forbidden request header, so a
policy could not allowlist it as a request header either.
validateVary now skips `accept-encoding`. No script-built Request carries
that header, so the stored and lookup requests both lack it and Cache.match
still matches exactly. Every other Vary name keeps the existing checks.
A policy whose allowedResponseHeaderNames lacked `content-type` passed
assertPublicCachePolicy, but activation re-validates the stored
Content-Type, so every activation failed as INTEGRITY_FAILED. The policy
check now rejects it. The ops runbook lists both rules.
Verified: "stages, activates and looks up a Vary: Accept-Encoding response
with the default policy" (stage returned ok:false) and "rejects a policy
that strips Content-Type from stored responses" (no throw) failed before
the fix and pass now. check:architecture, check:types:app,
check:types:test, lint, test:component, verify:documentation pass.
test:unit passes except removal-fixture, which needs generated
artifacts/release files that a fresh worktree lacks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EnhancedFilePicker and the download adapter captured showOpenFilePicker
and showSaveFilePicker with `.bind(options)`. A Window operation throws
TypeError("Illegal invocation") when `this` is not the Window, so passing
`window.showOpenFilePicker` / `window.showSaveFilePicker` as-is failed on
every call.
Both are now captured with `.bind(undefined)`. They are still captured at
construction, and Web IDL maps an undefined receiver to the global object,
so the native functions can be injected directly.
Verified: "calls an injected window picker without rebinding its
receiver" and "calls an injected window save picker without rebinding its
receiver" use a fake picker that throws "Illegal invocation" unless `this`
is undefined or globalThis. Both failed before the fix (ok:false) and pass
now. check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture, which needs
generated artifacts/release files that a fresh worktree lacks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tab whose BroadcastChannel postMessage failed once called
closeBroadcast(), which also removed its receive listener. Publishers
that broadcast successfully never write a storage pulse, so from then on
the tab missed every other tab's event while reporting
ACTIVE_STORAGE_FALLBACK. A tab whose BroadcastChannel failed to open had
the same blind spot and the same healthy-looking status.
Per D-4 there is no dual broadcast+storage publishing. Instead:
- A publish failure only sets broadcastPublishFailed. Later publishes go
to storage, and the channel stays open for receiving.
- BROADCAST_OPEN_FAILED now yields the additive status
DEGRADED_STORAGE_FALLBACK (the union lives in the adapter and is only
passed through by bootstrap). A browser without BroadcastChannel at all
keeps ACTIVE_STORAGE_FALLBACK, because every tab there uses storage.
- A successful storage publish recomputes the status instead of forcing
ACTIVE_STORAGE_FALLBACK, so it cannot hide the degraded state.
Existing tests fixed: "falls back when BroadcastChannel open or publish
fails" and "enters explicit local-only degradation when every transport
fails" expected ACTIVE_STORAGE_FALLBACK for a tab whose channel failed to
open. The ops runbook lists the new status.
Verified: "keeps receiving broadcasts after its own broadcast publish
fails" (received [] instead of [BROADCAST]) and the open-failure status
assertion (ACTIVE_STORAGE_FALLBACK) failed before the fix and pass now.
check:architecture, check:types:app, check:types:test, lint,
test:component, verify:documentation pass. test:unit passes except
removal-fixture, which needs generated artifacts/release files that a
fresh worktree lacks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-source high watermark was stored with the event's expiresAt and
pruned with it. After a source was quiet for longer than the 60 s event
TTL, its next event had no previous watermark and `sequence > 1`, so it
was delivered as GAP, and the query-cache coordinator then invalidated
every topic.
The watermark now carries only the sequence. It is removed only by the
existing sourceCapacity LRU. Event dedupe entries still expire with the
event TTL.
The existing test "bounds TTL and LRU tracking instead of growing with
remote sources" expected a same-source replay of seq 1 to be delivered
again after the TTL, which only worked because the watermark expired.
It now expects that replay to be dropped as STALE.
Verified: "keeps the per-source sequence watermark past the event TTL"
failed before the fix (seq 2 after 61 s was GAP) and passes now.
check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture, which needs
generated artifacts/release files that a fresh worktree lacks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boundedObjectUrlHandoff called resolveByteSource outside its try/finally.
When the authorized source open threw or was aborted, deliver() rejected
with an AbortError instead of returning {ok:false, ABORTED}, the observer
saw nothing, and the holder was never latched closed, so a lease that
arrived later was never closed by compensateLateSource.
Source resolution now runs inside the existing try/catch/finally, the same
shape promptAndStream already uses. The explicit closeHeldSource calls on
the early-return paths are covered by the finally.
Verified: "resolves ABORTED and closes a late lease when a bounded source
open is aborted" failed before the fix (promise rejected with AbortError)
and passes now. check:architecture, check:types:app, check:types:test,
lint, test:component pass. test:unit passes except removal-fixture, which
needs generated artifacts/release files that a fresh worktree lacks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
src/.generated is gitignored, but no entry point rendered it, so a fresh
checkout failed check:architecture, check:types:app/node/test, unit and
component tests, verify:documentation, dev and build.
- run-vitest renders the index before starting Vitest (all vitest suites)
- package scripts that load src (dev, build, storybook, architecture,
app/node/test type checks, the five fixtures that reach the index,
verify:documentation) render it first; CI runs these scripts by name
- tests/unit/product-index-entrypoints.test.ts guards the wiring
Verified from a fresh state (src/.generated removed before each gate):
architecture, types app/node/test, lint, unit 1781/1781, component 132/132,
verify:documentation, build, dev (HTTP 200), check:ci all pass;
fixture route-runtime still fails with its expected TS2740.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>