Repository navigation
Conversation
IRC 213(a) allows medical expenses the taxpayer paid. Premium inputs sit on the person who paid (#10055), so a dependent's own premium payments are not the filers' expenses. The federal subtotal now sums premiums over the head and spouse only and keeps every member's other medical expenses, which the CPS ASEC records on the person cared for. - New Jersey drops its per-dependent exclusion, which the federal base no longer needs, and counts only the filers' payroll premiums. - North Dakota's renter refund adds the dependents' premiums back: NDCC 57-02-08.1(5)(c) counts medical expenses the applicant's dependent paid. - Montana's 2021-2023 line 1 takes out only the filers' premiums. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add YAML cases for the federal subtotal, New Mexico's deduction, credit and exemption, New Jersey, North Dakota and Montana, each with the head and spouse labels both ways, plus Hypothesis properties: the filers' amounts do not depend on a dependent's own premiums, moving premiums from a filer to a dependent never raises them and moving back restores them, labels do not matter, and North Dakota keeps both payers' premiums. Update cases that expected a dependent's own premiums in Schedule A: two federal, nine Idaho federal expectations (Idaho's own outputs are unchanged), two New Jersey, and a Montana supplied subtotal that included the dependent's payment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8d657b8 to
b837849
Compare
Idaho's federal-first provenance test expected the dependent's own premiums in the federal deduction. It now gives the dependent other costs instead, which the federal subtotal counts and Idaho's claimant worksheet does not, so it still separates the two amounts. Montana's line 1 invariant subtracts only the filers' premiums, which are all the federal subtotal holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e5a6cb7 to
b3c256b
Compare
- Changelog: a dependent's own premiums leave New Jersey's general medical base (Worksheet F line 1); line 5 still carries a dependent's derived SE deduction. - North Dakota documentation: a supplied subtotal infers no exclusion, but the dependents' premiums are still added. - New Mexico: a parent-paid control for the general deduction (25% of 2,200 = 550), and the PIT-ADJ quote cited at PDF pages 5-6. - Property test docstring: the moved-back row checks determinism, and the file covers the named readers, not every reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Review: Count only filer-paid premiums in Schedule A medical expensesSummaryThis is a correct and carefully scoped fix. Under IRC 213(a), a taxpayer deducts medical expenses the taxpayer paid for themselves, their spouse and their dependents. Premium inputs already follow payer attribution (#10055, #10046). Main nevertheless summed every tax-unit member's The PR changes that sum to the head and spouse (
I checked each legal claim against its source. I hand-checked 16 expectations, traced the interactions with #10046 (pre-tax premiums), §162(l) and Medicare Part B, and confirmed consistency with #10272. I found no wrong result in a claimed year, no double exclusion and no double benefit. The PR merges cleanly with current main. The source-conflict ratchet passes statically on the merged tree. rulespec-us#1654 is open, labelled 0 critical, 0 should, 6 suggestions. Critical (must fix)None. Should addressNone. Suggestions
Verified correctLaw (each quote checked against the cited page).
The §213 premium split, item by item.
Consistency with #10272 (approved today, still open). #10272 builds W-2 box 1 as State slices.
Callers.
Code.
Hand-checks (2025 unless noted).
The PR body's household also checks: New Jersey 1,200 − 2% × 20,000 = 800 → 0, and New Mexico 25% × 1,200 = 300 → 0. Tests and cost.
Population effect (reasoned; no microsimulation run).
Source-conflict ratchet (#10287). The PR's CI ran before #10287 and #10334 merged, so I checked it statically.
Axiom line assessment
CI status
Branch status4 commits ahead and 45 behind main.
Sibling notes (not findings):
Verdict: APPROVE |
DTrim99
left a comment
There was a problem hiding this comment.
Schedule A now counts only premiums the filer paid, per IRC 213(a) and Pub 502. Pre-tax (#10046) premiums aren't excluded twice, the 162(l) deduction isn't doubled, Medicare Part B is handled right, and the change is consistent with #10272's box 1. The NJ/NM/ND slices follow their own statutes. 16 expectations hand-check, and the merged tree is clean and passes the ratchet. Six suggestions, including tracking OH and MO, which still pool dependents' own premiums. Full report in the comment above.
Exclude the medical premiums a dependent deducts as self-employed health insurance from the claiming filers' Schedule A medical expenses. Under 26 U.S.C. 213(a) and 26 CFR 1.213-1(a)(1), a taxpayer deducts only the medical expenses they paid. Under 162(l)(3), a taxpayer leaves the premiums they deduct as self-employed health insurance out of that deduction. A dependent who deducts their own premiums under 162(l) paid them. The model took the filers' deducted premiums and the long-term care part of each dependent's deduction out of `itemized_medical_expenses`. It kept the medical premiums a dependent deducted, so the parents counted premiums the dependent had deducted. Add `itemized_medical_expenses_excluded_dependent_premiums`: for each dependent, the smaller of their own medical premiums and their deduction less its long-term care part. Subtract it in `itemized_medical_expenses`. Add it to `itemized_medical_expenses_applied_exclusion`, so North Dakota's and New Mexico's paid-cost bases keep those premiums. North Dakota takes medical expenses "paid during the year by the applicant or the applicant's dependent" out of renter refund income (NDCC 57-02-08.1(5)(c)). In New Jersey, which already took those premiums out, subtract them from a supplied subtotal alone, less the part a supplied exclusion already covers. In Montana's 2017 to 2023 schedule, count them among the premiums the subtotal leaves out, so line 1 keeps the other medical expenses. Beside a computed subtotal, read a supplied applied exclusion as the filers' part, as main does, and add the dependents' computed exclusion in Montana, North Dakota and New Mexico. With a supplied subtotal, read the part of a supplied exclusion above the filers' own computed exclusion as the dependents' deducted premiums, up to their computed exclusion, in Montana and New Jersey. No source sets that split. A subtotal and exclusion supplied at their computed values then return the computed deductions, and an exclusion that covers the filers only returns main's result. Keep two of main's choices. Leave premiums a dependent paid and did not deduct in the parents' subtotal (#10270). Count premiums a dependent paid in New Mexico's paid-cost base, though the Taxation and Revenue Department asks for expenses "you paid" on PIT-RC line 23 and PIT-ADJ line 18. Add a federal YAML file with 25 cases and five cases to `nj_medical_expense_deduction.yaml`. In the conservation property tests, require that Schedule A's premium use plus every filer's and dependent's deduction equals the eligible premiums paid. Add the dependents' medical part to three assertions of the long-term care property tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Distinguish supplied filer-only subtotals from legacy totals in North Dakota and Montana. Document the missing payer information for nonpremium expenses and align the merged premium tests. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Both sides appended cases to mt_medical_expense_deduction_joint.yaml; keep both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DTrim99
left a comment
There was a problem hiding this comment.
Program review
Base repository: PolicyEngine/policyengine-us
PR number: 10270
Reviewed head SHA: b81e6b0
Merge base SHA: ab596b0
Mode: incremental from 2e5fccf
Scope: changed behavior and affected dependencies
Source manifest: /private/tmp/policyengine-command-runs/ea33c0bb2b64/pr-10270-review-sources.json
Review status: COMPLETE
Source Documents
Critical
None.
Should Address
A1 — New Jersey ignores itemized_medical_expenses_filer_only and takes a dependent's deducted premiums out of a subtotal that never held them (OPEN)
- Location:
policyengine_us/variables/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.pylines 47-68 (thehas_input_for_period(..., "itemized_medical_expenses", ...)block). The flag added by 66416a9 is wired into ND and MT only. - Trigger (2025, NJ): head and spouse pay 3,500 of premiums, the head's 3,000 through the SE deduction; every member's other costs total 7,800; a full-time-student dependent pays and deducts 1,000 of his own SE premiums; a 17-year-old dependent pays 1,200 of his own. Caller supplies the Schedule A subtotal 8,300 (3,500 - 3,000 + 7,800), the 3,000 filer exclusion, and
itemized_medical_expenses_filer_only: true. - Expected: 12,100, the same as the computed path for identical people (8,300 + 2,000 filer payroll premiums - 2% x 60,000 + 3,000 line 5). The flag's own documentation says "When this is true, any supplied applied exclusion covers the filers' premiums only", so nothing of the dependent's is in the base to remove.
- Observed: 11,100. NJ computes
dependent_exclusion - min(dependent_exclusion, max(0, 3,000 - 3,000))= 1,000 and subtracts it from the 8,300 base. The deduction is 1,000 too low, with or without the flag. - Why this diff: 66416a9 defines the flag as the way to say a supplied subtotal is filer-only and makes ND and MT honor it; NJ's supplied path (inherited from main #10831 through merge 17708cb) keeps the legacy reading. A caller cannot fix it by enlarging the supplied exclusion either, because ND and NM add the supplied exclusion back to paid costs.
- Impact: supplied-subtotal callers only (API/household inputs); the computed path, which the microsimulation uses, is correct. No test covers NJ with the flag.
- Fix: in NJ,
excluded_dependent_premiums = where(filer_only, 0, dependent_exclusion - already_excluded), plus a YAML case like the one above; or document NJ in the flag's scope. - Proposed severity: SHOULD ADDRESS.
Coordinator assessment: The policy review found the same defect independently with a simpler household. Parent with $30,000 of wages; a 17-year-old child who pays and deducts $3,000 of his own SE premiums; a supplied filer-only subtotal of $10,000 with the flag set. The NJ-1040 instructions (PDF p. 25) give 10,000 − 2% × 30,000 = $9,400. The head gives $6,400, the same with the flag unset, true or false. I've kept it at should-address because only the supplied-subtotal path is wrong. The computed path, which household calculations without the override and the microsimulation use, is correct. The policy review's legal check confirmed that NJ uses the filer-paid base.
Suggestions
S1 — The default reading of a supplied subtotal flipped from the approved head, and the PR body still describes the old behavior (OPEN)
- Location:
nd_renters_refund_income.pylines 136-143;mt_medical_expense_deduction_joint.pylines 40-70; PR body lines 28 and 79. - Executed with the code-1 household and the same supplied subtotal 8,300 and exclusion 3,000, flag left at its default:
- ND 2025
nd_renters_refund_income: approved head 50,500; head 52,700 (the dependents' 2,200 of own premiums are no longer added); head with the flag 50,500. - MT 2022
mt_medical_expense_deduction_joint(head): approved head 4,280.97; head 2,080.97 (2,200 of dependents' premiums taken out of a subtotal that held none); head with the flag 4,280.97. - Federal
medical_expense_deductionreads the same supplied 8,300 as a filer-only Schedule A amount (4,280.97) at every head, so one supplied number is read two ways by default.
- ND 2025
- This is a deliberate, documented backward-compatibility choice (the
itemized_medical_expensesdocumentation now tells ND and MT callers to set the flag), and both default and flag branches are tested. It does reverse hand-check 14 of the approval ("ND: supplied Schedule A subtotal 500; student's own 1,200 -> 28,300"), which now needs the flag. - The PR body still says ND adds dependents' premiums "to a supplied Schedule A subtotal as well, since one never includes them" (line 28) and that the MT supplied case's input "is now the $10,000 the head paid" (line 79). The changelog fragment was updated; the body was not.
- Proposed severity: SUGGESTION (update the PR body to state the legacy default and the flag; the coordinator may weigh whether the default itself should follow the federal reading).
Coordinator assessment: The policy review reached the same point. With the flag at its default, a genuine Schedule A line 1 is read on the pooled (legacy) basis in North Dakota and Montana, while federal Schedule A and New Mexico read the same input as a filer-only § 213 amount. One supplied number is therefore read two ways by default. The flag is documented and both branches are tested, so this is a contract-clarity point. Please state it in the itemized_medical_expenses documentation and the PR body, or default the flag to true when the subtotal is supplied in Schedule A form.
Evidence Gaps
No material gaps reported.
Notes
- This re-review covers the one commit pushed since the 10-21 approval (66416a9, "Preserve legacy state medical expense subtotals") and two merges of main.
- The computed path is unchanged. Federal
itemized_medical_expensesandmedical_expense_deductionare identical at the approved head, the merge and the current head in all 24 state and mode runs (for example 8,300 and 4,280.97 with SE premiums). The commit adds a caller-supplied flag,itemized_medical_expenses_filer_only, read only by North Dakota's renter refund income and Montana's 2021–2023 line 1. Both branches agree with NDCC 57-02-08.1(5)(c) and the Montana Form 2 instructions (pp. 32–33), as long as the flag correctly describes the supplied subtotal. - The commit also fixes an UnboundLocalError in
nd_renters_refund_incomethat merge 17708cb introduced; at the merge it raised on every ND household. That merge keeps main's long-term-care premiums, dependent-premium exclusion, NJ supplied-subtotal path, NM boundary and ND rewrite. No main entry was lost. Its main-sidenj_agichange lowers the computed NJ deduction for a household with a dependent's SE income, which is main's behavior. The b81e6b0 conflict keeps both sides' appended Montana cases. - Optional items from the approval, all still open: track Ohio and Missouri premium pooling (the body lists Missouri, not Ohio); show the payer contract in input labels; refresh rulespec-us#1654's stale fixture figures; open issues for the disclosed Idaho and NM gaps; give Linux CI cost figures; add an NJ dependent SE-overflow case and drop the
moved_backvariant. The axiom line still meets the CLAUDE.md rule, and the new flag needs no RuleSpec change.
Validation Summary
Local tests at the reviewed head (review venv, policyengine-core 3.37.2, matching uv.lock; imports resolved to the snapshot), split into two bounded runs for the deadline: the federal medical expense, Montana, North Dakota renter refund, New Jersey deductions and New Mexico medical folders, plus the Schedule A payer-attribution, premium-conservation, long-term-care and Montana invariant property tests, passed with 0 failures. A mutation forcing Montana's legacy dependent-exclusion term to zero failed 3 cases, so that branch is pinned. Diagnostics executed the households above at the approved head, the merge and the head. Sources: the Montana Form 2 instructions and MCA 15-30-2131; the ND and NJ quotes were reused from the approval's verified sources; manifest check passed. CI: 36/36 checks pass at b81e6b0.
Timing
setup seconds: 6.00s; scope seconds: 60.00s; parallel review seconds: 953.10s; policy role seconds: 333.60s; code role seconds: 953.10s; adjudication seconds: 150.00s; consolidation cleanup seconds: 50.70s; elapsed seconds: 1266.00s
Review Severity
COMMENT. Open findings: 0 critical, 1 should address, 1 suggestions.
Federal Schedule A medical expenses counted every tax-unit member's health insurance premiums, including premiums a dependent paid. IRC 213(a) allows "the expenses paid during the taxable year ... for medical care of the taxpayer, his spouse, or a dependent", and premium inputs record the person who paid them (#10055: "A parent-paid dependent policy belongs on the parent"). So a dependent's own payments are not the filers' expenses. This PR counts only the head's and spouse's premiums, and fixes the state bases that read the federal subtotal. The US + core hub's methodology review of #9947 found the bug.
Law and input contract
other_medical_expensesnow documents this.What changes
itemized_medical_expensessumsmedical_expense_health_insurance_premiumsover the head and spouse withtax_unit_non_dep_sum, the label-free helper. Everything else in the formula is unchanged: the §162(l)(3) exclusion (already bounded to the filers' premiums) and every member'sother_medical_expenses.Readers of the subtotal
medical_expense_deductionand the federal itemized totals, and through them taxable income, the itemized limitation, QBID, the shared state tax dispatcher, the state formulas that read them (CA, CO, DC, GA, IA, ID, KS, LA, MA, MD, ME, MN, MO, MS, MT from 2024, NC, NE, NM, OK, OR, SC, UT, VA, VT, WI), three reforms (CRFB senior deduction, MA dependent exemption, MN Walz) and the TAXSIM emulatorHousehold before and after
mainf9b55fc: a 2024 joint couple aged 70 and 68 with $20,000 of wages. A 19-year-old student dependent pays $1,200 of their own premiums; the filers pay none.itemized_medical_expensesnm_medical_care_expense_deductionnj_medical_expense_deductionnd_renters_refund_incomemt_medical_expense_deduction_joint(2022)Invariants
These hold for every input that follows the payer contract:
Dependent invariance. None of these depends on a dependent's own premium input:
NJ's total deduction can still rise when a premium moves to a self-employed dependent, because line 5 adds that dependent's derived SE deduction. Review r1's case: parent wages $30,000 and a dependent with $10,000 of SE earnings. A $1,000 premium paid by the parent gives $200 ($1,000 − 2% of $40,000). The same premium paid by the dependent gives $1,000, all on line 5.
Payer move. Moving premiums from a filer's input to a dependent's never raises any of those amounts, with the SE deductions held fixed. A moved-back row repeats the drawn inputs, so it checks determinism (each return depends only on its own inputs), not an undo.
Labels. Exchanging the head and spouse labels changes none of them, nor North Dakota's renter refund income.
Conservation. Schedule A premium use plus the SE deduction equals the filers' paid premiums, when the deduction is within that pool. Every member's other medical expenses stay in the subtotal.
Bounds.
itemized_medical_expenses.itemized_medical_expenses≤ filer premiums + every member's other medical expenses.North Dakota. The paid-cost base is invariant to who paid, and equals every member's premiums plus other medical expenses on the computed path.
Differential.
itemized_medical_expensesequals an independent oracle, max(0, filer premiums − SE deduction) + every member's other medical expenses.Tests
mainf9b55fc and pass at this head. The four parent-paid controls (federal; NM deduction, credit and exemption) pass on both.tests/core/test_schedule_a_payer_attribution_properties.py(Hypothesis) checks invariants 1, 2, 3, 6 and 7 for the readers named there, with a supplied tax-unit SE deduction, in one vectorized simulation per year. It does not cover every reader of the subtotal. Onmain, the filer test fails and the North Dakota test passes, as it should.test_medical_expense_premium_conservation.pynow checks conservation over the filers' paid premiums (invariants 4 and 5). Its NJ property now checks that the dependents' own premiums never enter line 1. Its ND/NM oracle now adds the dependents' premiums only for ND. Onmain, all five fail.medical_expense_deductionanditemized_taxable_income_deductionsmoved; every Idaho output is unchanged.test_id_health_insurance_premiums.py, the deletion-provenance test moves the dependent's $500 from premiums to other costs. That keeps its federal and Idaho amounts apart ($1,250 against $750), so it still catches the provenance defect.tests/unit/test_mt_medical_premium_deduction_invariants.py, invariant 6 (line 1 base) subtracts only the filers' premiums from the federal subtotal, since those are all it holds.coregroup.Known gaps (not changed here)
other_medical_expenses. Fix Idaho health insurance premium subtraction #10023 treated them as recorded on the payer, but the CPS asks them by the person cared for. In the Idaho case "Claimant medical overlap includes spouse expenses and excludes dependent expenses", the dependent's $4,000 of bills is in the federal subtotal but not in Idaho's overlap.mt_medical_expense_deduction_indiv) counts each spouse's ownother_medical_expenses, so a dependent's bills reach neither spouse.itemized_medical_expenses, adding eligible long-term care premiums recorded on the insured person. It needs the same payer decision for a dependent's policy, and whichever lands second rebases.nj_agiand their SE deductions on line 5 (pre-existing).Impact
The US + core hub runs the microsimulation impact.
axiom: us/statute/26/213, TheAxiomFoundation/rulespec-us#1654 queued (payer-scope extension: targets, verbatim law, required outputs, review_finding and 10 companion cases. rulespec-us's §213 module takes the taxpayer's paid expenses as a tax-unit input, so it has no person-level sum to get wrong; #1654's §162(l) amendment and its NM 7-2-37/7-2-5.9/7-2-18.13, NJ 54A:3-3 and ND 57-02-08.1(5)(c) slices carry the scope.)
🤖 Generated with Claude Code