Repository navigation
Conversation
Core 3.41.0 no longer branches a reform simulation's baseline arm in __init__; it builds the current-law copy through _build_current_law_simulation when something first asks for it. The SPM mixin's __init__ therefore never saw the copy, so the copy's provider never recorded counties supplied as numbers, and the baseline arm accepted them. Override the hook to give the copy what construction gave the baseline arm: drop holders built for the reform, rebind to the copy's policy, prime its parameter tracing and record its counties. The Social Security input test backend executes selected Core method bodies on a fixture class. Core 3.41's clone and get_branch read _current_law_source, _CurrentLawSource and the _supplied_current_law class default; load them when Core has them, and take every class-level default Core declares that the fixture does not set. Both changes are no-ops on core 3.40, so the pin stays at >=3.40.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing as superseded by #11729, which fixes the same three core 3.41.0 failures (the two SPM county tests and the Social Security input state machine) and passed the full suite. |
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.
What's failing on main
The main push run 47182438303 at f8b3ea5 failed in two jobs:
make test-other-python-spm): two failures inpolicyengine_us/tests/core/test_spm_system.pytest_a_reform_simulations_baseline_arm_rejects_the_same_county_input:DID NOT RAISE SPMInputErrortest_subsampling_records_the_counties_each_arm_then_reads:KeyError: (2024, '36061')test_social_security_input_state_machine.py::TestSocialSecurityInputStateMachine::runTestraisesAttributeError: 'DelegatingSimulation' object has no attribute '_current_law_source'Cause
The full-suite jobs run
uv lock --upgrade-package policyengine-corebefore installing, so they test the newest compatible core rather than the locked 3.40.0. policyengine-core 3.41.0 (core PR #675) stopped branching a reform simulation's baseline arm in__init__. Core now builds the current-law copy the first time something asks for it, through a new_build_current_law_simulationhook.Simulation.baselinebecomes a deprecated alias that builds the copy when read. CI now resolves 3.42.0. No policyengine-us commit since the last green full suite touches this code.Fix
SPM county rejection and the subsampling county record (
policyengine_us/spm.py).SPMSimulationMixin.__init__used to find the baseline arm inbranchesand record, on that arm's own SPM provider, which counties were supplied as numbers rather than text. Under core 3.41 the copy doesn't exist yet when__init__runs. In this package,migrate_social_security_inputsbuilds it later by readingbaseline. The copy's provider, created before any input arrived, therefore never recorded the mistyped county, and the baseline arm accepted it. The mixin now overrides core's_build_current_law_simulationhook. The override gives every copy core builds what construction gave the baseline arm: it drops holders built for the reform's variables, binds the rest to the copy's policy, primes that policy's parameter tracing, and records the copy's counties. The guarantee is unchanged: a reform simulation's current-law arm rejects the same county input before it computes anything. Both tests pass unchanged.Social Security state machine (
policyengine_us/tests/core/_social_security_state_backend.py). The backend runs selected, unmodified core method bodies on a small fixtureSimulation. Core 3.41'scloneandget_branchnow call_current_law_source(), construct_CurrentLawSource, and read the_supplied_current_lawclass default. The backend now loads_current_law_sourceand_CurrentLawSourcewhen core has them, matching how it already handlesrefuse_on_read_onlyand the fallback-cache methods. It also copies every class-level default that core declares onSimulationand the fixture doesn't set itself, so a default a later core adds won't break the fixture. The test and its assertions are unchanged.Version pin
Kept at
policyengine-core>=3.40.0, withuv.lockleft at 3.40.0. Both changes do nothing on 3.40: core 3.40 never calls the hook, and the backend additions are skipped when core lacks them. With the pin kept, the locked jobs test 3.40.0 and the jobs that resolve the latest core test 3.42.0, so CI covers both. Raising the floor would force core's new current-law behavior on every install, which deserves its own PR.Not changed here: policyengine-us still reads
simulation.baseline(now a deprecated alias with no warning) inmigrate_social_security_inputsand several formulas._rebuild_baseline_branchassigns the rebuilt arm back tobaseline, so on 3.41+ the copy is still built during construction and kept as an assigned copy, which core never makes read-only. Moving to the declared current-law calls (current_law_simulation(),compares_with_current_law) is a separate follow-up.Tests run
Locally on macOS with core 3.42.0, resolved as CI does with
uv lock --upgrade-package policyengine-core:make test-other-python-spmfiles:test_spm_policy_family.py,test_spm_simulation_isolation.py,test_spm_system.py): 116 passed.policyengine_us/tests/core/and other Python tests that touch reform baselines or current law: in progress; this section will be updated.ruff formatandruff check: clean.axiom: n/a: test and core-compatibility plumbing, no policy rule change
🤖 Generated with Claude Code