Repository navigation
Fix AR, MT and NM income tax gaps found in TAXSIM comparison sweep - #9585
Conversation
- AR: count partnership/S-corp income in gross income (AR1000F Line 19); stop flooring each spouse's net income separately on joint returns (all income goes in Column A), flooring the unit total instead. - MT: floor the capital gain credit at zero on net capital losses; allow dependent exemptions for non-child dependents with gross income at or below the exemption amount, with the disabled extra exemption for children only. - NM: from TY2023, compute net capital gains per IRC 1222(11) (net long-term gain less net short-term loss), excluding short-term gains. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9585 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 6 +2
Lines 76 106 +30
Branches 2 1 -1
=========================================
+ Hits 76 106 +30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PavelMakarchuk
left a comment
There was a problem hiding this comment.
Two correctness issues need addressing before merge: the Montana dependent-income test uses a variable that excludes dependents, and the New Mexico parameter introduces an unsupported 2023 effective date. Both were reproduced with isolated checks of the current-head formulas. All 37 hosted checks pass, but the current regression fixtures do not catch these issues. This was a manual code/source review with isolated formula checks, not the complete-review workflow or a new full-model test run. The Arkansas changes and Montana capital-gain credit floor look sound.
Program ReviewComplete review confirms the two existing blockers. Request changes; no additional correctness blocker found. Source Documents
Branch StatusThe reviewed branch is 9 commits behind main; rebase before merging. Staleness did not affect this review, which used the captured head and explicit merge-base diff. Critical (Must Fix)
Should Address
SuggestionsNone separately counted. Reference-title wording and unchanged model limitations are not merge blockers. PDF Audit Summary
Correct-rule count deduplicates repeated years and overlapping source passages: 2 Arkansas, 5 Montana, 7 New Mexico. Existing disability/dependency approximations, capital-loss carryover/residency details and unrelated credit interactions were not promoted to new findings. The Arkansas visual source is the 2025 booklet; no comprehensive historical audit of every source-list year is claimed. Validation Summary
Actual formula bodies were executed in isolated NumPy checks reproducing both disputed results. No new full-model, YAML-suite or microsimulation run was performed locally; hosted CI supplies suite coverage. Review completed in approximately 19 minutes, using 3 reused delegate workers across 20 roles. All five collected PDFs were fully rendered and sequence-verified: 480 pages at 300 DPI, plus 2 external pages and 3 independent 600-DPI verification renders (485 total; 0 cache hits). Topic auditors visually read the relevant pages, not all 480. To protect disk space, 470 bulk PNGs and the inspected 600-DPI PNGs were deleted after verification; PDFs, reports, operative 300-DPI evidence and verification hashes remain. The full render cache is therefore no longer reusable. No repository source edits. Review Severity: REQUEST_CHANGESNext StepsFix C1 and C2, add the targeted regression coverage, and rerun complete review before approval. The fix-pr workflow can apply the corrections. |
…nition Test Montana's non-child dependent exemption against the dependent's own gross income (dependent_gross_income) instead of irs_gross_income, which is zero for dependents, with earnings-derived below/at/above-limit cases. Apply New Mexico's IRC 1222(11) net capital gain definition in every year (NMSA 7-2-34(D), 2019 HB6) and drop the unsupported pre-2023 exception. Add Arkansas joint asymmetric profit/loss and New Mexico cross-spouse netting coverage. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Fixes applied (2ce9b1c): Pavel's review[C1] Montana dependent income test.
[C2] New Mexico net capital gain.
[A1] Arkansas joint loss coverage.
Together they cover table selection, final tax and the [A2] New Mexico cross-spouse netting.
Other updates: the changelog and the PR description's MT and NM sections are updated. Verification: all 37 CI checks pass at 2ce9b1c, including the full baseline state shards, and |
Program Review (incremental re-review)All four prior findings (C1, C2, A1, A2) are resolved. One new blocker remains: Montana's dependent income test needs a Montana-specific gross-income measure. Source Documents
Branch StatusThe branch is 2 commits ahead of and 57 commits behind Prior findings
Critical (Must Fix)
Should Address
Suggestions
Pre-existing issues (not introduced by this PR; non-blocking)
Verified correct
PDF Audit Summary
Validation Summary
Model runs on the reviewed head reproduced every model value above. No repository files were edited. Review Severity: REQUEST_CHANGESNext StepsApply the narrow Montana refinement in C3 and add the A3 and A4 cases. P1–P5 can be addressed here or tracked separately. To auto-fix issues: run the fix-pr workflow for this PR. |
PavelMakarchuk
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. All four findings from my previous review (C1, C2, A1, A2) are resolved; full incremental re-review here: #9585 (comment)
One new item is blocking:
- C3: The Montana dependent test now uses
dependent_gross_income, which follows the federal gross-income definition. Montana's own definition differs in three ways: it excludes unemployment compensation (MCA 15-30-2101), counts only taxable Social Security, and counts gains without netting losses. Each case moves 2022 MT tax by about $183. You followed my earlier suggestion here, so this is a narrow refinement to that fix: a Montana-specific gross-income measure.
The five pre-existing items in the report are non-blocking: the MT disabled adult child, NM capital gain distributions, the NM MFS base, AR mandatory joint filing, and AR formula vs table.
Test Montana's non-child dependent exemption against a new mt_dependent_gross_income (MCA 15-30-2114(5)(a) and 15-30-2101(10)): federal gross income excluding unemployment compensation, counting only the IRC 86 taxable part of Social Security on the dependent's own income, and flooring long- and short-term gains separately instead of netting. Also count a permanently and totally disabled adult child as a qualifying child, count New Mexico capital gain distributions, and fix docs and tests from the review. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
AR conflict: kept main's 2016-2018 unemployment cases and the PR's partnership/S-corp case in ar_gross_income_indiv.yaml, and added partnership_s_corp_income to main's new 2015-01-01 gross income source blocks. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
With one spouse's loss now offsetting the other's income, the summed ar_agi_joint can be negative. Main's medical, casualty loss and miscellaneous joint deductions multiply that total by their AGI floor rate, so a negative total enlarged each deduction beyond the expense. Floor the total at zero, as the federal deductions do with positive_agi. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Fixes applied (57a635e, merge 78624a8, b584e8b): Pavel's re-reviewC3 (blocking), Montana-specific dependent gross income: the non-child dependent test now uses a new Person variable,
Six 2022 cases reproduce your tax effects exactly: −$182.92 (unemployment), −$182.93 (Social Security) and +$182.92 (capital losses), each being 2,710 × 6.75%. ARM 42.15.403 is cited without subsection numbers because both copies blocked download; the two MCA sections are confirmed word for word. Pre-existing items fixed here, in files this PR changes:
Also:
Follow-ups filed:
Verification: Arkansas income tax passes 475/475, Montana exemptions 57/57 and New Mexico deductions 84/84, all run after the merge. No existing expected value changed, |
* Count pass-through, estate and Schedule F income in Arkansas gross income AR1000F line 19 covers partnership, S corporation, estate and trust income reported on Schedule E, and line 20 is Schedule F farm income. Add partnership_s_corp_income, estate_income and farm_operations_income to both Arkansas gross income source lists in every period. Fixes #9793. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Leave partnership/S-corp income to #9585; keep estate and Schedule F income #9585 already adds partnership_s_corp_income to Arkansas line 19. Drop it here to avoid duplicate work, and keep the parts #9585 does not cover: estate_income (line 19) and farm_operations_income (line 20, Schedule F). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the Arkansas gross income source lists against main's estate, Schedule F and gambling income additions, keeping this branch's partnership and S-corporation income on the same form line as estate income, and keep both sides' gross income tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
… return mt_agi_joint pooled every tax unit member's Montana additions and subtractions, but a dependent's federal AGI is not on the filer's return (adjusted_gross_income_person is zero for dependents). A dependent's subtraction, such as unemployment compensation, therefore lowered the filer's Montana AGI and, since main's PolicyEngine#9903, the joint standard deduction. Pool additions and subtractions over the head and spouse only. The adult-dependent exemption case had pinned the leaked AGI of 47,000; under the law the filer's Montana AGI is 50,000 and the tax is 1,731.65. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…me-tax-table Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…plit Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Keep both the joint negative-AGI medical deduction case and main's self-employed premium case (PolicyEngine#10055). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…me-tax-table Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…plit Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Main's code-health test pins the AR1000F line for every Arkansas gross income source. Partnership and S-corporation income is reported with Schedule E income: line 18 for 2015-2017 and line 19 from 2018. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…me-tax-table Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…plit Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
hua7450
left a comment
There was a problem hiding this comment.
[P2] Preserve deductible losses when calculating the dependent's taxable Social Security
In policyengine_us/variables/gov/states/mt/tax/income/exemptions/dependent/mt_dependent_gross_income.py:64-68, provisional_income reuses other_gross_income, whose components were floored at zero on line 49. That drops deductible capital losses from the Social Security calculation. The positive-only gross-income total for Montana's dependent test and the modified adjusted gross income used by IRC 86(b)(2) need separate treatment.
Local 2022 reproduction: a non-child dependent has $26,000 unemployment compensation, $10,000 Social Security, and a $3,000 long-term capital loss; the filer has $50,000 wages, and the dependent is not the spouse.
- Social Security MAGI is $23,000; adding half the benefits gives provisional income of $28,000 and taxable Social Security of $1,500.
- Montana excludes the unemployment compensation, leaving $1,500 of dependent gross income, below the $2,710 exemption threshold.
- The PR instead computes $3,000 of dependent gross income and denies the $2,710 exemption.
On this branch, the existing dependent_taxable_ss_magi and dependent_taxable_social_security variables already return the correct $23,000 and $1,500. Please reuse dependent_taxable_social_security for this component, retaining the positive-only non-Social-Security gross-income components and Montana's unemployment exclusion. Add coverage to the corresponding gross-income and exemption YAML files.
Validation: 127 changed-file cases passed; two independent cases reproduce the incorrect gross income and denied exemption. The affected runtime code and dependencies are unchanged on reviewed head a434b88b17d5b2e084de7e97005e56058448af3b.
…ncome mt_dependent_gross_income recomputed taxable Social Security itself and floored every income component at zero before forming provisional income, so a dependent's capital loss never lowered taxable Social Security. A 2022 dependent with $26,000 of unemployment compensation, $10,000 of Social Security and a $3,000 long-term loss got $3,000 of Montana gross income and no exemption, instead of $1,500 and the $2,710 exemption. MCA 15-30-2101(10) defines Montana gross income as IRC 61 gross income excluding unemployment compensation, and the 2021-2023 Form 2 instructions name no other difference. Since PolicyEngine#9691 the federal dependent_gross_income counts gains but not losses and only the IRC 86 taxable part of Social Security, figured on the dependent's own modified AGI (which nets capital losses, subtracts the dependent's adjustments and uses the $0 base for a dependent living with a spouse). Montana gross income is now that amount minus the dependent's unemployment compensation, which removes the duplicated IRC 86 code and its approximations. Adds the capital-loss case to both MT dependent test files and drops a test comment that described the pre-PolicyEngine#9691 federal treatment of Social Security. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…me-tax-table Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
…plit Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Fixes applied (6fea3d2)Should-address
Suggestions
Also since the last review
Verification
|
Keep main's California SSP values in spm_unit_benefits.yaml alongside the modeled-UI case, and route the two unemployment compensation readers that main added through total_unemployment_compensation: the Montana dependent gross income subtraction (#9585) and the Montana elderly credit add-back, so they match dependent_gross_income and count modeled state UI. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
#9585 landed as a squash commit; keep this branch's New Mexico deduction and tests, which build the separate-filer split on top of it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
#9585 landed as a squash commit; keep this branch's tax-table band and mandatory joint filing expectations in the Arkansas integration cases. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH
Resolves the conflict in ar_misc_deduction_joint.py with main's #9585: the miscellaneous pool keeps this branch's sources list, and Arkansas AGI keeps main's floor at zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A comparison sweep of PolicyEngine against TAXSIM (latest NBER binary,
opt(30)=1, 2021–2025) turned up five state income tax gaps in Arkansas, Montana and New Mexico. Each one is fixed here and checked against the form instructions. Review also surfaced a few small pre-existing gaps in the same lines of code, which are fixed here too.axiom: AR1000F lines 19, 23, 25 and 28 (Ark. Code § 26-51-404) TheAxiomFoundation/rulespec-us#1753 queued | MCA 15-30-2114(5), 15-30-2101(10), 15-30-2301 and 15-30-2110 (TY2021–2023) TheAxiomFoundation/rulespec-us#1754 queued | NMSA 7-2-34 (IRC 1222(11) base) TheAxiomFoundation/rulespec-us#1755 queued
Evidence
AR: partnership and S-corp income (Line 19)
2022 AR1000F instructions, p. 13 (same wording in 2025):
partnership_s_corp_incomehas never been ingross_income/sources/{individual,joint}.yaml, althoughrental_income(also Line 19) is. This was reported in taxsim #405, which was closed without a fix.AR: joint returns use Column A only
2022 AR1000F instructions, p. 12 (same wording in the 2024 instructions, p. 12):
Before this PR,
ar_agi_jointfloored each person's net income at zero before summing. A spouse's business loss therefore could not offset the other spouse's wages. The per-person zero floor now applies only to dependents' income, which is attributed to the head.ar_net_taxable_income_jointandar_low_income_tax_jointfloor the combined total instead.MT: capital gain credit
2022 Montana Form 2 instructions, p. 43:
The old formula multiplied 2% by
capital_gainseven when it was negative. For example, a return with a $11,418 short-term loss got a −$228 credit, which raised tax by $228.MT: dependent exemptions
MCA 15-30-2114(5)(a) (2021) allows an exemption for each dependent:
MCA 15-30-2101(10) defines that gross income:
The 2022 Form 2 instructions, p. 14 give the same test ("who does not have gross income of more than $2,710, unless the dependent is a 'qualifying child'") and limit the extra exemption to "a child who is disabled". The limits are $2,580 in 2021 and $2,960 in 2023.
The old formula granted exemptions only to qualifying children. Non-child dependents with low income, such as a 19-year-old non-student or a dependent parent, got nothing. The income test now uses a new Montana measure,
mt_dependent_gross_income. It takes the federaldependent_gross_income, which counts only the dependent's own income, and subtracts the dependent's unemployment compensation, which MCA 15-30-2101(10) excludes. That is the only Montana difference from IRC §61 gross income in the statute and in the 2021–2023 Form 2 instructions.Since #9691,
dependent_gross_incomefollows Pub. 501 (2022), p. 2:An earlier revision of this PR computed taxable Social Security inside the Montana variable. It floored every income component at zero before computing provisional income, so a capital loss never lowered taxable Social Security. Reusing the federal variable fixes that and removes the duplicated IRC §86 code. For example, a 2022 dependent with $26,000 of unemployment compensation, $10,000 of Social Security and a $3,000 long-term loss has modified AGI of $23,000 and $1,500 of taxable Social Security. The dependent's Montana gross income is therefore $1,500, so the dependent now qualifies for the $2,710 exemption. The earlier revision computed $3,000 and denied it.
irs_gross_incomedoes not work for this test because it is zero for dependents.A permanently and totally disabled adult child now counts as a qualifying child (IRC §152(c)(3)(B)), as in
is_qualifying_relative_dependent. For example, a 2022 dependent aged 30 with $5,000 of wages now gets $5,420 instead of $0, which lowers MT tax by $365.85.MT: joint AGI leaves out dependents' additions and subtractions
2022 Montana Form 2 instructions, Line 7:
Montana subtractions remove income that is on the filer's federal return. A dependent's income is not on that return:
adjusted_gross_income_personis zero for dependents. Before this PR,mt_agi_jointstill pooled every tax unit member'smt_additionsandmt_subtractions. A dependent's unemployment compensation therefore lowered the filer's Montana AGI. Since #9903 it also lowered the AGI-based joint standard deduction. Additions and subtractions are now pooled over the head and spouse only, so a spouse's subtraction still offsets the other spouse's income (commit 216b329). For example, a 2022 filer with $50,000 of wages and a dependent with $3,000 of unemployment compensation now has Montana AGI of $50,000 instead of $47,000.NM: net capital gains
2022 PIT instructions, PIT-1 line 15:
2023 PIT instructions, PIT-1 line 15:
The 2024 instructions (p. 33) carry the same §1222(11) definition. The shorter 2022 wording does not set a different rule. NMSA 7-2-34(D) has used IRC §1222(11) since 2019 HB6, section 14, which applies to tax years beginning January 1, 2019 (section 59(A), p. 105). From 2025 the same definition is in subsection (C) (2024 HB252, section 8, p. 30; applicability in section 42(B), p. 147).
The deduction therefore uses net long-term gain less any net short-term loss in every year, with no year-dated parameter. Capital gain distributions (
non_sch_d_capital_gains) are long-term capital gains under IRC §852(b)(3)(B), so they now count as well. For example, a 2023 single filer with $5,000 of distributions now gets $2,000 instead of $0.Two 2021 TAXSIM records that matched under the old formula now differ. The difference comes from TAXSIM including short-term gains; it is not a change in New Mexico law.
Validation against TAXSIM
I ran the sweep sample (150 records per state-year) through
policyengine-taxsim, before and after this change, and compared state tax plus rebates to TAXSIMopt(30)=1. Tolerance: max($25, 0.1% of federal AGI). These counts are from the first revision. The review-round changes affect only inputs the sweep does not set: dependents' own income, disability status and capital gain distributions.Why NM shows no change. In 2022–2024, TAXSIM deducts a flat $1,000 of net capital gains, not the greater of $1,000 or 40% that the instructions require. That gap is much larger than the short-term-gain change, so the affected records stay mismatched either way.
The 3 newly broken records:
Repro rows (TAXSIM input format)
siitaxNM has no clean TAXSIM repro row. TAXSIM counts short-term gains in every year, and its flat $1,000 deduction in 2022–2024 keeps the affected records mismatched either way. The unit tests show the change instead: long-term $10,000 and short-term $5,000 gives a deduction of $4,000 (40% × $10,000) in 2021, 2022, 2023 and 2024. Counting the short-term gain would give $6,000.
Tests
ar_agi_joint,ar_net_taxable_income_joint,ar_gross_income_indiv, the AR integration tests,mt_capital_gain_credit,mt_dependent_exemptions_person, the newmt_dependent_gross_incomeandmt_agi_jointtests, andnm_net_capital_gains_deduction.mt_income_tax$1,731.65, down $182.93;mt_income_tax$1,894.57, up $182.92), and a short-term gain with a long-term loss;mt_income_tax$1,548.72, down $365.85;mt_agi_joint: a dependent's $3,000 of unemployment compensation leaves the filer's Montana AGI at $50,000, and a spouse's $3,000 still offsets the joint return's income.is_tax_unit_spouse: falseis required, because without it the adult is inferred as the spouse and skips the income test.nm_net_capital_gains_deductioninputs moved fromcapital_gainstolong_term_capital_gains, so they keep testing the same amounts.ar_agi_jointcase with a spouse at −100 now expects −100 rather than 0.mt/tax/income/exemptions(59 passed),mt_agi_joint.yamlandmt_capital_gain_credit.yaml(5 passed), every AR and NM YAML file this PR touches (88 passed), andtest_ar_gross_income_source_line_comments.py(2 passed). The first revision also passedgov/states/{ar,mt,nm},gov/states/tax,gov/states/household, and the SALT refund and AMT integration tests (1,749 passed), plus the partner contract tests (620 passed). No partner files changed.Arkansas joint deduction floors
Because one spouse's loss can now offset the other's income on a joint return, the couple's combined AGI can be negative. Three Arkansas joint itemized deductions (medical, casualty loss and miscellaneous) take a percentage of that combined AGI as a floor, so a negative AGI made each deduction larger than the expense: $1,000 of medical expenses produced a $1,500 deduction. The combined AGI is now floored at zero in those three floors, as the federal deductions do, with one test per deduction (commit b584e8b). The medical case was already wrong on this branch before merging
main;mainadded the other two.Follow-ups (filed; out of scope here)
#9678 (federal
dependent_gross_incomecounting total Social Security and netting capital losses) was closed by #9691 on 2026-10-02. The Montana income test now builds on that fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01LqCGPgxDukji8Bhs57c5rH