Skip to content

Count every taxed cash source in SPM market income - #10663

Merged
MaxGhenis merged 7 commits into
mainfrom
spm-market-income-gross-income-sources
Nov 7, 2026
Merged

MaxGhenis merged 7 commits into
mainfrom
spm-market-income-gross-income-sources

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Part of #9919. #10669 fixes the mirror case, Alaska's energy relief payment, which SPM resources count and federal gross income leaves out, and closes the issue. #10573 handled the Alaska Permanent Fund Dividend, so this PR leaves the dividend alone.

The bug

spm_unit_net_income adds person market_income and subtracts spm_unit_taxes, which include federal income tax on every source in gov.irs.gross_income.sources. On main, five of those sources never reach market_income, so SPM resources lose the tax on them without gaining the income. household_market_income already counts two of them, partnership_s_corp_income and farm_rent_income, so for those two the household and SPM totals disagree by the whole amount.

For a Tennessee filer with $500,000 of wages, $287,010 of partnership income changes these 2026 totals, from a pair of Simulation runs of the same household on each tree:

spm_unit_market_income spm_unit_taxes spm_unit_net_income household_net_income
main +0.00 +102,911.69 −102,911.69 +184,098.31
This PR +287,010.00 +102,911.69 +184,098.31 +184,098.31

What each source does now

#9919 suggests a treatment for each source and asks for a decision on the four it marks for review. In the Census SPM technical documentation, section 4.3.1 covers noncash benefits and section 4.3.2 the expenses the SPM subtracts from resources. The documentation never mentions partnership, S corporation or farm rental income, capital gains, Form 4797 gains or disability benefits. So I started from the cash income Census counts, money income in the CPS subject definitions, and added one rule: SPM resources count every cash source in federal gross income, with its losses where it has them, since spm_unit_taxes subtracts the tax on it either way.

Source of federal gross income Now Why
partnership_s_corp_income Counts, with losses Census nonfarm self-employment income covers net income "from one's own business, professional enterprise, or partnership". Census doesn't name S corporations, and PolicyEngine holds their income in this same Schedule E variable.
farm_rent_income Counts, with losses Census lists "Rents, royalties, and estates and trusts". rental_income already counts.
non_sch_d_capital_gains Counts Census money income leaves out capital gains, but PolicyEngine's market_income already counts capital_gains, so it now counts capital gain distributions with them.
other_net_gain_gross_income (Form 4797) Counts, with losses, through a new other_net_gain_person Same reason as non_sch_d_capital_gains.
taxable_disability_benefits disability_benefits counts in full Census lists "Disability benefits" as a source of money income, with no split by taxability. #9919 didn't list this source; invariant 1's coverage test found it.
taxable_dependent_care_benefits Already counts employment_income holds these benefits. irs_employment_income subtracts them through pre_tax_contributions, and the taxable part comes back through this source.
debt_relief Stays out Discharged debt brings no cash. household_market_income keeps it, and invariant 2 pins the difference.
taxable_roth_conversions Stays out A conversion moves savings between retirement accounts.
salt_refund_income Stays out The refund returns tax from an earlier year, and the SPM subtracts each year's tax as the family owes it.

I recorded this rule and the three exclusions in docs/spm.md.

Other readers of market_income and household_market_income

Reader Effect of the wider definition Check
nd_renters_refund_income Counts the new sources N.D.C.C. 57-02-08.1(5)(c) counts income "from all sources" and leaves out "any amount excluded from income by federal or state law". The wider definition fits, so main understates income here. This PR subtracts the disability benefits federal law excludes (IRC 104(a)(3)).
wa_eceap_family_income Counts the new sources Form DCYF 05-006 (Rev 03/2025), section 9 asks for a tax return and lists "Disability income, including SSI" and "Self-employment net income".
mo_snc_countable_income Counts the new sources Missouri's SNC manual, section 0610.005.00, counts "gross income from all sources (SSI, OASDI, earned, etc.)".
adult_earnings_index Ranks adults by the wider income marginal_tax_rate simulates only the first simulation.marginal_tax_rate_adults adults in this rank. No law governs the rank.
cbo_household_market_income Follows household_market_income It starts from that variable and adds and subtracts its own lists, none of which holds the new sources.

Item 11 of the North Dakota Tax Commissioner's guideline lists insurance proceeds for illness or injury as not income. Federal law taxes wage-replacement benefits from employer-paid plans (IRC 105(a)), so the statute counts them, and the model follows the statute (source_conflicts/candidates.yaml: us-nd:renters-refund-insurance-proceeds). Neither source says whether a business loss offsets other income, so the model nets losses against other income by convention.

2026 national impact

I ran the 2026 microsimulation on the pinned Microcosm release, hf://datasets/policyengine/populace-us/populace_us_2024.h5@populace-us-2024-spm-20260909, at main's e53b4260 and at this PR's 5a6ed8e1. The commits after 5a6ed8e1 change only tests and source_conflicts/candidates.yaml. I haven't rerun at main's current 53666d3a, which this branch now includes.

Main This PR Change
SPM poverty, everyone 14.521% 13.748% −0.773 pp
Children 18.758% 17.558% −1.200 pp
Seniors 11.295% 10.899% −0.396 pp
Deep SPM poverty 3.365% 2.989% −0.376 pp
People in SPM poverty 50.197M 47.525M −2.673M

In these runs, 3.413 million people leave SPM poverty and 0.740 million enter it, including 1.073 million children who leave and 0.137 million who enter. Everyone who enters belongs to a unit with a partnership, S corporation or farm rental loss, which now counts against SPM resources as it already does against household income. In deep poverty, 1.919 million people leave and 0.620 million enter. Poverty falls most in Colorado (−2.82 pp), Indiana (−2.54 pp) and Tennessee (−2.41 pp), and rises in four states: Idaho (+1.16 pp), South Carolina (+0.55 pp), Michigan (+0.21 pp) and Nevada (+0.01 pp).

Total, $ billions Main This PR Change
spm_unit_market_income 18,195.040 19,306.001 +1,110.961
household_market_income 19,269.927 19,306.001 +36.073
spm_unit_net_income 14,653.017 15,763.978 +1,110.961
household_net_income 17,161.680 17,197.753 +36.073
spm_unit_taxes 4,168.255 4,168.255 0
irs_gross_income 19,282.744 19,282.744 0
adjusted_gross_income 18,986.027 18,986.027 0
income_tax 2,595.131 2,595.131 0

The four sources the file holds sum to the SPM change: $1,070.662 billion of partnership and S corporation income ($1,156.725 billion of income less $86.063 billion of losses), $4.226 billion of farm rental income, $13.402 billion of capital gain distributions that filers report without Schedule D and $22.671 billion of disability benefits. Household market income rises by only the last two, which it didn't count on main, and the SPM and household totals now agree at $19,306.001 billion. Taxes and gross income don't move, since federal gross income already counts every source.

Program reading market_income Main This PR
North Dakota renter's refund paid $5.734M $5.734M
North Dakota renter's refund income $42.374B $46.018B
Washington ECEAP family income $563.492B $588.682B
Washington ECEAP eligible children, weighted 68,280 33,863
Missouri SNC countable income $311.580B $329.149B
Missouri supplemental payments $0 $0

Three child records in two Washington families, each weighted about 11,470, account for nearly all of the 34,417 fall in ECEAP's weighted count. Since July 2025, DCYF has tested family income against 36% of state median income, $58,177 for these families. One family has no countable income on main and $74,426 of partnership income on this branch. The other has $52,936 on main and $53,753 of partnership income on top. DCYF's form asks for self-employment net income, so the business income belongs in the test. Only 49 sample records stand behind the state's eligible children, so two families can halve the count.

Two parts of this PR move no national total. The pinned file holds no other_net_gain, and its disability_benefits and taxable_disability_benefits both total $22.671 billion, so it has no federally excluded disability benefits for North Dakota to subtract. Household tests cover both.

Invariants

These hold for every input. policyengine_us/tests/test_household_spm_resource_parity.py checks invariants 1 and 2 exhaustively over the parameter lists and invariant 6 in every state. Its Hypothesis tests check invariants 3 to 5 on 25, 25 and 10 random cases plus pinned ones, and draw invariant 4's states from all 51. The tests for invariants 1 to 4 fail on main.

  1. Coverage. Every source in gov.irs.gross_income.sources, in any year block, maps to a resource variable that SPM resources add, or to an exclusion the test lists with its reason. No mapping goes stale.
  2. List parity. gov.household.market_income_sources and market_income differ only by debt_relief.
  3. Dollar for dollar. A dollar of any added source, or a dollar of loss where the source has losses, moves spm_unit_market_income and household_market_income by one dollar.
  4. No net loss. With no means-tested benefit in play, a dollar of cash income raises spm_unit_net_income by at least zero and at most one dollar. On main this fails by $102,911.69 in the Tennessee example.
  5. Form 4797 conservation. The head and spouse together hold a tax unit's whole other_net_gain, with its sign, for single and joint units with and without dependents. other_net_gain_gross_income holds its positive part, as on main.
  6. Household and SPM reconciliation, the file's existing differential test, still holds for one person in every state.

YAML tests pin market_income, household_market_income, spm_unit_market_income, spm_unit_net_income and nd_renters_refund_income, with expected values from the arithmetic of each case.

Test cost

I ran each file alone on one process on a shared, loaded host. On main e53b4260, the 57 tests in test_household_spm_resource_parity.py took 436.9 s from start to finish (324.5 s inside pytest) and 152.1 s of user and system CPU, and peaked at 2.10 GB. At 5a6ed8e1, its 60 tests took 472.2 s (387.2 s inside pytest) and 178.2 s of CPU, and peaked at 2.16 GB. The Form 4797 test that fc40c7a5 adds took 19.4 s inside pytest on its own. The new YAML cases run in seconds.

axiom: TheAxiomFoundation/rulespec-us#2042 queued (North Dakota's income definition). The SPM and household income lists measure income for the microsimulation and encode no law: n/a. rulespec-us has no module for Washington ECEAP or Missouri SNC income: n/a for this PR.

🤖 Generated with Claude Code

MaxGhenis and others added 4 commits November 4, 2026 19:53
spm_unit_taxes subtracts the tax on every source of federal gross income,
but person market_income, and so SPM resources, left out partnership and
S corporation income, farm rental income, capital gain distributions
reported without Schedule D, Form 4797 gains and losses, and employer-plan
disability benefits. A family with partnership income lost the tax on it
and never counted the income.

Add each to market_income, with losses where the source has them, and add
the last three to gov.household.market_income_sources so the person and
household lists differ only by discharged debt. A new other_net_gain_person
splits the tax unit's Form 4797 net amount between the head and spouse;
other_net_gain_gross_income now takes its positive part, unchanged in value.

The parity test now maps every source in gov.irs.gross_income.sources to
the resource that counts its cash, or documents why the SPM leaves it out
(discharged debt, Roth conversions, state and local tax refunds), and adds
Hypothesis properties: a dollar of market income or loss moves both totals
by a dollar, and cash income never lowers SPM net income for a family with
no means-tested benefits to lose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d income

NDCC 57-02-08.1(5)(c) counts income from all sources but excludes "any amount
excluded from income by federal or state law". market_income now counts
disability benefits in full, so subtract the part federal law excludes (IRC
104(a)(3)) from North Dakota's base, as the formula already does for pre-tax
premiums. Partnership income, farm rent and capital gain distributions stay in
the base, and new YAML cases pin both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main added taxable_dependent_care_benefits to the federal gross income
sources (#10579). employment_income already holds those benefits, because
irs_employment_income subtracts them and the part above the IRC 129 exclusion
returns through this source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… candidate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis and others added 2 commits November 5, 2026 11:34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis merged commit b0769dc into main Nov 7, 2026
38 checks passed
@MaxGhenis
MaxGhenis deleted the spm-market-income-gross-income-sources branch November 7, 2026 18:35
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

I can't approve my own PR, so I merged it with an admin override. GPT-6.1 Sol reviewed fc40c7a5 (Subfleet job 20261105-181544-spm9919-pr1-review) and agreed it should merge. Since then I've only merged main at 53666d3a, in 173bb794, and this PR still adds and removes the same lines. At 173bb794, 37 CI checks pass and the documentation deploy skips. Main gained three commits after 53666d3a, and none touches this PR's files.

MaxGhenis added a commit that referenced this pull request Nov 7, 2026
…e wage-replacement benefits in the North Dakota candidate

With #10663 on main, its coverage test needs a resource for every gross
income source. taxable_ak_energy_relief maps to ak_energy_relief, which
spm_unit_benefits and household_benefits count.

The us-nd:renters-refund-insurance-proceeds candidate now asks about
wage-replacement disability benefits, since IRC 105(b) and (c) leave
medical reimbursements and permanent-injury payments from employer-paid
plans out of gross income.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 7, 2026
Main's #10663 added a parity test that reads spm_unit_benefits' members
with the year-less spm_members() of its Python list; the next commit
passes it the year this branch's dated parameter needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 7, 2026
Main's #10663 read spm_unit_benefits' members from its Python list, which
had no years. This branch moves the list into a dated parameter, so
spm_members takes a year; check each year the other parity tests check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 7, 2026
… parity test

#10663 made the parity test require every source in gov.irs.gross_income.sources
to name the SPM resource that counts its cash. railroad_benefits, which #10693
adds to spm_unit_benefits, holds the whole annuity; taxable_railroad_pension_benefits
and taxable_railroad_social_security_equivalent_benefits tax its parts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Dec 1, 2026
… benefit (#10662)

* Move the SPM benefit list into a parameter that reforms extend

Four structural reforms that pay a benefit (the Texas rebate, the End
Child Poverty Act, its Economic Dignity for All Agenda version and the
BOOST Act) replaced spm_unit_benefits with copies of its program list.
The copies fell behind. Texas dropped 19 state SSI supplements. The
three Tlaib reforms dropped 42 supplements, Washington's cash aid and
the Washington and West Virginia child care subsidies, and counted ACP
and EBB twice, since spm_unit_net_income adds both itself.

spm_unit_benefits now reads gov.household.spm_unit_benefits, and each
reform adds its own benefit there, and to household_benefits, with
add_to_list_parameter. The ECPA and BOOST household totals regain CSFP
and household health benefits. BOOST gets a variable for its credit
paid through SSA, so the lists can name it.

Fixes #10226.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Read benefit lists without building each year's parameter tree

parameters(year) builds and caches the whole parameter tree for each
instant, and the list test draws 21 years, so one run peaked at 7.5 GB.
Reading the one list parameter avoids that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Run the reform benefit-list properties in remaining-heavy

The file builds a full reformed system for each of four reforms, the
kind of module that group isolates from the 14.4 GB remaining process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test the list helper over gaps and any start day; give its properties a Rest group

- The add_to_list_parameter property now draws None values (gaps) and values
  that start on any day, and checks each value's first day and the day before
  it as well as random days. A local mutation check ran it against six broken
  helpers: it fails on all six, while the old strategy, which drew no None
  values, let the helper that stops skipping them through.
- test_reform_benefit_lists.py leaves remaining-heavy for its own Rest group,
  reform-benefit-lists, so its 5.7 GiB peak RSS (local) never adds to the
  10.5 GiB remaining-heavy holds (release run 42082143005). remaining-heavy
  keeps main's files and comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Build the list helper's expectation before calling it; check it edits no list in place

The property built its expected lists after calling add_to_list_parameter.
The parameter holds the drawn member lists themselves, so a helper that
sorted the names or extended a member list in place moved the expectation
with it and passed. The test now copies the names and every member list
before the call, builds the expectation from those copies, and asserts the
helper left both unchanged. A clone shares its member lists, so an in-place
edit would reach every clone that shares them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check the list helper through its parent node and modified flag; draw repeated members

The helper property read only the parameter itself. A helper that set each
value's list directly, skipping Parameter.update, passed it, though the parent
node would keep returning its cached old lists to formulas and the parameter
would stay unmarked, so a simulation could serve a variable from its macro
cache. The property now reads through the parent node before and after the
call, and checks the modified flag after any change.

It also drew member lists without repeats, which hid a helper that dedupes the
member lists in place, and it now asserts that core keeps the drawn lists, so
its checks for edits in place cannot pass by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check every year's SPM list in the gross income parity test

Main's #10663 read spm_unit_benefits' members from its Python list, which
had no years. This branch moves the list into a dated parameter, so
spm_members takes a year; check each year the other parity tests check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Mark each benefit list a reform changes as modified on every application

CountryTaxBenefitSystem applies a reform it is given, clears the modified
flag of every parameter below the root, then applies the reform again.
add_to_list_parameter changed values, and so set the flag, only when a
name was missing, and the Texas rebate's household_state_benefits edit
skipped its update when the rebate was already listed. So the second
application left the lists unmarked: each of the four reforms passed as
an object ended with every list it changes, and gov.household, unmarked,
while the Texas rebate switched on through its in_effect parameter, which
applies the structural reform only after the flags are cleared, kept them.
Core skips its macro cache for a variable when a parameter the variable
declares carries the flag.

add_to_list_parameter now marks the parameter, and each node above it,
on every call, and the Texas rebate marks household_state_benefits after
its check. No figure changes: core reads the flag only when a simulation
turns its macro cache on, which it leaves off by default, and none of the
variables that read these lists declares its parameters.

The helper property now checks the parameter's and its parent's flags
before and after the first call, then clears both and checks that the
second call, which adds nothing, sets them again. A new test checks that
each reformed system marks exactly the lists its reform changes, and that
current law marks none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Say the reform build clears the flags below the root

CountryTaxBenefitSystem resets the modified flag of each parameter and
node that parameters.get_descendants() yields, and that generator skips
the root itself. Three comments and the helper's docstring said it
clears every flag. This changes comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Fail when a reform reaches a benefit list without a baseline check

test_aggregate_list_integrity.py guarded household_benefits and
spm_unit_benefits only, and only against a reform that redefines the
variable. It now derives the guarded totals from household_benefits (adding
each member that sums a list parameter of its own name), and scans every
reform module for a benefit list it reads or changes as a parameter. Each
such reform must appear in test_reform_benefit_lists.py's REFORMS, which
fails when a reform's list drops a baseline program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check every list and benefit total a reform could drop

A review of 2949b76 found that test_reform_benefit_lists.py compared
only three of the six lists the guard sends reforms to it for. A reform
that emptied household_local_benefits passed every test there: the sums
in the household test read each member as the reformed simulation
computes it, so the drop left both sides. The test also sampled
(year, list) pairs, so a one-year drop escaped some runs.

test_reform_benefit_lists.py now compares every list parameter in the
model with the baseline on each day either list, or a reform's additions,
can change, and checks that no reform neutralizes a benefit total or
changes its formula. Both test files derive the benefit totals the same
way, through nested lists such as state_property_tax_refunds and
child_care_subsidy_programs, and the property test checks that the two
derivations agree.

The guard in test_aggregate_list_integrity.py now counts any mention of
a total or list outside comments, docstrings and a variable's own label
or documentation: getattr and get_child strings, children[...], loops
over names, neutralize_variable and imports, as well as attributes. Of
the 291 reform modules, only the four in REFORMS name one. A reform that
only reads a total joins REFORMS with no additions.

The changelog now also notes that, with the flat tax's deduct_ptc switch
on, the Tlaib reforms count assigned_aca_ptc as current law does, where
their copies counted aca_ptc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep disabled BOOST out of benefits and preserve dated list metadata

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT-6.2 Sol <noreply@openai.com>
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.

1 participant