Repository navigation
Conversation
One household at a time, built as a .py US dataset, runs through the service's cliff calculation (the planned cliff columns, .py's Simulation(dataset=...), and the weighted totals) and must give the cliff gap and share policyengine-us calculates for the same household given as a situation. On .py 6.20.4 a retiree with Social Security gets a gap of $22,644.95 instead of $0, and a parent of two on a real cliff $5,224.68 instead of $460.95: .py lists none of the dataset's columns in input_variables, so marginal_tax_rate's copies lose them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.20.5 is the version the .py release that lists a US dataset's inputs in input_variables is expected to have; the pin and lock move to it once it is on PyPI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1. The parent of two now runs under a raised Child Tax Credit, which .py builds from the dataset twice (the reform and its baseline), so the test covers the reform side API v2 also calculates cliffs for. The test also checks that policyengine-us still gives that household a cliff gap, so a later model change can't turn the case into a second zero-gap check unnoticed. On .py 6.20.4 the parent's gap is $6,824.68 instead of $460.95. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1. API v2's requests name no .py version: they run on the v2 default worker, which this deployment moves, and need API v1's catalog for that version, which API v1 publishes only when it deploys it. The fragment now says API v2 refuses new calculations with unknown_catalog_version until then, gives the example's place and year, and says labor-supply responses change too and stored results are not recalculated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2. policyengine-us gives the parent the same cliff gap with and without the raised credit, so the cliff comparison alone would pass if the policy never reached .py. The test now also compares the tax unit's ctc, a column the cliff plan already stores, and the docstring says every compared value comes from .py's reform simulation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2. The fragment now names new reports, re-runs and household calculations as what API v2 refuses until API v1 publishes the 6.20.5 catalog, and says labor-supply and capital-gains responses may change, since neither has been measured with the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both policyengine[models] pins in the executor (its dependencies and the modal-simulation-image group) and uv.lock move from 6.20.4 to 6.20.5, which lists a US dataset's stored columns in input_variables (PolicyEngine/policyengine.py#783). Its bundle changes only version labels: policyengine-core, policyengine-us, policyengine-uk and the data releases are unchanged. The Stage 12 cliff test now gives policyengine-us's cliff gap and share for both households. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
anth-volk
marked this pull request as ready for review
December 2, 2026 21:51
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1174
Summary
Update .py (
policyengine) from 6.20.4 to 6.20.5 in the simulation service. 6.20.5 (PolicyEngine/policyengine.py#783) lists every column it stores from a US dataset in the simulation'sinput_variables. Bothpolicyengine[models]pins in the executor (the project's dependencies and themodal-simulation-imagegroup) anduv.lockmove to 6.20.5; they are identical to the automated update's in #1181. The executor's Docker image and every Modal image install from that lock.6.20.5 contains only that change. Its bundle manifest changes only version labels: policyengine-core 3.34.10, policyengine-us 2.2.2, policyengine-uk 2.179.2 and the US and UK data releases are the same as in 6.20.4.
From 6.0.0 to 6.20.4, .py builds a US simulation from a dataset by creating the country simulation empty and then storing each dataset column with
set_input. policyengine-core listsinput_variablesonly at construction, so the list names none of the dataset's columns. policyengine-us'smarginal_tax_raterecalculates each household's net income in copies of the simulation that keep only the values ininput_variables. The copies therefore lose age, location, Social Security and every other dataset input, andcliff_gapcounts the income they lose as a cliff. This affects the cliff gap and cliff share of Stage 12's cliff calculation (API v2) and of the v1 calculation'sinclude_cliffs. The fixed release makes those copies keep every dataset input, so the cliff values match policyengine-us's for the same household.Tests
New:
test_stage12_cliff_dataset_inputs. Each case builds one household as a .py US dataset held in memory and runs it through the steps a Stage 12 cliff worker takes:resolve_cliff_output_plan;Simulation(dataset=…, policy=normalise_policy(…))thatbuild_stage12_simulationbuilds;apply_output_plan, thenrun();validate_output_framesandcliff_totals_from_frames.The expected values are policyengine-us's own, calculated in the test from a situation for the same household and policy, so no country-model version's numbers are written into it. The worker calls
ensure(), which adds only loading and saving stored outputs around the samerun(). Both households live in Wake County, North Carolina, in 2026.ctcequals policyengine-us's ($6,000 under the reform), so a policy that never reached .py fails.ctccomparison passes. CI on the test commits showed the same two failures and nothing else (3,114 executor tests passed).uv lock --checkpass. The test module is outside the executor's Pyright scope.Review
Two rounds of adversarial review by a read-only reviewer.
Round 1 found one medium bug, now fixed. The changelog fragment said API v2's requests carry API v1's .py version. They don't: they run on the v2 default worker (next section). Its quality findings are fixed too:
Round 2 found no bugs. Its quality findings are fixed:
ctccomparison shows the reform took effect.No bugs are left. Not covered here: the baseline simulation .py builds alongside a reform; the .py change's own tests cover it.
What deploying this does
economy_workers.default_economy_worker), and this deploy'spublish_stage12_v2_defaultjob moves that default to the new release after every check. Each request also needs API v1's catalog for exactly that version (read_catalog_rows). API v1 publishes that catalog only when it deploys the version (this service's 0.17.0 changelog). So from this deploy until API v1 deploys the same release, API v2 refuses new reports, re-runs and household calculations withunknown_catalog_version. App v3 still sends its requests to API v1, so only direct callers of API v2 are affected.policyengine.latestat/versions. Once this deploys and staging'slatestis the new release, API v1masterdeploys stop at that check until API v1's raise merges. That PR should therefore be reviewed and ready before this one merges.What the merge waits for
mainafter it and changes the same pin after it; already reachedlatestpast 6.20.4; if it did so before that PR's deploy passed its version check, that deploy would stop; already reachedinput_variables(PolicyEngine/policyengine.py#783)This PR builds on
main, not on another task's branch;mainis merged in.Deployment and environment variables
No environment variable, secret, workflow, Dockerfile or Modal secret is added or changed. Once the pin is raised, the images install the new release from
uv.lock..py's update workflow opened its own PR for 6.20.5, #1181, with the same pins and lock. This PR supersedes it.
🤖 Generated with Claude Code