Repository navigation
Description
Delivery phase
Phase 1 - frontend with mock services
Goal
Prevent protected frontend data leaking during auth resolution, failures, logout or account switching.
Context and authority
Milestone F2; read AGENTS.md, docs/team/product-manager.md, docs/product/LCA_diff_PRD.md, docs/engineering/roadmap.md, and docs/engineering/LCA_diff_Implementation_Specification.md §§6.1, 6.8, 7.4. Current planning baseline is on docs/agent-workflow, pending review/merge into main; proposed ADRs are not accepted authority. Implement app auth/session controller and query gating/cache reset under apps/frontend/src/app/, keeping transport in services. These application paths are planned until created. Exclude all archive/reference folders.
Requirements and constraints
Resolve auth before deciding whether to show the login dialog. Protected queries require observed verified auth. Clear sensitive rendered state and query caches on logout/identity change/revocation; handle mock 401/403/EMAIL_NOT_VERIFIED safely. Do not delete future account-scoped saved workspace on signout; F5 owns workspace restore.
One session-sized task/PR including verification and handoff. Run all development, installation and checks in containers; install nothing on the host. No real backend, Firebase project, cloud credentials or proprietary inputs. If the current PRD/spec must change, prepare an ADR and updates to both current documents in the same PR.
Acceptance criteria
- AC1 - A returning valid simulated session shows only non-sensitive loading shell until resolved, then unlocks without a login-modal flash.
- AC2 - Unauthenticated/unverified/resolving states make zero protected catalog/comparison requests; confirmed anonymous state opens the required modal.
- AC3 - Logout, expiry, revoked session, failed refresh and auth failures remove protected rendered content, cancel in-flight work and clear prior account query data.
- AC4 - Switching account A to B cannot display A's cached content or reuse A's pending responses; stale responses cannot repopulate protected UI after logout.
- AC5 - Unit/component/browser cases prove these transitions; signout does not destructively delete the account-scoped workspace namespace reserved for F5.
Out of scope and follow-ups
Persisted comparison workspace behavior is F5; real token refresh/revocation/Admin verification remains Phase 2. Do not store secrets or claim a mock guard enforces real authorization.
Verification plan
Inside ./dev shell, run format:check/lint/typecheck/test:unit/build and npm --prefix apps/frontend run test:e2e. Instrument mock service calls and delayed responses to prove zero protected calls/late-response rejection and cache isolation.
Engineer records branch/SHA and exact results, leaves issue open, and hands off to QA. QA verifies every criterion at that SHA and reports PASS/FAIL/BLOCKED; mock evidence is not proof of real security/integration.
Dependencies and readiness
Blocked by #11, #12. No implementation until dependencies and the M1 environment runtime gate are satisfied. This body is groomed planning material, not PM READY while blockers remain. Coordinator/PM rechecks merged dependencies and session-sized scope before starting.
Current readiness — supersedes historical planning baseline/blockers above
PM: READY for Phase 1/F2 on merged main at d05e6823cf413f398eeba513a852eb18dd3cadb5. Dependencies #11 and #12 are closed after independent QA PASS, required hosted quality SUCCESS and explicit maintainer merges of PR #45 (f70420d) and PR #46 (d05e682). M1/M2/F1 prerequisites remain satisfied. Current merged documents/contracts replace the historical planning-branch statements above. AC1–5 are unchanged; no new ADR/product decision is required.
The merged baseline already contains createSessionStore, guardDataService, useAuthState, query helpers and provider composition under apps/frontend/src/app/; review and extend their behavior rather than create a parallel controller. Own service-context/queries/ApplicationProviders and focused lifecycle/query tests. #13 owns extraction/replacement of the App LoginDialog, forms, styles and form browser tests; avoid concurrent App edits. Prefer controller/context integration that existing useAuthState and services.auth consumers can use unchanged. Coordinate any minimal callback/API change with #13 and coordinator before implementation.
Preserve the no-login-flash resolving shell and verified-only calls. Treat protected auth failures (AUTH_REQUIRED, EMAIL_NOT_VERIFIED, relevant failed-session auth results) as loss of usable session; remove protected rendered state, cancel pending reads and clear caches. Reject stale successes/failures from account A after B becomes current and after logout/relogin to the same UID. Protect both TanStack queries and direct service consumers, and avoid late errors expiring a newer account. Signout/failed signout must not leave prior protected content exposed. No account namespace deletion: F5 owns persisted comparison state.
Verification: guarded rootless environment check; frozen npm ci; format:check/lint/typecheck/test:unit/build; Chromium and Firefox full available test:e2e. Instrument deterministic typed services and delayed responses to cover restore without modal flash, anonymous/unverified/resolving zero calls, expiry/revocation/failed refresh, service auth failures, logout, A→B changes, same-UID relogin, abort/cancellation and stale-success rejection. Component/browser probes must verify visible protected sentinels disappear and pending/cache results cannot repopulate UI; use test-only injected composition rather than a shipped auth bypass. Preserve a seeded UID-scoped workspace key through signout/account changes. Record exact commands, SHA and limitations; hand off to independent QA, then hosted quality CI and maintainer merge. Full forms integration/consolidation remains #13/#15, real auth remains B2/I1.
Activity
DavidVFitzGerald commentedon Nov 13, 2026
PM: BLOCKED
Groomed using docs/team/product-manager.md for F2, Phase 1 — frontend with mock services. Documentation review: PASS for scope, required sections, specification coverage and acyclic dependency links; this is not application QA or implementation readiness.
Blocking predecessor issues: #11, #12. The M1 runtime gate (#2) and merged bootstrap/M2 configuration (#3) also remain required. PM must recheck merged dependencies and current interfaces before changing this to READY.
Engineer implements one issue, commits regularly and hands the delivered SHA plus exact container checks to independent QA; do not close before QA, review and approved merge. No backend/Firebase/cloud credentials or host installations are required for Phase 1.
DavidVFitzGerald commentedon Nov 14, 2026
PM: READY — Phase 1/F2, AC1–5 unchanged. #11/#12 have independent QA PASS and successful required hosted quality; maintainer merged PR #45 (f70420d) and #46 (d05e682), dependencies now closed. Extend merged session store/guard/provider/query helpers per specification §§6.1,6.8,7.4; preserve no-modal-flash restore and workspace storage, harden auth failures/cancel/cache/account isolation with injected component/browser evidence. #13 owns forms/App; #14 owns service-context/queries/provider/controller tests. Coordinate minimal context API if needed and avoid concurrent App edits. Exact bounded scope/checks are appended to body. No ADR/product change required. Handoff to Software Engineer, then independent QA at delivered SHA.
DavidVFitzGerald commentedon Nov 14, 2026
Engineering: READY FOR QA
Branch
feat/f2-session-lifecycle(a new branch, because the earlier empty localfeat/f2-session-guardsworktree was left untouched). Delivered SHA397fb0d, PR #48.Changes: I extended the merged
createSessionStorewith a local lock/override andinvalidate, and hardenedguardDataServicefor 401/403 session loss and stale failures and rejections. I addedguardAuthService, which locks before sign-out, and wired it inApplicationProviders. I removed the App signing-out state that the guard made redundant. The verify panel's sign-out is no longer aborted when it unmounts. ExistinguseAuthState/services.authconsumers are unchanged.Criteria
@smoketest checks it across two reloads with an init-script observer. Implemented.AUTH_REQUIRED/EMAIL_NOT_VERIFIEDeach remove the sentinel, abort the pending query signal and empty the cache. A late answer cannot repopulate the UI, and slow or failed sign-outs lock first. Implemented.Commands (project
lca-diff-f2-forms, rootless container):./dev checkPASSnpm --prefix apps/frontend ci --no-audit --no-fundinstalls 230 packages with the lockfile unchangedcd apps/frontend && npm run format:check && npm run lint && npm run typecheck && npm run test:unit && npm run build && npm run test:e2eall PASS. Unit: 168/168. E2E: 18/18 across Chromium and Firefox.Limitations: There is no protected product UI until F3–F5, so the sentinel checks are component-level. Safari was not available. Hosted CI is pending. These mock guards are not real authorization.
Next: independent QA at
397fb0d.DavidVFitzGerald commentedon Nov 14, 2026
QA: PASS
Reviewed SHA:
397fb0db71efc4e9bb8da32bbfa9fe234b41de7e(PR #48, branchfeat/f2-session-lifecycle), diffed against base9012a65. I used an isolated detached worktree, and the shared checkout was not touched.Mode: Phase 1 mock services only. This evidence does not prove real Firebase/token/backend authorization or data security.
Environment: a rootless Docker Compose project
lca-diff-qa-14. Port 5179 was already bound by another local project (lca-diff-f2-session), so I usedFRONTEND_PORT=5183. No other deviation.Commands and results
COMPOSE_PROJECT_NAME=lca-diff-qa-14 FRONTEND_PORT=5183 ./dev upCOMPOSE_PROJECT_NAME=lca-diff-qa-14 FRONTEND_PORT=5183 ./dev checkdocker compose -p lca-diff-qa-14 exec -T workspace bash -lc 'npm --prefix apps/frontend ci --no-audit --no-fund'git status --porcelainwas clean, so the lockfile is unchanged... bash -lc 'cd apps/frontend; npm run format:check'npm run lintnpm run typechecknpm run test:unitnpm run buildnpm run test:e2e(Chromium and Firefox)gh pr checks 48qualitypass (2m18s), run 43600520887Criteria
<dialog>is ever mounted. The Playwright@smoketest checks the same thing with an init-script observer across two reloads in both browsers. The modal appears only after a confirmed unauthenticated, unverified or error state.guardDataServicerejects every non-health operation unless the snapshot is verified, and queryenabledis tied toverifiedUid. The test drives resolving, anonymous, unverified, error and locked states and asserts that no data operation is called. E2E monitors assert no fetch/XHR/API requests. Confirmed anonymous state opens "Sign in to LCA diff".AbortSignalis aborted, the cache is empty and a late answer does not repopulate.AUTH_REQUIREDorEMAIL_NOT_VERIFIEDresult in the current epoch locks the session to error, clears the cache and blocks further reads. A newer adapter state supersedes the lock.Authentication context changed. The same happens after logout and relogin as the same UID. Late AAUTH_REQUIREDresults do not lock B. TanStack queries and directservices.dataconsumers are both covered.session.test.tsxand 3 Playwright journeys × 2 browsers.lca-diff:workspace:v1:<uid>key survives sign-out and account switching in both unit and browser tests. Onlylca-diff:mock-session:v1is removed.mode: "test"runtime throughApplicationProvidersprops.createApplicationstill accepts only"mock"and throws otherwise, so no auth bypass ships.Independent adversarial probes
I wrote these as a throwaway
src/app/qa-probe.test.tsx(9/9 passed) and then deleted it. Each one uses the realcreateMockAuthwith controllable deferred reads:AUTH_REQUIREDandEMAIL_NOT_VERIFIED: one lock, no throw. The second result is replaced as stale. Signing in again through the dialog form unlocks and shows fresh data.refreshSessionfrom the locked state: the adapter re-publishes, the session unlocks and fresh reads start.QueryClient.clear()racing an in-flightrefetchQueries()while a direct read locks the session: the refetch signal is aborted and its late success does not repopulate the UI or cache. FurtherinvalidateQueriesandrefetchQueriescalls while locked make zero reads.TEMPORARILY_UNAVAILABLE): no protected content, the dialog is visible, the session marker is removed and the workspace key is preserved.signOutthat throws a non-abort error: content stays removed and direct reads are denied.Mutation check of the shipped tests, reverted afterwards:
invalidatecall makes 2 fail.invalidate()makes nothing fail. This is not a gap:guardDataServicealready replaces stale-epoch results before callinginvalidate, so that second check is redundant defence.Regression and documentation review
AuthDialogand composition tests are unchanged and pass. TheVerifyPanelsign-out no longer forwards an unmount-abort signal. This is correct because the guard locks first, and probe 5 confirms the flow. The App's inline "Sign out failed" alert was replaced by the locked error modal notice, which is consistent with spec §6.1 ("401/403 returns the user to the modal without exposing previously rendered licensed data").docs/engineering/f2-session-verification.mdare accurate. No historical folders were used.Non-blocking observations (no defect filed)
signOutfails without emitting a new state while the user is unverified, the lock override shows the plain sign-in form with no error, and the adapter's unverified session marker remains. A reload restores the verify panel. This exposes no protected data, and the shipped mock always emitsunauthenticatedbefore it awaits, so the case is unreachable in Phase 1. Phase 2 should decide the UX when real sign-out fails.Next action: coordinator and maintainer review and merge PR #48. No engineering rework is required.
feat: lock sessions on protected auth loss and isolate account transi…
DavidVFitzGerald commentedon Nov 14, 2026
Coordinator: closing. Independent QA PASS at 397fb0d, required hosted
qualitySUCCESS, maintainer merge of PR #48. Phase 2 (B2/I1) notes from QA: decide signout-failure UX for unverified sessions when the adapter emits no new state; avoid lock/unlock cycling when a real adapter re-emits the same verified state against a persistent server 401/403.test: record the F2 gate with shell keyboard and invalidated-session …