Skip to content

Count Montana casualty losses once per return and only for the spouses who had them, less $100 and 10% of Montana AGI - #9888

Merged
MaxGhenis merged 17 commits into
mainfrom
fix-mt-casualty-loss-misc-deduction
Nov 15, 2026
Merged

MaxGhenis merged 17 commits into
mainfrom
fix-mt-casualty-loss-misc-deduction

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Count Montana casualty and theft losses once per return and assign each separate deduction to the spouse who had the loss. The previous person-level miscellaneous deduction projected the federal tax-unit amount onto every member.

Add mt_casualty_loss_deduction_joint and mt_casualty_loss_deduction_indiv, using Montana AGI for the deduction floor. Add them directly to the joint, separate and federal-itemization aggregators, including mt_non_medical_itemized_deductions_indiv.

Retain mt_misc_deductions and its parameter list for the claim-of-right repayment and wagering loss deductions added on main. Remove only casualty_loss_deduction from that list, and reuse the federal per_casualty_reduction parameter already on main.

Sources

Montana taxpayers calculated Itemized Deductions Schedule line 15 with federal Form 4684, substituting Montana AGI for federal AGI. Spouses filing separately each calculated their own loss. See the 2022 Form 2 instructions, PDF pages 11 and 35–36.

For the modeled personal-use losses, taxpayers subtract $100 before applying the 10% AGI floor. Joint filers apply the reduction together; separate filers apply it to their own losses. See Form 4684, lines 11–12 and 17–18 and Publication 547, PDF page 10.

Montana taxpayers also used Form 4684 with Montana AGI for Schedule III line 20 in 2015, 2016 and 2017. Taxpayers applied the same reduction and floor to ordinary losses on the 2015 Form 4684.

Montana allowed these itemized deductions under former MCA 15-30-2131(1)(a). The Legislature repealed that section effective January 1, 2024, and the Montana Department of Revenue discontinued the schedule in its 2024 instructions, PDF page 8.

Invariants and tests

  • Joint filers count the head's and spouse's losses once, regardless of the number of dependents.
  • Separate filers use only their own loss and Montana AGI; dependents receive no deduction on their parents' return.
  • Each deduction equals max(max(loss - 100, 0) - 0.1 * Montana AGI, 0) when enabled.
  • Deductions remain nonnegative, rise with losses and fall with Montana AGI.
  • Both variables return zero when the federal casualty flag disables the deduction and from 2024 onward.

YAML cases cover aggregation, ownership, Montana AGI, deduction boundaries, dependents, the suspension and the 2024 transition. Additional cases cover a spouse-only loss, 2023 and baseline deductions in 2015 and 2017. Two 2017 aggregator cases compute Montana AGI from wages with no reform, one on a joint return and one for spouses filing separately. Sixteen property cases check the formula, allocation, bounds and monotonicity across filing paths and the 2024 ending. The claim-of-right fixture supplies the Montana casualty component separately and retains its combined itemized deduction.

Local formatting and lint passed.

Pull request run 43740959422 at e8c529843b passed all 37 jobs on GitHub's merge with main f28e759188.

On Linux CI, a selective job ran the property file in 33.17 seconds within pytest, including 17.08 seconds of fixture setup, and took 69.46 seconds from command start to summary. A local macOS run took 39.72 seconds within pytest and peaked at 3.0 GB of memory. It ran e425a8e737 with casualty_loss_deduction restored to the miscellaneous list, whose total the file's fixture sets to zero. This PR adds the file, so no earlier timing exists. CI runs the property file in the existing Rest Python shards.

Methodology choices

Treat recorded losses as one casualty per joint return or one casualty per spouse filing separately. The casualty_loss input does not distinguish events; taxpayers must apply a separate reduction to each event under Publication 547.

Keep the existing federal casualty flag. The model lacks an input identifying federally declared disaster losses, so baseline deductions remain zero in 2018–2023 even for the disaster losses Montana allowed. From its 2018 instructions, PDF page 29 through 2023, the department allowed only losses from a federally declared disaster on line 15. Reforms that enable the flag exercise the corrected calculation.

Date Montana's casualty applies parameter from 2015. In its 2015, 2016 and 2017 Form 2 instructions, the department told taxpayers to figure casualty and theft losses on Form 4684 with Montana AGI. The model keeps the federal casualty flag true through 2017, so the new variables change 2015–2017 baseline values for returns with casualty losses. Besides counting each loss once, they subtract $100 before the floor, apply the floor to Montana AGI in place of federal positive AGI, and leave dependents' losses out. The model lacks inputs for qualified disaster exceptions and casualty gain netting.

Microsimulation impact

This PR changes baseline results for tax years 2015 to 2017 only. The default dataset's records start in 2024, so no population estimate exists for those years.

Both new variables multiply by the federal casualty flag (joint, separate). So does the federal deduction that main adds through the miscellaneous list (casualty_loss_deduction.py, line 16). The flag reads true through 2017 and false from 2018, so values move only in 2015 to 2017 or under a reform that turns it on.

In 2018 to 2023, the baseline casualty amount stays $0 on main and on this branch. From 2024, both give $0 whatever the flag reads. This branch returns 0 once applies turns false, and the miscellaneous list holds nothing from 2024 on main as here.

impact: baseline results change for tax years 2015 to 2017 only, on Montana returns with casualty losses; the default dataset starts in 2024, so no estimate exists, and later years stay unchanged without a reform

axiom: TheAxiomFoundation/rulespec-us#2259 queued (former MCA 15-30-2131(1)(a) through 2015–2017 Schedule III line 20; the corpus lacks those Form 2 instructions, so the signed encoder can't run yet); TheAxiomFoundation/rulespec-us#1516 queued, extended with a comment (2018–2023 line 15)

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

MaxGhenis pushed a commit that referenced this pull request Nov 3, 2026
The comment this branch added is the file's only change, and open PR
#9888 deletes the file, so the comment would only cause a modify/delete
conflict there. The variables' own comments already say the federal
itemized total replaces the schedule from 2024.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwQq6GED1QuDGy4RPfx6fD
MaxGhenis and others added 7 commits November 13, 2026 09:51
Preserve current spouse allocations, medical deductions and claim-of-right repayments while adding the Montana casualty components.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expose the one-casualty convention in variable metadata, consolidate source references and cover spouse-only losses and 2023. Isolate the casualty property grid from other miscellaneous deductions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add sources and baseline cases for 2015 and 2017 to cover the model's parameter backdating. Extend the property grid across those years and document ordinary-loss limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert the state casualty component separately while retaining the
combined itemized deduction and the miscellaneous expense floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve misc_deductions.yaml: keep main's 2017 start date and 2017
references, and keep casualty_loss_deduction out of the list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…turns

Both cases compute Montana AGI from wages and need no reform, because the
federal casualty flag stays true through 2017. They fail if
casualty_loss_deduction returns to Montana's miscellaneous deductions list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…puts

Date the casualty `applies` parameter from 2015, the first year its
references cover. State in both formulas that the 2021-2023 instructions
limit line 15 to federally declared disaster losses. Remove two
casualty_loss_deduction test inputs that no Montana formula reads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Count a Montana casualty loss once per joint return and only for the spouse who had it Count Montana casualty losses once per return and only for the spouses who had them, less $100 and 10% of Montana AGI Nov 14, 2026
MaxGhenis and others added 2 commits November 14, 2026 15:58
Montana's Department of Revenue limits Form 2 line 15 to losses from
federally declared disasters in its instructions for every year from 2018
to 2023. Line 15 sits on PDF page 29 in 2018, 34 in 2019, 31 in 2020, 34
in 2021, 35 in 2022 and 39 in 2023. Its 2017 instructions set no such
limit. We now date the limit from 2018 in both casualty variables'
comments.

We also point the MCA 15-30-2131 references in the miscellaneous
deduction list and the four itemized deduction totals to the
Legislature's MCA 2021 page in place of law.justia.com. Two 2023 case
names now lower-case the word after "In 2023,". No values change.

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

Both Montana casualty loss variables' comments now state the 2018 to 2023
disaster-only limit in one sentence. A second sentence names the Department
of Revenue and the Form 2 instruction pages that state the limit at line 15.
The earlier single sentence ran 39 words. No values change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolve misc_deductions.yaml: keep the wagering losses entry main added
and the claim-of-right entry, and keep casualty_loss_deduction out of
the list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

David, here's where each item of your review stands at e8c529843b:

  • S1, the rebase: I merged main three times, in 6aad4a1d7f, 1e25dfdb9a and e8c529843b, and replayed no commit. CI passed on the last merge. Against main, each of the four aggregators gains its casualty line and a statute link and loses nothing from Align Montana separate-filing deductions and the elderly credit's income with the forms #9877. spouse_allocation_rate still splits the charitable deduction (federal itemization, non-medical), and Case 29 and mt_childcare_itemization_boundary.yaml stay as main has them.
  • S1, the KNOWN_VIOLATIONS entry: 6aad4a1d7f deleted it, and the set now stands empty (line 113).
  • S1, ZERO_PERSON_COMPONENTS and the mt_misc_deductions: 0 inputs: both stay valid. Main added the claim-of-right and wagering loss deductions to the miscellaneous list after your review, so the branch keeps mt_misc_deductions and removes casualty_loss_deduction alone from its list (lines 7-11). Main's mortgage tests still set a real variable (line 54).
  • S1, the description: it names no stack, says per_casualty_reduction already sits on main and carries no pending-review line.
  • S1, Fix casualty loss reductions and dependent allocation #9912: it stays open at ea42a82b02 with older copies of these Montana files, and I haven't updated it. It needs main merged once this lands.
  • Suggestion 1: 4945231b15 added a documentation string for the one-casualty convention to each variable (joint, lines 10-15; separate, lines 12-17).
  • Suggestion 2: the deferral stands, and both variables keep the federal flag. f631d4422a and c58defdd08 correct the span in both comments to 2018 through 2023, with the PDF page of each year's instructions (joint, lines 38-44; separate, lines 41-47).
  • Suggestion 3: 4945231b15 added both rows on each path. The spouse-only loss gives $900 on the joint return (lines 224-244) and $0 and $9,900 separately (lines 159-179). The 2023 cases give $19,900 (lines 201-221) and $23,900 and $0 (lines 135-156).
  • Suggestion 4: the description no longer says the 2021 and 2023 instructions match the 2022 text. Since 4945231b15, each variable cites one entry for each document, with its PDF pages in a comment (joint, lines 16-28; separate, lines 18-30).
  • Suggestion 5: the miscellaneous list stays, so lines 16 to 18 keep their hook.
  • Your hand check 11: mt_misc_deductions stays a person input, so that case keeps main's $2,212 (lines 46-76).

One line of your summary no longer holds at this head: that the PR changes no baseline value. applies now starts in 2015 (lines 27-28), on Schedule III line 20 of the 2015 to 2017 instructions, and the federal casualty flag holds true through 2017. So the PR changes 2015 to 2017 baseline values for returns with casualty losses. 99560b7d97 added cases for 2015 and 2017 on each path (joint, lines 252-292; separate, lines 187-229).

Three independent AI reviews followed yours, and the second approved e425a8e737. The two commits since then change comments, two test names and five statute links, and a merge of main follows them. The third review approved that merge at e8c529843b.

🤖 Generated with Claude Code

@MaxGhenis
MaxGhenis dismissed DTrim99’s stale review November 15, 2026 19:21

The commits since this review answer each of its items except #9912, which needs main merged once this lands. My reply above maps each item to its commit, file and line.

@MaxGhenis
MaxGhenis merged commit bdaf14f into main Nov 15, 2026
108 of 117 checks passed
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

US + core hub merge audit, us#9888 at e8c529843b09fffdde334fe8da22f9d3facd2846 (squash): Count Montana casualty losses once per return and only for the spouses who had them, less $100 and 10% of Montana AGI.

  • Reviews:
    • DTrim99 requested changes on October 12 at e352ed05bb. They found the law and the code right and asked to see the branch pass CI on main first. Their one should-address item asked for a rebase that keeps main's side of Align Montana separate-filing deductions and the elderly credit's income with the forms #9877's files and clears a ratchet entry and a test input that no conflict marks. Five optional suggestions followed.
    • Merges of main at 6aad4a1d7f, 1e25dfdb9a and e8c529843b answer that item. The branch now keeps mt_misc_deductions for the claim-of-right repayment and wagering loss deductions, so main's mortgage tests still set it, and the first merge cleared the ratchet entry. 4945231b15 added documentation strings for the one-casualty convention, a spouse-only case and a 2023 case on each path, and one reference per source document.
    • Three independent review rounds ran outside GitHub, and a fix round followed each of the first two.
    • The first round, at c527ba3c13, read the Montana instructions for 2015, 2017 and 2021 to 2024, former MCA 15-30-2131, 26 U.S.C. 165(h), Form 4684 and Publication 547. It computed four households and 11 YAML expectations by hand and ran no test. It found no error in the rules. It found a conflict with main in misc_deductions.yaml and an empty impact section, and it listed five minor items.
    • The fix round merged main and kept main's list minus the casualty_loss_deduction line. It added two 2017 cases that compute Montana AGI from wages, one on a joint return and one for spouses filing separately, dated applies from 2015 and removed two unread test inputs. With the list entry restored, three joint aggregator cases failed at $59,900 or $79,900 against $19,900, and so did the ratchet. With applies false before 2021, the 2015 and 2017 joint cases failed.
    • The second round approved e425a8e737 with no blocking finding. It checked that the merge differs from an automatic one in misc_deductions.yaml alone, recomputed both 2017 cases and their values under a revert, and matched CI's pass counts to each file's case count. It confirmed in the code that baseline values move in 2015 to 2017 alone. It also read the 2018 and 2020 instructions and found that Montana's disaster-only rule dates from 2018, where the comments said 2021.
    • The next two commits, f631d4422a and c58defdd08, correct that span in both comments with a PDF page for each year, lower-case two test names and point five statute references to the Legislature's site. git diff e425a8e737 c58defdd08 changes no value, formula or expectation.
    • Count gambling winnings in federal gross income and fix the wagering losses deduction #10070 then added mt_wagering_losses_deduction to main's miscellaneous list, under the entry this PR deletes, and the branch conflicted with main there. The third merge, e8c529843b, takes main at a29c73d587 and keeps main's list minus the casualty_loss_deduction entry.
    • The third round approved e8c529843b with no blocking finding. It found that misc_deductions.yaml and mt_claim_of_right_deduction.yaml alone differ from both parents and that the merge moves no expected value. It recomputed three claim-of-right cases and three joint aggregator cases by hand in the merged tree and matched CI's pass counts to each changed file's case count. Its one minor finding asked the description to name the wagering entry and link the new CI run.
    • I corrected the description before merge. It now names both deductions the miscellaneous list keeps and gives the disaster-only span as 2018 to 2023. It also states why a current-year microsimulation can't show this change, cites the 2016 instructions and reports a local time and peak memory for the property file.
    • I dismissed DTrim99's change request with a reply that maps each item to its commit and file.
  • Methodology choices for maintainers:
    • The model treats a joint return's losses as one casualty, and each separately filing spouse's loss as one casualty, because casualty_loss holds one amount for each person and no count of events. Under Publication 547, a taxpayer subtracts $100 from each casualty. A couple with no income and losses of $80 and $90 from two storms deducts $0 under that rule and $70 on the model's joint return.
    • Both variables keep the federal casualty flag, since the model has no input for federally declared disaster losses. Baseline deductions stay $0 in 2018 to 2023 even for the disaster losses Montana allowed on line 15. An input for those losses could replace the flag in both Montana variables.
    • applies starts in 2015, on the strength of Schedule III line 20 in the 2015, 2016 and 2017 instructions. The federal flag holds true through 2017, so the new variables change 2015 to 2017 baseline values for returns with casualty losses.
    • The 10% floor uses Montana AGI: the return's on a joint return and each spouse's own when they file separately. Main's federal amount used federal positive AGI.
    • Both paths leave a dependent's loss out, as Montana AGI leaves out the dependent's income. The model computes no return of the dependent's own inside the parents' tax unit, so that loss produces no Montana deduction.
    • The model has no input for casualty gains or for the qualified disaster loss rules, and the variables apply neither.
  • Gates checked live at merge:
  • Impact: the PR changes baseline results for tax years 2015 to 2017 alone, on Montana returns with casualty losses. The default dataset's records start in 2024, so no population estimate exists for those years. Both new variables and main's federal amount multiply by the federal casualty flag, which reads false from 2018. From 2024, applies reads false and main's miscellaneous list holds nothing. For example, a couple with wages of $60,000 and $40,000 and a $30,000 loss deducts $19,900 on a 2017 joint return: (30,000 − 100) − 10% × 100,000.
  • Next:
    • Fix casualty loss reductions and dependent allocation #9912, open at ea42a82b02, carries older copies of this PR's Montana files beside its federal, Alabama, Hawaii and New York casualty fixes. After this squash it should merge main and take main's version of each Montana file this PR changes.
    • The federal casualty_loss_deduction still counts dependents' losses, uses federal positive AGI and subtracts no $100. California, DC, Delaware, Minnesota, Virginia and Wisconsin read it, and Fix casualty loss reductions and dependent allocation #9912 carries the fix.
    • Eight law.justia.com links for MCA 15-30-2131 remain in Montana files this PR leaves alone: federal_income_tax/cap.yaml, the four mt_federal_income_tax_deduction variables, mt_itemized_deductions_indiv.py, mt_misc_deductions.py and mt_salt_deduction.py. An issue can point them to the Legislature's MCA 2021 page.
    • The 2017 claim-of-right case sets mt_casualty_loss_deduction_joint: 400 at line 165 of its YAML file and asserts the same value at line 173. A follow-up can drop the output line, since the $12,900 total already checks the sum.
    • A person-level input for federally declared disaster losses would let the federal deduction and Montana's 2018 to 2023 line 15 apply at baseline.
    • No one has run mt_itemized_deductions_indiv.yaml with casualty_loss_deduction restored to the list. By hand, each of its two natural-input cases would give $43,900 for the head and $20,000 for the spouse, against $23,900 and $0.
  • Axiom: Encode Montana's 2015–2017 casualty and theft loss deduction: Schedule III line 20 on Form 4684 with Montana AGI (former MCA 15-30-2131(1)(a); 26 U.S.C. 165(h)) (PE-US #9888) TheAxiomFoundation/rulespec-us#2259 queued, a new pe-parity issue for 2015 to 2017 Schedule III line 20 under former MCA 15-30-2131(1)(a) and 26 U.S.C. 165(h), with six companion rows from this PR's YAML. Encode Montana's 2021–2023 casualty and theft loss deduction (Form 2 line 15) once per joint return and per separately filing spouse TheAxiomFoundation/rulespec-us#1516 stays queued. A comment there re-pins its rows to this head, adds four cases and asks to extend line 15 back to 2018. It also records that the pinned corpus release now holds the 2021 to 2023 instructions and the MCA 2021 statute. The signed encoder can't run yet: the corpus lacks the 2015 to 2020 Form 2 instructions, every edition of MCA 15-30-2131 before 2019, Form 4684 and Publication 547.

🤖 Generated with Claude Code

@MaxGhenis
MaxGhenis deleted the fix-mt-casualty-loss-misc-deduction branch November 15, 2026 19:24
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