Skip to content

Build Stage 8 API v2 platform foundation - #3793

Draft
anth-volk wants to merge 12 commits into
masterfrom
stage-8-v2-platform-foundation
Draft

Build Stage 8 API v2 platform foundation#3793
anth-volk wants to merge 12 commits into
masterfrom
stage-8-v2-platform-foundation

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #3792

Summary

  • Establish a dedicated, qualified Supabase/Postgres and private Storage foundation for the dormant API v2-alpha data domain.
  • Add the reviewed canonical SQLModel schema, including stable reports with one-to-many versioned report runs and native UUID rerun idempotency.
  • Add a mechanically separate, Postgres-only Alembic v2 chain with autogenerated schema and application-data migrations while preserving the v1 MySQL history.
  • Replace writable runtime SQLite and per-container Redis with typed, expiring, shared managed-Redis cache repositories.
  • Add deployment, startup, cache-loss, cross-instance, migration-lifecycle, and repository guard coverage.

Migration boundaries

  • Covered routes and workflows: existing runtime-cache consumers, including computed households, tracers, AI analysis, reform impacts, budget-window coordination, and the historical /simulations response projection; v2 administrative migration and Storage bootstrap workflows; Cloud Run and App Engine cache wiring.
  • Remaining on Flask/API v1: all production route ownership, Cloud SQL durable reads and writes, the existing Simulation Entrypoint, and current compute routing.
  • Newly prepared: dormant Supabase Postgres/Storage, canonical SQLModel persistence, an isolated Alembic v2 lifecycle, managed cross-instance Redis, and associated CI and operational qualification.
  • Intentional user-visible API changes: none. Existing response contracts and production data authority remain unchanged.

Operational behavior

  • Redis contains only recoverable cache and bounded coordination state; durable domain data remains database-owned.
  • Deployed modes fail closed without valid managed-cache configuration and never fall back to localhost or launch an embedded Redis server.
  • Application imports, debug startup, and requests no longer create or initialize writable SQLite state.
  • Cache loss is treated as a miss where recomputation is safe; coordination operations fail closed.
  • The v2 schema remains dormant and is not activated for production request reads, writes, routes, or compute in Stage 8.

Verification

  • OpenSpec implementation and strict verification: 86/86 tasks complete.
  • Focused unit coverage: 205 tests passed.
  • Disposable Postgres migration lifecycle: 3 tests passed, including downgrade and re-upgrade.
  • Ruff lint and formatting checks passed for all changed Python files.
  • scripts/run_quality_guards.py passed.
  • scripts/export_migration_contracts.py completed with no generated drift.
  • Changelog-fragment validation passed.

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.43813% with 228 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.20%. Comparing base (354903f) to head (5965b74).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
policyengine_api/runtime_cache/repositories.py 81.65% 22 Missing and 18 partials ⚠️
policyengine_api/runtime_cache/fake.py 84.09% 13 Missing and 8 partials ⚠️
policyengine_api/runtime_cache/settings.py 84.49% 14 Missing and 6 partials ⚠️
policyengine_api/data/v2/migration_target.py 81.00% 10 Missing and 9 partials ⚠️
policyengine_api/data/v2/report_runs.py 82.02% 9 Missing and 7 partials ⚠️
policyengine_api/runtime_cache/client.py 51.72% 11 Missing and 3 partials ⚠️
policyengine_api/data/v2/storage_bootstrap.py 85.86% 6 Missing and 7 partials ⚠️
policyengine_api/runtime_cache/core.py 85.71% 4 Missing and 9 partials ⚠️
policyengine_api/data/v2/settings.py 90.00% 6 Missing and 4 partials ⚠️
policyengine_api/app_engine_runtime.py 81.81% 6 Missing and 2 partials ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3793      +/-   ##
==========================================
+ Coverage   84.19%   85.20%   +1.01%     
==========================================
  Files          86      108      +22     
  Lines        4720     6409    +1689     
  Branches      926     1112     +186     
==========================================
+ Hits         3974     5461    +1487     
- Misses        510      635     +125     
- Partials      236      313      +77     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Build Stage 8 API v2 platform foundation

1 participant