Skip to content

Upgrade simulation API to PolicyEngine v4.10#502

Draft
anth-volk wants to merge 14 commits into
mainfrom
codex/simulation-policyengine-4-10
Draft

Upgrade simulation API to PolicyEngine v4.10#502
anth-volk wants to merge 14 commits into
mainfrom
codex/simulation-policyengine-4-10

Conversation

@anth-volk
Copy link
Copy Markdown
Contributor

@anth-volk anth-volk commented May 21, 2026

Fixes #503

Summary

  • Upgrade the simulation runtime to policyengine==4.10.0 while keeping existing API response contracts intact.
  • Derive the deployed policyengine-us, policyengine-us-data, policyengine-uk, and policyengine-uk-data versions from the bundled policyengine.py release manifests instead of independently pinned/hard-coded values.
  • Replace the US/UK-specific country package updater streams with one policyengine.py updater; that PR updates policyengine and syncs country package pins to the newly bundled versions in the same branch.
  • Set gateway policyengine_bundle metadata from the same manifest-derived source, including policyengine_version, country model version, data package version, and manifest dataset URI.
  • Define internal schema models for the single-year macro output and its budget, detailed budget, decile, poverty, inequality, geography, and labor-supply segments before dumping back to the existing dict contract.
  • Centralize runtime output construction in src/modal/simulation_output_builder.py; SimulationOutputBuilder calls the PolicyEngine analysis/output functions, transforms raw .py objects into our segment schemas, and owns final build()/serialize() output assembly.
  • Remove the separate simulation_output_adapter.py layer so the runtime builder is the single owner of .py calling, transformation, and serialization.
  • Wire UK constituency and local authority outputs into the existing result keys and align dataset metadata with the PolicyEngine v4.10 bundle.
  • Refresh the simulation project lockfile and strengthen focused contract/unit coverage.
  • Add a model-agnostic AI guidance harness based on policyengine-us-data: canonical docs/engineering/skills/, thin tool-specific adapters, PR template, contributing guidance, and same-repository draft PR rules.

Testing

  • uv run ruff check src/modal/simulation.py src/modal/simulation_macro_output.py src/modal/simulation_output_builder.py tests/test_simulation_output_builder.py fixtures/test_simulation_output_builder.py
  • uv run pytest tests/test_simulation_output_builder.py tests/test_simulation_api_contracts.py tests/test_release_bundle.py tests/test_policyengine_dependency_source.py tests/test_modal_scripts.py tests/test_policyengine_package_update_scripts.py tests/gateway/test_endpoints.py tests/gateway/test_models.py -q
  • git diff --check
  • git diff --cached --check
  • make -n push-pr-branch
  • make -n help

Copy link
Copy Markdown
Contributor Author

Note for follow-up: this PR intentionally does not restore cliff_impact calculation yet. Before we wire that back into the simulation API, we need to add/restore cliff impact support in policyengine.py v4 as a reusable output surface, then have the API call that output when include_cliffs is requested. The old API behavior delegated this to .py via Simulation.calculate_economy_comparison(); the new v4 builder should not invent a separate API-local cliff implementation.

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.

Upgrade simulation API to PolicyEngine v4.10

1 participant