Skip to content

Add joint federal and state itemization and correct deduction worksheets - #11157

Open
MaxGhenis wants to merge 18 commits into
mainfrom
joint-federal-state-itemization
Open

MaxGhenis wants to merge 18 commits into
mainfrom
joint-federal-state-itemization

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Set gov.simulation.joint_federal_state_itemization to true to choose deductions for a 2025 full-year resident by comparing combined federal, state and local income tax. By default, PolicyEngine chooses the federal deduction under federal rules and applies each state's deduction formula. A supplied election applies to the tax unit that provided it. Callers can supply filing facts from a spouse's separate state return or a return in another state.

PolicyEngine tests up to four combinations of federal and state standard or itemized deductions, depending on state law. For example, DC requires the same method on both returns. A single DC resident who earns $150,000 and pays $13,500 in deductible mortgage interest and $2,500 in deductible income taxes would save $60 in federal tax by itemizing. DC tax would rise by $127.50. The resident saves $67.50 overall by taking the standard deduction. DC Act 26-214 · 2025 DC resident return instructions

Maryland lets federal itemizers take either state deduction, and PolicyEngine includes county income tax in the comparison. Nebraska reports the signed Form 1040N line 9 amount after subtracting elected income taxes, and uses the greater allowable deduction on line 10. Maryland resident instructions · Nebraska statute

PolicyEngine also compares the federal Schedule A elections for income and general sales taxes when the choice affects Maryland, Missouri, Nebraska or Virginia tax. Maryland retains eligible sales tax in the federal cap and applies its own itemized-deduction phaseout afterward. Missouri subtracts the income-tax share of the federal deduction and excludes city earnings taxes from that subtraction. Maryland Form 502 instructions · Missouri Schedule MO-A · Nebraska Form 1040N instructions · Virginia Schedule A instructions

For New York itemizers, PolicyEngine compares the college tuition deduction and credit using state and applicable city income tax. It also compares them when the caller explicitly supplies the automatic state method. It recomputes a filed New York itemized deduction that is below the standard deduction (N.Y. Tax Law §613). With the optimizer off, the state deduction and the tuition credit use the same New York election. When a repayment qualifies under section 1341, PolicyEngine carries the credit or deduction from the selected return into the final liability. New York Form IT-272 · IRS Publication 525

Prerequisites

Separate commits cover the state deduction amounts and credits used in the election calculations.

North Carolina gives a married separate filer a zero state standard deduction when their spouse itemizes federally. North Carolina statute

Axiom parity

axiom: TheAxiomFoundation/rulespec-us#2312 queued for North Carolina
axiom: TheAxiomFoundation/rulespec-us#2038 queued for the Nebraska income-tax exclusion; the signed Form 1040N line 9 case still needs parity coverage
axiom: TheAxiomFoundation/rulespec-us#1999 queued for Maryland's 2026 section 68 calculation; Maryland's 2025 election parity remains unverified
axiom: TheAxiomFoundation/rulespec-us#2002 queued for Missouri's 2015–2017 miscellaneous deductions; Missouri's 2025 election parity remains unverified

Before merge

The household regressions listed in the tests and the joint-election mutation check pass on Linux. GitHub checks at this head are pending. The national itemizer-count effects and full-population runtime remain unverified.

🤖 Generated with Claude Code

@MaxGhenis
MaxGhenis marked this pull request as ready for review November 19, 2026 12:07
MaxGhenis and others added 2 commits November 30, 2026 02:13
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
@MaxGhenis MaxGhenis changed the title Add joint federal and state itemization Add joint federal and state itemization and correct deduction worksheets Nov 30, 2026
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
MaxGhenis and others added 3 commits November 30, 2026 23:40
vt_medical_expense_deductions.yaml: Retain all federal-claim cases and the 2019 taxable-income case.
vt_medical_expense_deduction.py: Retain the federal itemization requirement and cite 2019 Act 71.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also recompute Virginia charitable gifts using their contribution limits.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine_us/tests/policy/baseline/gov/states/hi/tax/income/deductions/standard/hi_standard_deduction.yaml: Keep both sets of cases and cover Hawaii elections through the joint calculation.
policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_deductions.py: Use Hawaii's effective election for the allowable deduction.
policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_itemizes.py: Apply the shared state deduction method and tax-unit elections to Hawaii's default calculation.
policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_required_to_itemize.py: Retain the mandatory itemization input and its federal nonresident alien documentation.
policyengine_us/variables/gov/states/hi/tax/income/deductions/itemized/hi_itemized_deductions_eligible.py: Keep the applicable standard deduction comparison for default elections.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>

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

Program review

Base repository: PolicyEngine/policyengine-us
PR number: 11157
Reviewed head SHA: fb3035f
Merge base SHA: 094934a
Mode: full
Scope: changed behavior and affected dependencies
Source manifest: /private/tmp/policyengine-command-runs/ea33c0bb2b64/pr-11157-review-sources.json
Review status: PARTIAL

Source Documents

Critical

C1 — Default New York tuition election makes itemizers take the deduction, against IT-272's default credit, and raises tax for newly independent NY itemizers (OPEN)

  • Location: policyengine_us/variables/gov/states/ny/tax/income/credits/college_tuition/ny_elects_tuition_credit_when_itemizing.py:34 returns False when the optimizer is off. .../taxable_income/deductions/itemized/ny_college_tuition_deduction.py:27 then puts the tuition deduction into ny_itemized_deductions. The PR's new ny_itemizes.formula_2018 (ny_itemizes.py:29-37) lets New York itemize without federal itemizing. If that tuition-inflated itemized total is at least the standard deduction, ny_college_tuition_credit_eligible.py:19 denies the credit.
  • Trigger (run): 2025, NY single filer, age 30, $60,000 wages, $7,000 charitable cash, $2,000 qualified_tuition_expenses, optimizer off. The federal return takes the standard deduction.
  • Observed: ny_itemizes = True. NY itemized is $9,000 (including the $2,000 tuition deduction) against the $8,000 standard deduction. Tuition credit $0, ny_income_tax $2,640.
  • Expected: Form IT-272 Part 4 makes the credit the default for New York itemizers: "you may elect to claim the college tuition itemized deduction instead of the college tuition credit … Mark an X in this box only if you elect to claim the college tuition itemized deduction" (line 8). Without that election, NY itemized is $7,000, below the $8,000 standard. Section 613 recomputation then gives the standard deduction plus the $200 credit, and ny_income_tax is $2,495. The snapshot gives exactly this when ny_elects_tuition_credit_when_itemizing = True or state_deduction_method = STANDARD.
  • Why this diff: on main, ny_itemizes required federal itemizing, so this federal non-itemizer kept the $200 credit ($2,495). The PR's 2018+ independent election, combined with a default election that runs opposite to the form, raises New York tax by $145 for this household. The same thing happens to any NY filer whose tuition deduction lifts NY itemized over the standard deduction while the credit is worth more. The PR body says "With the optimizer off, the state deduction and the tuition credit use the same New York election", but the default election does not follow IT-272.
  • Source: NY Form IT-272 (2025), Part 4 and line 8 (manifest ny_it272_2025.pdf, extract lines 93-103). Reproduction: /tmp/policyengine-command-runs/ea33c0bb2b64/pr-11157-policy-ny-tuition-diag.py, log /tmp/policyengine-command-runs/ea33c0bb2b64/pr-11157-policy-ny-tuition-diag.log (imports confirmed from the snapshot).
  • Proposed severity: This is an executed default-on result that worsens a claimed year (2025) relative to main and to the form's default. The coordinator may weigh that both results are legal filing positions. If so, the deviation from the form default plus the regression still warrants at least SHOULD ADDRESS.

Coordinator assessment: I've kept this critical. It is an executed default-path result in a claimed year (2025) that is worse than main ($2,640 vs $2,495 for the executed single filer) and opposite to the form's default. IT-272 Part 4 makes the tuition credit the default for itemizers and the deduction an opt-in election (line 8). Both are legal filing positions, but with the optimizer off, the model should take the form's default rather than the costlier election. Defaulting ny_elects_tuition_credit_when_itemizing to true when the flag is off yields $2,495, the result the snapshot gives when the election is set.

Should Address

A1 — Maryland and Missouri 2025 deductions change when a caller supplies an intermediate that equals the computed value (OPEN)

  • Location: md_itemized_deductions.py:39-50 (formula_2025, has_input(... "capped_property_taxes") shortcut) and mo_net_state_income_taxes.py:41-47 (has_input(... "state_and_local_sales_or_income_tax") shortcut).
  • Trigger (executed, flag off, 2025, MD): single, $150k wages, $20k mortgage interest, $6k real estate tax, state_withheld_income_tax $500. The imputed state_sales_tax is $803, so state_and_local_sales_tax_elected = True.
  • Observed: Computed run: capped_property_taxes 6,000, md_itemized_deductions 26,803, md_income_tax 5,817.35. The same household, also supplying capped_property_taxes: 6000, gives md_itemized_deductions 26,000 and md_income_tax 5,857.50 (+$40.15). The shortcut only checks whether sales-tax variables were supplied. state_sales_tax has a formula (the IRS table), so an imputed sales election is silently dropped.
  • MO (code trace): supplying line 5a without state_and_local_sales_tax_elected routes to the pre-2025 formula. That skips the new city earnings-tax exclusion, so a Kansas City or St. Louis filer who supplies line 5a gets a different Missouri result.
  • Expected: under the PR's own rule (body; MD Form 502 line 17b), the same facts give the same MD deduction whichever intermediates were supplied. Both shortcuts appear to exist to keep pre-existing tests passing. Fix: update those tests or remove the provenance switch.
  • Impact: wrong 2025 MD and MO tax for callers that supply these intermediates (household API users, emulator-style inputs); $40.15 in the executed case.
  • Proposed severity: should-address.
  • Data: pr-11157-code-diag/md_provenance.json.

A2 — Flag-off change for sparse itemization inputs across tax units has no flag-off test (OPEN)

  • Location: system.py preprocess_situation → tools/itemization_inputs.py:preserve_partial_itemization_inputs, and apply_partial_input in tax_unit_itemizes, the state *_itemizes variables, state_deduction_method and state_and_local_sales_*.
  • Trigger (executed, flag off, 2025): two NY tax units. Unit A supplies tax_unit_itemizes: true. Unit B ($200k wages, $30k mortgage interest, $12k property tax) supplies nothing.
  • Observed: Main sets B to the default False (federal tax 37,067). Head computes B's formula, which returns True (federal tax 28,138.58; −$8,928.42). A's values are identical.
  • Assessment: head is the better result, and the PR body states that a supplied election applies to its own unit. But this is a default-path behaviour change for every multi-unit situation that supplies one of 14 itemization inputs on some units. The only test of the preprocessing path (TX/VA case in tax_unit_joint_itemization.yaml) runs with the flag on. Removing the flag-off apply_partial_input path in tax_unit_itemizes would not fail any test I found.
  • Related: the change also adds 14 dynamically registered filed_* variables (labels like "Partially supplied ...") to the public variable list.
  • Proposed severity: should-address (missing test for a new default-path branch). Also add a changelog line, since the current fragments describe only the flag and the state worksheets.
  • Data: pr-11157-code-diag/dcp_{main,head}.json (partial_two_units).

A3 — The axiom line omits most provisions this PR changes and points to unrelated older items (OPEN)

  • Location: PR body, "Axiom parity" section. Rule: repository CLAUDE.md lines 151-153 require one axiom: line per added, updated or fixed provision, marked encoded-correct, encoded, queued or n/a.
  • Observed: there are four lines. rulespec-us #2312 (NC spouse-itemization rule) matches this PR. #2038 is Nebraska 77-2716.01(4) from PE-US PR 10654, and the body says the signed line 9 case "still needs parity coverage". #1999 is Maryland's 2026 section 68 calculation (PE-US #10594), and the body says Maryland's 2025 election parity is "unverified". #2002 is Missouri's 2015-2017 miscellaneous deduction (PE-US #10096), and the body says Missouri's 2025 parity is "unverified". All four are open and labelled pe-parity.
  • Expected: a status for each changed provision. Missing entirely: the VA Schedule A worksheet (medical floor, line 5a cap, line 18), NY section 613/615 independent election and the tuition credit/deduction, the SC 2025 SALT conformity addback, OR Schedule 1-A subtractions, the CA AMT itemizer limitation, VT's medical-claim requirement, DC section 47-1803.04(b), the MD 2025 Form 502 line 17b treatment, the MO 2025 MO-A Part 2 worksheet, NE line 9 and the joint election rules.
  • Proposed severity: SHOULD ADDRESS (axiom-line problem).

Suggestions

S1 — PR body understates the branch count and the flag-on cost (OPEN)

  • The body says "up to four combinations". The code runs up to six full-recomputation branches; the two "alternative" trials apply to NY tuition and to MD/MO/NE/VA sales elections.
  • Each branch drops all inherited values, so national runs with the flag on will cost several times the baseline. The body lists full-population runtime as unverified. Measured: about 11.6x slower calculate on 156 tax units.
  • Proposed severity: suggestion. Correct the body/description and the parameter description; consider restricting branches to units where a trial is allowed.

Evidence Gaps

  • Optimizer allowed sets not verified for most states. These rules apply only with the opt-in flag. Verified against primary sources: DC (follows federal, D.C. Code 47-1803.04(b)), VA (follows federal), MD (state itemizing only for federal itemizers, free choice), NE (federal itemizers only, greater amount), NC (independent; zero standard deduction for a separate filer whose spouse itemizes) and MO (federal itemizers only). Not verified: AL, AR, AZ, CA, DE, GA, ID, KS, KY, ME, MN, MS, MT, NY and OK, and the separate-filer same-method rules for MD, KY, AR and MS.
  • N.Y. Tax Law §§ 613 and 615 could not be retrieved; the sites returned 403/401. policy-1 rests on IT-272, but the 2018+ independent NY election rests on the NY itemized-deductions page the PR cites, which was not fetched either.
  • Not checked:
    • whether 2026 South Carolina legislation adopted the OBBBA SALT change for tax year 2025 (SC IL #26-4 supports the addback as of January 2026);
    • whether Oregon allows the federal Schedule 1-A senior deduction for 2025;
    • Virginia's Limited Itemized Deduction Worksheet Part B and the line 11 rounding.

Notes

  • With the flag off, the change is otherwise neutral or an intended, tested correction.
  • Executed main against the head for 26 states × 6 profiles in 2025 and 2026. One row differs: SC MFJ $250,000 itemizer, +$120 in 2025, from the intended SALT conformity addback. A NY $60,000 filer's ny_itemizes flips from False to True with deductions and tax unchanged, and tuition eligibility is its only reader.
  • The intended flag-off corrections each have tests:
    • CA AMT limitation for itemizers only;
    • MD sales-tax electors keep the capped amount;
    • MO excludes KC/STL earnings taxes;
    • NE signed line 9 minus line 5a income tax;
    • NC separate-filer zero standard deduction;
    • OR Schedule 1-A subtractions;
    • SC 2025 SALT conformity;
    • the VA Schedule A worksheet on conformity AGI (10% medical floor from 2019).
  • Optimizer mechanics are sound:
    • Cycles. None, and every tax unit computes on TaxUnit, gated to 2025.
    • Vectorization. A vectorized argmin with a federal-rule tie preference, and supplied elections are honored per unit.
    • DC example. It reproduces the PR body's $67.50 saving: federal +$60, DC −$127.50.
    • Maryland county-tax comparison. It saves $157.76 for an MD federal-standard filer.
  • Cost: no added branches with the flag off, and the timing is within noise. With the flag on, it was about 11.6x slower on 156 tax units, with up to six full-recomputation branches, not four (code-3).
  • Code trace, not executed: with the flag on, contradictory filed inputs (for example DC with tax_unit_itemizes: true and state_deduction_method: STANDARD) leave no finite option. choose_joint_itemization then raises for the whole simulation, which would abort a microsimulation if a dataset ever supplied such inputs.

Validation Summary

Local tests at the reviewed head (review venv, policyengine-core 3.37.2, matching uv.lock; imports resolved to the snapshot): the focused set (every changed YAML file, the MD, NY, SC and VA integration files and the federal itemizing folder) passed in full; the three full touched-state folder groups reached their 540 s deadlines with 0 failures among the cases run. The 5 Python tests passed. Diagnostics executed the 156-unit flag-off comparison on main and the head for 2025 and 2026, the flag-on run, the DC and MD examples, the MD provenance case, the two-unit sparse-input case and the NY tuition household. Sources: 14 retrieved (DC Act 26-214 and the 2025 D-40 booklet, the MD 2025 resident booklet and Form 502, Neb. Rev. Stat. 77-2716.01 and the 1040N booklet, Schedule MO-A, the VA Schedule A instructions, NY IT-272, SC IL #26-4 and the SC1040 worksheet, N.C.G.S. 105-153.5, Oregon Laws 2026 ch. 142); manifest check passed. CI: 36/36 checks pass at fb3035f.

Timing

setup seconds: 19.00s; scope seconds: 60.00s; parallel review seconds: 1076.00s; policy role seconds: 747.10s; code role seconds: 1076.00s; adjudication seconds: 200.00s; consolidation cleanup seconds: 44.60s; elapsed seconds: 1767.00s

Review Severity

REQUEST_CHANGES. Open findings: 1 critical, 3 should address, 1 suggestions.

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