Repository navigation
Count every taxed cash source in SPM market income - #10663
Merged
Merged
Conversation
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>
…ss-income-sources
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>
MaxGhenis
marked this pull request as ready for review
November 5, 2026 16:05
… candidate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
I can't approve my own PR, so I merged it with an admin override. GPT-6.1 Sol reviewed |
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>
This was referenced Nov 8, 2026
Merged
Merged
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>
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.
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_incomeadds personmarket_incomeand subtractsspm_unit_taxes, which include federal income tax on every source ingov.irs.gross_income.sources. On main, five of those sources never reachmarket_income, so SPM resources lose the tax on them without gaining the income.household_market_incomealready counts two of them,partnership_s_corp_incomeandfarm_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
Simulationruns of the same household on each tree:spm_unit_market_incomespm_unit_taxesspm_unit_net_incomehousehold_net_incomeWhat 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_taxessubtracts the tax on it either way.partnership_s_corp_incomefarm_rent_incomerental_incomealready counts.non_sch_d_capital_gainsmarket_incomealready countscapital_gains, so it now counts capital gain distributions with them.other_net_gain_gross_income(Form 4797)other_net_gain_personnon_sch_d_capital_gains.taxable_disability_benefitsdisability_benefitscounts in fulltaxable_dependent_care_benefitsemployment_incomeholds these benefits.irs_employment_incomesubtracts them throughpre_tax_contributions, and the taxable part comes back through this source.debt_reliefhousehold_market_incomekeeps it, and invariant 2 pins the difference.taxable_roth_conversionssalt_refund_incomeI recorded this rule and the three exclusions in
docs/spm.md.Other readers of
market_incomeandhousehold_market_incomend_renters_refund_incomewa_eceap_family_incomemo_snc_countable_incomeadult_earnings_indexmarginal_tax_ratesimulates only the firstsimulation.marginal_tax_rate_adultsadults in this rank. No law governs the rank.cbo_household_market_incomehousehold_market_incomeItem 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'se53b4260and at this PR's5a6ed8e1. The commits after5a6ed8e1change only tests andsource_conflicts/candidates.yaml. I haven't rerun at main's current53666d3a, which this branch now includes.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).
spm_unit_market_incomehousehold_market_incomespm_unit_net_incomehousehold_net_incomespm_unit_taxesirs_gross_incomeadjusted_gross_incomeincome_taxThe 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.
market_incomeThree 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 itsdisability_benefitsandtaxable_disability_benefitsboth 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.pychecks 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.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.gov.household.market_income_sourcesandmarket_incomediffer only bydebt_relief.spm_unit_market_incomeandhousehold_market_incomeby one dollar.spm_unit_net_incomeby at least zero and at most one dollar. On main this fails by $102,911.69 in the Tennessee example.other_net_gain, with its sign, for single and joint units with and without dependents.other_net_gain_gross_incomeholds its positive part, as on main.YAML tests pin
market_income,household_market_income,spm_unit_market_income,spm_unit_net_incomeandnd_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 intest_household_spm_resource_parity.pytook 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. At5a6ed8e1, 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 thatfc40c7a5adds 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