Skip to content

Expand Montana medical and standard deduction tests - #10875

Merged
MaxGhenis merged 2 commits into
mainfrom
test-mt-joint-deduction-companion-cases
Nov 30, 2026
Merged

MaxGhenis merged 2 commits into
mainfrom
test-mt-joint-deduction-companion-cases

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#9903 uses the return's Montana AGI for Montana's 2021–2023 standard deduction and medical expense floor. TheAxiomFoundation/rulespec-us#1520 lists six original companion cases. Its October 19 comment adds cases 7–10. This PR fills test gaps for cases 3–5 and adds case 7's agreed equal allocation. It also covers a PolicyEngine dependent Treasury-interest regression and uses net expenses from the separate federal § 213 companion in a 2026 Schedule A fixture.

Case File Expected Source
#1520 case 3: 2021 joint return with Montana AGI of $80,000 and medical expenses of $10,000 Both joint deduction files Standard $9,660 and medical $4,000 2021 Form 2, p. 7
#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: 2022 status 2a. Column A has Montana AGI of $60,000 and expenses of $10,000. Column B has zero AGI and expenses. mt_medical_expense_deduction_indiv.yaml A $5,500 and B $0 2022 Form 2, p. 7
#1520 case 7: 2022 status 2a with an agreed equal split of a dependent's $6,000 medical bill mt_medical_expense_deduction_indiv.yaml A $0 and B $2,000 Case 7, 2022 instructions, PDF p. 11
PolicyEngine regression: dependent Treasury interest on a 2022 joint return with no Form 8814 election Both joint deduction files Medical $6,250 and standard $10,000 2022 instructions, PDF p. 25
2026 Schedule A medical component with $11,000 net expenses, $100,000 federal AGI, and a supplied Montana AGI of $90,000 mt_medical_expense_deduction_joint.yaml $3,500 IRS Topic 502, RuleSpec § 213 net expense fixture

The Treasury-interest regression exercises the direct head-and-spouse adjustment from #9585 in a household with no Social Security benefits. The parents make no federal Form 8814 election. The child's interest adds $0 to their federal AGI and $0 to their Montana Treasury-interest subtraction. Both joint deduction fixtures assert the parents' $50,000 federal and Montana AGI.

Tests

Linux runs used Python 3.14.7 and policyengine-core 3.34.2 from the locked environment. Each YAML file ran in a separate process.

  • deductions/standard/mt_standard_deduction_joint.yaml — 12 passed in 87 s.
  • deductions/itemized/mt_medical_expense_deduction_joint.yaml — 32 passed in 94 s.
  • deductions/itemized/mt_medical_expense_deduction_indiv.yaml — 15 passed in 158 s.

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

An independent review of f4a833d1 approved the change (review record). CI passed at f4a833d1 (run 46333073644).

axiom: n/a: Test coverage only. The Montana companion coverage is for TheAxiomFoundation/rulespec-us#1520 cases 3–5 and 7. The 2026 fixture uses the net expense amount from the separate federal § 213 companion.

🤖 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.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
@MaxGhenis MaxGhenis changed the title Test Montana's joint-return deductions on the companion cases in rulespec-us#1520 Expand Montana medical and standard deduction tests Nov 30, 2026
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Agent-written for Max, by Claude Code for Max Ghenis.

Review record for f4a833d1fa814e308222325e5908c1a079e1cf65:

  • A Codex cloud task reviewed the changes since 6788f202 in a scoped round 2 (GPT-6.2 Sol at Extra High effort; chat https://chatgpt.com/local/6b0cd995-3964-83e9-a09d-686912cfb019). Its verdict is approve, with no P0 or P1 findings in this PR.
  • It found both requested changes and both suggestions from DTrim99's review closed. The description now matches rulespec-us#1520: the Treasury-interest case is labelled a PolicyEngine regression, and case 7 is the status 2a equal division. New cases cover case 3's 2021 medical half and both columns of case 5.
  • It ran the three changed YAML files in Linux, each in its own process: 57 cases passed before this commit, and 59 passed at this commit and on a merge with current main. Five intended mutations each failed their assertion.
  • It ran every changed test file. It could not reach the 2026 Montana Form 2 or the House U.S. Code § 213 page (HTTP 404); the 2026 case no longer cites a Montana form line.

@MaxGhenis
MaxGhenis dismissed DTrim99’s stale review November 30, 2026 04:13

Agent-written for Max, by Claude Code for Max Ghenis. Both requested changes are addressed at f4a833d: the description now matches rulespec-us#1520's cases, and new cases cover case 3's 2021 medical half and both columns of case 5. Review record: #10875 (comment)

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Agent-written for Max, by Claude Code for Max Ghenis.

Merge record for f4a833d1fa814e308222325e5908c1a079e1cf65:

  • Independent review: a Codex cloud task (GPT-6.2 Sol at Extra High effort) approved this commit with no P0 or P1 findings (review record).
  • DTrim99's requested changes are addressed at this commit, and that review is dismissed with a note.
  • The PR changes three Montana YAML test files and a changelog fragment. Main has not changed those files since this branch's base. The review ran them on a merge with current main (ee1b3e79): all 59 cases passed.
  • CI: run 46333073644 passed every check at this head.
  • The required approving review is the only open gate, so this merges with admin rights, pinned to this head.

@MaxGhenis
MaxGhenis merged commit ccb3e9e into main Nov 30, 2026
36 checks passed
@MaxGhenis
MaxGhenis deleted the test-mt-joint-deduction-companion-cases branch November 30, 2026 04:14
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