Repository navigation
Conversation
…racket test_parameter_scale_thresholds only checked ParameterScale brackets, so federal-style schedules (a `thresholds` node mapping bracket numbers to a value per filing status, as gov.irs.income.bracket does) could repeat or invert a threshold unnoticed, and nothing checked parameter values for NaN, which YAML loads silently in scalars and inside list values. The new mapped-threshold guard found one live inversion: the additional_tax_bracket contrib reform's SEPARATE bracket-5 top for 2026-2035 copied the JOINT values (541,550 in 2026, above bracket 6's 305,875). #6235 fixed the same copy in gov.irs.income.bracket; the contrib file kept it. The values are now half the joint thresholds, as in every other bracket and year of the file and in #6235. Under the reform, a separate filer's income from 270,775 to 305,875 was taxed at 33% instead of 35% in 2026. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_shipped_additional_tax_bracket_reform_is_clamped relied on the shipped SEPARATE inversion, which the previous commit removed, so a zero-income filer owed nothing with or without the clamp. The test now recreates the old 541,550 bracket-5 top itself. The mapped-threshold guard now requires a `rates` sibling, the node tax_at_main_rates reads with `thresholds`, so a household-size table named `thresholds` cannot be swept in. New unit cases show it flags a repeated -inf and a NaN threshold, and the NaN test asserts it visited parameters. A second reform case covers the 39.6% band. The old data also taxed a separate filer's income from 305,875 to 541,550 at 33% instead of 39.6% (not only 270,775 to 305,875 at 33% instead of 35%, as the previous commit said): taxable income of 400,000 owed 115,896.25, not 122,810.50. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round-2 review: a zero-income filer owes nothing under any loop that is never negative per bracket, so the clamp test could not tell today's unclamped form from the clamped one, nor notice if the recreated inversion failed to apply. A separate filer with 400,000 of taxable income now must owe exactly 115,896.25 under the recreated inversion: 122,810.50 if the inversion did not apply, other figures if the loop did not clamp. (The previous commit's "owed nothing with or without the clamp" held only for the old clip form.) The table finder also skips an empty `thresholds` node, and the 2035 SEPARATE line loses a trailing space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Review: Guard federal-style bracket thresholds and NaN parameter values; fix the contrib MFS 33% bracketPR #9934 (author: MaxGhenis, head SummaryThe PR does three things:
The substance is right:
Two should-fix items remain:
Critical (must fix)None. Should address1. The branch conflicts with
2. The PR body still has placeholder sections and asks to be used as the squash commit body.
Suggestions
Verified correct
Axiom line assessmentValid. The line reads
CI statusAll 35 checks pass (
Branch status
Verdict: REQUEST_CHANGES |
DTrim99
left a comment
There was a problem hiding this comment.
The ten new MFS values match the CBO Jan 2025 Table 1 'Sixth rate begins' row and are exact halves of JOINT. The guard catches injected inversions and NaN, all expectations check by hand, and the axiom n/a is valid. Two should items (see the comment above): (1) the branch conflicts with main in test_parameter_scale_thresholds.py and additional_tax_bracket_reform.yaml; both are additive, and a union resolution passes locally, so main's newer parameters violate neither guard; (2) the PR body still has the queued 'Tests' and 'Impact' placeholders and asks to be the squash message, so fill in the verified results. Also worth fixing: the stale 2022 SINGLE 539,000 in the same contrib file (should be 539,900).
Keep the calendar-date checks and all contrib reform cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct the 2022 single threshold and cover a later reform year. Check half-joint thresholds in the contrib schedule, infinite top thresholds in ordinary income schedules, and NaN in nested containers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Correct two thresholds in the additional tax bracket contrib reform and add parameter guards that catch malformed rate schedules and NaN values.
For married separate filers, the reform now ends the 33% band at half the joint threshold in 2026–2035: $270,775 in 2026 and $323,625 in 2035. CBO published these values in its January 2025 TCJA-expiration projection. The reform previously copied the joint thresholds, which emptied the 35% band and extended the 33% band.
For single filers in 2022, the reform now ends the 35% band at $539,900 rather than $539,000, as IRS Table 3 specifies. The correction reduces tax by $18 when taxable income reaches $539,900.
Sources
Invariants
The mapped-table guard requires sibling rates and consecutively numbered brackets, and it asserts that both federal tables appear. The clamp regression recreates the old separate-filer inversion and checks tax within the affected band. The test module loads the US system through a fixture, allowing isolated guard tests to avoid constructing the parameter tree.
Methodology choices
Tests
Ruff formatting and lint checks pass. A static comparison matches 336 CBO cells covering four filing statuses, six finite bracket tops, and 2022–2035.
Independent source arithmetic confirms these YAML expectations:
Quick Feedback on this head passed all 52 distinct tests and cases in the four affected files:
test_parameter_scale_thresholds.pytest_negative_main_rates_inverted_brackets.pytest_additional_tax_bracket_unset_bracket.pyadditional_tax_bracket_reform.yamlThe same CI run passed the 65 additional required files changed on main, covering 1,140 tests. Across all 69 files, passing coverage totals 1,192 distinct tests and cases. The Rest run skipped one optional bundle check; the package job's complete 39-test metadata result covers it. These counts deduplicate each file.
CI tested the merge of this head with main on Ubuntu, Python 3.14 and Core 3.36.0. Local checks used Python 3.13.9 and Core 3.34.2. They passed 13 isolated guard tests, seven IRA differential tests and ten local sales-tax build tests.
Two earlier YAML attempts and a whole-file guard attempt hit 900-second limits during model setup. The local clamp attempt also reached its 1,800-second limit without reporting results. The whole-file guard attempt emitted a failure indicator in an unchanged calendar property, then timed out without a traceback. Two isolated guard runs and the full CI file passed; the local failure's cause remains unconfirmed. These attempts establish no dynamic fail-before result.
Microsimulation impact
To be measured before merge.
Axiom
axiom: n/a: test guards plus a contrib (hypothetical reform) parameter; no enacted-law provision changes.
🤖 Generated with Claude Code