Repository navigation
Conversation
… the forms - Federal income tax deduction (through 2023): attribute federal tax to the spouse who earned the income and cap each spouse at $5,000, instead of prorating the jointly capped amount by Montana AGI (2022 Form 2 instructions, Itemized Deductions Schedule, line 4). - Child and dependent care expense deduction (through 2023): phase out on the couple's combined Montana AGI and split the result equally only for spouses filing separately on the same form; a single filer and a joint return take the whole deduction (Form 2441-M lines 3-7). - Elderly homeowner/renter credit: count federal AGI without regard to losses (MCA 15-30-2337(9)(a); Form 2EC line 9). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions Each spouse filing separately on the same form deducts their own federal income tax up to $5,000, so both spouses itemize and Montana tax is 6,295.56. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…chedule - A married person filing on a separate form (federal filing status SEPARATE) cannot take the child and dependent care expense deduction: "married couples shall file a joint return or file separately on the same form" (MCA 15-30-2131(1)(c)(vi)(A)); 2022 instructions, line 14. - The 2023 credit schedule was the Elderly Homeowner/Renter Credit Schedule; it became Schedule 2EC in 2024. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ouse mt_misc_deductions is a Person variable whose `adds` list included the TaxUnit casualty_loss_deduction. policyengine-core evaluates `adds` with calculate(..., map_to=person), which projects a tax-unit value onto every member, so the joint path (summing over the tax unit) counted a couple's casualty loss once per member, and each spouse filing separately got the full amount. Replace it with two Montana variables following the 2021-2023 Form 2 instructions, Itemized Deductions Schedule line 15: complete federal Form 4684 using Montana AGI in place of federal AGI; spouses filing separately each complete their own Form 4684 (and a deduction attributable to one spouse is claimed by that spouse). - mt_casualty_loss_deduction_joint (TaxUnit): the unit's loss above 10% of mt_agi_joint, counted once. - mt_casualty_loss_deduction_indiv (Person): each spouse's own loss above 10% of their own mt_agi_indiv; dependents' losses go to the head, as mt_agi_indiv does with dependents' income. - casualty_loss/applies ends the line in 2024, when Montana discontinued its Itemized Deductions Schedule (2024 instructions, p. 8). With the child care deduction moved out of the misc list (stacked on fix-mt-separate-filing-allocations), the list held only the casualty loss, so the list parameter and mt_misc_deductions are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erties Montana's line 15 has filers complete federal Form 4684, whose line 11 reduces each casualty by $100 before the 10%-of-AGI floor (line 17). IRS Publication 547: a joint return is one individual for the $100 rule; spouses filing separately each reduce their own loss by $100. Add the federal amount as gov.irs.deductions.itemized.casualty.per_casualty_reduction (26 U.S.C. 165(h)(1)) and apply it once per joint return and once per spouse's column. The model has one loss amount per person, so each return's (or column's) losses are treated as one casualty, as the Arkansas casualty deduction already does. Add grid property tests: both variants match a closed-form Form 4684 reference; the joint return counts the unit's loss once whatever the number of members; separate filers deduct only their own loss; the deduction is non-negative, bounded, monotone; single-filer variants agree; and it ends in 2024. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions' into fix-mt-casualty-loss-misc-deduction
From the adversarial review of #9888 (law, code and test lenses, all approving): - A dependent's casualty loss belongs on the dependent's own return, as the dependent's income does (adjusted_gross_income_person, and so Montana AGI, leaves it out; Pub. 547: only the owner claims the loss). The joint path now sums non-dependents' losses (tax_unit_non_dep_add) and the separate path counts only the head's or spouse's own loss, instead of moving dependents' losses into the head's column while their income stayed out of it. - Say what the suspension flag models: PE has no input distinguishing federally declared disaster losses, so, like the federal deduction, no personal casualty loss is deductible from 2018 unless gov.irs.deductions.itemized.casualty.active is on. - Cite former MCA 15-30-2131(1)(a) (MCA 2021), which allowed the items of IRC 161 (including 165 losses), on the parameter and variables. - Describe the Form 4684 computation per lines 10-18 rather than as one form per return, and fix the separate-path test headers. - Add the 2008 $100 value to per_casualty_reduction (2008 and 2009 Form 4684 line 11), so it is defined before 2009. - Tests: natural-input dependent cases on both paths, and a 2024 case with filing status 2a allowed that exercises the separate path's applies gate (it fails if the gate is removed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gets the whole group amount) (#9897) * Guard against person variables that add group variables policyengine-core evaluates adds/subtracts with calculate(..., map_to=<the variable's entity>), and map_result projects a group value onto every member with no split. A person variable that lists a tax unit or SPM unit variable therefore gives each member the whole group amount, and a group total counts it once per member (MT casualty loss #9888, MS HSA #9865, WV senior #9856, and OH, IL, CA Riverside and LA cases found the same day). The new code-health test scans the shared baseline system, resolving parameter-path lists across their whole history. Three boolean enrollment flags are allowed; the 10 current cases are known bugs that may only be removed. A premise test pins the projection on core's template country. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Refresh group projection registry and scope boolean exemptions to reviewed edges --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ota itemized deductions (#10068) * Allow non-disaster casualty losses in California and Minnesota itemized deductions California and Minnesota read the federal casualty_loss_deduction, which is zero from 2018 under 26 U.S.C. 165(h)(5). Neither state follows that limit: Cal. Rev. & Tax. Code 17204(b) and Schedule CA (540) line 15; Minn. Stat. 290.0122, subd. 8, and Schedule M1CAT. Add ca_casualty_loss_deduction and mn_casualty_loss_deduction: the head's and spouse's loss, less $100, less 10% of federal adjusted gross income. Use them in place of the federal deduction in ca_itemized_deductions_pre_limitation, California's limitation exclusion list, mn_itemized_deductions, mn_amt_taxable_income (Schedule M1MT line 12) and the Walz HF1938 reform. The $100 comes from gov.irs.deductions.itemized.casualty.per_casualty_reduction, the same file #9888 adds, copied unchanged so the two merge cleanly in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Qualify the Minnesota casualty loss documentation for 2018 and 2020 Review r1: the 2018 Schedule M1CAT line 18 takes Schedule M1NC line 38 from filers of that schedule, and the 2020 Schedule M1SA takes a net qualified disaster loss from federal Form 4684 line 15 ($500, no 10% floor), deductible without itemizing. The model has neither input, so say so in the variable, the YAML header and the property test. No formula or expected value changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Say that the 2018 M1CAT sends its result to M1SA line 18 Review r2 (P3): the 2018 form has the same $100 reduction and 10% floor but a different destination line. Comment only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
PR Review: Count a Montana casualty loss once per joint return and only for the spouse who had itPR #9888 (author: MaxGhenis, head SummaryFor 2021–2023, Montana's Itemized Deductions Schedule line 15 allows a casualty and theft loss figured on federal Form 4684, with Montana AGI in place of federal AGI. Spouses filing separately on the same form each complete their own Form 4684. On The PR replaces that path with two variables:
Both leave dependents' losses out. Both are gated by a new The law and code are right. The stage-A source audit found no critical problems, and I re-checked the code independently.
The branch cannot merge yet. It is 189 commits behind
There is one should-address item and five optional suggestions. Critical (must fix)None. Should addressS1. Rebase onto
SuggestionsAll five are optional. 1. State the joint path's one-casualty convention in a
2. Baseline gives $0 for 2021–2023 even for federally declared disaster losses (documented deferral).
3. Optional readable YAML cases for edges that only the property test covers.
4. Source hygiene.
5. Itemized Deductions Schedule lines 16–18 have no hook once the misc list is gone (pre-existing, out of scope).
Verified correct
Axiom line assessmentThe PR body reads
CI status
Branch status
Verdict: REQUEST_CHANGES |
DTrim99
left a comment
There was a problem hiding this comment.
The law and code are right. The new joint/indiv casualty deductions apply Form 4684 with Montana AGI ($100, then the 10% floor), leave dependents out, cover 2021-2023 only, and replace the person-level projection. The tests pass and rulespec-us#1516 is dispatch-ready. One should item (see the comment above): the branch is 189 behind and conflicting in 17 files. Rebase only this PR's three commits, don't take the branch's side of #9877's files (that would silently revert spouse_allocation_rate), and fix the two non-textual CI breaks (main's KNOWN_VIOLATIONS entry and the mt_misc_deductions name in the mortgage-interest property test). Then update the PR body and #9912.
Stacked on #9877 (
fix-mt-separate-filing-allocations), which moves the child and dependent care deduction out of the same Montana miscellaneous deduction list. Until #9877 merges, this diff includes its commits; the changes reviewed here are the commits after6eefe271dc. Merge #9877 first.The bug
mt_misc_deductionsis a Person variable whoseaddsis the parameter listgov.states.mt.tax.income.deductions.itemized.misc_deductions. For 2021–2023 that list includedcasualty_loss_deduction, a TaxUnit variable.for_each_variablewould raise on a person-from-group aggregation, butaddsdoes not go through it. policyengine-core's_run_formulaevaluates eachaddsentry withcalculate(var, period, map_to=variable.entity.key), andmap_resulthandles group→person with nohowasentity_pop.project(values)(policyengine_core/simulations/simulation.py,_run_formulaandmap_result). So every member of the tax unit got the full unit casualty deduction:mt_itemized_deductions_jointandmt_itemized_deductions_for_federal_itemization_joint, whichaddmt_misc_deductionsover the tax unit) counted it once per member: twice for a couple, three times with one child;mt_itemized_deductions_indivand its federal-itemization twin) gave each spouse the full amount, whoever had the loss.Verified on main with a 2022 Montana couple: wages $60,000 and $40,000, and a $30,000
casualty_losson the head. The casualty deduction has to be switched on, becausegov.irs.deductions.itemized.casualty.activeisfalsefrom 2018:casualty_loss_deductionmt_misc_deductionsmt_itemized_deductions_joint(head)mt_itemized_deductions_indivcasualty.active: trueUnder current law the bug is latent, because the casualty deduction is suspended for every year the Montana line exists. It changes results under any reform that enables casualty losses for 2021–2023.
The rule
2022 Montana Form 2 instructions, Itemized Deductions Schedule, line 15 (PDF pp. 35–36). The 2021 (PDF p. 34) and 2023 (PDF p. 39) instructions say the same:
The same instructions, Filing Separately When Married (PDF p. 11): "Deductions that are attributable to only one spouse must be claimed by that spouse."
Form 4684 (2022) has line 11 ("Enter $100") subtracted from each loss on line 12, and line 17 takes 10% of adjusted gross income. IRS Publication 547 (2022, PDF p. 10) says: "If you and your spouse file a joint return, you are treated as one individual in applying the $100 rule … If you and your spouse have a casualty or theft loss and you file separate returns, each of you must reduce your loss by $100 … If one spouse owns the property, only that spouse can claim a loss deduction on a separate return." The 2024 instructions (PDF p. 8) list the Itemized Deductions Schedule under discontinued schedules.
The fix
mt_casualty_loss_deduction_joint(TaxUnit) figures the return's loss as on Form 4684, lines 10–18: (the spouses'casualty_loss− $100), less 10% ofmt_agi_joint, floored at 0. It is counted once.mt_casualty_loss_deduction_indiv(Person) figures each spouse's own: (own loss − $100), less 10% of their ownmt_agi_indiv.adjusted_gross_income_person, and so Montana AGI, leaves it out. Pub. 547 also allows only the owner to claim a loss.gov.irs.deductions.itemized.casualty.active, which the old path also used. Both are gated by the newgov.states.mt.tax.income.deductions.itemized.casualty_loss.applies(true 2021–2023, false from 2024), which replaces the misc list's2024-01-01: [].gov.irs.deductions.itemized.casualty.per_casualty_reduction, holds the $100 per-casualty reduction (26 U.S.C. § 165(h)(1); Form 4684 line 11: $100 in 2008, $500 in 2009, $100 from 2010).mt_misc_deductions. After Align Montana separate-filing deductions and the elderly credit's income with the forms #9877, the misc list held only the casualty loss, so the list parameter andmt_misc_deductionsare removed. A repo-wide grep finds no other references.Methodology notes
ar_casualty_loss_deduction_*already does the same.gov.irs.deductions.itemized.casualty.activeis switched on.casualty_loss_deductiondoes not apply the $100 reduction. That gap only touches 2010–2017, since the deduction is suspended from 2018. It is left for a separate PR; see the follow-ups below.Tests
New
casualty_loss/mt_casualty_loss_deduction_joint.yaml(9 cases) and…_indiv.yaml(5 cases) cover:appliesgate is removed, which I checked by deleting the gate.The headers quote line 15, Form 4684 and Pub. 547.
Six aggregator cases use natural inputs (wages plus
casualty_loss) in the two joint and two separate aggregator files. All six fail onmainwith the double count and pass here:mainThe joint cases appear in both
mt_itemized_deductions_jointand its federal-itemization twin, and the separate case in both_indivfiles. Themaincolumn showsmain's actual failing outputs, run onupstream/main4c900b6d3d.Existing aggregator tests that used
casualty_loss_deductionor a per-personmt_misc_deductionsas inputs now use the path-specific variable. The joint "Amount only distributed to the head" case puts its $100 at the tax unit, counted once, so it expects 2,012 where it expected 2,212.New
tests/unit/test_mt_casualty_loss_deduction_properties.pyis a grid property test in the style oftest_ar_misc_casualty_deduction_properties.py. The grid has 432 couples, with 0–2 dependents and dependent losses, plus 18 single filers: 1,314 people in 450 tax units, all in one simulation for 2021–2024. It checks these invariants for every grid input:mt_itemized_deductions_jointequals the unit deduction, whatever the member count, and only the head carries it;Local cost of the committed file, measured on macOS (not Linux CI): 10 tests in 9.5 s, 23.7 s wall. Peak RSS was 2.44 GB, against 13.1 s and 0.94 GB for a collect-only run of the same file. So the file adds about 11 s and about 1.5 GB at peak, mostly for one reform system and the 1,314-person simulation. It runs in the Rest
remaininggroup.All of these pass locally, run one file per process: the 6 touched or new MT itemized YAML files (36 cases), 15 more MT tax files (76 cases), the cross-state
state_itemized_deductions.yamlandstate_standard_deduction.yaml(31 cases), and the code-health checks (parameters.py,variable_names.py, the reference-URL checks, the builtin-sum and cached-array checks, andtest_rest_python_groups.py).Impact
No microsimulation was run, because baseline values cannot change. The new variables are multiplied by
gov.irs.deductions.itemized.casualty.active, which isfalsefrom 2018, and the Montana line exists only for 2021–2023. The removed path wascasualty_loss_deduction, which isp.active * …, so it was also 0 in every year it was listed. Reforms that enable casualty losses for 2021–2023 change, as described above.Follow-ups (out of scope, filed separately)
The federal
casualty_loss_deductiondoes not apply the § 165(h)(1) $100 per-casualty reduction (2010–2017 only, while the deduction is active), and it sums dependents' losses. New York's pre-TCJA copy also lacks the $100 reduction and is not gated byactive. Both are left for a follow-up PR.A repo-wide check of Person variables whose
addspull group-level variables (core projects each onto every member) found five more real double counts. Each reproduces on a household run, and each is left for its own PR:MS (
ms_agi_adjustments) and WV (wv_senior_citizen_disability_deduction_total_modifications) are already being fixed in other PRs. A code-health guard against new cases of this pattern is also planned.axiom: TheAxiomFoundation/rulespec-us#1516 queued (former MCA 15-30-2131(1)(a) via 2021–2023 Form 2 line 15 and 26 U.S.C. 165(h)(1), (2), (4)(B); blocked on ingesting the historical Montana statute and Form 2 instructions, as in #1512, and on Max's approval for signed runs)
Review:
9e7c5d162b. Its two minor findings and five nits are addressed ine352ed05bb: the dependent rule, the suspension wording, the MCA citation, the Form 4684 wording, the $100 history, the 2024 gate test and the grid size.review/standard) is pending; results will be posted here.🤖 Generated with Claude Code