Skip to content

Add migration contract harness#3637

Draft
anth-volk wants to merge 1 commit into
masterfrom
migration-pr1-contract-harness
Draft

Add migration contract harness#3637
anth-volk wants to merge 1 commit into
masterfrom
migration-pr1-contract-harness

Conversation

@anth-volk
Copy link
Copy Markdown
Collaborator

Fixes #3636

Summary

Adds the PR 1 migration safety harness for the API v2 migration plan without changing production behavior by default.

Changes

  • Adds typed migration route metadata and no-op source/traffic flags.
  • Adds structured migration-context request logging to the Flask app.
  • Adds typed app-v2 workflow contract registry and API v1 contract tests.
  • Adds current simulation gateway contract tests.
  • Adds opt-in baseline capture tooling for API route request metrics and simulation completion metrics.
  • Adds a PR 1 baseline runbook and changelog entry.

Testing

  • python -m pytest tests/contract -q -> 20 passed
  • FLASK_DEBUG=1 python -m pytest tests/unit/test_migration_flags.py tests/unit/routes/test_migration_context_logging.py tests/unit/test_capture_migration_baseline.py tests/unit/libs/test_simulation_api_modal.py tests/contract -q -> 82 passed, 1 existing warning
  • ruff format --check policyengine_api/api.py policyengine_api/migration_registry.py policyengine_api/migration_flags.py policyengine_api/migration_logging.py scripts/capture_migration_baseline.py tests/unit/test_migration_flags.py tests/unit/routes/test_migration_context_logging.py tests/unit/test_capture_migration_baseline.py tests/contract -> passed
  • ruff check policyengine_api/migration_registry.py policyengine_api/migration_flags.py policyengine_api/migration_logging.py scripts/capture_migration_baseline.py tests/unit/test_migration_flags.py tests/unit/routes/test_migration_context_logging.py tests/unit/test_capture_migration_baseline.py tests/contract -> passed

Notes

This PR does not shift traffic, add FastAPI, add Cloud Run deployment, migrate schema/storage, or change the public API contract.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

❌ Patch coverage is 87.82609% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.66%. Comparing base (9b249e5) to head (61e0fac).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
policyengine_api/migration_flags.py 87.83% 5 Missing and 4 partials ⚠️
policyengine_api/migration_logging.py 88.88% 2 Missing and 1 partial ⚠️
policyengine_api/migration_registry.py 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3637      +/-   ##
==========================================
+ Coverage   78.01%   78.66%   +0.65%     
==========================================
  Files          67       70       +3     
  Lines        4071     4186     +115     
  Branches      759      776      +17     
==========================================
+ Hits         3176     3293     +117     
+ Misses        700      691       -9     
- Partials      195      202       +7     

☔ View full report in Codecov by Sentry.
📢 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.

Add PR 1 migration safety harness for API v2 migration

1 participant