Repository navigation
Guard mapped thresholds and NaN values; correct contrib tax brackets - #9934
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>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Require the contrib threshold table and describe the corrected band tops. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Describe the positive-infinity exception for mapped thresholds. State that NaN compares unequal to itself. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Require thresholds for active nonfinal rates and flag dates with no active rates after a schedule starts. Cover a zero rate and thresholds that predate the first rate. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-written for Max, by Claude Code for Max Ghenis. Answered at 9172e6a: the conflicts with main in test_parameter_scale_thresholds.py and additional_tax_bracket_reform.yaml were resolved as a union in cc2a8bd; the body's Tests and Impact sections now hold the verified results; and the 2022 SINGLE threshold reads 539,900 (bracket.yaml:760 and :841). An independent review approved 2f090df with no P0 or P1 findings, and CI passed at this head.
|
Agent-written for Max, by Claude Code for Max Ghenis. Merge record for
|
Summary
We correct eleven dated values in two threshold series of the additional tax bracket contrib reform, and add tests that check mapped bracket thresholds and NaN parameter values.
For married separate filers, we end the reform's 33% band at half the joint upper threshold for 2026–2035, from $270,775 in 2026 to $323,625 in 2035. The earlier schedule gave separate filers the joint upper threshold for that band, which emptied the 35% band and ran the 33% band to $541,550 in 2026.
For single filers in 2022, we raise the top of the reform's 35% band from $539,000 to $539,900. With $539,900 or more of taxable income at ordinary rates, a single filer's tax at those rates falls by $18.
Sources
Invariants
float64NaNs included, at the top level and inside lists, tuples, dictionary keys and values, sets and frozen sets.The mapped-threshold test finds each table with a sibling
ratesnode and consecutively numbered threshold keys. It fails unless it finds the federal income and capital gains tables and the additional tax bracket contrib table, and it checks every table it finds. The clamp regression recreates the old separate-filer inversion and checks tax inside the affected band.Methodology choices
Tests
The five new YAML cases check tax at ordinary rates under the reform. We computed the earlier-threshold column by hand from main's thresholds and rates with the same bracket calculation, and the YAML cases assert the corrected column.
The lone-NaN regression fails when we remove its check. The active-rate regression fails when we restore the threshold-only scan, which misses both the fixture's finite 2026 top and its 2027 rate gap.
Removing the check for missing intermediate thresholds makes
test_income_bracket_top_guard_flags_missing_intermediate_thresholdfail.Removing the check for dates with no active rates after the schedule starts makes
test_income_bracket_top_guard_flags_later_inactive_schedulefail.Rejecting dates before the first active rate makes
test_income_bracket_top_guard_allows_thresholds_before_ratesfail.Using a truthiness test to select active rates makes
test_income_bracket_top_guard_flags_inactive_ratesfail.With main's contrib bracket table, the ordering test fails because the 2026 separate-filer thresholds fall from $541,550 at bracket 5 to $305,875 at bracket 6. The half-joint test rejects the same $541,550, since half the joint value comes to $270,775.
Removing the running-top clamp raises the recreated-inversion case's tax from $115,896.25 to $153,169.75 at $400,000 of taxable income. The mixed-status regression also fails, because the separate filer's tax at ordinary rates, $371,585.50, exceeds the baseline's $325,125.25.
We merged main at
8769cc75bc2efc7a3287834fc75a85c326343af6incc2a8bd42a.At the final head, on PolicyEngine Core 3.38.0, the four changed test files passed:
test_parameter_scale_thresholds.pytest_negative_main_rates_inverted_brackets.pytest_additional_tax_bracket_unset_bracket.pyadditional_tax_bracket_reform.yamlCI passed at
9172e6ab: Pull request run.Microsimulation impact
Only the additional tax bracket contrib reform reads the corrected schedule. The reform factory applies that reform when it finds
gov.contrib.additional_tax_bracket.in_effecttrue in the years it checks, and the parameter defaults to false. The Tests table gives the reform's tax for five households; we have not estimated the reform's aggregate effect.impact: none: only the default-off additional tax bracket contrib reform reads the corrected schedule
Axiom
axiom: n/a: test guards plus a contrib (hypothetical reform) parameter; no enacted-law provision changes.
🤖 Generated with Claude Code