Repository navigation
Add the section 911(a)(1) exclusion to NIIT modified AGI (26 U.S.C. 1411(d)) - #9808
Merged
Merged
Conversation
26 U.S.C. 1411(d) defines modified adjusted gross income as AGI increased
by the foreign earned income excluded under section 911(a)(1), less the
deductions and exclusions section 911(d)(6) disallows for it. niit_magi
added only the estate and trust code H change, so a filer whose MAGI
crossed the threshold only through the exclusion paid no NIIT.
The add-back is a new tax-unit variable, niit_magi_section_911_addition,
defaulting to foreign_earned_income_exclusion. Section 1411(d) and the
Form 8960 Line 13 MAGI Worksheet (line 2a: Form 2555 line 42) leave out
the section 911(a)(2) housing exclusion and the housing deduction, which
foreign_earned_income_exclusion includes (Form 2555 lines 45 and 50), so
a filer with housing amounts can enter the worksheet amount directly.
niit_magi floors the addition at zero ("the excess (if any)").
Tests: YAML cases for the reproducer, a case below the threshold, a
partly binding excess, joint and separate filers, an entered addition
without housing amounts and a negative entered amount; Hypothesis
property and differential tests against the pre-change formula run as a
reform.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on #9808. foreign_earned_income_exclusion is Foreign Earned Income Tax Worksheet line 2c: Form 2555 lines 45 and 50 less the itemized deductions and exclusions disallowed for excluded income (line 2b). Section 1411(d)(2) subtracts only deductions taken into account in computing AGI, so the default addition is exact only with no housing amounts and nothing on line 2b: housing makes it too high, line 2b itemized deductions too low. The documentation said it could only overstate. Also: a YAML case restoring line 2b itemized deductions through an entered addition; surviving spouse ($250,000) in the property tests; tolerance scaled by the compared amounts only; the 2025 Form 8960 worksheet page in niit_magi's references. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Line 2b exclusions disallowed for the 911(a)(1) amount are also subtracted under section 1411(d)(2), so an empty line 2b is enough for the default to be exact but not required. Spell out the line 44 premise in the line 2b YAML case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Handing this PR to the US + core hub.
|
MaxGhenis
added a commit
that referenced
this pull request
Oct 5, 2026
#9808 adds the section 1411(d) add-back with a separate, overridable section 911(a)(1) amount, which is more precise than adding the whole foreign_earned_income_exclusion input. Restore niit_magi and its tests to main and drop the NIIT assertion from the property test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9808 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 3 -1
Lines 76 35 -41
Branches 2 0 -2
=========================================
- Hits 76 35 -41
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:
|
Contributor
Author
|
Merged by the US + core hub on its merge gates. Audit:
|
MaxGhenis
added a commit
that referenced
this pull request
Oct 6, 2026
MaxGhenis
added a commit
that referenced
this pull request
Oct 6, 2026
Conflicts resolved keeping both sides: - student_loan_interest_ald_magi: #9801's tax_unit_non_dep_add (with filer_amounts_recorded_on_dependents) for the tax unit deduction sum, and this branch's section_911_excluded_income add-back. - foreign_earned_income_exclusion documentation: both notes (modified AGIs add back section_911_excluded_income; NIIT adds back only the section 911(a)(1) part, niit_magi_section_911_addition). taxable_ss_magi and test_ald_determinism merged cleanly with both changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
added a commit
that referenced
this pull request
Oct 7, 2026
…AGIs (student loan interest and 11 siblings) (#9817) * Figure student-loan MAGI as 26 U.S.C. 221(b)(2)(C) says Section 221(b)(2)(C) defines modified AGI as adjusted gross income determined "(i) without regard to this section and sections 85(c), 911, 931, and 933, and (ii) after application of sections 86, 135, 137, 219, and 469". The model got three parts wrong: - Section 931 (specified_possession_income) was subtracted like any other above-the-line deduction. It is now in excluded_alds with section 933. - Section 911: income inputs are net of foreign_earned_income_exclusion, and nothing added it back. The formula now adds it, split between spouses like the tax unit's deductions. - Unemployment compensation was dropped entirely (excluded_gross_income_ sources), a misreading of "without regard to section 85(c)": only the 2020 exclusion is disregarded, so all of it counts. The formula reads the untaxed amount, which also avoids the cycle through AGI that the old exclusion side-stepped. The parameter is removed. excluded_alds also follows the amendment history: section 222 until 2020 (Pub. L. 116-260) and section 199 from 2005 through 2017 (Pub. L. 108-357, Pub. L. 115-97). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Phase out on AGI plus income excluded under sections 911, 931 and 933 Ten provisions phase out on "adjusted gross income increased by any amount excluded from gross income under section 911, 931, or 933": 24(b)(1) (CTC, and the 2021 ARPA phase-out through Schedule 8812 line 3), 25A(d)(2) (education credits), 25B(e) (saver's credit), 25E(b)(3) and 30D(f)(10)(C) (clean vehicle credits), 151(d)(5)(C) (senior deduction), 163(h)(4)(C) (car loan interest), 164(b)(7)(B) (SALT cap), 224(b)(2)(B) (tips) and 225(b)(2)(B) (overtime). Only the senior deduction added the exclusions back; the rest read plain AGI. agi_plus_section_911_931_933_exclusions computes the amount once (Schedule 1-A line 3), and every one of them reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add back section 911 in the Social Security, NIIT and IRMAA MAGIs - Taxable Social Security, 26 U.S.C. 86(b)(2)(A): determined without regard to section 911. The revoked-deductions list already covered sections 931 and 933; the 911 exclusion is netted out of the income inputs, so taxable_ss_magi adds it back. - Net investment income tax, 26 U.S.C. 1411(d): adds back the section 911(a)(1) exclusion (Form 8960 line 13 worksheet). The model's one exclusion input also holds the housing amounts, which the worksheet leaves out; niit_magi documents that. - Medicare IRMAA, 42 U.S.C. 1395r(i)(4)(A): determined without regard to IRC sections 135, 911, 931 and 933, plus tax-exempt interest. All four are added back, for both the modeled and the provided lag years. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Test the modified AGI add-backs on random households Differential: on every return, student-loan MAGI (built from gross income sources) equals AGI plus the student loan interest deduction, the section 911, 931 and 933 amounts and any unemployment compensation section 85(c) excluded; the shared modified AGI equals AGI plus the three amounts. Shifting income into an excluded category at otherwise fixed AGI raises student-loan MAGI and taxable_ss_magi by exactly the amount shifted, never raises the student loan interest deduction, and moves every phase- out the shared modified AGI feeds in one direction only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Leave the NIIT modified AGI to #9808 #9808 adds the section 1411(d) add-back with a separate, overridable section 911(a)(1) amount, which is more precise than adding the whole foreign_earned_income_exclusion input. Restore niit_magi and its tests to main and drop the NIIT assertion from the property test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Address review r1: Form 2555 amounts, clean vehicle prior year, IRMAA 135 - Modified AGIs add back section 911 in full: Form 2555 lines 45 and 50 (Schedule 8812 line 2b, Schedule 1-A lines 2b and 2c, Pub. 970 Worksheet 4-1, Form 8936 lines 1c and 1d, Form 8962 Worksheet 1-1 line 3). New input section_911_excluded_income carries that amount; it defaults to foreign_earned_income_exclusion, which stays the section 911(f) stacking amount net of disallowed deductions. The shared modified AGI, student-loan MAGI, Social Security MAGI, IRMAA MAGI and the Medicaid/ACA modification list use it. - Clean vehicles: 30D(f)(10) and 25E(b) allow the credit when the lesser of this year's and the preceding year's modified AGI is within the limit. New inputs clean_vehicle_credit_prior_year_magi (defaults to this year's modified AGI) and clean_vehicle_credit_prior_year_filing_status (defaults to this year's status); each year is tested against its own status's limit (26 CFR 1.30D-4(b)(3), 1.25E-1(c)(3)). - IRMAA keeps adding back the section 135 exclusion wherever it is recorded, because AGI deducts it there: a bond in a child's name does not qualify (135(c)(1)(B), Form 8815), so an amount on a dependent is the filer's. A filer-only add-back would leave the dependent-recorded deduction in AGI and give 99,000 for 100,000 of wages. - Tests: the reviewer's reproductions as YAML cases, Hypothesis invariants for the gross and net section 911 amounts, the lesser-of test and the IRMAA identity on provided and computed AGI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sum IRMAA add-backs over the members AGI counts 42 U.S.C. 1395r(i)(4) reads the beneficiary's own return. After #9801, adjusted gross income sums person-level deductions over the head and spouse, plus every member for gov.irs.ald.filer_amounts_recorded_on_ dependents. The IRMAA MAGI now sums its person-level add-backs with the same rule (tax_unit_non_dep_add): - Tax-exempt interest counts for the head and spouse only. A dependent's interest is on the dependent's own return, like the rest of the dependent's income; main summed it over every member. - The section 135 exclusion counts for every member, because #9801 lists it: a bond in a child's name does not qualify (135(c)(1)(B), Form 8815), so an amount recorded on a dependent is the parent's exclusion, and AGI deducts it. Head and spouse only would give 99,000 for a parent with 100,000 of wages and 1,000 recorded on the child. - The 2015-2016 fallback applies the same rule with the benefit year's roles, reading stored values only. Tests: YAML cases for a dependent's tax-exempt interest in a modeled and an unmodeled lag year; the Hypothesis IRMAA identity now draws spouse and dependent tax-exempt interest and sets lag-year ages in both paths (age defaults to 40, which would make a child a second adult). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Account for SALT phaseout in section 911 interaction properties Section 164(b)(7)(B)(iv) and the 2025 Schedule A worksheet add Form 2555 lines 45 and 50 to SALT MAGI. An exclusion can reduce itemized deductions even when the choice to itemize holds, so fixed taxable income was an invalid premise. Preserve equality for election changes and unchanged deductions, assert nondecreasing taxable income for same-choice exclusion pairs, and reuse the grid simulation for a hand-calculated SALT regression and independent form comparisons. Production formulas are unchanged. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
niit_magireturned adjusted gross income plus the estate and trust code H change and never added the amount excluded under section 911. 26 U.S.C. 1411(d) defines modified adjusted gross income as AGI "increased by the excess of— (1) the amount excluded from gross income under section 911(a)(1), over (2) the amount of any deductions (taken into account in computing adjusted gross income) or exclusions disallowed under section 911(d)(6) with respect to the amounts described in paragraph (1)" (repeated in Treas. Reg. 1.1411-2(c)(1)).Reproducer (2025, single, Texas, age 45): wages $150,000, qualified dividends $50,000, tax-unit
foreign_earned_income_exclusion$100,000.adjusted_gross_incomeniit_maginet_investment_income_taxEarned income only, not housing
Section 1411(d)(1) cites section 911(a)(1), the foreign earned income. Section 911(a)(2), the housing cost amount, is a separate exclusion. The 2025 Form 8960 Line 13 MAGI Worksheet (instructions, PDF page 23) matches: line 2(a) is "your foreign earned income exclusion (from line 42 of Form 2555)", less line 2(b), "the deductions reported on line 44 of Form 2555 allocable to your foreign earned income exclusion". Neither the housing exclusion (Form 2555 line 36) nor the housing deduction (line 50) is added back. The 2024 worksheet is the same.
The model can't separate them on its own.
foreign_earned_income_exclusionis line 2c of the Form 1040 Foreign Earned Income Tax Worksheet (2025 instructions, p. 37): Form 2555 lines 45 and 50 (line 45 is lines 36 + 42 − 44), less line 2b, "itemized deductions or exclusions you couldn't claim because they are related to excluded income". So the add-back is a new tax-unit variable,niit_magi_section_911_addition:max(0, foreign_earned_income_exclusion). For a filer with no housing exclusion, no housing deduction and nothing on worksheet line 2b, it equals the section 1411(d) amount. Housing amounts make the default too high. Itemized deductions on line 2b make it too low, since section 1411(d)(2) subtracts only deductions "taken into account in computing adjusted gross income". The variable's documentation says so.estate_income_niit_magi_adjustment(a formula default that a user can override).niit_magiaddsmax(0, niit_magi_section_911_addition): section 1411(d) adds "the excess (if any)", so a negative entered amount adds nothing.foreign_earned_income_exclusion's documentation now points to the new variable.Invariants
They hold for every input and are tested in
policyengine_us/tests/test_niit_section_911_magi.py(Hypothesis plus a fixed grid, 2018, 2022, 2025 and 2026, all five filing statuses):niit_magi,net_investment_income_tax,income_tax_before_refundable_creditsandincome_taxarenp.array_equalto the pre-change formula. That formula runs as a reform on the same households, so this is a differential test of old against new code. A household without an exclusion also gets identical results whatever the others in its batch exclude.niit_magiandnet_investment_income_taxnever fall as the excluded amount rises (exact; float rounding is monotone).YAML (
niit_magi.yaml,net_investment_income_tax.yaml): the reproducer; a case below the threshold (MAGI 190,000, tax 0); a case where the MAGI excess binds (1,140); a joint return pushed over the $250,000 threshold only by the add-back (1,520); a separate return ($125,000 threshold, 760); an entered addition without housing amounts (760 rather than the default's 1,900); an entered addition that restores line 2b itemized deductions (MAGI 300,000 where the default gives 295,000); the add-back alongside code H; and a negative entered amount. On the pre-change formula, 9 of the 10 new YAML cases fail (all but the negative-amount case) and so does the property test.Local runs (Python 3.14, dev extras installed,
-rsshows nothing skipped): the two NIIT YAML files (32 cases) pass, and the new property test file, the dependent and estate NIIT invariant tests andtest_section_911_tax_stacking.pypass (49 tests, about 2 minutes).make formatis clean. CI runs the full YAML shards.Microsimulation impact
I ran the default dataset (
populace-us-2024-spm-20260909, checksum-verified by the loader) twice in one process, this branch against the pre-changeniit_magias a reform, for 2025 and 2026. The dataset has noforeign_earned_income_exclusioncolumn: none of its 18 tax-unit or 318 person columns matchesforeign,911,housing,possessionorpuerto(read from the cached h5 tables). The run confirms the variable and the new addition are 0 for all 79,729 tax units.niit_magi,net_investment_income_tax,income_tax_before_refundable_creditsandincome_taxare bit-identical:niit_magi,net_investment_income_tax,income_tax_before_refundable_credits,income_tax($2,417.929bn)niit_magi,net_investment_income_taxThe 2026 income tax comparison wasn't run: the process was killed in an app restart after the 2026 MAGI and NIIT lines. The only baseline reader of
niit_magiisnet_investment_income_tax, so no 2026 income tax change is expected, but that figure is not measured.Run output (script: microsim_impact.py, default dataset, this branch vs the pre-change formula as a reform)
The fix changes household calculations that enter a section 911 exclusion, and microsimulation once the data carries one.
Overlap check
test_section_911_tax_stacking.py, so the new properties are in their own file.niit_magiand NIIT, and pick up the fix.Other federal MAGI definitions that add back section 911 amounts (CTC §24(b)(1), student loan interest §221(b)(2)(C), §86, §25A, §25B, §§224, 225 and 163(h)(4)) are missing it too. That work is a separate follow-up with a reproducer for each. The premium tax credit's
aca_magialready adds the exclusion. The model has no §219(g) IRA phase-out to fix.Axiom
us:statutes/26/1411#niit_modified_adjusted_gross_incomeencodes the add-back, but the §911(d)(6) rule it imports is versioned only from 2026-01-01. On the pinned engine (89571cc2), these tests' 2025 cases fail with "no formula version at 2025-01-01"; the same cases dated 2026 pass with the expected values. TheAxiomFoundation/rulespec-us#1495 is dispatch-ready, with the verbatim law, areview_findingand these companion cases. The signed re-encode needs approval for a billed run.axiom: us/statute/26/1411/d TheAxiomFoundation/rulespec-us#1495 queued
🤖 Generated with Claude Code