Repository navigation
Conversation
G.S. 105-153.5(a)(2)d, added by S.L. 2016-5 for 2014 and later, lets North Carolina itemizers deduct repayments of income included in AGI in an earlier year under a claim of right (Form D-400 Schedule A line 8). Repayments above $3,000 are deductible in full; smaller ones are reduced by 2% of federal AGI less other miscellaneous itemized deductions, which the 2016 and 2025 NCDOR worksheets both reproduce. PE had no input for these repayments, so it adds claim_of_right_repayment (person level; only the head's and spouse's count) and moves North Carolina's uncapped itemized items into a parameter list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…C taxed Review r1 (subfleet 20261009-090558-nc-itemized-review): - S.L. 2026-31 section 1.8 rewrites G.S. 105-153.5(a)(2)d for taxable years beginning on or after January 1, 2026: the repaid amount must have been included in AGI "as modified in G.S. 105-153.5 and G.S. 105-153.6" in the earlier year. New person input nc_claim_of_right_repayment_excluded_from_income (the part NC deducted when received, such as repaid Social Security) and a dated parameter apply it. - Count only the head's and spouse's other miscellaneous expenses against the pre-2018 floor; a dependent's are on the dependent's return. - The property grid now varies property taxes (so the $20,000 cap binds) and adds a 2026 grid for the excluded part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h Carolina's 1341(a)(5) bar and G.S. 105-266.2 payment (WIP) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es that exclude them (AZ, KS, WI, MO, OR, VA); property tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fragment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to keep it at two seconds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…urn-level prior-year inputs, California and Montana flows - The branches that fix the claim of right method start from inputs only, and the itemization branches settle the method in the parent first, so a tax liability calculated before the method is known cannot leak into them. - Ties are compared to the cent, so a one-cent difference picks the credit. - The prior-year federal decrease and NC increase are return-level inputs defined on chapter 1 and Article 4 tax. - California leaves out the federal deduction (Schedule CA Part II line 16); Montana deducts it through 2023 (Form 2 itemized line 18). - Section 67(g) is now 67(h); document the Arizona and NC coverage limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2 found that with itemization branching off, tax_liability_if_not_itemizing used the parent's method when calculated first but chose its own after income_tax. The itemizing branches now take the method as an input. A branch keeps its parent's cache when an override equals the value the parent already holds, so ordinary simulations still share it. Adds the review's Texas household as an order test under both itemization settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… branches only when someone qualifies Review r3 showed that keeping a parent's cache when an override equals the parent's current value can reuse tax calculated before another input changed. Branches again drop inherited values whenever the parent knows an overridden variable. The itemizing branches add the claim of right method as an override only when some tax unit repays more than $3,000, so simulations without a qualifying repayment keep sharing the parent's cache. Adds the review's stale-parent sequence as a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
…th use tax Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
October 11, 2026 19:19
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A filer who repays income that was taxed in an earlier year under a claim of right gets federal relief under 26 U.S.C. 1341 when the repayment exceeds $3,000. PolicyEngine had no part of that section, so such a filer got no federal relief. This PR adds it, and wires the two North Carolina rules that depend on it.
Stacked on #10028 (branch
nc-claim-of-right-deduction), which adds the person-level inputclaim_of_right_repaymentand North Carolina's deduction. Review the commits after3b57231636that are not merges (the branch has since merged #10028's updated head andmain). Merge #10028 first.Federal:
claim_of_right_prior_year_tax_decrease, a tax-unit input: the decrease in the filers' chapter 1 tax for the earlier year or years that would result solely from excluding all the income they repaid (section 1341(a)(5)(B)). It is a return-level amount, because separately computed decreases for two spouses do not add up to the decrease from excluding both. It counts tax after credits, including the alternative minimum tax, and leaves out the net investment income tax and payroll taxes.claim_of_right_section_1341_eligible: the head's and spouse's repayments total more than $3,000 (gov.irs.deductions.itemized.claim_of_right.threshold).claim_of_right_credit_applies: whether tax is computed under section 1341(a)(5). The model derives it by computing federal income tax both ways.claim_of_right_deduction: the Schedule A line 16 deduction, used under section 1341(a)(4). It joinsgov.irs.deductions.itemized_deductions.claim_of_right_credit: the Schedule 3 line 13b credit, used under section 1341(a)(5). It joinsgov.irs.credits.refundable.North Carolina:
nc_claim_of_right_deductionis now zero when federal tax is computed under section 1341(a)(5) (G.S. 105-153.5(a)(2)d, last sentence).nc_claim_of_right_payment, with the tax-unit inputnc_claim_of_right_prior_year_tax_increase, the increase in the earlier year's North Carolina tax from including the repaid income (G.S. 105-266.2). North Carolina had no refundable credits in the model, so this PR addsnc_refundable_creditsandnc_income_tax_before_refundable_creditsin the pattern other states use.Eight states read the federal amounts this PR changes in ways their own laws or forms do not follow. The PR corrects each (see "Other states").
The law
26 U.S.C. 1341(a):
Section 1341(b)(1) and (b)(3), same page:
26 CFR 1.1341-1:
IRS forms and instructions:
North Carolina:
Design notes
claim_of_right_credit_appliesfollows the pattern oftax_unit_itemizes,id_receives_aged_or_disabled_creditandva_claims_refundable_eitc: two branches fix the method and computeincome_tax, and the main simulation takes the cheaper one. Each branch makes its own itemize-or-standard choice.tax_liability_if_itemizingis calculated first).get_override_branchgainsinherit_calculated=False, which the two method branches use. When some tax unit repays more than $3,000, the two itemizing branches (tax_liability_if_itemizing,tax_liability_if_not_itemizing) also take the simulation's method as an input next totax_unit_itemizes, so they never choose their own, whatever is calculated first and under both settings ofgov.simulation.branch_to_determine_itemization(review r2 found the setting-off case). Because the parent then already holds the method, those branches start from inputs too. When nobody qualifies the method is false everywhere, the extra input is left out, and the itemizing branches share the parent's cache as before. Branches still drop inherited values whenever the parent holds a value for an overridden variable: an equal value is not enough, because the parent's cache can predate a change to another input (review r3). Tests cover the review's household in every order under both settings, and r3's stale-parent sequence.income_tax, which is chapter 1 tax after credits plus the net investment income tax (chapter 2A) andunreported_payroll_tax. In the model neither addition depends on the repayment: the net investment income tax reads MAGI built from AGI and net investment income, and the deduction is below AGI. So the comparison ranks the methods as a chapter 1 comparison after credits would. Comparing after credits follows the IRS: the clawback FAQ says the taxpayer gets "whichever results in less tax (or a greater refund)", and Publication 525 says to "use the method (deduction or credit) that results in less tax". If the model later lets the repayment affect the net investment income tax, the comparison must move to chapter 1 tax.claim_of_right_repaymentdoes not joingov.irs.deductions.itemized.misc.sources.programs.yaml); the brackets and the standard deduction have no earlier values. So the federal list entry would change no supported year.ar_misc_deduction_*) and New York (ny_misc_deduction) readtotal_misc_deductions, and North Carolina's deduction reads the list for its "other miscellaneous deductions" term. Adding the repayment there would count it twice in North Carolina and put it into Arkansas's 2% pool, where I found no Arkansas authority for it. New York does keep small repayments in its 2% pool (2025 IT-196 instructions, PDF p. 16); that belongs with New York's own claim of right rules (see "Follow-ups").claim_of_right_deduction.claim_of_right_repaymentcovers only repayments not deducted in arriving at AGI, which reach North Carolina only through its itemized deduction. Under section 1341(a)(5) G.S. 105-153.5(a)(2)d allows no such deduction, so for these repayments the payment is term (i), the input.nc_eitcandnc_cdcceach replacednc_refundable_credits. They now add their credit to the baseline list, as State EITC contrib reforms delete baseline refundable credits (ID, AZ, NC, WV) #8775 did for Idaho, Arizona and West Virginia. Theirnc_income_taxoverrides are gone because the baseline now subtracts refundable credits. Thenc_cdccoverride addednc_use_tax, whichstate_use_taxalready counts; State EITC contrib reforms delete baseline refundable credits (ID, AZ, NC, WV) #8775 removed the same double count fromnc_eitc.Not modeled:
claim_of_right_repaymentexcludes them, so section 1341 for those repayments is out of scope.claim_of_right_credit_appliesas an input; the 2017 YAML case does.nc_claim_of_right_paymentsays so.Other states
A sweep of the other 41 income tax jurisdictions (reports in
~/reviews/us-hub/federal-1341/state-sweep/) asked which have their own claim of right rule and whether the new federal deduction and credit reach each state's calculation correctly. I then ran a differential on this branch: every state, with and without a $10,000 repayment, under each federal method (~/reviews/us-hub/federal-1341/state_flow_grid.json).Corrected in this PR. I fetched and read each source below. For Missouri, Oregon and Wisconsin the PR follows the worksheet each variable already cites; the statutes could support the other answer, and decision d1204 asks Max whether to switch (see "Readings for Max").
ca_itemized_deductions_pre_limitationmt_claim_of_right_deductionto Montana's miscellaneous deductions, 2021–2023az_itemized_deductions(see "Not modeled" for the AGI addition)itemized_deductions_less_saltks_itemized_deductionswi_itemized_deduction_credit_potentialignored_creditsignored_creditsalready follows: Form 1040 Line 22 minus Lines 27a and 29, Schedule 2 Part 1 Line 3 and Schedule 3 Part 2 Line 9; Schedule 3 line 13b is not subtracted. RSMo 143.171 speaks of tax "after reduction for all credits thereon"or_federal_tax_liability_subtractionreduction.applicableAfter these fixes, for the tested household (single, age 40, wages $60,000, charitable gifts $25,000, a $10,000 repayment, one per state, 2025) with no state input supplied, the repayment changes no state's income tax when the federal credit method is fixed, and none in Arizona, California, Kansas or Wisconsin when the deduction method is fixed. A property test checks both. That is a result for that household under these conventions, not a claim that section 1341(b)(3) binds the states. It does not hold for every household: Montana's elderly homeowner/renter credit counts the federal credit as household income (next paragraph), so a Montana filer eligible for that credit can see state tax change under the credit method.
Deduction flows left as they are. Under the federal deduction method the deduction reaches the states that start from federal itemized deductions or federal taxable income: AL (through its federal tax deduction), CO, DC, GA, IA, ID, KY, MD, ME, MN, MO, MS, NE, NM, ND, OK, OR, SC (to 2025), UT and VA. Three kinds of question remain, none introduced by this PR:
Credit flows left as they are.
mainnow counts federalincome_tax_refundable_creditsin Montana's elderly homeowner/renter credit household income (#9915), so the section 1341 credit counts there too. ARM 42.4.301(2)(b), which that variable cites, says "federal refundable tax credits received"; the credit is one. Idaho already read federal itemized deductions after the section 68 limitation (itemized_taxable_income_deductions), so the deduction reaches it as intended; #10023 added medical and health-premium coordination to that formula without changing this flow.Overlap with #10093. #10093 rewrites
or_federal_tax_liability_subtractionto the OR-17 worksheet's own credit list, which leaves out the section 1341 credit; the follow-up session also plans to replaceks_itemized_deductionswith Kansas's closed list. If #10093 lands first, this PR drops its Oregon edit and the Oregon YAML case takesincome_tax_before_refundable_credits: 4_000as its input (expected unchanged); if this PR lands first, #10093 drops it. The Kansas edit stays until the closed-list rewrite actually lands.Own rules, not modeled here. The sweep reports that these jurisdictions have their own claim of right credit, deduction or subtraction: AR, AZ, CA, CT, GA, HI, IA, ID, IL, IN, LA, MA, MD, MI, MN, NE, NJ, NY and New York City, OH, OK, OR, SC, VA, WI and WV (KY and PA uncertain). I verified Arizona's and Wisconsin's statutes myself; the rest are research leads with sources in the reports. See "Follow-ups".
Household on
mainvs this branch (2025, single, age 40)Computed at head
8f268ca794, before the review fixes, and not rerun at the final head (host held). The same households are YAML cases (integration.yamlcases 1 and 4; the last cases innc_claim_of_right_deduction.yaml), so CI checks their federal tax or credit and North Carolina tax at the final head.~/reviews/us-hub/federal-1341/evidence/households_{main,pr10028,branch}.json(scripthouseholds.pythere).mainisff479aa74a; #10028 is3b57231636.mainTests
YAML, with each expected value computed by hand from the cited source:
gov/irs/credits/claim_of_right/integration.yaml, 6 cases: Publication 525's Example 40 from the 2025, 2024 and 2018 editions; a standard-deduction filer for whom only the credit helps; a prior-year decrease above the year's tax (refunded); a joint return with a dependent. The 2024 and 2018 editions figure tax from the Tax Table, so the cases state both the rate-schedule amount PolicyEngine computes and the publication's figure.claim_of_right_credit_applies.yaml, 7 cases: equal tax under both methods keeps the deduction; one cent and 50 cents more decrease switch to the credit; exactly $3,000; no prior-year decrease; and two cases withgov.simulation.branch_to_determine_itemizationoff.claim_of_right_section_1341_eligible.yaml(5),tax_unit_claim_of_right_repayment.yaml(2),claim_of_right_credit.yaml(3).claim_of_right_deduction.yaml, 5 cases, including the 2017 overall limitation (method fixed, since 2017 federal tax is not modeled) and the 2026 limitation under section 68 as amended by P.L. 119-21.nc_claim_of_right_deduction.yaml(one in 2016 with the method derived),nc_claim_of_right_payment.yaml(3), 1 innc_income_tax.yaml.nc_eitcandnc_cdccreforms.tests/unit/test_claim_of_right_section_1341_properties.py(the Rest job'sremainingPython group). Why Python: the method is chosen in override branches, and the failure this file detects is a branch that disagrees with a fresh simulation. That depends on calculation order and on reusing a simulation across years, which a YAML case cannot control. The file also states cross-case relations (monotonicity across the threshold) over a 350-point grid (repayment × prior-year decrease × wages × charity) for 2025 and 2026, and runs one 51-jurisdiction simulation set for 2025. The fixed-method reference simulations run the same deduction formula, so they check the branch machinery and the lesser-of rule, not the deduction's arithmetic, which the YAML cases check against Publication 525.Invariants (stated and executed over the grids)
2a. Calculation order. Every reported variable is the same when a tax liability under one itemizing choice, or either method branch, is calculated first: over the grid with itemization branching on, and for the review's household with it on and off.
2b. Later years. A second year calculated on the same simulation equals a simulation of that year alone.
nc_income_taxequals tax before refundable credits minus the payment.Mutation check, at head
4526aed52f: six single-line mutants (the deduction ignoring the method, ties going to the credit, an inclusive threshold, the North Carolina bar dropped, the North Carolina payment ignoring the method, the credit counting dependents) each failed the property file. To repeat at the final head.Status. The tests run in this PR's CI, at its head. Locked local runs (
~/reviews/us-hub/scripts/heavy_run.sh) were not made at the final head: from 2026-10-10 Fleet ops held this session off tests and microsimulations while the shared host was saturated (load 170–330, 10–20 tickets queued for the heavy lock on 2026-10-11). Earlier direct runs in the worktree, at heads up to03439621bcand before the review fixes:va_itemized_deductions.yaml: 51 passed.test_claim_of_right_section_1341_properties.py: 16 passed at head4526aed52f(with the 51-jurisdiction check run for two years). It now has 33 tests: the check runs for 2025 only, and the order, later-year, Texas and stale-parent tests were added after the reviews.test_nc_claim_of_right_properties.py: 7 passed at head03439621bc.sum, Rest groups, non-refundable consumers, in-place writes, uprating placement) andtest_programs_registry.py: 820 passed, 10 skipped.Not yet repeated at the final head: the mutation check and the household evidence below. The YAML cases and property tests added after review r1 (California, Montana, the 2016 North Carolina case, the cent comparison, both itemization settings, the stacked contrib credits, the order and stale-parent tests) have not run anywhere but CI.
Cost
remaininggroup onmain(run 37926760594, as reported in Add North Carolina's claim of right repayment itemized deduction (G.S. 105-153.5(a)(2)d) #10028) has 2,151 tests: 1,315 s of test time, 24:05 wall clock, 12.8 GB max RSS on the 16 GB runner.remaininggroup will show the cost.test_nc_claim_of_right_properties.py. Its repayments up to $250,000 now trigger the method comparison: 2.18 s and 1,012 MB at Add North Carolina's claim of right repayment itemized deduction (G.S. 105-153.5(a)(2)d) #10028's head, 14.14 s and 1,841 MB with the comparison running. Those tests check the deduction's arithmetic, so they now fix the method as an input: 1.98 s and 1,040 MB.Microsimulation
Pending. The 2025 pair compares
main7dc07567eb(themainthis branch last merged) with this branch atde58d20b95, on the default dataset, from frozen snapshots of each, base and branch back to back under one acquisition of the shared heavy lock (driver~/reviews/us-hub/federal-1341/impact/pair.sh, queue-aware; dry-run checked). An earlier attempt was withdrawn while still waiting for the lock, at Fleet ops' request, because the host was saturated. It runs when the host allows: the US + core hub has offered to run it after hand-off, and the result is added here. If the head changes first, the snapshots are retaken.Expected: no record changes. #10028's four runs found
claim_of_right_repaymentzero on every record of the default dataset, and this PR's formulas return before branching in that case.Axiom
axiom: TheAxiomFoundation/rulespec-us#1657 queued (26 U.S.C. 1341 and N.C. Gen. Stat. 105-266.2), labelled
pe-parity, filed by the US hub under Max's standing go (d1142).main16a667719has nous/statutes/26/1341module and no module for G.S. 105-266.2.review_findingand companion tests from Publication 525. It also supplies the section 1341(a)(5) bar that the North Carolina (a)(2)d draft (d1165) leaves as an input.us/statute/26/1341andus-nc/statute/105/105-266.2is not verified; the issue lists that check.Follow-ups (not in this PR)
misc_deductioncounted twice before 2018 in Mississippi and Missouri; Alabama's miscellaneous deduction reading the suspended federal one; Oregon's subtraction falling by refundable credits its worksheet does not list; Montana'scasualty_loss_deductionprojected to every person in its miscellaneous list.Readings for Max
🤖 Generated with Claude Code