Repository navigation
Add excluded foreign earnings to Massachusetts gross income - #9976
Merged
Merged
Conversation
M.G.L. c. 62 s. 2(a)(1)(C) lists "Earned income from foreign sources excluded under section nine hundred and eleven of the Code" among the items added to federal gross income. ma_gross_income subtracted the federal stacking amount instead, so a $10,000 exclusion left Massachusetts gross income $20,000 too low. The new TaxUnit input ma_foreign_earned_income_exclusion_addback is the section 911(a) amount actually excluded (Form 2555 line 43, before line 44 allocable deductions, without the line 50 housing deduction). It defaults to foreign_earned_income_exclusion, which is exact when Form 2555 lines 44 and 50 and Foreign Earned Income Tax Worksheet line 2b are zero; an entered amount, including zero, replaces the default. The restored wages reach Part B through its residual definition in s. 2(b)(2); Parts A and C are unchanged. Adds the hub spec's five YAML cases plus explicit-zero, non-MA and zero-floor controls, and property/differential tests against the old formula. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… floor The zero-floor property only checked that gross income is non-negative, zero at the floor and monotone in the addback. The formula before this change satisfies all three, so the test passed on main. It now also checks that where federal gross income less the Massachusetts exclusions is negative but the addback lifts it above zero, gross income equals their sum, which main gets wrong (it returns zero). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…convention Review follow-ups: - The addback defaulted to foreign_earned_income_exclusion through `adds`, which passed a negative entry straight through. Every federal reader of that input floors it at zero (worksheet line 2c: "If zero or less, enter -0-"), so the default is now max(0, foreign_earned_income_exclusion). A YAML case covers a -5,000 entry. - The documentation now states that other income inputs must already exclude the line 43 amount, says the default equals line 43 when line 50 equals line 44 plus line 2b (not "only when" all are zero), keeps line 2b's "or exclusions", and cites the 2025 Form 1 instructions (line 3). - The property tests release the reformed system and cached results when the module ends, as #9643 does, and the Hypothesis test is derandomized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as draft
October 8, 2026 23:18
MaxGhenis
marked this pull request as ready for review
October 9, 2026 06:24
MaxGhenis
marked this pull request as draft
October 9, 2026 06:33
MaxGhenis
marked this pull request as ready for review
October 9, 2026 10:02
Contributor
Author
|
US + core hub merge audit, us#9976 at
|
MaxGhenis
added a commit
that referenced
this pull request
Oct 12, 2026
…0022) Follow-ups from the r5 review of #9976: - 26 U.S.C. 6012(c): the filing add-back is Form 2555 line 43 (foreign_earned_income_exclusion_gross) when leaf inputs apply, with the legacy foreign_earned_income_exclusion fallback, floored at zero. - One Form 2555 leaf check (has_section_911_leaf_inputs) and one line 43 helper (section_911_gross_exclusion) replace hand-written leaf lists. - elects_section_911_exclusion docstring: the housing-deduction-only bar rests on the IRS instructions, not section 24(d)(3). 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.
Massachusetts adds back earnings excluded under IRC §911 under M.G.L. c.62 §2(a)(1)(C). This change restores the gross exclusions to Massachusetts gross income and its Part B residual. It preserves the loss adjustment and main's filer-only Social Security, state/local refund and exempt public-pension subtractions from #9699. Main's #9954 capital-loss allocation is also preserved: capital losses offset the applicable capital schedules, while the foreign-income add-back enters Part B. The independent property-test oracle now derives capital income from the raw fixture inputs rather than subtracting Part A and C from Massachusetts gross income; all existing assertions, generated households and differential coverage remain.
Max's d1051 ruling applies the 2026-10-07 principle, “make inputs as leaf-nodey as possible.” The TaxUnit/USD/YEAR inputs sum both spouses' forms:
foreign_earned_income_exclusion_amountforeign_housing_exclusionforeign_earned_income_exclusion_allocable_deductionsforeign_housing_deductionforeign_earned_income_exclusion_disallowed_deductionsforeign_earned_income_exclusion_grossis line 43 = lines 36 + 42. Massachusetts uses its nonnegative value whenever applicable leaves were supplied, including carried inputs; explicit Massachusetts overrides still win, including zero. No applicable leaves retains the nonnegative legacy stacking-amount fallback, which cannot reconstruct the gross exclusion.Main's #9817 separate
section_911_excluded_incomeis preserved and derives Form 2555 lines 45 + 50 asgross - line44 + line50when applicable leaves are supplied. It preserves a signed line 45 and does not subtract worksheet line 2b. Its explicit overrides and no-leaf fallback remain available. Federalforeign_earned_income_exclusionretains worksheet line 2c:max(0, gross - line44 + line50 - worksheet2b), with explicit legacy overrides and the original no-leaf carry/uprating behavior. Form 2555, Schedule 1-A, federal worksheet.The shared
elects_section_911_exclusion(tax_unit, period)helper recognizes positive legacy stacking amounts, the separatesection_911_excluded_incomeamount, or any Form 2555 leaf amount. It supplies five election tests: the refundable CTC bar, federal EITC eligibility, the state EITC helper, New Jersey's childless age route, and filing propensity. This keeps the bars effective for a housing-exclusion-only filer, a leaf-only caller, or positive Form 2555 amounts whose deductions or explicit aggregate overrides reduce worksheet line 2c to zero. Section 911(a) permits separate earned-income and housing exclusion elections. The Schedule 8812 instructions, Line 13 and Part II-A, and Publication 596, Rule 5, restrict Form 2555 filers; the Form 2555 instructions, “Choosing the Exclusion(s),” expressly cover either exclusion or the housing deduction.Worksheet B retains main's structure: it reads
refundable_ctc_barred_by_section_911_exclusion, preserving explicit overrides of that variable and its existing year rules. The section 24(d)(3) bar begins in 2015 and remains disabled in the model's fully refundable year, 2021; Worksheet B's fully refundable-year exception is also preserved. The model still has no independent Form 2555 filing flag for filings with every amount zero.US
Simulationrejects ambiguous multi-tax-unit JSON histories with a clear error before Core fills omitted inputs with zeros. Core has whole-array provenance, so an aggregate override bypasses formulas for all units and cannot safely resolve mixed representations per unit. Where both aggregates and leaves are supplied, units must have matching aggregate and combined leaf input periods. A given leaf component must also have matching periods among units supplying that component; wholly absent components remain allowed. Different values, different leaf components, explicit zeros, and uniform aggregate overrides remain supported. The check conservatively rejects inconsistent future histories before calculations. Use consistent input coverage or calculate those units separately. Raw CoreSimulation/SimulationBuilderbypass the US constructor and must continue to use consistent input coverage; dataset and setter arrays represent all entities explicitly.AGI inputs retain their existing reported/net definitions. Form 2555 line 45 feeds Schedule 1 line 8d; the housing deduction on line 50 belongs on Schedule 1 line 24j. These leaves supply stacking and MAGI adjustments and do not subtract those amounts from AGI again. NIIT's legacy fallback remains approximate when housing/deduction components differ; its independent
niit_magi_section_911_additionremains available.Validation and invariants:
default_input_period. The new Python batch file exercises JSON/Core provenance unavailable through the YAML runner and routes once to the existing Restremaininggroup. No runner, concurrency or CI-job changes are made.Historical regression evidence from the earlier approved-head work was captured before each formula/guard fix:
687ac6668d687ac6668dThe earlier main merge also exposed two stale Massachusetts property-test expectations under #9954 (2 failed, 8 passed). Correcting the independent capital-income oracle, while retaining main's model, produced 10 passing cases; a focused two-tax-unit YAML regression also verifies that capital losses do not absorb the foreign-income Part B add-back. Failure evidence is retained outside the committed source.
Validation of the conflict repair at merge commit 0aabd69:
make format, Ruff checks, andgit diff --checkpassed.The following table records the required single-file validation of the repaired head. All invocations passed on macOS/Python 3.13.9/Core 3.32.15. Elapsed times include fresh-process startup, model construction, and shutdown.
Historical approved-head validation at
72adfa3f6e88457070de2f15109309186f33c915reported 111 collected tests passing (46 Python and 65 YAML cases), including focused Massachusetts partner signature coverage whose contract expectations were unchanged. Those results describe the earlier head and do not validate this conflict repair. The earlier Linux CI run 37618140995 used headb859c5b5ec724c5b7e84720722aeae28c114b949and likewise does not validate the repaired head. Exact-head CI must pass before merge.CI cost: this repair adds 14 policy YAML regressions and retains the existing Python coverage and routing. The batch file exercises JSON/Core input provenance that YAML cannot represent; the Python properties and differentials retain their independent invariants. Local per-file elapsed times include fresh interpreter/model setup and process shutdown. Peak memory was not measured in this repair. Historical Rest
remainingLinux CI run 37618140995, artifact 11485104048, atb859c5b5ec724c5b7e84720722aeae28c114b949measured 17:01.36 elapsed and 11,062,232 KiB peak RSS. Neither those historical group results nor passing local files establish combined timing or memory use at the repaired head.Impact: the historical hub microsimulation below compared main at
8b8ae4cc12with approved head72adfa3f6efor 2025 and 2026, and every compared output was identical. No microsimulation has run at the repaired head; the hub will handle that validation.Open follow-ups and HOLD:
axiom: TheAxiomFoundation/rulespec-us#1541 queued
Partner contract files and expected outputs are unchanged by this repair. Main at
0a8c3c2c43e12bef720aba38dbb33b2acdada1fbis integrated in merge commit 0aabd69, retaining approved PR head72adfa3f6e88457070de2f15109309186f33c915in its history. The conflict is resolved by preserving main's Worksheet B consumer and sharing this PR's widened section 911 election detection across all five election tests. The PR is draft for this repair round. This updates the PR branch with a merge commit and a fast-forward push, without rebasing, rewriting history, or merging the PR.Hub microsimulation impact (current head)
A real microsimulation on the default dataset, main at the merge base
0a8c3c2c43against this PR's head0aabd69bfb, for 2025 and 2026. The runs went one at a time under the shared heavy-job lock. Sums are weighted.foreign_earned_income_exclusionma_gross_incomema_part_a_gross_incomema_part_b_taxable_incomema_income_taxeitcrefundable_ctcstate_income_taxincome_taxhousehold_net_incomehousehold_benefitsThe zero is by construction. The default dataset has no foreign earned income or Form 2555 inputs, so no record elects section 911: the Massachusetts add-back, the refundable CTC bar and the EITC denial all leave every record unchanged. The change reaches only household calculations that enter Form 2555 amounts, and this PR's YAML and property tests cover those.
Comparison files are in
fixes/9976-impact/on the hub host.Historical hub microsimulation impact (approved head
72adfa3f6e)This historical real microsimulation used the default dataset, comparing main at merge base
8b8ae4cc12against approved PR head72adfa3f6e, for 2025 and 2026. It predates this conflict repair and does not establish its impact. Sums are weighted.foreign_earned_income_exclusionma_gross_incomema_part_a_gross_incomema_part_b_taxable_incomema_income_taxstate_income_taxincome_taxhousehold_net_incomehousehold_benefitsThe zero is by construction: the default dataset carries no foreign earned income or Form 2555 inputs, so
foreign_earned_income_exclusionis $0 on both sides and the Massachusetts add-back has nothing to add back. The change reaches only household calculations that enter Form 2555 amounts; the YAML and property tests in this PR cover those.