Skip to content

Test Montana's joint-return deductions on the companion cases in rulespec-us#1520 - #10875

Open
MaxGhenis wants to merge 1 commit into
mainfrom
test-mt-joint-deduction-companion-cases
Open

MaxGhenis wants to merge 1 commit into
mainfrom
test-mt-joint-deduction-companion-cases

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Summary

#9903 (merged 2026-10-10) floors Montana's 2021–2023 joint-return medical deduction and standard deduction on the return's Montana AGI. TheAxiomFoundation/rulespec-us#1520 queues the matching Axiom encoding with seven companion cases. Four of those cases had no PolicyEngine test. This PR adds them to the variable-named YAML files, plus the 2026 case used by the rulespec-us § 213 companion. Tests only; no model change.

Case File Expected Source
#1520 case 3: joint return at the 2021 maximum (line 14 = 80,000) mt_standard_deduction_joint.yaml 9,660 2021 Form 2 p. 7, Standard Deduction Worksheet line 3
#1520 case 4: single return at the 2023 maximum (line 14 = 40,000) mt_standard_deduction_joint.yaml 5,540 2023 Form 2 p. 7, worksheet line 3
#1520 case 5: status 2a column with Montana AGI 60,000 and expenses 10,000 mt_medical_expense_deduction_indiv.yaml 5,500 2022 Form 2 p. 7, Itemized Deductions Schedule line 1
#1520 case 7: a dependent child's U.S. Treasury interest (TY2022; parents' wages 50,000, medical 10,000) both joint files medical 6,250; standard 10,000 2022 instructions p. 25: the subtraction applies to U.S. obligations' interest "if they are included in your Federal Adjusted Gross Income"
2026: expenses 11,000, federal AGI 100,000 mt_medical_expense_deduction_joint.yaml 3,500 Federal Schedule A through Form 2 line 2; the same case as us/statutes/26/213.test.yaml in rulespec-us

The dependent case guards the deductions against a leak found in an independent review of #9903 at 7fb88f0abf: there the child's subtraction lowered the parents' pooled Montana AGI, giving 7,000 and 8,000. Main has been right since #9585, which limits mt_agi_joint's Montana additions and subtractions to the head and spouse. mt_agi_joint.yaml tests that at the AGI level; these cases test it where it reaches the two deductions.

Tests

Local runs, one file at a time, in the foreground, on policyengine-core 3.34.2 (from uv.lock):

  • deductions/standard/mt_standard_deduction_joint.yaml: 12 passed (90 s including import, 2.5 GB peak)
  • deductions/itemized/mt_medical_expense_deduction_joint.yaml: 31 passed (70 s, 2.9 GB)
  • deductions/itemized/mt_medical_expense_deduction_indiv.yaml: 14 passed (121 s, 5.8 GB)

YAML cases only; no new Python tests, CI jobs or selectors.

axiom: n/a: tests only, no policy change; these cases are the PolicyEngine side of the companion tests in TheAxiomFoundation/rulespec-us#1520 (queued)

🤖 Generated with Claude Code

Adds YAML cases for the companion tests in TheAxiomFoundation/rulespec-us#1520
that had no PolicyEngine test after #9903 merged:

- a dependent child's U.S. Treasury interest stays off the parents' Montana AGI,
  for both the medical floor (6,250) and the standard deduction (10,000);
- the joint 2021 maximum (9,660) and the single 2023 maximum (5,540), from the
  Form 2 Standard Deduction Worksheet;
- a status 2a column on its own Montana AGI (5,500);
- the 2026 federal floor (3,500), the case in rulespec-us us/statutes/26/213.

Tests only; no model change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DTrim99

DTrim99 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Review: Test Montana's joint-return deductions on the companion cases in rulespec-us#1520

Summary

This PR (head 6788f20) adds tests only: six YAML cases in three variable-named files, plus a changelog fragment. It changes no variable, parameter or tool file.

All eight new assertions match my hand trace from the external sources:

  • the 2021–2023 Form 2, page 7 (Standard Deduction Worksheet and Itemized Deductions Schedule line 1) and page 1, line 14;
  • the 2022 Form 2 instructions on U.S. obligation interest;
  • 26 U.S.C. 213(a).

The two dependent cases pin the head-and-spouse mask that #9585 added to mt_agi_joint, where it reaches both deductions. CI is 38/38 green, and the merge with main is clean.

The problem is how the cases map to rulespec-us#1520. There are two should-address findings:

  1. The PR calls the dependent-interest case "Use a reform instead of a parameter to simulate taxsim's incorrectnesses #1520 case 7" and says the issue has seven companion cases. The issue body lists six. Its case 7, added in a comment, is a different case (status 2a equal division), and the issue has no dependent-interest row.
  2. Two Use a reform instead of a parameter to simulate taxsim's incorrectnesses #1520 expectations that the PR says it now covers are still missing on the PolicyEngine side: case 3's TY2021 medical deduction (4,000) and case 5's column B on a status 2a couple.

Basis: reading the code at the head, hand traces, the Montana PDFs (read directly), the rulespec-us issue and test file, and CI logs. I did not run Python locally.

Critical

None.

Should address

S1. The dependent-interest case is not a rulespec-us#1520 companion case, but the PR body numbers it as one.

S2. Two #1520 expectations that the PR says it covers are still missing.

The body says these cases "had no PolicyEngine test" and that "This PR adds them". Two are only half added.

  • Case 3 (TY2021 joint return; line 14 = 80,000; medical 10,000) expects a standard deduction of 9,660 and a medical deduction of 4,000. The PR adds only the standard half. No PolicyEngine case asserts the TY2021 joint medical deduction at that line 14. The 2021 cases in mt_medical_expense_deduction_joint.yaml supply mt_agi_joint of 1,000 and 0, and the long-term care case uses 40,000.
  • Case 5 (TY2022 status 2a) has column A with line 14 = 60,000 and medical 10,000, and column B with line 14 = 0 and no expenses. It expects A 5,500 and B 0.
    • The new case in mt_medical_expense_deduction_indiv.yaml (lines 324–334) has one unmarried person, so it has no spouse and no column B.
    • Its name, "Each spouse filing separately on the same form uses their own column's Montana AGI", describes something a one-person case cannot test: with one column, flooring on the column's AGI and on pooled AGI both give 5,500. The same holds for case 5's own numbers, since B's line 14 is 0. So the couple version is worth adding for the one-to-one match and the B = 0 assertion, not for discrimination.
    • Own-column flooring is already pinned by the existing case "Each spouse filing separately on the same form deducts their own premiums". There the head's floor on 20,000 leaves 500, where pooled AGI of 30,000 would leave 0.
  • Fix. Add case 3's medical half and replace the indiv case with case 5 as a couple. I have not run these locally.
# mt_medical_expense_deduction_joint.yaml
- name: Joint return in 2021 floors medical expenses on the return's Montana AGI
  period: 2021
  absolute_error_margin: 1
  input:
    people:
      person1:
        is_tax_unit_head: true
        other_medical_expenses: 10_000
      person2:
        is_tax_unit_spouse: true
    tax_units:
      tax_unit:
        members: [person1, person2]
        mt_agi_joint: 80_000
    households:
      household:
        members: [person1, person2]
        state_code: MT
  output:
    # 2021 Itemized Deductions Schedule line 1: 10,000 - 7.5% x 80,000 = 4,000.
    mt_medical_expense_deduction_joint: [4_000, 0]
# mt_medical_expense_deduction_indiv.yaml (replaces the one-person case)
- name: Status 2a return with column A above its floor and column B without expenses
  period: 2022
  absolute_error_margin: 0.01
  input:
    people:
      head:
        age: 40
        is_tax_unit_head: true
        other_medical_expenses: 10_000
        mt_agi_indiv: 60_000
      spouse:
        age: 40
        is_tax_unit_spouse: true
        mt_agi_indiv: 0
    tax_units:
      tax_unit:
        members: [head, spouse]
    households:
      household:
        members: [head, spouse]
        state_code: MT
  output:
    # Itemized Deductions Schedule line 1, each column on its own line 14.
    # A: 10,000 - 7.5% x 60,000 = 5,500. B: no expenses, 0.
    mt_medical_expense_deduction_indiv: [5_500, 0]

Suggestions

G1. The 2026 case's name claims more than the case tests (mt_medical_expense_deduction_joint.yaml, lines 789–807).

  • "In 2026 the federal floor applies to federal AGI": with age 40 and wages only, Montana AGI is also 100,000. A floor on mt_agi_joint would give the same 3,500, so the case cannot tell the two bases apart.
  • The 2024 case at lines 136–160 (age 70, medicare_enrolled: false, Montana AGI 94,500) already pins that distinction.
  • Rename the case (for example, "In 2026 the federal medical expense deduction carries through"), or reuse the 2024 case's age-70 setup so that Montana AGI differs from federal AGI.

G2. The dependent cases' comments rest on an unstated assumption (both files).

  • The comments say the child's interest "is on the child's own return". Cite the 2022 instructions (PDF p. 25: the U.S. obligations subtraction applies only to interest "included in your Federal Adjusted Gross Income on Form 2").
  • Also state the assumption that the parents made no federal Form 8814 election. With that election, the child's interest would be reported on the parents' return. The model does not take the election.

Verified correct

Scope

  • Four files: three YAML test files and a changelog fragment. No non-test file changed, so there is no code to review.
  • The tests are in variable-named files, and the periods are plain years.
  • Outputs are at the right entity: Person arrays for the _joint and _indiv deductions, and a TaxUnit scalar for mt_agi_joint.

Form values, read from the PDFs

Standard Deduction Worksheet (page 7), maximum on line 3 and minimum on line 5:

Year Single / separate: max, min Joint / head of household: max, min
2021 $4,830, $2,140 $9,660, $4,280
2022 $5,090, $2,260 $10,180, $4,520
2023 $5,540, $2,460 $11,080, $4,920
  • Itemized Deductions Schedule line 1 has the same text in all three years: 1a expenses; 1b "Enter the amount from page 1, line 14"; 1c × 7.5%; line 1 is 1a − 1c, "but not less than zero".
  • Page 1, line 14: "Montana Adjusted Gross Income. Add lines 11 and 12, then subtract line 13."

Hand checks (all eight assertions)

# Case Arithmetic Expected
1 Status 2a column, 2022 10,000 − 0.075 × 60,000 = 10,000 − 4,500 5,500 ✓
2 Dependent case, medical file: mt_agi_joint line 11 is 50,000 (the child's interest is off the parents' return: irs_gross_income zeroes a tax-unit dependent's income) + line 12 0 − line 13 0 50,000 ✓
3 Dependent case: medical 10,000 − 0.075 × 50,000 = 10,000 − 3,750; head only [6,250, 0, 0] ✓
4 2026 medical 11,000 − 0.075 × 100,000 (26 U.S.C. 213(a)); same as the rulespec-us § 213 companion, 12,000 − 1,000 = 11,000 → 3,500 3,500 ✓
5 Dependent case, standard file: mt_agi_joint as #2 50,000 ✓
6 Dependent case: standard 0.20 × 50,000 = 10,000, inside [4,520, 10,180]; head only [10,000, 0, 0] ✓
7 2021 joint 0.20 × 80,000 = 16,000 > 9,660 9,660 ✓
8 2023 single 0.20 × 40,000 = 8,000 > 5,540 5,540 ✓

Formula lines each case reaches (read at the head)

  • Dependent case, standard:
    1. mt_standard_deduction_joint.py L18 (pre-2024 branch) and L22.
    2. mt_agi_joint.py L15 (pooled per-person federal AGI), L23–25 (additions and subtractions limited to the head and spouse), L31, and L37–42 (Social Security adjustment, 0 here).
    3. Back in mt_standard_deduction_joint.py: L25–26 (20%, held between the minimum and maximum) and L33–34 (head only).
  • Dependent case, medical: mt_medical_expense_deduction_joint.py
    1. L22.
    2. L43–49: line 1a from itemized_medical_expenses, with no premiums.
    3. L52: mt_agi_joint, through the same chain.
    4. L53: the 7.5% floor.
    5. L56 and L62.
  • 2021 joint and 2023 single: mt_standard_deduction_joint.py L18, then L22 (mt_agi_joint supplied), then L23–26 with the cap binding, then L34. These cases do not exercise pooling. They pin cap[JOINT] for 2021 and cap[SINGLE] for 2023, neither of which had a case in this file before.
  • 2026: mt_medical_expense_deduction_joint.py L22 is false (the itemized state_specific_deduction_applies is false from 2024), so the case goes to L60 (federal medical_expense_deduction) and L62.
  • Status 2a column:
    1. mt_medical_expense_deduction_indiv.py L38.
    2. mt_medical_and_dental_expenses_indiv.py L52–61: own expenses of 10,000, no dependents.
    3. mt_separate_return.mt_medical_deduction L29 (floor on the column's mt_agi_indiv), L31–36 and L40.

What the dependent cases pin (by reading)

  • Dropping * on_return from mt_agi_joint.py L25 would put the child's us_govt_interest_person into line 13; it is on the 2021+ subtraction list.
  • That gives mt_agi_joint 40,000, a medical deduction of 7,000 and a standard deduction of 8,000, so all four dependent-case assertions would fail.
  • So these cases pin Fix AR, MT and NM income tax gaps found in TAXSIM comparison sweep #9585's mask where it reaches both deductions, as the body says. mt_agi_joint.yaml pins the same mask at the AGI level, with a dependent's unemployment compensation.

Other checks

  • Legal premise of the dependent case: the 2022 instructions (PDF p. 25) allow the U.S. obligations subtraction "if they are included in your Federal Adjusted Gross Income on Form 2". Interest on the child's own return is not in the parents' line 11, so the parents have nothing to subtract.
  • Changelog: a top-level changelog.d/*.changed.md fragment, which is a valid towncrier type.
  • Not applicable: no new state-gated key variable (the NH Add New Hampshire state supplementation for 2026 #10156 pattern does not apply), no partner tests, no conflict-sounding comments (the source-conflict ratchet is unaffected), and no Python tests.

Axiom line assessment

axiom: n/a: tests only, no policy change; these cases are the PolicyEngine side of the companion tests in TheAxiomFoundation/rulespec-us#1520 (queued)

CI status

  • gh pr checks 10875: 38/38 pass at 6788f20 (run 43438940054), with none pending.
  • Quick Feedback ran all three changed files. Each count is the file's existing cases plus the new ones:
File Passed
mt_medical_expense_deduction_indiv.yaml 14 (13 + 1)
mt_medical_expense_deduction_joint.yaml 31 (29 + 2)
mt_standard_deduction_joint.yaml 12 (9 + 3)

Branch status

  • The branch is 1 commit ahead of main and 25 behind (merge base 47c4e87).
  • git merge-tree --write-tree PolicyEngine/main 6788f202ba is clean.
  • Since the merge base, main has not changed:
    • the three test files;
    • the Montana deduction and AGI variables or the Montana parameters;
    • the federal AGI variables;
    • mt_separate_return.py.
  • The 25 commits on main touch ACA, Medicaid, SNAP, SSI, HUD rents and other states. There is no merged-tree risk.

Verdict: REQUEST_CHANGES

@DTrim99 DTrim99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: 0 critical, 2 should address, 2 suggestions (details in the report above). All eight new assertions match hand traces from the Montana forms. The two items are about the claimed correspondence with TheAxiomFoundation/rulespec-us#1520:

  • The description counts seven companion cases there and calls the dependent Treasury-interest case "#1520 case 7". The issue's table has six cases, its case 7 (in the 10/19 comment) is a status 2a equal-division case, and no dependent-interest row exists.
  • Two of #1520's cases aren't covered one to one: case 3's TY2021 medical half, and case 5's two-column status 2a return.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants