Repository navigation
Fix policyengine-us for policyengine-core 3.41.0's on-demand current-law copy - #11729
Merged
Merged
Conversation
…law copy Core 3.41.0 (PolicyEngine/policyengine-core#675) stopped building a reform simulation's baseline branch in Simulation.__init__ and builds it the first time something reads `baseline`. That broke three tests on main: - Two SPM tests: the baseline arm accepted a county supplied as a number, which the reform arm rejects. The SPM mixin records which counties were not text before policyengine-us builds the arm, so the arm's provider never got the record. `_rebuild_baseline_branch` now records them on the rebuilt arm. - The Social Security input state machine test: its backend runs Core's clone and get_branch bodies, which now call `_current_law_source` and read `_supplied_current_law`. The backend grafts the method and supplies the class and attribute when Core has them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
policyengine-us CI installs the newest policyengine-core on every run. Core 3.41.0 (PolicyEngine/policyengine-core#675, released 2:07 PM ET on Dec 3) changed when a reform simulation's baseline branch is built:
Simulation.__init__no longer builds it, and Core builds it the first time something readsbaseline. Since then, three Python tests fail on main (release run 47182438303) and on every PR, with both 3.41.0 and 3.42.0:core/test_spm_system.py::test_a_reform_simulations_baseline_arm_rejects_the_same_county_input: DID NOT RAISESPMInputErrorcore/test_spm_system.py::test_subsampling_records_the_counties_each_arm_then_reads:KeyError: (2024, '36061')core/test_social_security_input_state_machine.py::TestSocialSecurityInputStateMachine::runTest:AttributeError: 'DelegatingSimulation' object has no attribute '_current_law_source'What changes
The baseline arm rejects a mistyped county again (
policyengine_us/system.py). This is a real behavior fix, not only a test fix.__init__.SPMSimulationMixin.__init__then recorded, for each simulation in the family, which counties were supplied as numbers instead of text. The baseline's SPM provider got that record, and_rebuild_baseline_branchkept that provider.migrate_social_security_inputsreadsbaseline, after the mixin has already recorded. So the baseline arm accepted a county such as36_061that the reform arm rejects._rebuild_baseline_branchnow records the county input types on the rebuilt arm. With an older Core this repeats a record the arm already has, which is harmless.The state machine test backend (
tests/core/_social_security_state_backend.py). The backend runs Core's owncloneandget_branchsource, which now call_current_law_sourceand read_supplied_current_law. Like the 3.39.0 fix (PR 11657), each addition applies only when the installed Core has the name:_current_law_source;_CurrentLawSourceto the backend's namespace;Simulation_supplied_current_law = None, since it supplies no current-law values.While editing that statement, I also changed
sim_methods += tuple(...)to an explicit assignment.How I found it
cloneandget_branchchanged in a way that matters, plus a docstring change in_bind_to_tax_benefit_system.Checks
ruff format --checkpasses on both files.axiom: n/a: policyengine-core compatibility fix; no policy change
🤖 Generated with Claude Code