Repository navigation
Stop requiring unlinked scale brackets in the pinned system test - #11126
Conversation
PolicyEngine/policyengine-core#660 links every scale bracket on a loaded parameter tree to its scale, so the `parent is None` assertion would fail in the PR that moves uv.lock to a core release containing it. Remove the assertion and correct the docstrings that described loaded brackets as having no parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Program ReviewSource DocumentsNo source documents apply: this PR changes one test and adds a changelog fragment, so the PDF audit was skipped.
Branch StatusPR branch is 4 commits behind main. Consider rebasing before merging. This review was scoped to the PR's actual changes, so the staleness did not affect the findings. Critical (Must Fix)None. Should Address1. Merge this PR before a policyengine-core release contains #660, and correct the trigger in the PR descriptionWhere: PR description, "What and why" section; Problem: The PR description says "CI installs with This PR's own CI shows the upgrade. Failure scenario if a release containing #660 is published first:
Current state: #660 was still open and PyPI's latest core release was 3.36.1 when this review was prepared, so this failure has not occurred. Fix: Merge this PR before #660, and replace the quoted sentence with:
Evidence: The workflow steps were read and the version upgrade appears in the CI log. The failure sequence was traced through code, not run. 2. Once core links brackets, this test no longer builds the stale-cache caseWhere: Problem: The removed assertion guaranteed that the edit at line 562 stopped at the bracket and left every cached view above it stale. With #660, the same edit clears caches up to the root. The test still proves that an edit reaches a rebuilt pin, but it no longer proves that the EITC pin ignores a stale view held by its source. Concrete failure scenario: Suppose a later change makes
The regression would still produce wrong results on a linked core after a write that clears no cache, such as interpolation. What the test still catches on both core versions: a pin that is reused without being rebuilt, and removal of the restore loop at Priority: The test review rates this as should address. The logic review records the same narrowing and treats it as an expected result of #660. The gap has no effect until a core release contains #660. It stays in this section because the scenario is concrete and one line preserves the coverage. It does not block merge. Fix: State the premise in the test, where the assertion used to be: loaded = CountryTaxBenefitSystem()
# The edit below then clears no cache above the bracket, on any core.
loaded.parameters.gov.irs.credits.eitc.max.brackets[1].parent = NoneThis line changes nothing on core 3.36.0, where the parent is already If maintainers prefer to retire the scenario after #660, remove "so a pin has to read the parameter itself" from the docstring at lines 549-550. Evidence: The table and the fix were traced through the core 3.36.0 source and the #660 source. Neither the hypothetical regression nor the fix was run. Suggestions1. Name the changed test in the changelog fragmentWhere: Problem: "The pinned tax-benefit system test" reads as the whole module. Fix:
Validation Summary
What was run and what was traced:
Review Severity: COMMENTThe PR has no critical issues, and the test change is correct on both core versions by code trace. The two should-address findings do not block merge, but finding 1 sets the order in which this PR and #660 should land. Next Steps
|
…he case With policyengine-core#660, a loaded tree's scale brackets are linked to their scale, so an edit to a bracket clears the cached views above it. The test then no longer checked that a pin reads past a stale view held by its source. Setting the edited bracket's parent to None gives the same case on core versions with and without linked brackets. Also name the changed test in the changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
This prepares policyengine-us for PolicyEngine/policyengine-core#660, which makes every loaded parameter tree link each scale bracket to the scale holding it.
test_an_edit_to_a_loaded_tree_reaches_the_next_simulationassertedbrackets[1].parent is Nonebefore doing its real work. CI's test jobs runuv lock --upgrade-package policyengine-corebefore installing, so this assertion would fail on every PR and onmainas soon as a policyengine-core release containing #660 is published. policyengine-core publishes a release automatically when a PR merges tomaster, so merge this PR before #660.Nonebefore the edit. On core 3.36.0 the bracket already has no parent, so this changes nothing there. With Verify if HUD adjusted income can be negative #660 it keeps the case the test was written for: the edit clears no cache above the bracket, so the source tree's cached views stay stale, and the pin still has to read the parameter itself. The test's other assertions are unchanged: the next simulation'sny_eitcchanges, and a fresh clone of the pinned system gives the same result.change_small_tree, which described loaded brackets as having no parent, so they are true on both policyengine-core versions.uv.lockandpyproject.tomlare unchanged.Test plan
At commit
d9da18c, I ran onlypolicyengine_us/tests/test_pinned_tbs_sharing.py::test_an_edit_to_a_loaded_tree_reaches_the_next_simulation, selected by node ID, in two separate environments. It passed in both:uv.lock84e4d33e5d56da6b6425cbaadcb25185faf787cclink-parameter-parentsTo check that setting the parent to
Nonekeeps the stale-cache case, a separate script loadedCountryTaxBenefitSystem, read the 2021 EITC maximum for one qualifying child through the root tree's cached view (parameters("2021-01-01")), set the bracket's amount to 5,000, and read the view again:None(as loaded)None(set by the test)The other tests in this file were not run locally on either version.
make format(the sameruff format .andruff check .commands, run without syncing the environment)changelog.d/axiom: n/a: test-only change
🤖 Generated with Claude Code