The demo adapter now reports "demo-user" as its subject while
authenticated (null otherwise), so an authenticated notification for the
same demo user no longer fences the server-state scope. Sign-out and any
state change still fence.
The scope runtime now treats an empty-string subject like a missing one
(fail-closed), so an owner that returns "" for everyone cannot disable
fencing between users.
Pinned: state change fences, subject change fences, an external owner
without readSubject fences on every authenticated notification.
RED (before the fix, tests/unit/server-state-scope-runtime.test.ts):
x does not fence when the demo session re-announces the same user
expected [ { kind: 'FENCED', ... } ] to deeply equal []
x still fences when an authenticated session names an empty subject
expected true to be false
Tests 2 failed | 12 passed (14)
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>