Phase 2 — Alpha Production Execution Plan¶
Baseline commit: 3b8dd47 (main, tag v1.0.0-rc.3)
Plan date: 2026-11-27
Alpha definition: A hardened, self-hostable build that is safe to deploy on a single controlled host (e.g. hamlet-server) with fail-closed configuration, no known high/critical dependency CVEs, CIS-aligned containers, a single schema authority, and CI that exercises real Postgres/Redis. Connectors remain simulated and no real complaint PII is authorized — that boundary belongs to Phases 3–5.
Out of scope for alpha: cloud IaC (Phase 4), real IdP/object-level authz (Phase 3), durable workflow state machine (Phase 3), real agency connector (Phase 5).
Standards applied¶
| Area | Standard / practice |
|---|---|
| Configuration | 12-Factor config; fail-closed startup validation (pydantic-settings) |
| Security baseline | OWASP ASVS L1→L2 config/deployment controls; secret hygiene |
| Containers | CIS Docker Benchmark; non-root, read-only rootfs, dropped caps, no-new-privileges, resource limits, digest pinning |
| Supply chain | SLSA-style provenance direction; SBOM (CycloneDX); dependency + secret + image scanning as PR gates |
| Schema | Single migration authority (Alembic); no runtime create_all in shared envs |
| Testing | Test pyramid + service-backed integration; CIS-aligned image scan in CI |
| Observability | Dependency-aware readiness (Kubernetes/Compose health-check semantics) |
Exit gate (Definition of Done for alpha)¶
The alpha is complete when all hold on main:
APP_ENV=productionwith any demo/fallback secret, demo mode, mock connector, wildcard CORS, or non-TLS public URL causes a non-zero exit before serving.npm audit --audit-level=highandpip-audit -r backend/requirements.txtpass (or carry a dated, approved exception).- Backend and frontend runtime images run non-root, read-only rootfs, no-new-privileges, pass a container scan with no unapproved high/critical CVEs, and are pinned by digest in the production Compose override.
- A clean
devCompose profile starts unchanged on loopback; ashared-hostprofile starts onhamlet-serverwith no data/broker/SMTP/collector port reachable off-host. - Alembic is the only schema authority;
create_allnever runs whenAPP_ENV != local/test; a drift test passes. - CI runs a real Postgres + Redis integration suite proving submit → track → retry → evidence → delete through the API, plus SAST, secret scan, image build + scan, and SBOM upload.
- Readiness reflects DB and required broker/config; liveness stays independent.
Workstreams → PRs¶
Seven PRs, sequenced by dependency. Each is independently reviewable and revertible. Branch prefix phase2/.
PR 1 — phase2/config-fail-closed (B-SEC-02, H-OPS-01)¶
Depends on: none (foundational; other PRs build on the settings object).
Introduce backend/app/config.py using pydantic-settings as the single typed config surface, replacing scattered os.getenv reads (currently in auth.py, db.py, main.py, celery_app.py, tasks.py, observability.py, fcc_plugin.py).
APP_ENVenum:local | test | staging | production.- Fail-closed validator refuses to construct in
staging/productionwhen:JWT_SECRETis a known demo/fallback value or < 32 bytes entropy;DEMO_MODE=true;FCC_CONNECTOR_MODE != networkwith an approved URL;CORS_ORIGINSempty/*; any public URL is non-TLS. - App and Celery import the settings object; no module reads
os.getenvfor business config after this PR. - Extend
/health/readyto check DB and (when async enabled) Redis broker reachability and config validity; keep/health/livedependency-free.
Acceptance: invalid/missing prod config exits non-zero before serving (new test); local/test unaffected; grep -rn "os.getenv" backend/app returns only config.py; readiness test covers DB-up/Redis-down degraded state.
PR 2 — phase2/dependency-remediation (B-SEC-03)¶
Depends on: none (can run parallel to PR 1).
Land the open Dependabot fixes and regenerate locks: pyjwt 2.15.0, opentelemetry-api 1.45.2, backend-dependencies group; frontend vite 8.3.8, undici 8.12.4, brace-expansion, source-map-js, frontend-dependencies group. Run full regression (pytest, vitest, build, e2e) after each group.
Acceptance: npm audit --audit-level=high → 0; pip-audit -r backend/requirements.txt → 0 (or dated approved exception recorded in docs/SECURITY.md); all existing tests green; OpenAPI contract unchanged (scripts/export_openapi.py diff clean).
PR 3 — phase2/migration-authority (H-DATA-01)¶
Depends on: PR 1 (uses APP_ENV).
Make Alembic the sole schema authority. Guard store.init() / Base.metadata.create_all (backend/app/db.py:103) so it only runs when APP_ENV in {local, test}; staging/production rely on alembic upgrade head (already in Dockerfile.backend CMD). Archive the two stale SQL schemas (backend/schema.sql, backend/migrations/) under docs/archive/ with a README, or delete if confirmed unused.
Acceptance: empty DB and rc.3-version DB both alembic upgrade head cleanly; a schema-drift test (autogenerate → expect "no changes") passes; startup in a production-mode test never creates tables.
PR 4 — phase2/hardened-images (H-CTR-01)¶
Depends on: PR 2 (scan against patched deps).
- Backend: convert
infra/Dockerfile.backendto multi-stage (builder installs into a venv/wheel; slim runtime copies only the venv + app). Keep non-rootappuser(uid 10001). Add OCI labels. Drop a writable/app/dataonly where needed (tmpfs in Compose). - Frontend: declare a non-root runtime user in the
nginxstage; use an unprivileged nginx config (listen high port already 8080) and OCI labels. - Both: documented digest-pinning strategy; base images pinned by digest in the production override.
Acceptance: docker scout/Trivy scan (added in PR 7) shows no unapproved high/critical; both runtimes start with read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] and pass health checks; graceful-stop (SIGTERM) and writable-path tests pass.
PR 5 — phase2/compose-profiles-parity (H-PARITY-01)¶
Depends on: PR 4 (hardened images referenced by override).
Split Compose into a base + profiles/override:
- dev profile: current behavior but host ports bound to 127.0.0.1 only.
- shared-host profile (new infra/docker-compose.prod.yml override): data services (Postgres, Redis, OTel, MailHog→real SMTP relay slot, Prometheus) internal only, no published ports; only the frontend reverse proxy (and optionally API) published, on loopback for an existing host reverse proxy to front. Add read_only, tmpfs, cap_drop, no-new-privileges, mem_limit/cpus, and restart: unless-stopped. Replace static local_demo_only / demo-admin credentials with .env-sourced values; ship infra/.env.prod.example (no real secrets).
- Parameterize the Prometheus 9090 collision seen on hamlet-server.
Acceptance: docker compose --profile dev config and -f ... -f docker-compose.prod.yml config both validate; dev starts unchanged on loopback; shared-host profile starts on hamlet-server without port collision and exposes only approved ingress; nmap/ss confirms no DB/broker/SMTP/collector port reachable off-host; same health/e2e suite passes under the prod override.
PR 6 — phase2/service-backed-integration (H-TEST-01, part of B-CICD-01)¶
Depends on: PR 3, PR 5.
Add a Postgres+Redis integration test suite (pytest + testcontainers or CI service containers) proving the real flow: create complaint → track → retry → add evidence → delete, with Alembic-migrated schema (not create_all). Add a migration test and a connector contract test against the mock-FCC service. Keep the 90% unit threshold.
Acceptance: CI job spins real Postgres + Redis and the flow passes end-to-end; migration test green; suite runs in the backend matrix without flaking twice consecutively.
PR 7 — phase2/ci-supply-chain (B-CICD-01 CI subset, M-CICD-01 SBOM)¶
Depends on: PR 2, PR 4, PR 6.
Extend .github/workflows/ci.yml with mandatory PR gates:
- SAST: CodeQL (Python + JS) or Semgrep.
- Secret scan: Gitleaks/TruffleHog on the diff.
- Image build + scan: build backend & frontend images, scan with Trivy (fail on unapproved high/critical).
- SBOM: generate CycloneDX per image, upload as artifact.
- Wire the PR 6 integration job as a required check.
- pip-audit + npm audit promoted to hard-fail gates (remove any soft-continue).
Acceptance: PR gate fails on an introduced high CVE, a planted secret, and a SAST finding (verified with a throwaway test commit); SBOMs attached to the run; all gates documented in CONTRIBUTING.md.
Sequencing¶
PR1 ─┐
PR2 ─┼─► PR3 ─┐
└─► PR4 ─┴─► PR5 ─► PR6 ─► PR7 (exit gate)
PR1 and PR2 land first in parallel. PR3 needs PR1; PR4 needs PR2. PR5 needs PR4. PR6 needs PR3+PR5. PR7 closes the chain and enforces everything as gates.
Verification command set (run before each PR merge)¶
# backend
cd backend && python -m ruff check . && python -m ruff format --check . \
&& python -m mypy app --ignore-missing-imports \
&& python -m pytest --cov=app --cov-fail-under=90 && pip-audit -r requirements.txt
# frontend
cd ../frontend && npm run lint && npm test && npm run build && npm audit --audit-level=high
# stack
cd .. && docker compose -f infra/docker-compose.yml config --quiet \
&& docker compose -f infra/docker-compose.yml -f infra/docker-compose.prod.yml config --quiet \
&& python -m mkdocs build --strict
Risks & notes¶
- Celery sync-in-FastAPI and the stubbed polling/escalation tasks (B-APP-01) are Phase 3, not alpha — this plan hardens deployment around them, it does not make the workflow durable.
- Replacing MailHog with a real SMTP relay in
shared-hostis a config slot only; wiring a real provider is deployment-time. hamlet-serverhas Docker 29.10 / Compose 5.7 confirmed (Phase 0). Theshared-hostprofile is validated there as the alpha target.- Each PR ends its description with the required attribution lines.