Skip to content

Count a Montana casualty loss once per joint return and only for the spouse who had it - #9888

Open
MaxGhenis wants to merge 7 commits into
mainfrom
fix-mt-casualty-loss-misc-deduction
Open

MaxGhenis wants to merge 7 commits into
mainfrom
fix-mt-casualty-loss-misc-deduction

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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 after 6eefe271dc. Merge #9877 first.

The bug

mt_misc_deductions is a Person variable whose adds is the parameter list gov.states.mt.tax.income.deductions.itemized.misc_deductions. For 2021–2023 that list included casualty_loss_deduction, a TaxUnit variable. for_each_variable would raise on a person-from-group aggregation, but adds does not go through it. policyengine-core's _run_formula evaluates each adds entry with calculate(var, period, map_to=variable.entity.key), and map_result handles group→person with no how as entity_pop.project(values) (policyengine_core/simulations/simulation.py, _run_formula and map_result). So every member of the tax unit got the full unit casualty deduction:

  • the joint path (mt_itemized_deductions_joint and mt_itemized_deductions_for_federal_itemization_joint, which add mt_misc_deductions over the tax unit) counted it once per member: twice for a couple, three times with one child;
  • the separate path (mt_itemized_deductions_indiv and 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_loss on the head. The casualty deduction has to be switched on, because gov.irs.deductions.itemized.casualty.active is false from 2018:

casualty_loss_deduction mt_misc_deductions mt_itemized_deductions_joint (head) mt_itemized_deductions_indiv
baseline 0 [0, 0] 8,481 [5,000, 3,392]
casualty.active: true 20,000 [20,000, 20,000] 48,481 (casualty counted twice) [25,000, 23,392] (full amount to each spouse)
same, plus a child 20,000 [20,000, 20,000, 20,000] 66,481 (three times)

Under 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:

You may deduct a casualty and theft loss from a federally declared disaster (other than net qualified disaster losses). If you have a casualty and/or theft loss, complete federal Form 4684 to figure the amount of the Montana loss that you can enter on this line. To determine your casualty and/or theft loss, use your Montana Adjusted Gross Income in place of the Federal Adjusted Gross Income. If you and your spouse are filing separately, you each should complete a separate federal Form 4684 to determine the amount of your separate casualty and/or theft loss.

Deductions for all other casualty and theft losses are suspended until tax years beginning after December 31, 2025.

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% of mt_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 own mt_agi_indiv.
  • A dependent's loss is left to the dependent's own return on both paths, as the dependent's income already is: adjusted_gross_income_person, and so Montana AGI, leaves it out. Pub. 547 also allows only the owner to claim a loss.
  • Both are multiplied by the federal suspension flag gov.irs.deductions.itemized.casualty.active, which the old path also used. Both are gated by the new gov.states.mt.tax.income.deductions.itemized.casualty_loss.applies (true 2021–2023, false from 2024), which replaces the misc list's 2024-01-01: [].
  • A new federal parameter, 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).
  • Former MCA § 15-30-2131(1)(a) (MCA 2021), which allowed the items of IRC § 161 including § 165 losses, is cited on the new parameter and variables.
  • The four Montana itemized aggregators add the new path-specific variable where they added 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 and mt_misc_deductions are removed. A repo-wide grep finds no other references.

Methodology notes

  • PE records one loss amount per person, not separate casualty events. Each return's losses (joint) or each spouse's losses (separate) are treated as one casualty, so the $100 reduction applies once per return or once per spouse with a loss. ar_casualty_loss_deduction_* already does the same.
  • PE has no input that distinguishes federally declared disaster losses, which are the only losses line 15 allows. So, like the federal deduction, no personal casualty loss is deductible from 2018 unless gov.irs.deductions.itemized.casualty.active is switched on.
  • The federal casualty_loss_deduction does 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:

    • losses pooled once on a joint return;
    • the Montana AGI floor rather than federal AGI (Montana AGI $80,000 with federal AGI $100,000);
    • the boundaries at the floor ($10,100 → $0 and $10,101 → $1 on Montana AGI of $100,000);
    • a loss under $100;
    • each spouse's own loss and floor;
    • a working dependent's loss left off both paths (natural inputs, no AGI overrides);
    • the suspension;
    • the 2024 end on both paths. The 2024 separate-path case allows filing status 2a; it fails if the applies gate 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 on main with the double count and pass here:

    Case main This PR
    joint, couple [40,000, 0] [19,900, 0]
    joint, couple and child [60,000, 0, 0] [19,900, 0, 0]
    separate, couple [20,000, 20,000] [23,900, 0]

    The joint cases appear in both mt_itemized_deductions_joint and its federal-itemization twin, and the separate case in both _indiv files. The main column shows main's actual failing outputs, run on upstream/main 4c900b6d3d.

  • Existing aggregator tests that used casualty_loss_deduction or a per-person mt_misc_deductions as 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.py is a grid property test in the style of test_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:

    • both variants equal the closed-form Form 4684 reference, max(max(loss − 100, 0) − 10% × Montana AGI, 0);
    • joint: the per-unit sum of mt_itemized_deductions_joint equals the unit deduction, whatever the member count, and only the head carries it;
    • separate: each spouse's amount uses only their own loss and AGI, a spouse without a loss gets 0, and dependents get 0;
    • a dependent's loss changes neither path;
    • 0 ≤ deduction ≤ max(loss − 100, 0);
    • the deduction rises with the loss and falls with Montana AGI;
    • for single filers, the joint and separate variants agree;
    • 2024 gives 0.

    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 remaining group.

  • 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.yaml and state_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, and test_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 is false from 2018, and the Montana line exists only for 2021–2023. The removed path was casualty_loss_deduction, which is p.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_deduction does 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 by active. Both are left for a follow-up PR.

  • A repo-wide check of Person variables whose adds pull 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:

    • Ohio's insured medical deduction is counted once per member, so Ohio AGI is understated.
    • Illinois AABD/HBWD gives each member the unit's state withholding.
    • Riverside General Relief counts cash and vehicles once per member, and earners deduct each other's withholding.
    • LA General Relief counts TANF once per member.

    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:

  • An in-session adversarial review with three lenses (law and sources, code and entities, tests) approved head 9e7c5d162b. Its two minor findings and five nits are addressed in e352ed05bb: the dependent rule, the suspension wording, the MCA citation, the Form 4684 wording, the $100 history, the 2024 gate test and the grid size.
  • The independent Subfleet Opus review (review/standard) is pending; results will be posted here.

🤖 Generated with Claude Code

MaxGhenis and others added 6 commits October 6, 2026 07:08
… 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>
MaxGhenis added a commit that referenced this pull request Oct 10, 2026
… 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>
MaxGhenis added a commit that referenced this pull request Oct 11, 2026
…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>
@DTrim99

DTrim99 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

PR Review: Count a Montana casualty loss once per joint return and only for the spouse who had it

PR #9888 (author: MaxGhenis, head e352ed05bb). The PR's own changes are its three commits after 6eefe271dc, the round-1 head of #9877. The branch also carries #9877's pre-merge commits and a merge of #9877's branch; #9877 itself was squash-merged to main on 2026-10-12 as b686c9f0e3. #9912 is stacked on this PR and is reviewed separately.

Summary

For 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 main, mt_misc_deductions is a Person variable whose adds list held the TaxUnit variable casualty_loss_deduction. Core projected the unit amount onto every member. So the joint aggregators counted the loss once per member, and the separate aggregators gave each spouse the whole loss, whoever had it.

The PR replaces that path with two variables:

  • mt_casualty_loss_deduction_joint (TaxUnit): the spouses' losses less $100, above 10% of mt_agi_joint.
  • mt_casualty_loss_deduction_indiv (Person): each spouse's own loss less $100, above 10% of their own mt_agi_indiv.

Both leave dependents' losses out. Both are gated by a new casualty_loss.applies parameter (2021–2023) and by the federal casualty.active flag. The misc list and mt_misc_deductions are deleted, and the four Montana itemized aggregators add the path-specific variable instead.

The law and code are right. The stage-A source audit found no critical problems, and I re-checked the code independently.

  • All 36 YAML cases in the six touched files pass on the extracted head tree, and so do all 10 property tests.
  • Twelve expectations check by hand.
  • CI is 35/35 green.
  • The axiom issue is open, labelled pe-parity and dispatch-ready.
  • Under current law the PR changes no baseline value: casualty.active is false from 2018, and the Montana line exists only for 2021–2023. Results change only under reforms that enable casualty losses.

The branch cannot merge yet. It is 189 commits behind main, and GitHub reports it CONFLICTING. A rebase is more than mechanical (S1):

There is one should-address item and five optional suggestions.

Critical (must fix)

None.

Should address

S1. Rebase onto main by replaying only this PR's own commits, then clear main's three newer uses of the deleted mt_misc_deductions.

Suggestions

All five are optional.

1. State the joint path's one-casualty convention in a documentation string.

  • Where: mt_casualty_loss_deduction_joint.py:34-42. The separate path makes the same per-column choice at mt_casualty_loss_deduction_indiv.py:44-46.
  • Law: Pub. 547 (2022), PDF p. 10: "If you have more than one casualty or theft loss during your tax year, you must reduce each loss by $100." Its example has two storms with losses of $75 and $90, and "you aren't entitled to any deduction for these storms."
  • Effect (TY2022, active on): a couple with zero income, a head loss of $80 and a spouse loss of $90 from different storms.
    • The law gives $0.
    • The joint path gives $70 = 170 − 100.
    • The separate path gives [0, 0].
  • Why it is not blocking: PE has one casualty_loss per person and no casualty count. The code comments and the PR body say so, and AR, CA and MN on main use the same convention. A documentation string would surface it in the API metadata.

2. Baseline gives $0 for 2021–2023 even for federally declared disaster losses (documented deferral).

  • Law: line 15 allows "a casualty and theft loss from a federally declared disaster" (2022 Form 2 instructions, PDF p. 35). § 165(h)(5)(A) allows the same losses federally.
  • Model: both variables are multiplied by gov.irs.deductions.itemized.casualty.active, which is false from 2018. This keeps the prior behavior, because the removed path read casualty_loss_deduction, which is also p.active * …. It is documented in both formulas and the PR body.
  • Follow-up: a person-level federally declared disaster loss input would fix the federal deduction and every state that inherits § 165(h)(5).

3. Optional readable YAML cases for edges that only the property test covers.

Case Inputs Expected (head)
Only the spouse had a loss (2022) wages 90,000 / 20,000; spouse casualty_loss 12,000; active on mt_casualty_loss_deduction_indiv [0, 9,900] = 12,000 − 100 − 2,000; mt_casualty_loss_deduction_joint 900 = 12,000 − 100 − 11,000
A year other than 2022 (2023) the joint YAML's first case with period: 2023 19,900; and [23,900, 0] for the first indiv case
  • All casualty YAML cases run in 2022 or 2024. The property test covers 2021 and 2023, and covers spouse-only losses through its grid.
  • Stage A reproduced both rows on the head tree.

4. Source hygiene.

  • PR body: it says the 2021 (PDF p. 34) and 2023 (PDF p. 39) instructions "say the same" as 2022.
    • The 2023 text is identical.
    • The 2021 text reads "a casualty loss and theft from a federally declared disaster", and its suspension sentence ends "after December 31, 2026" (probably a typo for 2025).
    • rulespec-us#1516 already records this. It does not affect the model.
  • References (optional, when rebasing): the variables cite the 2022 instructions as separate entries per page: #page=35, #page=36 and #page=11 in _indiv (lines 16-19), and #page=35 and #page=36 in _joint (lines 14-15).

5. Itemized Deductions Schedule lines 16–18 have no hook once the misc list is gone (pre-existing, out of scope).

  • Line 16, political contributions: "limited to a total of $100 for yourself and $100 for your spouse".
  • Line 17, gambling losses: "allowed only to the extent of the amount of gambling winnings" (2023 instructions, PDF p. 39).
  • Line 18, other miscellaneous deductions.
  • PE already has a gambling_losses input. The PR did not cause the gap, and deleting the list is fine. File a follow-up issue if wanted.

Verified correct

  • Diagnosis and fix, reproduced by stage A (TY2022; wages $60,000 / $40,000; $30,000 loss on the head; active on).

    Parent 6eefe271dc Head
    Casualty amount per member mt_misc_deductions [20,000, 20,000] joint 19,900, counted once
    mt_itemized_deductions_joint (head) 48,481 (66,481 with a child) 28,381 = 8,481 + 19,900, with or without a child
    mt_itemized_deductions_indiv [25,000, 23,392.40] [28,900, 3,392.40]

    With active off, both paths give 0.

  • Law (stage A, quotes checked at the anchored pages):

    • Former MCA 15-30-2131(1)(a) (MCA 2021) allows "the items referred to in sections 161 … and 211 of the Internal Revenue Code", and is "Repealed effective January 1, 2024".
    • Form 2 line 15 is in the 2021 instructions at PDF p. 34, 2022 at pp. 35–36 and 2023 at p. 39.
    • 2022 PDF p. 11: "Deductions that are attributable to only one spouse must be claimed by that spouse."
    • 2024 PDF p. 8 lists the discontinued schedule.
    • Form 4684 lines 11-12 and 17-18, and § 165(h)(1), (2), (3)(B) and (4)(B).
    • Pub. 547 p. 10 states the joint "one individual" rule and the separate-return and owner rules.
  • Code patterns (every changed file):

    • Entities: TaxUnit _joint and Person _indiv, matching mt_medical_expense_deduction_joint/_indiv. Names follow the Montana _joint/_indiv convention.
    • defined_for: _indiv uses mt_married_filing_separately_on_same_return_eligible and _joint uses StateCode.MT, the same as their aggregators.
    • No hard-coded values: the $100 comes from per_casualty_reduction and the 10% from casualty.floor. REDUCTION/FLOOR appear only in the test's independent reference.
    • Vectorized: the formulas use max_ and role masks. if not p.casualty_loss.applies: return 0 gates on a period-level scalar parameter; 13 state formulas on main use the same early return.
    • The floor can't go negative: mt_agi_joint and mt_agi_indiv are both floored at 0 (max_(agi + additions - subtractions, 0)), so the 10% floor never increases the deduction.
    • Dependents: they are left out through tax_unit_non_dep_add (joint) and is_tax_unit_head_or_spouse (indiv). This is consistent with adjusted_gross_income_person and with CA/MN on main.
    • No dead code: there is no leftover reference to mt_misc_deductions or the misc list at the head.
  • Parameters:

    • casualty_loss/applies.yaml follows the boolean template ("…, if this is true."), with unit: bool, period: year, values true 2021 and false 2024, and five single-URL references that corroborate.
    • per_casualty_reduction.yaml (100 / 500 / 100 from 2008 / 2009 / 2010) is byte-identical to main's.
  • Callers at the head:

    • The two new variables feed only the four aggregators.
    • The aggregators feed mt_tax_unit_itemizes, mt_deductions_indiv, mt_taxable_income_joint, state_itemized_deductions and the MFS generator, and their interfaces are unchanged.
    • The federal casualty_loss_deduction, casualty_loss, casualty.floor and casualty.active are untouched.
    • The other casualty users (AL, AR, CA, DC, DE, HI, MN, NY) are unaffected. CA and MN read the same per_casualty_reduction.
  • Tests run on the extracted head tree, one file per process (local policyengine-core 3.26):

    • mt_casualty_loss_deduction_joint.yaml 9/9 and mt_casualty_loss_deduction_indiv.yaml 5/5;
    • the aggregator files: mt_itemized_deductions_joint 6/6, _indiv 5/5, …_for_federal_itemization_joint 6/6 and _indiv 5/5;
    • tests/unit/test_mt_casualty_loss_deduction_properties.py 10/10 in 90 s, of which 60 s is the module fixture (model load plus the 1,314-person simulation).
  • The property test works:

    • It uses a fixed grid with no randomness or hypothesis, so no derandomization is needed, and no importorskip is needed.
    • Each test guards against a vacuous pass (max() > 0).
    • The joint per-unit sum and the own-loss-only checks would fail on the old mt_misc_deductions projection.
    • It is collected by the Rest remaining group. The PR body reports cost measured on macOS, as main's CLAUDE.md asks.
  • Test hygiene: test periods are plain (2022, 2024). The PR adds two parameter-only override combos to the Montana tree (active, and active with 2a allowed). main's batcher weights those at 0.25 each against a 5.0 budget, so the tree goes from 1.0 to 1.5.

  • Hand checks (12):

    1. Joint: (30,000 − 100) − 10% × 100,000 = 19,900.
    2. Pooled: (35,000 − 100) − 10,000 = 24,900, one $100.
    3. Montana AGI floor: 29,900 − 8,000 = 21,900; a federal-AGI floor would give 19,900.
    4. At the floor: 10,100 − 100 − 10,000 = 0.
    5. One dollar over the floor: 10,101 → 1.
    6. Under $100: max(80 − 100, 0) = 0.
    7. Joint with a dependent: Montana AGI is 100,000 (the dependent's $5,000 wages are excluded), giving 19,900. Counting the dependent's loss would give 29,900.
    8. Indiv: [29,900 − 6,000, 0] = [23,900, 0].
    9. Indiv, both spouses: [23,900, 4,900 − 4,000] = [23,900, 900].
    10. Indiv with a dependent: [23,900, 0, 0]. The dependent's own column would otherwise be 9,900.
    11. "Amount only distributed to the head": 100 interest + 100 casualty + 412 medical + 800 SALT + 600 federal tax = 2,012. The old 2,212 counted the misc 100 three times.
    12. Natural-input aggregator cases: joint [19,900, 0] and [19,900, 0, 0]; indiv [23,900, 0]. Montana AGI is computed from wages. The PR body shows main at [40,000, 0], [60,000, 0, 0] and [20,000, 20,000].
  • Changelog: changelog.d/fix-mt-casualty-loss-misc-deduction.fixed.md is a top-level file of type fixed, and its sentence matches the change.

  • Partner tests: nothing under tests/policy/baseline/partners/** is touched, and no partner file sets casualty_loss or mt_misc_deductions. Household API Partners passed.

Axiom line assessment

The PR body reads 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 …). The line is valid.

CI status

Branch status

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.

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.

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