Skip to content

L1: single-command local stack with seeded synthetic release (Refs #96) - #100

Merged
DavidVFitzGerald merged 3 commits into
mainfrom
feat/l1-local-stack
Nov 16, 2026
Merged

DavidVFitzGerald merged 3 commits into
mainfrom
feat/l1-local-stack

Conversation

@DavidVFitzGerald

Copy link
Copy Markdown
Owner

Refs #96

L1 of ADR 0006: ./dev app-up (and make up) starts the whole local application with one command, in healthcheck order, with a deterministic synthetic release that is published through B4.

Behavior

Commands. ./dev app-up, app-down (keeps volumes), app-reset (refuses without --yes), app-status, app-logs [service], app-smoke and app-import <lca-import args>. make up and make down wrap app-up and app-down. ./dev config now also validates compose.app.yaml. The existing up, api-up, etl-*, publication-* and mock-frontend flows are unchanged.

Isolation. The stack is compose.app.yaml. It uses project --project-name ${LCA_APP_PROJECT:-lca-diff-app}, which is never COMPOSE_PROJECT_NAME. It has its own network and its own volumes, app-db and app-archive. The database service is named db, so test suites, which reset only postgres/postgres-target in other projects, cannot reach it.

Ports. Ports bind to 127.0.0.1 only: frontend 5180, API 8010, auth 9110. They can be overridden with the LCA_APP_*_PORT variables. Postgres has no host port. app-up stops before starting anything if a configured port is in use.

Startup order.

  1. db becomes healthy.
  2. migrate runs alembic upgrade head as lca_migrator.
  3. seed runs python -m lca_etl.seed load, which uses B4 promote then publish as lca_import/lca_publisher with fixed operation UUIDs.
  4. auth becomes healthy.
  5. auth-seed recreates the verified demo account. The emulator keeps no state, so this runs on every start.
  6. api starts as lca_api with LCA_ENVIRONMENT=local, the emulator, and CORS restricted to the local frontend origin. It has a healthcheck on /api/v1/ready and never migrates.
  7. frontend starts: a locked npm ci and a VITE_SERVICE_MODE=mock build served by vite preview.

Airflow and Spark are not started. Every service has cap_drop: [ALL] and no-new-privileges.

Seed. data_pipeline/seed/ holds invented, BAFU-shaped data and no provider data:

  • 25 XML processes (one multi-output, excluded) and a 47-indicator workbook;
  • empty rules;
  • a pre-built ready B3 artifact generated from those sources with the Spark pipeline (python -m lca_etl.seed build). Startup therefore needs neither Spark nor an import database.

The seed has a fixed version, synthetic-local-2026.1, and deterministic release and revision IDs. It publishes 24 processes under three top-level categories, with paths of depth 3. It includes:

  • 5 reference units and 2 reference amounts;
  • a CO2 flow that is positive, negative, 0 and absent across processes;
  • valid, missing and unresolved-basis GWP 100 scores;
  • decimals with 34 significant digits, plus 1.2345E-33 and …e-40.

The loader refuses any revision or pointer for its release that it did not create (SEED_UNEXPECTED_REVISION / SEED_UNEXPECTED_ACTIVE_REVISION). It never writes tables directly. Later starts are B4 reused: true no-ops.

Tools image. ops/local/tools.Dockerfile is the stack's ETL runtime: the lca-etl package from the frozen lock, without Spark's JVM. It runs migrate, seed, auth-seed, smoke and the opt-in import. The API image is unchanged and still excludes pyspark and airflow. seed and import run as namespace UID 0 (ADR 0003) so that they share the archive owner and can read owner-only private B3 artifacts.

Smoke (AC2). ./dev app-smoke runs ops/local/local_stack.py smoke in a container on the stack network. It prints no tokens.

Docs.

  • The README covers the quick start, ports and URLs, local-only demo login, the L1 mock limitation, troubleshooting, the seed and how to regenerate it, and the opt-in BAFU path (target JSON, environment variables, network and volume).
  • development-environment.md gains an app-stack section and the L1 verification record.
  • The roadmap records L1 status.

CI. The ETL workflow now runs make backend-test-seed. Backend ruff and mypy now cover ops/.

Exact commands and results (engineering, rootless host, Compose v5.7.0)

All runs used an isolated app project and ports (LCA_APP_PROJECT=lca-diff-l1-app LCA_APP_FRONTEND_PORT=5240 LCA_APP_API_PORT=8240 LCA_APP_AUTH_PORT=9240) and workspace project lca-diff-l1. Other projects' containers were left running.

Command Result
./dev config exit 0
./dev app-up (no volumes, no .env) exit 0 in 2m26s; 4 services healthy, migrate/seed/auth-seed Exited (0). curl from 127.0.0.1: frontend 200, /api/v1/health 200, /api/v1/ready 200
Fresh git clone of this branch at 59dce85, project lca-diff-l1-clean, ports 5241/8241/9241: ./dev app-up, ./dev app-smoke, make down, make up all exit 0; smoke passed
./dev app-smoke 8/8 ok: health/ready 200; no token 401 AUTH_REQUIRED; demo token returns release e0639837-ac2a-56e4-9746-967bc5ad433f / revision dc63c04e-8927-5825-8544-ffbfe2de8e8e; exact 1.234567890123456789012345678901234; unverified 403 EMAIL_NOT_VERIFIED; untrusted-origin preflight without allow header; local origin allowed
./dev app-down, then ./dev app-up same release, revision and pointer activated_at; one revision; the same 2 publication_operation rows (promote lca_import/lca_import, publish lca_publisher/lca_publisher); archive has 55 files with the same digest; seed reports promote_reused/publish_reused true; smoke passes
./dev app-reset exit 1 "Refusing…", volumes kept
./dev app-reset --yes, then ./dev app-up volumes removed; clean reseed (seeded: true) with the same IDs
Injected foreign revision, then ./dev app-up exit 1, SEED_UNEXPECTED_REVISION, API and frontend not started (then reset)
LCA_APP_FRONTEND_PORT=5173 ./dev app-up while the lca-diff-dev workspace holds 5173 exit 1 before start, naming the variable
./dev app-up with lca-diff-l1 and lca-diff-dev workspaces running exit 0
Rendered config and docker port only 127.0.0.1 bindings; db none; every service cap_drop [ALL], no-new-privileges:true. API image: pyspark/airflow/lca_etl absent; user 65532:65532
Workspace: make backend-format-check backend-lint backend-typecheck backend-test-unit all exit 0 (mypy 46 files; 15 unit passed)
Workspace with app stack running: make backend-test-integration backend-test-api backend-test-auth backend-openapi-check exit 0 (5, 4 and 1 passed; OpenAPI unchanged)
./dev publication-run make backend-test-publication / make backend-test-seed 3 passed / 6 passed
App state before and after the destructive suites (AC5) identical

Inside the containers, commands used UV_PROJECT_ENVIRONMENT=/var/tmp/lca-venv, because this worktree sits on a size-limited tmpfs. The locked packages are the same.

Limitations and follow-ups

  • L1 frontend is mock mode. The stack's frontend shows "Local demo mode" and mock data, not the seeded release. L2 ([Task] L2 — Connect the frontend to the real API and Auth Emulator #97) adds the real adapter, generated DTOs and the real-stack Playwright smoke. apps/frontend/src is unchanged.
  • No hosted CI job for the app stack. ./dev requires a rootless daemon, and GitHub runners are rootful. The stack and smoke are therefore a documented local check here. ADR 0006 item 7 covers adding a CI smoke with L2/L3.
  • The opt-in BAFU path is documented and wired but not executed. ./dev app-import exists; running the path end to end is L3 ([Task] L3 — Differences toggles on the real API and local MVP acceptance #30) verification.
  • The tools image omits the JVM. Anything that needs Spark (artifact regeneration, B3 imports) still uses the existing data_pipeline/Dockerfile ETL image.

🤖 Generated with Claude Code

DavidVFitzGerald and others added 3 commits November 16, 2026 11:02
#96)

Add invented BAFU-shaped seed sources, a pre-built B3 artifact built from them
with the Spark pipeline, and an idempotent loader that only uses B4 promote and
publish with fixed operation IDs. Unexpected release state fails loudly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k (Refs #96)

Add compose.app.yaml under its own project/volumes, ./dev app-up/app-down/
app-reset/app-status/app-logs/app-smoke/app-import and make up/down. Postgres,
one-shot migrate and B4 seed tasks, the Auth Emulator with a recreated verified
demo account, the lca_api API and a mock-mode frontend start in healthcheck
order on localhost-only ports. Seed tests run in ETL CI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant