Skip to content

F2: guard protected queries through session restoration and account changes - #48

Merged
DavidVFitzGerald merged 1 commit into
mainfrom
feat/f2-session-lifecycle
Nov 14, 2026
Merged

DavidVFitzGerald merged 1 commit into
mainfrom
feat/f2-session-lifecycle

Conversation

@DavidVFitzGerald

Copy link
Copy Markdown
Owner

Refs #14

Behavior

  • The session store, which is still the single controller, gains a local lock that holds until the adapter reports a newer state. Each time the verified identity is lost or changes, the store advances its epoch, clears the query cache (aborting in-flight queries) and invalidates pending direct reads.
  • When a protected read returns AUTH_REQUIRED or EMAIL_NOT_VERIFIED during the current epoch, the session locks into an error state and the modal opens. The same failure arriving from an earlier epoch is ignored, so a late response for one account can't sign out the next one.
  • The new guardAuthService locks the UI and clears caches before the adapter answers sign-out. A sign-out that fails stays locked, so App's old signing-out UI and inline error were removed.
  • A success, a typed failure or a thrown error that arrives after the account changes, or after the same user signs out and back in, is replaced with Authentication context changed. A caller's own abort still propagates.
  • Sign-out and account switching never delete the account-scoped workspace key.

Checks (rootless workspace container)

  • ./dev check PASS
  • Frozen npm ci: 230 packages, lockfile unchanged
  • format:check, lint, typecheck and build all PASS
  • test:unit: 168 tests in 9 files PASS, including 15 new session lifecycle tests. Disabling any one of the new guards makes four of those tests fail.
  • test:e2e: 18 cases PASS in Chromium and Firefox. The 3 new session journeys include restore without a modal flash (@smoke).

Details: docs/engineering/f2-session-verification.md.

Limitations

  • There is no protected data UI until F3–F5. Browser tests therefore check shell and account state, and removal of protected content is proven only in component tests.
  • Safari was not available.
  • These guards are not real token or backend security. Real adapters must map 401/403 to the typed codes.
  • Independent QA is still pending.

🤖 Generated with Claude Code

…tions (Refs #14)

Extend the session store with a local lock that holds until the adapter
reports a newer state. Protected AUTH_REQUIRED/EMAIL_NOT_VERIFIED reads in the
current epoch lock the session, clear caches and abort pending work; late
results, failures and rejections from an earlier epoch are replaced and can
never expire a newer account.

Guard signout so protected UI and caches lock before the adapter answers; a
failed signout stays locked. Remove the App's now-redundant signing-out UI.

Add session lifecycle component tests with a protected sentinel and delayed
reads, and browser checks for restore without a modal flash and workspace-key
preservation through signout and account switching.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DavidVFitzGerald
DavidVFitzGerald merged commit 93872b3 into main Nov 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant