Skip to content

[Task] B1 — Python domain, schema and release contracts #57

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 2 — backend and real integration (B1)

Goal

Deliver the complete Python domain/schema foundation in one issue and one PR, ready for B2 read services and B3 ingestion. Work may span sessions with internal checklists and incremental commits; do not split this milestone into extra implementation issues without maintainer instruction.

Context and authority

Maintainer instruction 2026-11-14; roadmap B1; PRD §§4–6; specification §§0.2, 3–4, 8–9.2 and 12; accepted ADRs 0001/0003 and ADR 0005 after approved merge (#55, PR #56). Read AGENTS.md, docs/team/software-engineer.md, current PRD/specification, docs/engineering/development-environment.md and applicable ADRs. Exclude all archive/reference folders. The proposed ADR alone does not make this issue ready.

Requirements and constraints

  • Use an isolated backend worktree/branch and separate rootless Compose project, ports and volumes; preserve the other agent's frontend checkout, source, mocks and provisional contracts. Coordinate shared root config/locks/CI changes. Do not stop the frontend project's containers.
  • All dependencies, resolution, generation and checks run in guarded containers. Use one committed uv.lock, a runnable shared member and separate documented API/ETL dependency selections; lean API installs exclude Airflow/PySpark. Introduce actual API/ETL members with meaningful implementations in B2/B3 rather than fabricating empty services to satisfy a check. Establish a mutually supported Python/toolchain version and honor Airflow constraints before locking. Current bootstrap Python 3.14 is not evidence of Airflow/PySpark compatibility. If a single resolver cannot satisfy the stack, document the conflict and follow the ADR process before splitting projects/locks.
  • Exact numeric storage and deterministic keys must preserve scientific meaning. No arbitrary NUMERIC scale, float persistence, guessed identity, redundant process release FK, staging deduplication or cross-revision joins. No backend integration changes inside apps/frontend/.

Acceptance criteria

  • AC1 — A runnable pinned shared uv member, frozen workspace sync and compatible Python/container toolchain exist. Lean API and ETL dependency selections and single-lock compatibility are documented and reproducibly verified; actual API/ETL members arrive with B2/B3 unless B1 has a meaningful implementation for them. Shared Pydantic v2/Settings boundaries, Loguru context and local-only dotenv with environment precedence are usable; tooling runs without host installation.
  • AC2 — SQLAlchemy/Alembic implements specification §4.1 release/revision/publication/import/source/validation/resolution-rule tables; release version uniqueness, revision numbering and composite publication membership prevent mismatched release pointers. Published revision values are protected from mutation/deletion; old revisions remain available for rollback/snapshots.
  • AC3 — All five stg_bafu_* contracts preserve raw values and source coordinates, duplicates and original cell types. Revision-safe source/parent FKs prevent cross-revision associations; staging allows malformed duplicate process numbers to be retained and reported.
  • AC4 — Harmonized flow/process/process_flows/flow_provenance/impact_method/impact_indicator/lcia_score/process_warning relations, enums, integrity constraints and §4.5 indexes exist. Exactly scoped keys prevent duplicate measurements; valid/missing/unresolved scores and zero/absence remain distinct. Decimal serialization uses strings and rejects non-finite measurements.
  • AC5 — UUIDv5 namespace/key encoding is stable and versioned, release-scoped across reimport revisions, includes type and relevant compartments/unit/meaning, excludes display name/sign, and prevents unsafe collisions. Shared exact decimal helpers avoid context rounding in sums/conversions/comparisons. Provenance is self-contained without mandatory local-only staging links.
  • AC6 — A private disposable Postgres profile and documented container commands support clean migrations, targeted database checks and separate migration/import/read roles. API role cannot write or read private staging; no application superuser credential is used. Production topology is not provisioned.
  • AC7 — Focused container-backed behavior checks prove clean-DB upgrade, critical unique/FK/revision/publication protections, immutable publication data, decimal precision/missingness, deterministic identity and config/log redaction. Applicable frozen-lock/Ruff/MyPy/pytest/migration CI is introduced with this component, using synthetic data only; existing frontend checks remain intact.
  • AC8 — Roadmap and backend verification record document exact commands/results, provisional contract decisions, remaining B2/B3/B4 responsibilities and independent QA handoff at the delivered SHA. One PR references this issue; issue remains open pending checks, QA and approved merge.

Out of scope and follow-ups

B2 owns public endpoints/Firebase verification; B3 owns extraction/harmonization/reconciliation/reports; B4 owns artifact transfer and publish/rollback commands. I1 owns generated frontend types, real adapter and UI integration; R1/R2 own cloud provisioning/deployment, license approval and full-data release gates. Preserve DESIGN-NOW interfaces only; no post-MVP feature implementation. Those milestone issues, once published, must be cross-linked rather than creating extra B1 implementation issues.

Verification plan

Existing entry points: guarded ./dev and container Make targets. B1 must introduce backend-targeted commands (names below are planned, not current passing evidence) and document invocation under a distinct COMPOSE_PROJECT_NAME/FRONTEND_PORT. Inside the isolated workspace: uv lock --check, uv sync --frozen --all-packages for the implemented members under the selected compatible constraints, make backend-format-check, make backend-lint, make backend-typecheck, make backend-test-unit, and make backend-test-integration. The integration target starts/uses only disposable isolated Postgres, runs alembic upgrade head against an empty database and the focused constraint/immutability tests. Add reproducible dependency-resolution evidence proving the intended lean API selection omits ETL libraries and the intended ETL selection honors Airflow constraints; do not fabricate runtime packages for this check. Do not invent success or run nonexistent targets; implement/document these commands with the component. No coverage percentage target or redundant full suites. Frontend tests run as required by shared configuration changes, not as backend security evidence.

Dependencies and readiness

BLOCKED until ADR 0005 is approved and merged through #55 / PR #56 and verified M1/M2 configuration is available on the base branch. Confirm rootless tooling and compatible dependency resolution before application development. After those gates, B1 is independent of F3–F5 completion. B2/B3 consume B1; B4 consumes B3 and B2 visibility evidence. PM must record readiness; exact-SHA independent QA and maintainer review/merge remain required.

Published implementation graph: B1 #57 → B2 #58 / B3 #59 → B4 #60.

Activity

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

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY — B1 / Phase 2

    ADR 0005's approval-and-merge gate is satisfied: the maintainer explicitly authorized merge, and GitHub confirms PR #56 merged at 125b0909595a6db89b214ac3db59b0d108a44226 on 2026-11-14. The remaining Proposed wording is historical branch wording, not evidence that the merged decision remains blocked. #55 is closed. M1/M2 foundation delivery is recorded in the merged roadmap; the coordinator reports the isolated planning workspace's guarded rootless container check passed with Python 3.14.2 and uv 0.9.30. I verified the issue scope, merged roadmap and PR merge state independently; the container observations are attributed coordinator evidence.

    Proceed with one B1 issue and one PR in an isolated backend worktree, preserving the active frontend checkout. Authority: specification §§3–4, 8–9.2 and 12; PRD §§4–6; ADRs 0001/0003 and merged 0005. B1's first engineering step must reproducibly resolve compatible pinned Python/API/ETL dependency selections under Airflow constraints before application development; bootstrap version availability is not proof of resolver compatibility. Keep one lock and introduce actual API/ETL members with B2/B3 unless B1 has meaningful implementations.

    Acceptance criteria and container verification plan are complete in this issue. Introduce the listed backend targets with their components; they are planned commands, not already passing checks. Focus tests on domain precision/identity, migration/revision/publication constraints, private/read-only roles and config/log safety. Independent QA must verify the delivered SHA. No merge, deployment or production publication is authorized by this readiness record.

    B2 #58 and B3 #59 remain blocked on B1 delivery and QA; B4 #60 waits on B3 and B2 visibility. I1 retains Phase 1, B2 and B4 gates.

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

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: IN PROGRESS

    B1 implementation is isolated on feat/b1-domain-schema in /tmp/lca-diff-b1; no frontend files changed. Domain/schema/roles/migration and guarded backend profile are implemented. Focused container checks currently pass: 9 unit cases, 5 PostgreSQL integration scenarios, Ruff and strict MyPy (12 source files).

    The real uv resolver proves Python 3.14 compatibility for lean FastAPI/Firebase and combined API/Airflow/PySpark selections under official Airflow 3.4.0 constraints. Firebase Admin 7.8.0 conflicted with its Google dependency pin; verified 7.7.0 resolves. One workspace lock is retained. Checks include exact decimals, revision FKs, self-contained provenance, private read-only views, importer publication denial, immutable history/reparenting and publication/write lock contention.

    Remaining: verification/runbook documentation and merged-ADR status reconciliation, CI run, final review and exact-SHA independent QA. No API endpoints, ETL import, production resources or publication are claimed.

  5. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    Issue #57; PR #61; branch feat/b1-domain-schema; delivered SHA 11596f0e2a33aa43cdb2c391be4de3fb51149a7e. Worktree /tmp/lca-diff-b1 is clean. No frontend application files changed, no source archive extracted/imported and no production action performed.

    AC1–AC8: implemented with passing local evidence. Shared Pydantic/Settings/domain member, exact arithmetic/JSON strings, deterministic UUIDv5 keys, all specified staging/harmonized/release tables, composite revision/publication membership and self-contained provenance are delivered. Separate migration/import/publisher/API roles, private Postgres profile, safe api.* views, immutable published metadata/measurements/rule history and targeted CI are included. ADR 0005 acceptance status records the verified PR #56 merge at 125b090; PRD/spec/roadmap/roles agree. Full component/ownership details and commands are in docs/engineering/b1-verification.md.

    Exact observed container commands from the isolated checkout:

    COMPOSE_PROJECT_NAME=lca-diff-b1 FRONTEND_PORT=5188 ./dev up
    COMPOSE_PROJECT_NAME=lca-diff-b1 FRONTEND_PORT=5188 ./dev check
    COMPOSE_PROJECT_NAME=lca-diff-b1 FRONTEND_PORT=5188 ./dev backend-up
    docker compose -p lca-diff-b1 exec -T workspace bash -c 'uv lock --check && uv sync --frozen --all-packages && make backend-format-check && make backend-lint && make backend-typecheck && make backend-test-unit && make backend-test-integration && make backend-migrate && make backend-compat'

    Results: frozen lock/sync PASS; Ruff format/lint PASS; strict MyPy PASS (12 source files); 9 unit cases PASS; 5 PostgreSQL integration scenarios PASS; clean upgrade and idempotent migration PASS; lean FastAPI/Firebase and combined Airflow/PySpark resolver selections PASS under checksummed official Airflow constraints. The last small guard edits were rechecked with Ruff/MyPy and the affected 5 integration scenarios. Default uv sync --frozen followed by shared import also passed. Host git diff --check and synchronized Task-form comparison passed. No host runtime/install used.

    Independent QA found and engineering fixed a release-metadata/publication race, draft-rule audit mutation and importer temporary-table shadowing. Regressions stay within the five integration scenarios. Every guard pins its trusted search path with pg_temp last; revision freeze locks revision/release/shared rule/flow metadata. Rule references are release scoped and immutable once used in published history. Root frozen sync retains the real shared package.

    Dependency evidence: Python 3.14.2/uv 0.9.30; Airflow 3.4.0 constraints SHA 0521ca33b8fcf92d9cd672d25ec85fdaf95a0021116b64d193079eb334143268. Firebase Admin 7.8.0 failed its Google-core constraint; 7.7.0 resolves with FastAPI 0.162.0, Uvicorn 0.54.0, Airflow 3.4.0 and PySpark 4.3.0. Exactly one workspace lock remains; no placeholder API/ETL member. B2/B3 introduce actual runtime members and runtime checks.

    Limitations/next actions: independent QA must reverify this delivered SHA and hosted checks must pass for it. B2 #58 owns verified Firebase/read endpoints/cursors/transport budgets; B3 #59 owns ingestion/reconciliation/all audits; B4 #60 owns complete readiness gates, authenticated artifacts/promotion/publication/rollback. API role reads only documented api.* ever-published views, active release list uses publication pointer, and older published snapshots remain available. I1 owns generated TS contracts and real frontend integration. Java/Spark execution, real Firebase authorization, full-data licensing/validation and cloud deployment are not claimed by B1. Issue remains open; no merge authorization assumed.

  6. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA — updated delivered SHA

    The delivered SHA is now d3a23893faea5668cdf35bc34a3750f55193dea0 on feat/b1-domain-schema, PR #61, superseding 11596f0 in the earlier handoff.

    Final self-review found that the publisher's shared-row freeze locks require UPDATE privileges even though publication must not grant catalog mutation rights. A narrowly granted SECURITY DEFINER helper now obtains only the trusted revision/release/rule/flow locks, with the pinned safe search path; role authorization remains in the invoker trigger. Only publisher/migrator can execute the helper. The actual lca_publisher connection now freezes successfully and is denied catalog UPDATE in the existing role scenario.

    Affected container checks passed: make backend-format, make backend-lint, make backend-typecheck (12 source files), make backend-test-integration (5 scenarios). Other earlier exact commands/results and AC1–AC8 delivery remain unchanged. Documentation records the role boundary. Independent QA and hosted checks must use this SHA. No merge or production action performed.

  7. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Reviewed B1 SHA: d3a23893faea5668cdf35bc34a3750f55193dea0, issue #57 / PR #61. Independent QA used detached worktree /tmp/lca-diff-b1-qa, rootless Compose project lca-diff-b1-qa, frontend port 5190 and its own private PostgreSQL volume. This verifies shared domain/database foundation using synthetic data; no real Firebase/API, ETL import, frontend integration or production publication is claimed. QA authored no application/test changes.

    Criterion evidence

    • AC1 PASS: real pinned lca-shared member and one committed uv lock; frozen checks/install pass. Python 3.14.2 / uv 0.9.30 in the guarded container. Both lean API and combined API/Airflow/PySpark dependency probes resolve under official Airflow 3.4.0 Python 3.14 constraints, with lean selection excluding ETL libraries. Official downloaded constraint SHA independently matches the vendored 0521ca33b8fcf92d9cd672d25ec85fdaf95a0021116b64d193079eb334143268. Settings precedence, production dotenv refusal and operational-log redaction pass. Root frozen sync retains the shared member.
    • AC2 PASS: all §4.1 tables inspected; clean migration, release/revision unique keys and composite publication membership pass. Database guards protect published and superseded revision data, shared release/flow descriptions and referenced rule evidence. Old/new revision reparenting is denied. Independent concurrent release metadata/rule writers block actual-publisher freezing until commit; edits after freeze are rejected.
    • AC3 PASS: all five staging contracts preserve raw source representation and coordinates; synthetic invalid textual amounts and duplicate source identities are retained. Composite parent/source/reference FKs enforce revision membership. Workbook original-cell/type representation is available in source-preserving JSONB; actual extraction remains B3.
    • AC4 PASS: all specified harmonized relations, scoped keys, finite unrestricted NUMERIC storage, score status/presence checks and §4.5 indexes inspected. Full-precision round trip, present zero/absence and valid/missing/unresolved distinctions pass. API measurement schemas serialize strings; non-finite inputs/storage are rejected.
    • AC5 PASS: fixed versioned UUIDv5 namespace/tuple encoding includes release/type/compartment/unit and excludes names/sign/reimport revisions. Environmental/fallback identities remain separate. Exact sum/product helpers preserve long/tiny values under low caller precision. Provenance retains durable source object/path/process/ordinal/amount/rules with optional local staging FK. Rule references are source-release validated, including provenance JSON IDs.
    • AC6 PASS: isolated private pinned PostgreSQL profile, documented lifecycle/migration commands and distinct nonsuperuser roles. Actual lca_publisher successfully freezes a revision containing flow/rule dependencies and inserts its publication pointer, while direct process/flow edits are denied. Its SECURITY DEFINER helper only locks rows, pins a trusted search path and grants EXECUTE to publisher, not API/import roles. API cannot read staging, assume migrator role or write public views even after disabling its client default read-only setting. Import cannot publish or bypass immutability using temporary relation names/caller search paths.
    • AC7 PASS: final exact-SHA frozen-lock/install, Ruff formatting/lint, strict MyPy, 9 unit cases and 5 PostgreSQL integration scenarios, clean migration and idempotent upgrade pass. Additional independent adversarial/concurrency probes pass. Applicable backend CI is introduced; existing frontend code/workflow is unchanged. Hosted backend-quality and frontend quality pass at this head (links below).
    • AC8 PASS: roadmap, dependency provenance and docs/engineering/b1-verification.md record implemented behavior, exact commands, limitations and B2 [Task] B2 — Read API and real authorization #58 / B3 [Task] B3 — BAFU ingestion and LCIA reconciliation #59 / B4 [Task] B4 — Promotion, atomic publication and rollback #60 / I1 responsibilities. Accepted ADR 0005 status is reconciled with recorded merge evidence. One B1 PR references [Task] B1 — Python domain, schema and release contracts #57; no issue closure or merge performed by QA.

    Commands and results

    From the isolated QA worktree, with COMPOSE_PROJECT_NAME=lca-diff-b1-qa FRONTEND_PORT=5190:

    ./dev backend-up
    ./dev check
    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-migrate'
    docker compose exec -T workspace make backend-compat
    docker compose exec -T workspace bash -lc 'curl -fsSL https://raw.githubusercontent.com/apache/airflow/constraints-3.4.0/constraints-3.14.txt | sha256sum'
    git diff --check 125b0909595a6db89b214ac3db59b0d108a44226...HEAD
    git diff 125b0909595a6db89b214ac3db59b0d108a44226...HEAD -- apps/frontend .github/workflows/frontend.yml
    git status --short

    All exit 0; frontend diff and tracked/untracked QA status are empty. ./dev check independently passed rootless UID/GID mapping, dropped capabilities/no-new-privileges and eight preflight scenarios. Final MyPy checked 12 source files; Ruff checked 16 formatted files. Additional stdin Python/SQL probes used only synthetic fixtures and separate actual-role connections: release/rule writer contention returns 55P03; frozen metadata/rule or temp-shadow mutation returns 23514; cross-release rule linkage returns 23503; forbidden helper/role/base-table operations return 42501; non-updatable API-view deletion is denied.

    Earlier code review found release metadata/publication races, mutable draft-rule evidence referenced by frozen history and an importer temporary-table shadow bypass. Engineering corrected them and added focused regression assertions within the existing scenarios. Publisher privilege correction was additionally verified with populated flow/rule dependencies rather than only the migrator connection.

    Hosted final-head checks: backend-quality, frontend quality.

    Unrun/out of scope: real auth/endpoints (B2), XML/workbook/Airflow/Spark execution and reports (B3), promotion/publication operations (B4), full real-integration browser journeys (I1) and release validation (R1/R2). Dependency resolution is not runtime ETL evidence. Next action: coordinator/maintainer review; continue dependent backend work under its existing issues, retaining explicit merge authorization requirements.

  8. 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.

  9. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Updated exact-SHA review: 485c480f6944813d5e2ca880219b8aa95aa7a3ee on PR #61 after merging current main. This supersedes the previous delivered-SHA verdict without claiming a new implementation.

    B1 AC1–AC8 remain PASS. I independently compared the prior QA-passed d3a23893faea5668cdf35bc34a3750f55193dea0 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. The previously verified domain/schema, publication/rule/temporary-shadow protections, roles, locks and tooling are unchanged. The detailed original B1 QA evidence therefore carries forward.

    I inspected the combined roadmap merge diff and confirmed main's frontend status was retained, B1/B2 branch-only QA evidence is explicitly distinguished from merged completion, and I1 reconciliation remains recorded. git diff 485c480^2 485c480 -- apps/frontend .github/workflows/frontend.yml is empty: the merge preserves main's actual frontend tree/workflow. Applicable whitespace checks pass. No application edits, local test repetition, main merge or issue closure performed by QA.

    Fresh exact-head hosted checks pass and rerun the executable gates: backend-quality, frontend quality. The inherited local evidence remains 9 unit cases, 5 database scenarios, frozen/static/migration/compatibility checks and actual-role adversarial/concurrency probes; unchanged suites were not redundantly rerun locally for a roadmap/main merge.

    Next action: coordinator/maintainer review at this exact SHA. PR remains unmerged; existing authorization and production-release gates remain in force.

  10. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: merged delivery verified

    PR #61 was merged by the maintainer into main at f790803cde32a13c8115abed0fb09f448a85ff9a. Its reviewed head 485c480f6944813d5e2ca880219b8aa95aa7a3ee had independent QA PASS and passing hosted checks. This completes B1 #57; closure records observed delivery rather than the later feature-target merges.

    B2 #58 and B3 #59 remain open until recovery PR #82 delivers their reviewed code to main. B4 #60 remains unimplemented.

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