From 86bf03b397ad2f730d2301d9f7f249d3d5e36c63 Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Tue, 27 Oct 2026 11:12:07 -0400 Subject: [PATCH] Check Montana's pension exemption in the Montana AGI pooling invariant #10392 subtracts the 2021-2023 partial pension, annuity, and IRA income exemption in mt_agi_indiv and mt_agi_joint rather than through mt_subtractions, so a Hypothesis-drawn pensioner with no other Montana adjustment reported Montana AGI below federal AGI and failed the pooling property. Require both exemption amounts to be zero for that property and for the seeded grid's matching guard. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../fix-mt-agi-invariant-pension-exemption.fixed.md | 1 + .../tests/core/test_mt_state_agi_invariants.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fix-mt-agi-invariant-pension-exemption.fixed.md diff --git a/changelog.d/fix-mt-agi-invariant-pension-exemption.fixed.md b/changelog.d/fix-mt-agi-invariant-pension-exemption.fixed.md new file mode 100644 index 00000000000..ea4ffb12b37 --- /dev/null +++ b/changelog.d/fix-mt-agi-invariant-pension-exemption.fixed.md @@ -0,0 +1 @@ +Exclude filers with Montana's 2021–2023 partial pension, annuity, and IRA income exemption from the Montana AGI pooling test, which assumed only `mt_subtractions` reduce Montana AGI. diff --git a/policyengine_us/tests/core/test_mt_state_agi_invariants.py b/policyengine_us/tests/core/test_mt_state_agi_invariants.py index 330b4e02af5..707ff16a247 100644 --- a/policyengine_us/tests/core/test_mt_state_agi_invariants.py +++ b/policyengine_us/tests/core/test_mt_state_agi_invariants.py @@ -24,8 +24,11 @@ 2. Reporting: `taxsim_state_agi`, and its alias `state_agi`, equal `mt_agi` through 2023 and federal adjusted gross income from 2024. 3. Pooling: through 2023, a unit on the joint path with non-negative federal - AGI, no Montana additions or subtractions and no Social Security reports - federal AGI, so one spouse's loss offsets the other spouse's income. + AGI, no Montana additions or subtractions, no partial pension, annuity, and + IRA income exemption and no Social Security reports federal AGI, so one + spouse's loss offsets the other spouse's income. The exemption is outside + `mt_subtractions` (`mt_agi_indiv` and `mt_agi_joint` subtract it), so it is + checked separately. 4. Bounds: `mt_agi` is never negative, and a unit outside Montana has no `mt_agi`. @@ -72,11 +75,13 @@ "taxsim_state_agi", "state_agi", "adjusted_gross_income", + "mt_pension_exemption_joint", ) PERSON_OUTPUTS = ( "mt_agi_indiv", "mt_additions", "mt_subtractions", + "mt_pension_exemption_indiv", "social_security", ) @@ -196,6 +201,8 @@ def _check(units, year): unadjusted = ( (run["mt_additions"] == 0) & (run["mt_subtractions"] == 0) + & (run["mt_pension_exemption_indiv"] == 0) + & (run["mt_pension_exemption_joint"] == 0) & (run["social_security"] == 0) ) pooled = in_mt & ~separate & unadjusted & (run["adjusted_gross_income"] >= 0) @@ -231,6 +238,8 @@ def test_seeded_grid(year): & (run["adjusted_gross_income"] >= 0) & (run["mt_additions"] == 0) & (run["mt_subtractions"] == 0) + & (run["mt_pension_exemption_indiv"] == 0) + & (run["mt_pension_exemption_joint"] == 0) & (run["social_security"] == 0) ) assert (floored_sum[joint_path] > run["mt_agi"][joint_path] + 1).any()