Skip to content

[Task] L2 — Connect the frontend to the real API and Auth Emulator #97

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 2, backend and real integration. This is milestone L2 of the local MVP (ADR 0006), the second of three implementation PRs, and it replaces I1 for the local scope. It stays one issue and one PR (ADR 0006 §6), with incremental commits and an internal checklist.

Ownership:

  • frontend: apps/frontend/ and packages/contracts/;
  • coordinated shared changes: compose.app.yaml, dev, ops/local/, CI and docs.

API code changes only if a reconciliation strictly needs them.

Goal

The ./dev app-up stack serves a real-mode frontend that uses the FastAPI backend and the Firebase Auth Emulator through the existing typed services boundary.

A user does either of these:

  • logs in with the demo account;
  • registers and verifies a new account through the emulator.

The user then searches, bulk-selects, reorders and compares the seeded processes on Flows and Scores, with the data served from PostgreSQL.

TypeScript DTOs are generated from the FastAPI OpenAPI schema with a drift check. The provisional contracts are reconciled, and parity with the mock adapter is tested. A real-stack Playwright smoke passes.

Context and authority

Read:

  • AGENTS.md;
  • docs/adr/0006-local-only-mvp.md;
  • ADR 0002's service-boundary rules (docs/adr/0002-frontend-first-delivery.md);
  • PRD §§3, 5 and 7;
  • specification §0.3, §3 (including §3.1 and §3.3: packages/contracts/), §6.1, §6.4–6.6, §6.8, §7 (all), §8 items 1, 2 and 5, and §9.2 behaviors 13–15 and the per-PR tier ("OpenAPI contract drift (from L2)");
  • docs/engineering/roadmap.md L2;
  • docs/engineering/f2-verification.md;
  • docs/engineering/development-environment.md (local application stack);
  • README.md ("Run the local application");
  • docs/engineering/b2-verification.md.

Do not read the archive or reference folders.

Code to read and change:

  • Frontend:
    • apps/frontend/src/services/contracts.ts and apps/frontend/src/services/README.md;
    • apps/frontend/src/services/mock/;
    • apps/frontend/src/app/composition.ts, which accepts only mode === "mock" today;
    • apps/frontend/src/app/service-context.ts (ApplicationRuntime.mode is "mock" | "test") and apps/frontend/src/app/queries.ts;
    • apps/frontend/src/components/comparison/useFlowGrid.ts, useScoreGrid.ts and geometry.ts;
    • apps/frontend/src/main.tsx, apps/frontend/eslint.config.js, apps/frontend/vite.config.ts and apps/frontend/playwright.config.ts;
    • apps/frontend/package.json and package-lock.json.
  • API:
    • apps/api/src/lca_api/app.py, dtos.py, errors.py, queries.py, auth.py and config.py;
    • apps/api/openapi.json.
  • Stack:
    • compose.app.yaml;
    • ops/local/frontend.Dockerfile and its .dockerignore, which currently admits only apps/frontend/**;
    • ops/local/local_stack.py;
    • dev.
  • CI: .github/workflows/frontend.yml.

Planned new paths:

  • packages/contracts/ (generated TypeScript);
  • apps/frontend/src/services/http/ and apps/frontend/src/services/firebase/ (adapters; exact names are the engineer's choice under src/services/);
  • a real-stack Playwright config and specs;
  • a ./dev app-e2e command.

Authority. B2's FastAPI contract is authoritative over the provisional frontend DTOs (ADR 0002, roadmap). None of the reconciliations below changes product or scientific meaning, so the planned path needs no ADR. An ADR, with updates to the PRD and specification in the same PR, is required if the implementation would do any of these:

  • change §7 semantics, for example decimal-as-number, lexeme normalization, missing or unresolved scores becoming zero, absent becoming zero, a different 401/403 meaning, or summaries computed over a column window instead of the whole selection;
  • make the API depend on server-held token state;
  • weaken a §8 control.

Requirements and constraints

R1. Generated contracts

  • Generate TypeScript types from the committed apps/api/openapi.json into packages/contracts/. Use openapi-typescript: types only, no runtime client, an exact-pinned frontend devDependency. Another types-only generator is acceptable only with a recorded rationale.
  • Add npm scripts that run in the frontend container and in CI without the API running:
    • contracts:generate;
    • contracts:check, which regenerates to a temporary path, byte-compares and exits nonzero on drift.
  • Generated files carry a "generated, do not edit" header and are never hand-edited. Output must be deterministic, byte-identical across runs.
  • The chain is FastAPI → apps/api/openapi.json (existing make backend-openapi-check, already in backend CI) → packages/contracts/ (new check, added to the per-PR frontend workflow).
  • Make packages/contracts/ resolvable by tsc, Vite and ESLint (tsconfig include or path alias), and copy it into the frontend image. Update ops/local/frontend.Dockerfile and its .dockerignore.
  • services/contracts.ts remains the UI-facing boundary. It derives wire types from, or maps them to, the generated types deliberately. Generated wire types do not leak into components.

R2. Contract reconciliation

Resolve each mismatch below and record the resolution in apps/frontend/src/services/README.md, replacing the "I1 will reconcile" notes. These are mismatches between contracts.ts and B2 at 41c6b14:

  • M1. Summaries (decided). There are no flowSummaries or scoreSummaries routes. B2 returns a whole-selection summary: NumericSummary {minimum, maximum, present_count, selected_count} on every FlowRow and on every score-row Indicator. In the indicator tree, summary is absent or null.

    • The frontend max_positive/max_negative_magnitude derive exactly from that summary:
      • P = maximum if it is > 0, else "0";
      • N = minimum with its sign removed if it is < 0, else "0";
      • the comparisons use services/decimal.ts, never Number.
    • Absent = selected_count − present_count.
    • Positive, negative and zero counts, and the missing versus unresolved split, are not served. Only geometry.ts consumes P and N.
    • Decision: row pages carry their summaries across the boundary. Remove the provisional DataService.flowSummaries and scoreSummaries methods and the unused counts. Make the mock compute the same derived summary per row page, and update useFlowGrid, useScoreGrid and queries.ts.
    • This is the "derivation" option in the roadmap. It keeps the API stateless and matches §7.1, so it needs no API change and no ADR.
  • M2. Error envelope. The API returns {"error": {code, message, request_id, retryable}}:

    • 401 → AUTH_REQUIRED, with WWW-Authenticate;
    • 403 → EMAIL_NOT_VERIFIED;
    • 404 → RELEASE_UNAVAILABLE / UNKNOWN_PROCESS;
    • 409 → STALE_SNAPSHOT;
    • 422 → INVALID_FILTER for any request-validation failure, and also REQUEST_WINDOW_TOO_LARGE;
    • 429 → TEMPORARILY_UNAVAILABLE, retryable, with Retry-After: 60;
    • 503 → TEMPORARILY_UNAVAILABLE, retryable.

    The adapter unwraps the envelope and uses X-Request-ID. It maps network failure, a non-JSON body, an unknown code or a schema-invalid body to a safe typed error (TEMPORARILY_UNAVAILABLE, retryable as appropriate), with no raw payload in the message. UNSUPPORTED_OPERATION and AUTH_FAILED are client-only codes and do not appear in the API enum.

  • M3. Lost unions. OpenAPI flattens these:

    • FlowCell becomes {present: boolean, amount: string | null};
    • ScoreCell becomes {status, amount: string | null};
    • SearchNode becomes one object with an optional geography, an optional matching_descendant_count, and children defaulting to [].

    The adapter validates the invariants (present ⇔ amount; valid ⇔ amount; decimalString syntax; the node kind fields) and returns a typed error on violation. It never coerces.

  • M4. Identity. In GET /api/v1/me, access is Record<string, boolean> and email_verified is an optional const true. Map it to {published_catalog: access.published_catalog === true}.

  • M5. Indicator tree. This is a GET /api/v1/indicators/tree with revision_snapshot as a JSON-encoded query parameter (an array of {release_id, revision_id}). There is no body.

  • M6. Transport bounds. The API bounds are:

    • page limit 1–200 (default 100);
    • headers ≤200 IDs per batch;
    • cells ≤200 processes, ≤200 rows and ≤10,000 cells;
    • request 2 MB, response 4 MB;
    • requests_per_minute default 240 per client address.

    The frontend windows (100 and 1,000) fit. The cell process_ids must be a subset of the signed comparison_token's set, and the token embeds the full sorted selection, so it grows with the selection. Batches never cap the selection.

  • M7. IDs. The API validates process_ids and indicator_ids as UUIDs and rejects duplicates with 422. row_keys must be <uuid>|<FlowType> and belong to the token's rows.

  • M8. Decimals. The API emits str(Decimal) of PostgreSQL NUMERIC, for example 1.2345E-33 with an uppercase exponent, and never -0. Display and comparison must accept the API's lexemes unchanged. Parity fixtures use the lexemes the API actually emits for the seed, not mock lexemes.

  • M9. differences_only. The API implements it, while the mock returns UNSUPPORTED_OPERATION. In L2 the UI never sends true, and the HTTP adapter passes the flag through unchanged. Aligning the two is L3 [Task] L3 — Differences toggles on the real API and local MVP acceptance #30.

  • M10. Runtime mode. Add a real runtime mode (see R4).

R3. Adapters

  • Add an HTTP DataService adapter that maps every boundary method to its /api/v1 route.
  • Add a Firebase JS SDK AuthService adapter connected to the emulator. It covers sign-in, registration, verification email, password reset, sign-out, session restore through Firebase persistence and token refresh.
  • Preserve:
    • decimal strings and missingness;
    • revision snapshots, echoed and never replaced by the latest;
    • opaque cursors and comparison tokens;
    • structured errors;
    • AbortSignal cancellation with no stale success.
  • Tokens:
  • firebase and fetch are used only under src/services/. The existing boundary lint must keep passing unchanged, or be tightened, but never loosened for UI code.
  • Firebase dependency. Add firebase as an exact-pinned runtime dependency with npm install --save-exact inside the dev container. Choose the newest stable release that is at least 14 days old at implementation time and compatible with Node 24 and the pinned emulator (firebase-tools 15.36.0 in apps/api/emulator/package.json). Record the version and the check in the handoff. Commit package-lock.json; npm ci stays frozen.

R4. Configuration and composition

  • composition.ts stays the only adapter-selection point. VITE_SERVICE_MODE accepts exactly mock or real, and anything else shows the configuration error.
  • real requires validated build-time settings:
    • the API base;
    • the Firebase project ID and API key: local, non-secret placeholders;
    • the emulator setting.
  • With the emulator, the project ID must start with demo-, mirroring the API's rule.
  • Missing or invalid settings, an unreachable API or an unreachable emulator show an explicit error state. Never mock data, never a silent fallback.
  • The "Local demo mode" indicator and the mock demo guidance appear only in mock mode.
  • npm run dev, Vitest and the existing mock Playwright suite keep mock mode. The app stack builds real.

R5. Browser origins and stack wiring (decided; resolves L1 QA note (b))

  • Same origin. The browser talks only to the page's origin:

    • the frontend container serves the SPA;
    • it reverse-proxies /api/ to http://api:8000;
    • it reverse-proxies the emulator REST paths (/identitytoolkit.googleapis.com/, /securetoken.googleapis.com/, /emulator/) to http://auth:9099.

    The API base is the relative /api/v1. The Auth SDK connects to the emulator at window.location.origin.

  • Proxy configuration. Configure the proxy through runtime environment variables in the frontend container (for example vite preview preview.proxy), enabled only when those variables are set. Port changes therefore need no rebuild.

  • Why. http://127.0.0.1:<port> and http://localhost:<port> both work with no browser CORS dependency, and the containerized Playwright run can use http://frontend:4173.

  • CORS allowlist. Defense in depth for direct clients: LCA_CORS_ORIGINS becomes exactly ["http://127.0.0.1:<frontend port>", "http://localhost:<frontend port>"], with no wildcard. ./dev app-smoke asserts that both are allowed and an untrusted origin is not.

  • Docs. The README documents 127.0.0.1 as the canonical URL. It also says Firebase sessions are stored per origin, so switching spellings requires a fresh login.

  • Fallback. If same-origin emulator proxying proves unworkable, fall back to direct URLs from build arguments, with the two-spelling CORS allowlist. Record the reason, and AC8 must still pass.

  • Rate limit. Behind the proxy, all browser traffic shares one client address. Set a justified local LCA_REQUESTS_PER_MINUTE (≤10,000) in compose.app.yaml, so that normal grid scrolling and the smoke never hit 429. Record the value and the reason.

  • Frontend image. compose.app.yaml builds the frontend with VITE_SERVICE_MODE: real. The image stays unprivileged (node), with cap_drop: [ALL], no-new-privileges and a 127.0.0.1-only port.

R6. L1 QA notes (a) and (c)

  • (a) For every app-* command, ./dev must refuse an LCA_APP_PROJECT equal to the effective workspace project name. That name is COMPOSE_PROJECT_NAME from the environment or the repository .env, defaulting to lca-diff-dev, the name: in compose.yaml. The check runs before any Compose call, because otherwise --remove-orphans could remove workspace containers.
  • (c) The README states that ./dev app-import needs private/, or the directory named by LCA_APP_PRIVATE_DIR, to exist (create_host_path: false), and shows the failure seen otherwise.

R7. Real-stack Playwright smoke

  • Add a separate Chromium-only config and specs, excluded from the mock test:e2e run and its @smoke grep, with no webServer.
  • Run it in a pinned container on the app stack network through a new ./dev app-e2e, against http://frontend:4173. The container is built from the committed lock, with browsers from .devcontainer/install-browsers.sh and its pinned snapshot, or from a digest-pinned Playwright image matching @playwright/test 1.65.1.
  • Steps:
    1. The unauthenticated modal appears, and no /api/v1/ dataset request is observed.
    2. Demo login.
    3. Search, bulk-select and select two seeded processes, then reorder the columns.
    4. Flows shows the seeded exact 34-digit value at full precision, a present 0, and a blank absent cell.
    5. Scores (GWP 100) shows a valid value and N/A for both missing and unresolved_basis.
    6. Register, verify through the emulator's oobCodes endpoint, refresh, and unlock.
    7. Disable, delete or revoke the account through the emulator. The next protected read locks the shell and clears the data.
    8. Logout clears the data.
  • Hosted CI. Try a per-PR job on hosted runners using docker compose -p <ci project> -f compose.app.yaml directly; runners are rootful, so ./dev cannot run there (see etl.yml). Add it to the per-PR tier only if it passes reliably. Otherwise keep it a documented local check, and open a linked gap issue before handoff (ADR 0006 §7).

R8. Documentation

Update:

  • the README: remove the L1 limitation; real mode; URLs and both spellings; demo login; how a person obtains the emulator verification link; that emulator accounts other than demo are lost on restart; (c);
  • apps/frontend/src/services/README.md: the M1–M10 resolutions;
  • docs/engineering/development-environment.md: the frontend image, proxy, CORS and app-e2e;
  • the roadmap L2 delivery note.

Acceptance criteria

  • AC1. Generated contracts. contracts:generate is reproducible: two runs give byte-identical output. contracts:check exits 0 on a clean tree and nonzero after a deliberate change to apps/api/openapi.json or to a generated file. The contracts check runs in the per-PR frontend workflow, and make backend-openapi-check still passes. The boundary lint passes, with firebase/fetch imports only under src/services/.

  • AC2. Reconciliation. contracts.ts maps onto the generated types. The flowSummaries/scoreSummaries methods are replaced by row-page summaries derived as in M1. The services README records the resolution of M1–M10. There is no §7 semantic change (otherwise an ADR is included).

  • AC3. Adapter parity. One shared adapter-contract test suite runs against both the mock adapter and the HTTP adapter. The HTTP adapter uses a fetch stub whose responses are valid against the generated types and use API-emitted seed lexemes. The suite covers:

    • exact decimals: 1.234567890123456789012345678901234, 1.2345E-33, the high-precision score 12.3456789012345678901234567890123 and the e-40 score;
    • present-zero versus absent;
    • valid-zero versus missing versus unresolved_basis;
    • the derived P/N for positive-only, negative-only, mixed and all-zero/absent rows;
    • snapshot echo, cursor continuation and token reuse;
    • the error mapping for 401, 403, 404, 409, 422 (both codes), 429, 503, network failure, a non-JSON body and an invariant violation;
    • AbortSignal cancellation with no stale success.
  • AC4. Real mode end to end. After ./dev app-up, a browser at http://127.0.0.1:<port> and at http://localhost:<port> can log in with the demo account. It can then search, bulk-select, reorder, and compare Flows and Scores with the seeded PostgreSQL data, and no mock banner is shown. QA verifies this manually.

  • AC5. Registration and verification. A new account can register and verify through the emulator using the documented procedure. Before verification, the account sees the verification guidance and no dataset content. After verification and a refresh, it unlocks.

  • AC6. Session safety. All of these are checked by emulator-backed tests:

    • there are zero dataset API calls before a verified identity;
    • a reload restores the session without the modal flashing;
    • a revoked, disabled or deleted account, and any protected 401/403, locks the shell and clears protected caches;
    • a persistent 401/403 causes no lock/unlock cycling;
    • a sign-out failure for an unverified session shows the F2 UX.
  • AC7. Misconfiguration. Each of these shows an explicit error state and never mock data:

    • an invalid or missing VITE_SERVICE_MODE;
    • missing real settings;
    • a non-demo- project with the emulator;
    • a stopped api or auth container.

    This is covered by unit tests plus one stack check, for example ./dev app-logs or stopping api.

  • AC8. Real-stack smoke. ./dev app-e2e passes R7 steps 1–8 at the delivered SHA. Hosted CI either has a passing per-PR real-stack job, or the handoff links a gap issue with the reason.

  • AC9. L1 QA notes.

    • (a): LCA_APP_PROJECT=lca-diff-dev ./dev app-up exits nonzero with a clear message and no container change. So does COMPOSE_PROJECT_NAME=lca-x LCA_APP_PROJECT=lca-x ./dev app-down. The default project still works.
    • (b): the CORS allowlist is exactly the two loopback spellings, and ./dev app-smoke asserts both allowed and an untrusted origin denied.
    • (c): the README states the private/ / LCA_APP_PRIVATE_DIR requirement.
  • AC10. Mock mode intact. npm run dev runs standalone with no API, database or Firebase. Frontend format:check, lint, typecheck, test:unit and build pass. The mock Playwright suite passes: @smoke in Chromium and Firefox, plus the full suite once.

  • AC11. Security and runtime.

    • firebase and the generator are pinned exactly, and the lock is committed.
    • Only labelled local-only placeholders are added, with no .env files.
    • No tokens are logged or printed.
    • The API image is unchanged: lean, 65532.
    • All services drop all capabilities and set no-new-privileges, and host ports bind 127.0.0.1 only.
    • L1's ./dev app-up, app-down, app-reset --yes and app-smoke behavior is unchanged apart from R5 and R6.

Out of scope and follow-ups

Verification plan

Inside ./dev shell. Run npm --prefix apps/frontend run with each of:

  • format:check, lint, typecheck, test:unit and build;
  • contracts:check (new), plus the deliberate-drift negative check;
  • test:e2e (mock, both browsers).

Also run make backend-openapi-check. If any API file changes, also run make backend-format-check backend-lint backend-typecheck backend-test-unit backend-test-api backend-test-auth.

On the host, with a distinct LCA_APP_PROJECT and ports, for example LCA_APP_PROJECT=lca-diff-l2-app LCA_APP_FRONTEND_PORT=5260 LCA_APP_API_PORT=8260 LCA_APP_AUTH_PORT=9260:

  • ./dev app-up;
  • ./dev app-smoke;
  • ./dev app-e2e (new);
  • ./dev app-down && ./dev app-up, after which the login and data still work;
  • the AC9(a) negative invocations;
  • a manual browser check on both loopback spellings (AC4/AC5);
  • the misconfiguration check (AC7).

Hosted CI. All workflows are green at the delivered SHA; record whether the real-stack job is in the per-PR tier.

Record the exact commands, exit codes and the pinned versions chosen. QA independently re-runs AC4, AC5 and AC8 from a clean clone at the delivered SHA.

The mock checks prove UI semantics only. The real-stack checks are the evidence for authentication and integration.

Dependencies and readiness

All dependencies are satisfied:

There is no open maintainer decision. M1 and R5 are decided above within the existing contracts, so no ADR is needed. #101 is independent and does not block this issue.

Activity

  1. added
    task
    frontend
    blocked
    and removed
    blocked
    on Nov 16, 2026
  2. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY

    L2 is groomed against main at 41c6b14.

    Phase: Phase 2 / Local MVP, milestone L2. One issue and one PR, per ADR 0006 §6.

    Dependencies: all satisfied.

    Spec references:

    • §0.3, §3 (§3.1, §3.3), §6.1, §6.4–6.6, §6.8;
    • §7 (all), §8 items 1, 2 and 5;
    • §9.2 behaviors 13–15 and the per-PR "OpenAPI contract drift (from L2)" check;
    • ADR 0002's service boundary, and roadmap L2.

    Evidence checked at 41c6b14

    • Composition. apps/frontend/src/app/composition.ts throws unless mode === "mock". ApplicationRuntime.mode is "mock" | "test". No HTTP or Firebase adapter exists yet. The boundary lint in eslint.config.js already forbids firebase and fetch outside src/services/.
    • Dependencies. apps/frontend/package.json pins exact versions and has no firebase and no OpenAPI generator. package-lock.json is committed. packages/contracts/ does not exist.
    • OpenAPI. make backend-openapi-check exists (container-only, uv run --frozen lca-openapi --check). It runs in backend CI and passed at 41c6b14. apps/api/openapi.json is OpenAPI 3.1 with 13 paths.
    • Playwright runs in the workspace container against a mock vite preview webServer on 127.0.0.1:4173. CI runs @smoke in both browsers inside the node image. The workspace network cannot reach the app stack, so the real smoke needs a container on the app network.
    • Frontend image. ops/local/frontend.Dockerfile bakes VITE_SERVICE_MODE at build time; compose.app.yaml passes mock. Its .dockerignore admits only apps/frontend/**.
    • API. CORS is exactly http://127.0.0.1:<frontend port>. The API rate-limits at 240 requests per minute per client address.
    • ./dev has no guard against LCA_APP_PROJECT colliding with the workspace project (lca-diff-dev).
    • Provisional DTOs versus B2: ten mismatches, M1–M10, are now listed in the body. The most significant is M1: the API has no flowSummaries/scoreSummaries routes. It returns a whole-selection NumericSummary {minimum, maximum, present_count, selected_count} on each row instead.
    • Meaning. None of the mismatches changes product or scientific meaning. The body lists which deviations would require an ADR.

    Decisions recorded, all within existing contracts (no ADR)

    1. M1 summaries. P and N are derived exactly from the row-page summary. The provisional summary methods and the unused counts are removed from the boundary, and the mock computes the same derived summary. Only geometry.ts consumes P and N.
    2. R5 origins (L1 QA note (b)).
      • The browser uses the same origin: the frontend container proxies /api/ and the emulator REST paths.
      • Both 127.0.0.1 and localhost work, and so does a containerized Playwright run.
      • The CORS allowlist is exactly the two loopback spellings, and the smoke asserts both.
      • A direct-URL fallback is permitted with recorded reasons.
      • A justified local rate limit is set.
    3. Pinning. firebase and openapi-typescript are pinned exactly: the newest stable release at least 14 days old, compatible with Node 24 and firebase-tools 15.36.0. The lock is committed.
    4. Real-stack smoke runs through a new ./dev app-e2e on the app network. It goes into per-PR CI only if it is reliable on hosted runners; otherwise there is a linked gap issue (ADR 0006 §7).

    Changes made to #97

    • Body rewritten, keeping every Task-form section:
      • R1–R8 requirements and the M1–M10 mismatch table;
      • ACs expanded from 6 to 11, with objective evidence;
      • exact container and host commands, with the new ones marked (contracts:check, ./dev app-e2e);
      • out-of-scope links.
    • L1 QA notes folded in:
      • (a): LCA_APP_PROJECT collision guard, R6 and AC9;
      • (b): the CORS/localhost decision, R5 and AC9;
      • (c): the README private/ requirement, R6, R8 and AC9.
    • F2 carried items made explicit (R3, AC6): expiry and revocation journeys, sign-out failure for unverified sessions, and no lock/unlock cycling.
    • Removed the blocked label, because its dependencies are complete. Labels are now task and frontend; the milestone is unchanged, L — Local MVP.
    • Linked the non-blocking tooling follow-up [Task] Harden workspace tooling: fresh-clone uv sync, Spark interpreter, guard docs and app port validation #101, which covers L1 QA notes 1, 3 and 6.

    Next: hand off to the Software Engineer in an isolated worktree, with a distinct COMPOSE_PROJECT_NAME, LCA_APP_PROJECT and ports.

  3. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: maintainer decision (2026-11-16). The emulator does not keep accounts across restarts. Non-demo accounts and stored browser sessions are lost when the stack restarts. This is accepted as a documented MVP limitation, and persisting emulator state stays out of scope. The open questions (the §7.2 revision_snapshot example, and the untracked L1 QA notes 7 and 8) are still pending. Implementation awaits explicit maintainer go-ahead.

  4. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: IMPLEMENTING on feat/l2-real-adapter from 0fe3ff3. Current maintainer request authorizes L2. Existing PM READY remains valid: L1 #96 and correction #102 are closed; #101/#103 are nonblocking. Rootless ./dev check passed before development. Engineering is implementing generated DTOs, exact row-summary reconciliation, HTTP/Firebase adapters and real-stack browser validation under the existing contracts; independent QA will review the delivered SHA. No merge or closure is authorized.

  5. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    Candidate: 37874df on feat/l2-real-adapter; PR #105. Base 0fe3ff3, core increment fec23ae. Issue remains open; merge is not authorized.

    Implemented AC1–AC11 scope: reproducible generated DTOs/drift CI, whole-selection row summaries, shared mock/HTTP parity, real Firebase SDK lifecycle, strict wire/error invariants, same-origin proxy, real stack build, independent real browser config/container/command, lifecycle collision guards, CORS fixes and current docs. Differences remain off in L2; L3 #30 owns toggles.

    Container evidence and exact commands: docs/engineering/l2-verification.md. Rootless preflight/toolchain passed. Frontend format/lint/typecheck/build/contracts and backend OpenAPI check pass. Full integrated units: 460/37 files before two final malformed-envelope cases; targeted adapter suite 46/46 after those cases. Core mock browser72/72, integrated final rerun ongoing. Real-stack Chromium5/5 passes, including actual registration/OOB verification, restore, account disable, persistent401/403 locking, unverified signout failure and logout. Real API smoke9/9 includes both loopback origins. Guard regression covers every app command and dotenv/environment precedence; both required live collision commands exit2 before Compose.

    Runtime identities/capability/port configuration remain hardened; API source/image recipe unchanged. Dependencies pinned exactly: Firebase13.1.0 (Oct21; next stable Nov2 18:16 was under14days at Nov16 12:33), openapi-typescript7.13.0, existing TypeScript6.0.3 via recorded peer override. No tokens, host installs, licensed fixtures, .env files or deployment introduced.

    Strict MyPy/Ruff pass for changed ops sources with workspace import path. An unscoped local MyPy attempt lacked Airflow stubs/toolchain; hosted backend/ETL CI installs all packages and remains required. Hosted jobs are running, including new real-stack trial.

    QA owner /root/qa is independently checking the candidate in a clean clone with separate containers/ports. Next: complete AC4/AC5 both-origin directed browser/visual checks, AC7 actual outage, restart persistence, full checks and AC8 real smoke; record exact evidence and verdict here. No interactive browser-control tool is exposed, so automated/directed browser evidence must not be described as human manual testing. Any required gap blocks PASS until resolved or tracked per the issue's specific hosted-CI allowance.

  6. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Reviewed head: 6d68472f720faa074a2c87cb280e776c9d5fca4d, PR #105. Tested application source: b27cc2babe7fe67c4622546a50fda24a66c87271. The final head changes only three engineering documents; independent diff review confirms that application, tests, generated contracts, images, tooling and CI are identical to the tested source.

    Independent checkout: /tmp/lca-l2-qa-37874df, initially detached at 37874df, advanced cleanly to the final source and documentation head. Workspace project lca-diff-l2-qa (5271); app project lca-diff-l2-qa-app (5270/8270/9270). Rootless Docker, namespace UID 0 mapped to unprivileged host UID 1000, all capabilities dropped and no-new-privileges verified. Node 24.22.3/npm 11.19.1, Python 3.14.2/uv 0.9.30. All development tools ran in containers. No application code, tests or criteria were changed by QA; deliberate drift probes were restored, and the checkout is clean.

    Criterion Verdict and evidence
    AC1 — generated contracts PASS. Two generation runs were byte-identical to the committed file (SHA-256 120030a96c16badc9b7c12f292d597720bcc133d63fe31dcbddfc367ef7005e1). Clean contracts:check passes; deliberate generated-file and OpenAPI-schema changes both fail the check. backend-openapi-check and boundary lint pass. Generation/negative probes ran at 37874df; those files are unchanged at final head and final contract check passes.
    AC2 — reconciliation PASS. Reviewed generated-wire mappings, removal of separate summary methods, whole-selection row-page extrema and exact P/N derivation. The services README records M1–M10. No scientific/product/security semantic change requiring an ADR was found.
    AC3 — adapter parity PASS. Final unit suite: 464/464 tests in 37 files, including 48 adapter-contract cases. Shared mock/HTTP cases retain exact long/tiny decimals, zero/absence and score states, whole-selection extrema, deterministic equal-value extrema across reordering, snapshots, cursors, tokens and cancellation. HTTP failures cover the required status/code combinations, retry bounds, malformed/unknown envelopes, invalid invariants and safe errors.
    AC4 — real comparison/origins PASS. QA-directed Chromium interactions and screenshot inspection confirmed both http://127.0.0.1:4173 and http://localhost:4173, using a pinned test container sharing the frontend network namespace. Demo login, search, filtered bulk selection, keyboard reorder, exact precision, zero/absence and Flows/Scores worked without mock guidance. These visual checks ran at 37874df; the final source changes only mock extrema/tests, and the complete real suite was rerun at b27cc2b. This is directed browser automation with visual inspection, not a claim of human GUI testing.
    AC5 — registration/verification PASS. Independently registered an emulator user, followed the README's OOB procedure using the returned verification link with the frontend origin, inspected the emulator's successful verification page, refreshed and unlocked. The pre-verification shell stayed locked. Final real suite repeats registration/verification.
    AC6 — session safety PASS. Final emulator-backed browser tests verify zero dataset calls before verification, restoration without modal flicker, actual account disabling followed by locked/cleared data, persistent protected 401/403 without cycling, failed unverified signout guidance and logout clearing. The 401/403 cases inject denial envelopes while retaining the real Firebase SDK/emulator session. Final session/component regressions also pass.
    AC7 — configuration/outages PASS. Invalid/missing mode and real-setting tests pass, including non-demo project rejection. Separate independent stopped-API and stopped-Auth checks showed explicit unavailable errors and no mock fallback; screenshots were inspected. Services were restored and smoke passed afterward.
    AC8 — real smoke/hosted CI PASS. At final source, clean-clone ./dev app-e2e: 5/5 passed (18.9 s), covering R7 steps 1–8. The hosted real-stack job passes on the final reviewed head and remains in the per-PR tier; no CI-gap issue is needed.
    AC9 — L1 notes PASS. Both required host collision invocations exit 2 before Compose. Container regressions cover every app command, environment/default/quoted and commented .env cases and precedence. API smoke checks exactly both allowed loopback spellings and an untrusted origin. The README documents the existing private-directory requirement.
    AC10 — mock mode PASS. Final format, lint, typecheck, contracts, build and unit gates pass. Full independent Chromium/Firefox suite: 72/72 passed (3.7 min), including all smoke cases; hosted per-PR smoke also passes. The documented VITE_SERVICE_MODE=mock npm --prefix apps/frontend run dev starts standalone in the workspace-only network, renders the modal/demo banner and makes zero API/external reads. Missing mode remains an explicit configuration error.
    AC11 — security/runtime PASS. Exact Firebase/generator pins and committed lock inspected; Firebase registry timestamps independently confirm the documented release-age choice. API Dockerfile is unchanged and actual API runtime is 65532:65532; frontend is node. Rendered services and runtime inspection confirm capability/privilege restrictions and loopback-only host bindings. No tokens/raw licensed inputs/new .env files are committed or printed by the real tests. Independent down/up preserved publication revision and activation timestamp byte-for-byte; subsequent API smoke passes 9/9. Destructive reset was not rerun: its implementation is unchanged from L1; refusal without confirmation and prior L1 evidence are retained.

    Commands/results (host lifecycle commands used the project/port values above):

    COMPOSE_PROJECT_NAME=lca-diff-l2-qa FRONTEND_PORT=5271 ./dev up
    COMPOSE_PROJECT_NAME=lca-diff-l2-qa FRONTEND_PORT=5271 ./dev check
    ./dev app-up
    ./dev app-smoke
    ./dev app-e2e
    ./dev app-down
    ./dev app-up
    ./dev app-smoke
    LCA_APP_PROJECT=lca-diff-dev ./dev app-up                  # expected exit 2
    COMPOSE_PROJECT_NAME=lca-x LCA_APP_PROJECT=lca-x ./dev app-down  # expected exit 2

    Inside the isolated workspace, all exited 0:

    npm --prefix apps/frontend ci --ignore-scripts --no-audit --no-fund
    cd apps/frontend
    npm run format:check
    npm run lint
    npm run typecheck
    npm run contracts:check
    npm run build
    npm run test:unit
    npm run test:e2e
    # From repository root:
    make backend-openapi-check
    uv run --frozen python ops/local/test_project_guard.py
    uv run --frozen ruff check ops/local
    uv run --frozen ruff format --check ops/local
    MYPYPATH=data_pipeline/src uv run --frozen mypy ops/local

    The repeated-generation/drift probe ran inside the same container with original bytes restored in finally; directed browser probes ran in the pinned e2e image. Local evidence is in /tmp/lca-l2-qa-*.log and /tmp/lca-l2-qa-images/. Destructive volume deletion was not performed. An initial workspace image-unpack interruption recovered through the guarded cached startup. An early outage probe used incorrect timing; the corrected already-stopped-service probes passed. Two engineering full-browser runs under overlapping heavy work timed out; QA's complete final suite passed without relaxing timeouts. The build's bundle-size advisory is informational.

    Final-head hosted checks: Frontend quality and real-stack, API/backend, ETL.

    Next owner/action: coordinator hands PR #105 to the maintainer for review and explicit merge. Issue remains open; QA does not merge or close it. L3 #30 remains the next implementation milestone after L2 merges.

  7. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: READY FOR REVIEW

    Task L2 is implemented in PR #105 on feat/l2-real-adapter, final head 6d68472f720faa074a2c87cb280e776c9d5fca4d. Application source was independently tested at b27cc2b; the final commit changes three verification documents only, reviewed independently by QA.

    Independent QA PASS verifies AC1–AC11. Container checks pass: 464 unit tests/37 files, full Chromium/Firefox mock suite 72/72, real Firebase/API/PostgreSQL browser suite 5/5, API smoke 9/9, frozen install, format/lint/types/build, deterministic generation and negative drift, backend OpenAPI, ops Ruff/MyPy and project-collision regressions. Both loopback spellings and documented OOB verification were checked through QA-directed browser actions/screenshots; stopped API/Auth show explicit errors without fallback. Publication pointer and activation timestamp survive down/up unchanged. All five hosted jobs pass on the final head, including real-stack.

    Exact commands, pinned-version rationale and evidence are in docs/engineering/l2-verification.md; the independent QA verdict is recorded on this issue. Two engineering full-browser runs hit Firefox timeouts during overlapping heavy work; the exclusive independent final full suite passes without relaxed timeouts. Automatic approval review rejected a destructive reset test; volumes were preserved, refusal without --yes was verified, and the unchanged L1 destructive reset branch was checked by source comparison. No new volume-deletion test is claimed.

    Working tree is clean. No API/scientific semantic change, host install, licensed data, deployment, merge or issue closure. L3 #30 retains differences toggles and local opt-in BAFU acceptance. Next action: maintainer review/merge of PR #105; close #97 only after approved merge. L3 remains dependent on L2 delivery.

  8. DavidVFitzGerald commented on Nov 16, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: closing after the maintainer merged PR #105 at cd6d8a6. Independent QA PASS is recorded at #97 (comment) and all five final-head CI jobs passed. L2 is delivered; remaining MVP acceptance and differences toggles belong to L3 #30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendtask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions