Skip to content

[Task] B2 — Read API and real authorization #58

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 2 — backend and real integration (B2)

Goal

Deliver the complete authenticated read API and authoritative OpenAPI contract in one issue and one PR, with a synthetic published revision usable by later integration. Retain one PR across sessions and incremental commits.

Context and authority

Roadmap B2; PRD §§2–5; specification §§4.5, 6.2–6.7, 7–9.2 and 12; ADR 0005 after approved merge (#55, PR #56). Read AGENTS.md, engineering role, current PRD/specification and services boundary README/contracts for reconciliation, without changing frontend code. Current frontend DTOs are provisional; specification §7 governs. Archive/reference folders are excluded.

Requirements and constraints

Use an isolated backend branch/worktree and container project, preserving F3–F5 frontend source/mocks/contracts. All tooling in rootless guarded containers; no production Firebase credentials or provider data in public CI. API is read-only, uses a least-privileged role and never exposes raw/staging sources or unpublished candidates. Explicitly configurable emulator use must not bypass identity verification in production. No arbitrary total user-selection cap: bound transport/work, use batched/windowed reads and timeouts/cancellation. Decimal strings, immutable snapshots and categorical missingness must survive every response.

Acceptance criteria

  • AC1 — FastAPI/Pydantic v2 exposes all §7.1 routes under /api/v1: me, releases, processes/search, processes/resolve-selection, processes/headers, indicators/tree, comparison/{flows,scores}/{rows,cells}, health and separate readiness. OpenAPI is reproducibly exported and validated; response models include required IDs/display metadata/cursors/snapshots, stable row keys, exact decimal strings and cell warnings.
  • AC2 — Firebase Admin verifies ID tokens, project/audience and email_verified; missing/invalid/expired/revoked identities are denied. Server derives UID, uses an entitlement boundary, rejects unverified accounts, and allows only authorized published releases. Health checks disclose no secrets. Real 401/403 map to AUTH_REQUIRED/EMAIL_NOT_VERIFIED; document Firebase reset/email-enumeration behavior carried from F2.
  • AC3 — AND-tokenized case-insensitive substring search covers allowed fields and branch paths, returns hierarchy/ancestor context and complete matching descendant counts, and uses deterministic cursor pagination. Selection resolution pages every eligible ID beyond visible pages in deterministic alphabetical order; header batches preserve revision metadata and safe warnings.
  • AC4 — Flow rows are ordered union by flow ID plus type and §6.4 sorting; score rows follow selected source indicator order with IPCC 2021/GWP100 default descriptor. Cells are batched windows with distinct present-zero/absent and valid/missing/unresolved states, safe affected-cell warnings and per-row numeric summary metadata needed for cross-window bar consistency.
  • AC5 — Exact difference predicates run only when requested and preserve presence/status versus zero. Canonical selection/snapshot/indicator semantics are order-independent for tokens/cache; correctness is independent of optional in-process cache. Cursors/comparison tokens reject mismatched queries/snapshots. No interactive unit normalization or scientific transformation occurs in API.
  • AC6 — Published snapshot requests remain on the specified immutable revision across later publication; unauthorized/unpublished revisions cannot be queried. Unknown/stale process/indicator/row IDs cannot silently mix revisions or leak data. Indexed SQL/batched joins avoid per-cell N+1 and unbounded synchronous work; requests have validated sizes, response budgets, cancellation and timeout behavior.
  • AC7 — Structured errors use the §7.4 codes and distinguish 401/403/404/409/422/429/5xx. Add validated settings, controlled CORS, operational request metrics/slow-query logging and correlation IDs without tokens, raw provider payloads or full audit rows. Invalid user input is parameterized and never echoed unsafely.
  • AC8 — Minimal meaningful unit/Postgres/API/Auth Emulator integration checks prove verified/unverified/expired/revoked access, unpublished/staging denial, exact decimal/missingness, page-spanning search/selection, row/cell windows, on-demand differences, token/snapshot isolation and safe invalid/oversized responses. Frozen lock, Ruff/MyPy/tests/build/OpenAPI checks pass in containers; runtime image is pinned, unprivileged and excludes ETL packages.
  • AC9 — Record exact commands/results, OpenAPI artifact location and provisional frontend contract discrepancies for I1; do not edit frontend DTOs/mocks to force agreement. Issue/PR handoff includes completed criteria and independent exact-SHA QA.

Out of scope and follow-ups

B3/B4 provide actual ingestion and maintainer publication operations. B2 uses deterministic synthetic seed data. I1 owns frontend DTO generation/drift checks, mock/real parity, Firebase browser adapter and real UI E2E. R1/R2 own production infrastructure, deployment, licensing and complete private data validation. Do not implement post-MVP uploads, saved comparisons, exports or mapping features.

Verification plan

B1's container-backed backend quality/unit/integration targets remain mandatory. B2 adds documented make backend-test-api, make backend-test-auth and make backend-openapi targets (planned until implemented), using isolated disposable Postgres and Firebase Auth Emulator with committed synthetic fixtures. Inside the guarded container: uv lock --check, frozen selected package sync, make backend-format-check backend-lint backend-typecheck backend-test-unit backend-test-integration backend-test-api backend-test-auth backend-openapi. Include one query-count/window behavior integration assertion and snapshot switch case rather than a broad benchmark suite. Validate the lean API container build/readiness. No production identity or private raw files in CI. Existing frontend mock smoke remains independent; real browser integration is I1.

Dependencies and readiness

BLOCKED until B1 domain/schema/roles are delivered and verified, plus ADR0005 acceptance and compatible container tooling. Link the published B1 issue/PR before PM readiness. B2 and B3 may proceed independently after B1, with only one writer for shared changes. B4's API visibility validation consumes B2; I1 waits for Phase 1, B2 and B4. Backend issue #55/PR #56 preparation does not satisfy acceptance by itself.

Published dependencies: B1 #57; sibling B3 #59; B4 #60 consumes this API.

Activity

  1. added
    task
    blocked
    on Nov 14, 2026
  2. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY — B2 / Phase 2

    B1 #57 / PR #61 is delivered at d3a23893faea5668cdf35bc34a3750f55193dea0 with independent exact-SHA QA PASS. I verified the final PR head and both hosted backend-quality and frontend quality checks are SUCCESS. QA independently reran frozen dependency/install, Ruff/MyPy, 9 unit cases, 5 database scenarios, migrations/compatibility and actual-role/concurrency/security probes. The previously found publication/rule/search-path defects and publisher lock permissions are corrected at this SHA. ADR0005 is accepted through merged #56; rootless foundation and the single-lock compatible dependency selections are verified.

    The complete #58 scope and acceptance criteria are unchanged and ready. Authority: PRD §§2–5; specification §§4.5, 6.2–6.7, 7–9.2 and 12; merged ADR0005. Proceed on isolated /tmp/lca-diff-b2, branch feat/b2-read-api, based on the delivered B1 SHA. Use one stacked B2 PR with base feat/b1-domain-schema while B1 awaits maintainer merge. Delivered QA-passed predecessor code satisfies this development dependency; no approval or merge of B1/B2 is inferred.

    Engineering handoff: use documented safe api.* views with the read-only API role, active publication pointers and authorized older ever-published snapshots. Implement the actual lean API member, Firebase Admin 7.7.0 under the verified shared Airflow constraints, auth/entitlement enforcement, signed query-bound cursors/tokens, cancellation/transport budgets, exact decimal/missingness semantics and focused Auth Emulator/Postgres/API checks. Introduce the planned B2 make/OpenAPI targets with the component. Preserve frontend source, mocks and provisional contracts; document discrepancies for I1 rather than editing them. Keep an isolated Compose project/ports/volumes and coordinate shared locks/tooling.

    No unresolved product/scientific decision blocks B2's synthetic read API. B3 #59 owns ingestion/reconciliation and all private audit reports; B4 #60 owns promotion/readiness/publication/rollback and consumes B2 visibility evidence. I1 still requires Phase 1, B2 and B4. B2 delivery requires exact-SHA independent QA and passing applicable checks; no production deployment/publication is authorized.

  3. removed
    blocked
    on Nov 15, 2026
  4. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    Delivered B2 #58 on branch feat/b2-read-api, commit 44471c61d91c323a85c0ef05d60cdec64729f64a, PR #70, stacked on verified B1 PR #61. No merge/deployment/publication performed. Frontend source/mocks/provisional contracts are unchanged.

    Criteria implemented: AC1 routes/strict DTOs/OpenAPI export+drift; AC2 Firebase verification/revocation and verified-email entitlement boundary; AC3 literal AND search, complete ancestor counts and all-ID pagination; AC4 exact row/cell windows and whole-comparison summaries; AC5 on-demand exact differences/canonical signed tokens; AC6 immutable snapshots, restricted DB role, window budgets/cancellation/timeouts; AC7 safe errors/CORS/correlation logging and bounded per-instance metrics/rate limits; AC8 focused synthetic Postgres/API/real Auth Emulator checks and lean unprivileged image; AC9 full verification and I1 reconciliation record. Independent QA and final hosted checks remain pending; implementation does not self-certify QA.

    Container environment: guarded rootless project lca-diff-b2, worktree /tmp/lca-diff-b2, frontend tooling port5189, API8189, auth9199, isolated Postgres volume/network. Exact commands and interfaces are in docs/engineering/b2-verification.md.

    Commands/results inside that workspace: uv lock --check, uv sync --frozen --all-packages, make backend-format-check backend-lint backend-typecheck, make backend-test-unit backend-test-integration backend-test-api backend-test-auth, make backend-openapi backend-openapi-check backend-compat PASS. Counts:11 unit cases (9 inherited),5 inherited database scenarios,4 API scenarios,1 real Auth Emulator scenario. Both official Airflow-constraint resolver selections pass. The API image build asserts absence of Airflow/PySpark; real HTTP health/readiness/auth-denial/verified identity/synthetic release smoke PASS. Inspection confirms UID/GID65532, all capabilities dropped and no-new-privileges.

    The first hosted API job exposed a checkout ownership mismatch before tests; final candidate runs its restricted test container as the checkout owner with disposable HOME/cache and bounded service readiness. Hosted backend/frontend jobs passed on the earlier candidate; the final three-job run must be read back before readiness for review. No host runtime/package installation or private input use occurred.

    Limits/ownership: transport defaults2MB/4MB,200 header/row/column windows,10000 cells/warnings; selection has no count cap. Per-instance rate limiting is not a distributed quota. One upstream TestClient deprecation warning remains under the official constrained httpx compatibility path, with passing tests. I1 owns actual browser Firebase/HTTP adapter, generated frontend types and parity/E2E. B3 owns ingestion/audits; B4 owns real candidate publication/rollback/visibility. R1/R2 retain production/infrastructure/full-data/license gates. Next action: independent exact-SHA QA and final hosted checks, then maintainer review.

  5. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Reviewed final B2 SHA 44471c61d91c323a85c0ef05d60cdec64729f64a, PR #70, stacked on independently verified B1. QA used detached /tmp/lca-diff-b2-qa, rootless Compose project lca-diff-b2-qa, ports 5298/8298/9298 and a separate private Postgres volume. Mode: synthetic PostgreSQL data, actual Firebase Auth Emulator and actual lean HTTP runtime. No application/tests/criteria changed by QA; no source archives or production credentials used.

    • AC1 PASS: all §7 routes, health/readiness and typed envelopes inspected/exercised. Deterministic apps/api/openapi.json drift check passes, including bearer security metadata and decimal-string schemas.
    • AC2 PASS: actual Admin SDK/Emulator scenario verifies verified UID, unverified 403, expired/wrong-project/revoked 401. Production emulator refusal and least-privilege configuration checks pass. Every dataset route requires verified identity; BAFU entitlement and ever-published snapshot membership are checked. No production Firebase account/security claim is made.
    • AC3 PASS: 205 IDs resolve across cursor pages, complete ancestor counts and literal AND filters pass. SQL-projected Unicode ordering values prevent cursor drift; path fingerprints distinguish delimiter-containing branch paths. Header batches are bounded and preserve revision/reference metadata.
    • AC4 PASS: flow union/type ordering, source-order indicators/default descriptor, whole-selection numeric summaries and exact cell windows pass. Long decimal strings, zero/absence, missing/unresolved scores and affected-cell warnings are preserved. Warning SQL is filtered to the requested window/scope and bounded.
    • AC5 PASS: differences are conditional on activation and compare exact values/presence/status. Canonical reordered selections reuse signed tokens; mismatched/tampered query tokens are rejected. Independent synthetic HTTP probes additionally verified equal-zero/equal-high-precision rows are excluded, present-zero versus absent differs, status-only score differences remain, and differing reference quantities/units do not normalize stored values.
    • AC6 PASS: immutable older snapshots continue working after active-pointer changes; unpublished snapshots are denied. Window query-count assertion is constant (at most eight SQL executions for the tested flow-cell request), not per cell. Request/response/window/warning/SQL/pool budgets are explicit. Final-SHA independent cancellation probe ran real SELECT pg_sleep(30) as the API role: disconnect cancelled and rolled back the query in 0.24 seconds. Outer cancellation is also covered by the unit group.
    • AC7 PASS: safe structured error envelopes, 401/403/409/422/429 behavior, correlation IDs, bounded operational counters and controlled CORS pass. Invalid private-looking input is not echoed. Actual runtime request logs are structured JSON with request_id/status/duration and no tokens/provider rows. SQLAlchemy statements use only restricted api.* projections; requests use read-only repeatable-read transactions.
    • AC8 PASS: final-SHA frozen lock/install, Ruff, strict MyPy, 11 unit cases + 5 inherited database scenarios + 4 API scenarios + 1 Auth Emulator scenario, and OpenAPI drift pass. Final runtime image builds/runs as UID/GID 65532, with all capabilities dropped and no-new-privileges; Airflow/PySpark imports are absent. All three hosted checks pass at this exact head.
    • AC9 PASS: docs/engineering/b2-verification.md and roadmap document exact commands, limits, OpenAPI artifact and I1 contract reconciliation. Frontend code/mocks/workflow are unchanged relative to B1. [Task] B2 — Read API and real authorization #58 remains open; no merge or issue closure performed.

    Commands, all successful, with COMPOSE_PROJECT_NAME=lca-diff-b2-qa FRONTEND_PORT=5298 API_PORT=8298 AUTH_PORT=9298 in the isolated worktree:

    ./dev api-up
    docker compose exec -T workspace bash -lc 'uv lock --check && uv sync --frozen --all-packages && make backend-format-check backend-lint backend-typecheck backend-test-unit backend-test-integration backend-test-api backend-test-auth backend-openapi-check'
    # Affected API/auth/schema checks rerun after resuming the same unchanged SHA:
    docker compose exec -T workspace bash -lc 'make backend-test-api backend-test-auth backend-openapi-check'
    git diff --check d3a23893faea5668cdf35bc34a3750f55193dea0...HEAD
    git diff d3a23893faea5668cdf35bc34a3750f55193dea0...HEAD -- apps/frontend .github/workflows/frontend.yml
    git status --short
    

    Ruff: 30 formatted files; MyPy: 21 source files. Frontend diff and QA worktree status are empty. Additional stdin Python probes exercised actual HTTP health/readiness, verified identity, exact decimal cells/absence, old and unpublished snapshots, sanitized errors/correlation IDs, real DB cancellation, and image UID/import assertions. These are synthetic checks, not a private-data import or browser integration.

    Review findings corrected before this final handoff: unscoped warning reads, Python/SQL Unicode cursor mismatch, ambiguous branch-path IDs, missing OpenAPI bearer metadata and CI bind-mount ownership. The initial API CI permission failure is resolved while retaining dropped capabilities. The one upstream Starlette/httpx deprecation warning is documented; no test or gate was skipped for it.

    Hosted exact-head checks: backend-quality, api-quality, frontend quality.

    Unrun/out of scope: production Firebase, actual ingestion/audits (B3), promotion/publication operations (B4), real frontend/browser adapter parity (I1), deployment/licensing/full-data release checks (R1/R2). Per-instance/IP quotas and configurable transport budgets remain documented limits. Next action: coordinator/maintainer review and dependent B4 visibility work; merge still requires explicit maintainer authorization.

  6. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: stack reconciled with current main

    No maintainer action is required to unblock ongoing B3/B4 development. PRs remain unmerged.

    Merged current origin/main into the isolated B1 branch and propagated B1 into B2 without rewriting history. Conflicts were limited to the roadmap; current frontend progress and delivered backend QA/CI status were retained.

    The API/shared/database/Python lock/scripts/backend workflow diff from the prior B2 delivery is empty. Whitespace/conflict checks passed. New hosted runs and independent reconciliation review are pending; prior exact-SHA evidence is retained rather than misattributed to the new commits. B3 will integrate the updated B2 branch before its single PR. The active frontend checkout and its uncommitted work were untouched.

  7. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Updated exact-SHA review: c49aa58d905fef5767e552460673431da5c8a154 on PR #70 after propagating B1's current-main merge. This supersedes the previous delivered-SHA verdict without claiming a new backend implementation.

    B2 AC1–AC9 remain PASS. I independently compared the prior QA-passed 44471c61d91c323a85c0ef05d60cdec64729f64a against this head for apps/api, packages/python, db, pyproject.toml, uv.lock, scripts, .github/workflows/backend.yml, compose.yaml, dev, Makefile and .dockerignore: empty diff. Auth, exact read/window/difference/snapshot semantics, signed tokens, cancellation, lean runtime and backend checks are unchanged. The detailed original B2 QA evidence therefore carries forward.

    I reviewed both merge ancestry and roadmap reconciliation: current main frontend progress is preserved, B1/B2 QA/CI is accurately identified as delivered branch evidence pending merge, and the frontend's provisional flowSummaries reconciliation remains an I1 handoff. Both relevant diff whitespace checks pass. No application/test changes, local suite repetition, main merge or issue closure performed by QA.

    All three fresh exact-head hosted checks pass and rerun executable coverage: backend-quality, api-quality, frontend quality.

    Inherited local evidence remains 11 unit cases, 5 database scenarios, 4 API scenarios, 1 actual Auth Emulator scenario, frozen/static/OpenAPI and lean-runtime checks, plus independent exact-decimal/status/equality, Unicode/path-ID and actual DB cancellation probes. Unchanged suites were not redundantly rerun locally for this merge. Mode remains synthetic DB/real local Emulator; no production Firebase/private import/frontend integration claim.

    Next action: coordinator/maintainer review at this exact SHA and dependent backend work. PR remains unmerged; explicit merge and production-release authorization requirements remain unchanged.

  8. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: delivery to main verified

    The maintainer merged recovery PR #82 into main at 9b0ebbaf07130ed0a8e8c964a1aca4f2e30b53ac. Its delivered head cc69f1e030d5e439433f34dc59ce2c419cef9828 had independent QA PASS and all four required hosted checks passing.

    Verified that main contains the recovery commit and that API/shared/schema/ETL/runtime/test/lock/tooling/workflow files match independently QA-passed B3 9e8fcc2aedf6ac3f20bd9629946a8e56863f26db. Thus B2 #58, B3 #59 and recovery #81 are delivered and ready for closure. B1 #57 was already closed after its verified main merge.

    This closure does not claim real frontend integration, full-data release, production deployment or publication. The maintainer has now authorized resuming the remaining backend milestone B4 #60 in its own issue/PR and isolated worktree.

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

    task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions