Repository navigation
Floor Montana's joint-return medical and standard deductions on the return's Montana AGI, and on federal AGI from 2024 - #9903
Merged
Conversation
…eturn's Montana AGI The 2021-2023 Form 2 Itemized Deductions Schedule (line 1b) and Standard Deduction Worksheet (line 1) take Montana AGI from page 1, line 14. Single, head of household and joint returns report that line in one column, so a joint return pools both spouses' income before flooring at zero. Both joint-path variables instead summed each spouse's mt_agi_indiv, which floors each spouse at zero first, so a spouse's loss never offset the other's income. They now use mt_agi_joint. From 2024 mt_agi_indiv is switched off (Montana repealed filing separately on the same form), so the joint medical floor fell to zero and the full medical expense was deducted. From 2024 Form 2 line 2 takes federal itemized deductions (Worksheet A), so the variable now carries the federal medical expense deduction (7.5% of federal AGI). A new parameter, gov.states.mt.tax.income.deductions.itemized.state_specific_deduction_applies, marks the switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
Contributor
Author
|
Reopened by the US + core hub to start a fresh CI run at the same head. The previous run failed on |
Contributor
Author
|
US + core hub merge audit, us#9903 at
|
MaxGhenis
added a commit
that referenced
this pull request
Oct 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DTrim99
added a commit
to DTrim99/policyengine-us
that referenced
this pull request
Oct 12, 2026
… return mt_agi_joint pooled every tax unit member's Montana additions and subtractions, but a dependent's federal AGI is not on the filer's return (adjusted_gross_income_person is zero for dependents). A dependent's subtraction, such as unemployment compensation, therefore lowered the filer's Montana AGI and, since main's PolicyEngine#9903, the joint standard deduction. Pool additions and subtractions over the head and spouse only. The adult-dependent exemption case had pinned the leaked AGI of 47,000; under the law the filer's Montana AGI is 50,000 and the tax is 1,731.65. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Montana's joint-path medical expense deduction and standard deduction computed their AGI base as
add(tax_unit, ["mt_agi_indiv"]): the sum of each spouse's Montana AGI, each floored at zero. A joint return's Montana AGI is one figure that pools both spouses' income first, which PE already computes asmt_agi_jointand uses for taxable income. A spouse's loss was not fully reflected in those deductions: shared federal adjustments already reduced the old AGI base, but separately zero-clipped Montana AGIs still discarded part of the loss. In the medical example below, that partial effect produced $3,250 instead of the $2,500 without the loss; pooling the return's AGI correctly produces $4,000.Checking whether the medical variable is still used from 2024 found a larger problem. It is: every non-separate Montana return (single, head of household, joint) reaches it through
mt_itemized_deductions_joint, which feedsmt_taxable_income_jointin every year. From 2024, though,mt_agi_indivis switched off (defined_for = mt_married_filing_separately_on_same_return_eligible, false from 2024 after #6348 / 2a20d65). The floor therefore became 7.5% × 0, and every Montana itemizer deducted their full medical expenses. From 2024, Form 2 line 2 takes federal itemized deductions, so the variable now carries the federal medical expense deduction (7.5% of federal AGI).What the forms say
2021–2023 Form 2, Itemized Deductions Schedule (2022 Form 2, PDF p. 7; 2021 and 2023 are the same on p. 7):
Same page, Standard Deduction Worksheet:
Form 2 page 1 (same PDF, p. 1). Line 14 is "Montana Adjusted Gross Income. Add lines 11 and 12, then subtract line 13." Line 11 is federal AGI. The amounts go in Column A; Column B is headed "for spouse when filing separately using filing status 2a". So a joint return (status 4) has one line 14 for the couple, and line 11 is the joint federal AGI. Only status 2a gives each spouse their own line 14. The 2022 instructions (PDF p. 32, printed p. 26) send line 1 back to "the instructions for lines 1c and 2". The 2021 instructions (PDF p. 31) and 2023 instructions (PDF p. 36) say the same.
Statute. Former MCA § 15-30-2131(1)(a) (MCA 2021, mca.legmt.gov) allows "the items referred to in sections 161 … and 211 of the Internal Revenue Code", which brings in the § 213 medical deduction and its 7.5%-of-AGI floor. The statute does not say which AGI; the form uses Montana AGI from line 14. The old code comment cited (1)(g)(i), which covers insurance premiums, so it now cites (1)(a).
From 2024 (2024 instructions, PDF p. 15, printed p. 7). Form 2 line 1 is "Federal adjusted gross income from Form 1040, line 11". Line 2 is the "Federal standard deduction or adjusted federal itemized deductions". Worksheet A line 1 reads: "Enter your total federal itemized deductions from Form 1040, line 12". It then removes state income tax and takes the greater of that and the federal standard deduction. PDF p. 8 lists the Itemized Deductions Schedule and the Standard Deduction Worksheet as discontinued. So from 2024 the medical component is federal Schedule A's: 7.5% of federal AGI (2024 Schedule A, PDF p. 1, lines 1–4).
Changes
mt_medical_expense_deduction_joint:max(0, itemized_medical_expenses − 7.5% × mt_agi_joint).medical_expense_deduction(7.5% ×positive_agi).mt_standard_deduction_joint(2021–2023 branch): 20% ×mt_agi_joint, held between the existing minimum and maximum. Its 2024+ branch, the federal standard deduction, is unchanged.gov.states.mt.tax.income.deductions.itemized.state_specific_deduction_applies(true 2021, false 2024). It mirrors the existingdeductions.standard.state_specific_deduction_applies._indiv) are unchanged. On status 2a each spouse's column has its own line 14, which ismt_agi_indiv.Household effects (real runs on
mainb79705b and this branch)Script and outputs:
~/reviews/mt-medical-floor-2026-10-06/household_examples.py,household_base.json,household_pr.json.Hub microsimulation impact
Completed archival run from October 6, 2026, for tax year 2026, comparing former
mainb79705b with PR head 7fb88f0. Both usedhf://datasets/policyengine/populace-us/populace_us_2024.h5@populace-us-2024-spm-20260909. This is the prior run, not a comparison against today'smain; this review round changes tests and the description only.All 97 affected tax-unit records pay more; none pay less. The largest tax increase is $1,374.06. Person-level deduction and taxable-income variables are allocated to heads; their weighted affected-entity counts retain that entity label. Weighted tax change is recomputed as sum((PR − base) × weight), using identical saved weights and entity ordering; rounding the displayed totals can differ by one cent.
Evidence:
~/reviews/mt-medical-floor-2026-10-06/impact_2026.json, the completedimpact_queue.sh(which records the compared heads), and~/reviews/pe-us-merge-backlog-2026-10-02/impact/out/mtmedfl-{base,pr}.2026.{json,log}with the per-variable arrays. The output metadata records the year and pinned dataset; the head provenance comes from the queue script. This round recomputed the comparison from the saved arrays without launching a microsimulation. The hub can append a current-main comparison here if its landing gate requires one.Tests
mt_medical_expense_deduction_joint.yaml:mt_agi_jointas the input.maingives $3,250).mainpredicts failures in 5 of the 7 cases.mt_standard_deduction_joint.yaml: existing cases moved tomt_agi_joint. New negative-income spouse case: $8,000, wheremaingives $9,000.tests/unit/test_mt_joint_agi_deductions_properties.py: one vectorized grid simulation with 256 couples (with and without a dependent child) and 48 single filers, over 2021–2025, plus eight Hypothesis-generated batches over 2021–2026 with fixed witnesses for losses, dependent expenses, and senior subtractions. Static comparison with the formermainpredicts failures in 8 of the original 14 deterministic cases. The other 6 are premise checks and the single-filer agreement, which already held.mt/tax/income/integration.yaml,mt_income_tax*.yaml,mt_taxable_income_joint.yaml,mt_regular_income_tax_joint.yaml;mt_itemized_deductions_joint.yaml,mt_itemized_deductions_for_federal_itemization_joint.yaml;mt_standard_deduction_indiv.yaml,mt_medical_expense_deduction_indiv.yaml;states/tax/income/state_itemized_deductions.yaml,state_standard_deduction.yaml,irs/salt_refund_integration.yaml;test_parameter_files.pyand the reference-URL code-health tests.Invariants (asserted by the deterministic grid and generated checks)
mainviolates.Non-vacuity guards check, for each state-schedule year, that pooling changes the result somewhere on the grid. Hypothesis checks the same pooling, transfer, head-allocation, bounds and post-2024 federal-equivalence invariants; Medicare enrollment is disabled in the generated twins so expenses stay fixed when income is transferred. Generated cases include an older second adult; allocation is checked against the model's
is_tax_unit_headflag rather than input order, with exactly one head asserted per return.The new
joint_agi_deductions_integration.yamladds eight downstream cases: 2022 medical-floor selection below/at/above a controlled competing separate tax, the 2022 standard-loss example, and 2024 capital-gains threshold neighbors plus a medical itemizer. Both deduction aggregates, state deductions, selected filing treatment, taxable income, capital-gains tax and final tax are asserted. Hand arithmetic and source page anchors are recorded in comments; the separate-tax comparator is explicitly supplied to isolate the selection boundary.Current-round runtime verification, one file at a time: 30 passed — 7 medical YAML cases, 8 downstream integration cases, and 15 property tests (14 deterministic tests plus the Hypothesis test with eight batches across 2021–2026). A counterfactual replay on this checkout using the exact pre-PR medical and standard formulas from
b79705b4bdproduced 7 failures and 1 pass when restricted tomt_files_separatelyandmt_income_tax; all assertions in the eight integration cases pass with the PR formulas. The first generated run exposed a test-fixture input-order assumption about head selection; the fixture now checks the calculated head and retains the minimized older-second-adult witness. The full property file then passed with the prescribed command. Ruff format/lint andgit diff --checkpassed. A local description audit failed four checks on the original body and passes all five on this revision, including verbatim preservation of theaxiom:line. Logs, the failing replay, and the initial fixture failure remain untracked in the assigned workspace'shub-evidence/directory.Methodology
mt_agi_joint, as onmain; for the no-Social-Security cases here this ismax(0, signed Montana AGI). The alternative is to use signed Form 2 line 14 literally in the medical worksheet. With line 14 = −$20,000 and expenses = $10,000, that alternative yields $10,000 − 7.5% × (−$20,000) = $11,500; the retained convention yields $10,000 and limits the deduction to expenses paid. 2022 Form 2, PDF pp. 1 and 7 does not explicitly resolve a negative medical-floor base. This PR changes pooling of spouses' incomes, but does not change this convention relative tomain.maincomparison shown above. This review round adds coverage and documentation without changing model behavior.Tax precision in regression expectations: retain main's unrounded marginal-rate calculation. The alternative is the rounded offset in the 2022 Form 2 tax table, PDF p. 8: $603 rather than the model's $602.50. The tests document this inherited precision difference and do not change it relative to
main.Review round
Corrected the loss mechanism and distinguished Axiom's 2026 coverage from the queued 2024–2025 years. Recovered the completed 2026 population impact evidence and added downstream regressions plus Hypothesis checks to cover filing selection, federal-itemization aggregates, state deductions, capital-gains thresholds, and final Montana tax. Partner contract tests remain untouched. No model formulas, policy conventions, merges, or new microsimulation runs are included in this round.
Coordination
mt_itemized_deductions_joint, the federal-itemization aggregates, the care and casualty components andintegration.yaml. This PR touches none of those files.mt_medical_expense_deduction_jointby name, so the fix flows through unchanged.Out of scope (filed separately)
taxsim_state_agisumsmt_agi_indiv(gov.states.household.state_agis). For 2021–2023 that misses pooling on joint returns, and from 2024 it is 0.Axiom scope clarification: the federal module's encoded coverage starts in 2026 (
effective_from: 2026-01-01in 26/213). Federal years 2024–2025 and the historical Montana provisions remain queued in issue #1520. The hub'saxiom:line below is preserved verbatim; its “2024+” wording does not establish encoded coverage for 2024–2025.axiom: us/statute/26/213 encoded-correct for the 2024+ federal floor (
us/statutes/26/213.yaml, companion testtax_unit_medical_expense_deduction_after_section_21_exclusion; the Montana 2026 pipeline takes federal itemized deductions as inputmt_pit_2026_federal_itemized_deduction) | TheAxiomFoundation/rulespec-us#1520 queued for the 2021–2023 Montana schedule (former MCA § 15-30-2131(1)(a) medical floor and the Standard Deduction Worksheet on the return's Montana AGI)🤖 Generated with Claude Code