Repository navigation
Net household members' Medicaid MAGI before the zero floor, and give each spouse their own deductions - #9860
Merged
Merged
Conversation
adjusted_gross_income_person split every above-the-line deduction other than the three self-employment ones 50/50 between head and spouse on a joint return. Each person now takes their own deductions through above_the_line_deductions_person; only tax-unit-level inputs (HSA, tuition and fees, domestic production, possession income) are divided equally. Adds alimony_expense_ald_person, loss_ald_person and limited_capital_loss_person, moves Medicaid's per-person AGI and Montana's Social Security worksheet onto the same attribution, and applies Montana's capital loss rule for spouses filing separately (MCA 15-30-2110(6)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loss_ald_person now divides the Section 461(l)-limited business loss by each spouse's business losses and the rest of loss_ald by their capital losses, so it stays right when loss_ald gains capital components (#9788). Adds the filer_share helper used by the per-person deduction variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Attributing each spouse's deductions in Medicaid AGI without also netting the couple's MAGI before medicaid_magi_person's zero floor moved Medicaid eligibility in both directions; the two belong in one Medicaid change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…view r1 fixes; strengthen property test The property test's new independent 461(l) check still has a test-side indexing bug: the model gives the right limited_business_loss (256,000 for a 2026 single filer with a 1.5M loss). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eductions above_the_line_deductions_person gave a tax unit dependent every person-level deduction recorded on them, including employer adoption assistance and education savings bond interest, which gov.irs.ald.filer_amounts_recorded_on_dependents marks as the filer's. Those now count only for the head and spouse, whose parts already take them up through above_the_line_deductions. The dependent's part matters once Medicaid AGI reads it for a dependent's own return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d spouse Education savings bond interest and employer adoption assistance recorded on a dependent are the filer's (gov.irs.ald.filer_amounts_recorded_on_dependents), but which spouse's is not recorded. They reached the head's and spouse's parts through the reconciliation to above_the_line_deductions, in proportion to each spouse's other deductions, so the spouse's IRA deduction changed the head's share. They are now divided equally, as the other amounts recorded only for the return are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Units that set a tax-unit deduction directly run in their own simulation. An input given for one tax unit is an input for every unit in a simulation, so one unit's loss_ald set to 0 zeroed every other unit's. - The Section 461(l) reference keeps each business source's gain and loss separate (aggregate income against aggregate deductions), as the model does, rather than netting a person's sources first. - The capital loss reference nets losses against capital gains and distributions before the 1211(b) limit, as main does since #9788. - The alimony identity skips units that set alimony_expense_ald directly: alimony_expense_ald_person stays each payer's own alimony there. - The reference gives a dependent's filer amounts to the head and spouse equally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…list above_the_line_deductions_person now reads gov.irs.ald.filer_amounts_recorded_on_dependents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 13:22
390a2de to
016520c
Compare
…ouse AGI With each spouse's own deductions, a spouse with a business loss or an IRA deduction above their income has negative AGI, and these two withholding estimates multiplied it by the rate. Every other state's withholding formula already floors its base at zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
va_agi_person divides tax-unit additions by each spouse's share of federal AGI. A spouse with negative AGI got a negative share and the other spouse more than all of it. A spouse with negative AGI now gets none, as #9878 does for Delaware's itemized deductions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Directly set loss_ald still reconciles through loss_ald_person, so its identity is checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 14:36
016520c to
e3660c8
Compare
…ules are modeled Montana spouses who filed separately on one form through 2023 allocate capital losses by one of two elections (ARM 42.15.206(3)) and recompute the Section 461(l) limit with the single filer's threshold. Neither is modeled. Giving each spouse their own federal losses instead of half moved Montana away from both. With one spouse's $1,000 gain against the other's $3,000 loss, the loss spouse's AGI was $7,000, though separate tracking caps the loss at $1,500 ($8,500). A $600,000 business loss on one spouse used the joint limit, lowering tax by $45.65 against main. mt_loss_ald_reallocation adds back to each spouse's federal AGI the difference between their own loss_ald_person and an equal share of the return's loss_ald, so Montana divides losses as before. The IRA and other deductions still go to the spouse who has them (former MCA 15-30-2110(8); ARM 42.15.206(1)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 16:27
e3660c8 to
14a53e3
Compare
…t return's AGI mt_standard_deduction_joint and mt_medical_expense_deduction_joint added each spouse's mt_agi_indiv, which is floored at zero. With each spouse's own deductions, a spousal IRA above that spouse's income was lost to the floor: head wages $30,000 and a $6,000 spousal IRA gave a joint deduction of $6,000 (20% of $30,000) instead of $4,920 (the floor, 20% of the joint $24,000 being less). Both now read mt_agi_joint, the joint column's Montana AGI through 2023. Their tests take mt_agi_joint as the input. Adds the spousal IRA case, a single filer's loss and a case with student loan interest and an IRA in each spouse's own column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 20:48
1681b9b to
b8be91c
Compare
Review r5: the medical floor had no year gate, so reading mt_agi_joint also changed 2024 and later, when mt_agi_indiv is zero for everyone and main's floor was zero. From 2024 Montana starts from federal itemized deductions, whose floor is a share of federal AGI, a separate fix. The joint AGI now applies while married filing separately on the same return is allowed (through 2023); 2024 on is unchanged from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 21:31
b8be91c to
4afd853
Compare
Comment only (review r6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 6, 2026 21:39
4afd853 to
9824d72
Compare
…se allocation from 2024 Per Max's d1014 ruling: - DC: spouses filing separately on the same return each deduct their own capital losses up to their own capital gains plus the $1,500 married filing separately limit (D-40 instructions, line c), via dc_separate_capital_loss_adjustment. It applies only to the separate column; dc_taxable_income_joint keeps the federal joint deduction. - Montana: mt_loss_ald_reallocation and mt_applicable_ald_deductions apply only while spouses may file separately on the same form (through 2023). Adds YAML cases and DC/Montana invariants to the spouse property test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bute each spouse's own deductions medicaid_magi_person floored each person's MAGI at zero, and medicaid_household_income added the floored amounts, so a spouse's business loss never offset the other spouse's wages on their joint return. Household income is the sum of every member's MAGI-based income (42 CFR 435.603(d)(1)), and the 36B methodology the regulation adopts (435.603(e)) combines the taxpayer's and dependents' modified AGIs "even if one or both of them are negative" before entering a negative total as zero (Form 8962, line 3). medicaid_magi_person is now unfloored and medicaid_household_income floors only the household's total. medicaid_adjusted_gross_income_person now subtracts above_the_line_deductions_person, so each spouse's own IRA deduction, student loan interest, alimony and business and capital losses lower only their own amount, and a dependent's own deductions, alimony paid included, lower the dependent's own AGI. Tax-unit-only MAGI additions are divided equally between the head and spouse with filer_share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ned in the Medicaid filing test medicaid_person_is_required_to_file took unearned income as gross income less earned_income. Gross income counts each source's positive amount, so a self-employment loss made other income look unearned: a dependent with a 5,000 loss and 100 of interest had 5,100 of unearned income and was required to file. With household members' MAGI no longer floored, that would count the dependent's negative income. Unearned income is now gross income less the positive wage and self-employment sources it includes (Pub. 501, Table 2), which also stops 401(k) deferrals, left out of box 1 wages, from hiding unearned income. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hypothesis draws batches of joint filers with dependent children, non-filing couples, cohabiting spouses filing separately and single filers, with losses, own deductions and children who may be required to file. For every household: joint filers' household income is max(0, J + D), with J the couple's MAGI figured from the tax unit's AGI; the spouses' MAGIs add up to J; spouses outside a joint return are netted before the floor; income is never negative and is zero exactly when the unfloored sum is not positive; and three metamorphic relations hold (the spouse's own deductions never change the head's, swapping spouses changes nothing, and lowering the spouse's self-employment income never raises household income). 20 examples plus a seeded population of 200 households: 44 s wall and 1.17 GB peak locally (macOS, loaded host). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ive dependents the claimant's separate spouse Two findings from review r1: - A non-filer household's parents and siblings are read from the whole family, which can include people outside the household, such as a grandparent who is also a parent there. With signed amounts, a grandmother's $5,000 loss cut her granddaughter's household income from $12,000 to $7,000, though 42 CFR 435.603(f)(3)(iii) leaves her out. Those relatives' amounts are now added only when positive: each child's, and each couple's parents' netted together, so married parents' losses still offset each other. The individual's and spouse's amounts stay signed. #9406's co-resident parent IDs fix the membership itself. - A dependent's tax household is the claimant's (435.603(f)(2)), which includes the claimant's cohabiting spouse who files separately (f)(4). Household size already counted that spouse; household income now does too. Also corrects two comments to the 2025 standard deduction, $15,750. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2 notes: - A non-filer child's own amount and their siblings' enter with the family's children, only when positive, and unmarried co-resident parents are each counted only when positive. The documentation now says so, rather than "always added signed". - Medicaid AGI documentation says a dependent's own business and capital losses are not modeled. - New case: married non-filer parents, $12,000 of wages and a $5,000 business loss, give their child's household $7,000. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
medicaid-magi-joint-floor
branch
from
October 7, 2026 10:37
9824d72 to
d4b561e
Compare
…oss_ald Review r7: dc_separate_capital_loss_adjustment removed the computed capital loss deduction even when loss_ald was set directly, so it took out an amount federal AGI did not contain. It now removes the capital part of each spouse's loss_ald_person (loss_ald less the business loss, by own capital losses). Adds YAML cases with loss_ald set to $0 and $1,000, and the property test checks every unit against that capital part, keeping the nonnegative couple sum for computed units only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 7, 2026
…s_ald Review r8: with loss_ald set directly and both business and capital losses, dc_self_employment_loss_addition isolated the business loss by subtracting the computed capital deduction, while loss_ald_person (and so federal AGI and the DC capital adjustment) takes the business part first. Use min(limited_business_loss, loss_ald), as loss_ald_person does; the amount is unchanged when loss_ald is computed. Adds computed and direct mixed-loss YAML cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
October 9, 2026 01:04
MaxGhenis
marked this pull request as draft
October 9, 2026 01:05
MaxGhenis
marked this pull request as ready for review
October 9, 2026 10:14
Contributor
Author
|
Context for the hub from the original session, which is handing this PR over and will not push to it.
🤖 Generated with Claude Code |
Keep main's landed spouse ALD allocation, loss calculations, state integrations and all applicable regression cases. Retain #9860's signed Medicaid member sums, household zero floor, own-ALD reads, separate-spouse income membership and dependent filing-requirement correction. Account for shared IRA compensation and MAGI limits in the Medicaid independence property. Capture total unemployment compensation in the main determinism probe so its dependency set matches current main.
Take main's determinism-test fixture from #10221 (total_unemployment_compensation only); none of the probed formulas read unemployment_compensation directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The documentation said a spouse's business loss lowers only that spouse's amount. loss_ald_person divides it in proportion to each spouse's own net business losses, and equally when neither has one. Documentation only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restating the allocation left out the equal share of a Form 4797 loss. Refer to loss_ald_person instead. Documentation only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
US + core hub merge audit, us#9860 at
|
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
Medicaid household income now sums members' signed MAGI before applying one zero floor to the household total. Each person's Medicaid AGI reads the reviewed
above_the_line_deductions_personallocator now on main. With one spouse earning $30,000 and the other losing $20,000, main's per-person floor counts $20,000; this PR counts $10,000 = max(0, $30,000 - $20,000).The PR also preserves its separate-spouse income membership correction, the conservative positive-income fallback for family-wide relatives without parent links, and the Medicaid dependent filing-requirement correction: a business loss no longer turns other income into unearned income, and 401(k) deferrals do not hide unearned income.
Reconciliation after #9890 landed
Merged main
654a0c9b54a57e6422f4d0418d0d039a3bb3537cinto approved head6c5f5cddd8ad7cb43c21cd84ff281d382e9ecee7with history-preserving merge commit77e92b20487a36815a09407193fbec50542b96eb. #9890 landed as7e9ce42c1856d4b759e55f6f4fca3ba007b9bf2d.Both branches carried the same concept: own-spouse ALDs, filer/dependent attribution, business/capital loss allocation, HSA ownership reconciliation and equal fallback,
filer_share, per-person federal AGI, D.C. capital/business loss adjustments, Montana ALD allocation, MI/PA withholding floors and Virginia additions allocation. Those implementation changes and their tests now belong to main; every model overlap keeps main's version. The duplicate ALD changelog fragment was removed because its provision was already released.loss_aldkeeps main's declarative sum, which has the same components and order as the old PR formula.The remaining delta is one Medicaid changelog, five Medicaid variables, four Medicaid YAML files and the Medicaid household invariant file. The ALD determinism fixture repair is no longer in the delta: #10221 fixed the same fixture on main, and a second merge of main at
121d534b6btakes main's version (none of the probed formulas readunemployment_compensationdirectly;test_ald_determinism.py9 passed, the spouse-ALD invariants 7 and the Medicaid household invariants 5 on that tree). No IRS or state formula/test change remains in the PR delta. No additional non-Medicaid fix from #9860 was needed.Behavioral differences explicitly retained from main
These are static formula comparisons of the old PR with fetched main, not new microsimulation results. Dollar amounts below use only the stated incomes/deductions. The SE examples explicitly supply zero
self_employment_tax_aldand zero person equivalents so the differing loss formula is isolated.medical_expense_health_insurance_premiums$6,000, ownself_employed_health_insurance_ald_person$1,000, other medical $500,mt_agi_indiv$40,000Test retention and changes
No distinct test case was dropped and no YAML expected output changed. A normalized audit of all 22 original YAML files found 129 matching cases with identical inputs, outputs, periods and tolerances. Every ALD/state case from the old PR remains on main, including all old Montana medical (3), Montana standard (8), and WV (5) cases. Main's additional HSA ratio, IRA compensation, medical and WV cases remain. The HSA fallback case has main's renamed title with identical inputs/results. The merge briefly duplicated Ohio's identically named spouse-IRA case; the redundant copy was removed, leaving main's existing case intact.
The first determinism run passed 8 cases but its hash-seed child failed because main's student-loan MAGI formula reads
total_unemployment_compensation, while the slim fixture captured onlyunemployment_compensation. The fixture now captures the total as well. It still compares the same five production formulas and float32 holders with its full-country oracle across all six hash seeds; all nine tests and expectations are retained. The repaired file passed all 9 cases, including all six hash seeds (local wall 110.52 s, pytest 74.58 s, peak reported process RSS 1,047,199,744 bytes; the failed pre-repair run was 62.45 s, pytest 6.01 s, peak 1,056,260,096 bytes). This is a test-harness repair, with no policy formula or full-model construction added. After #10221 landed the same repair on main, the second merge of main (121d534b6b) took main's version of the file, so it no longer appears in this PR's diff.The Medicaid invariant now excludes
traditional_ira_deductionalongside student-loan deductions from the head's independence comparison, because IRA deductions respond to shared compensation and joint MAGI. For example, in the $1,000/$6,000 wage household above, removing the spouse's $6,000 IRA legitimately raises the head's deductible IRA from $1,000 to $6,000. All generated households still receive the accounting, signed-netting, floor, swap and fixed $7,500 SE-reduction checks; no simulation construction or test case was added.Fresh verification runs each file separately in the foreground, sequentially, with all five thread caps set to 4 and
OMP_WAIT_POLICY=PASSIVE, using supplied Python 3.13.9 / Core 3.33.2 / pytest 9.1.1 / Hypothesis 6.168.5. No partner contract tests were edited. No microsimulation or full suite was run.89 passed across 10 files.
make format(ruff format and check) passed with no formatting changes.medicaid_adjusted_gross_income_person.yamltest_medicaid_household_income_invariants.pymedicaid_household_income.yamlmedicaid_magi_person.yamlmedicaid_person_is_required_to_file.yamltest_spouse_above_the_line_deductions_invariants.pytest_ald_determinism.pymt_medical_expense_deduction_joint.yamlmt_standard_deduction_joint.yamlwv_senior_citizen_disability_deduction_person.yamlThe new Medicaid Python file tests vectorized accounting, metamorphic relations and independent linked membership across simulation API calls; policy examples remain in variable-named YAML. It runs in the existing Rest Python shard 2/core group. The reconcile adds no test cases or simulation constructions to that file. Local macOS measurement including startup: 102.25 s wall, 36.79 s pytest, with 13.66 s total test calls. Before-reconcile timing was not measured in this checkout. Its initial BSD resource wrapper could not obtain peak memory because the sandbox denied
sysctl; test execution itself passed. Other file measurements use per-processgetrusagein untracked evidence. These local results do not establish Linux CI group memory usage. The repository's historical pre-isolation core group report was 13.3 GB / 11:51; current group fit remains for CI, with no added runners or parallel heavy processes.Law and approved methodology
42 CFR 435.603(d), (e), (f) defines the included members and summation of MAGI-based income; IRC 36B(d)(2) supplies the MAGI methodology. 2025 Form 8962 instructions, line 3, p. 8 combines signed taxpayer and dependent MAGIs before flooring only the total.
Methodology ruling (Max, d1120, 2026-10-09): approved as built. A non-filer Medicaid household sums its members' signed MAGI and floors only the household total at zero (42 CFR 435.603(d)(1); Form 8962 line 3). Unlinked relatives' income counts only when positive.
axiom: TheAxiomFoundation/rulespec-us#1507 queued (42 CFR 435.603(d)(1):
us/policies/medicaid/magi_household_income_pipeline.yamlalready sums members' MAGI with no per-member floor; the queued companion tests pin a spouse's negative MAGI offsetting the household)Hub microsimulation impact (current head)
A real microsimulation on the default dataset, main at the merge base
800e5bf53cagainst this PR's head987402badf, for 2025 and 2026. The runs went one at a time under the shared heavy-job lock. Sums are weighted.medicaidis_medicaid_eligibleis_chip_eligibleaca_ptchousehold_health_benefitshousehold_net_income_including_health_benefitsstate_income_taxincome_taxhousehold_net_incomehousehold_benefitsFederal and state income tax don't change: the per-spouse deductions are main's since #9890, so this PR's remaining effect is Medicaid's signed netting of members' MAGI. Medicaid eligibility rises by 60.6k people in 2025 (68 records) and 195.0k in 2026 (73 records); no one loses it.
is_chip_eligiblechanges for 14 and 11 records, a net fall of 19.3k and 19.4k. Totalmedicaidmoves by only $570 and $1,730 out of about $880bn, because the model holds each state's Medicaid spending fixed:medicaid_cost_if_enrolleddivides the state's calibrated spending bymedicaid_slcsp_state_denominator, which over a dataset sums weight × cost index × enrollment by state. More enrollees therefore lower the per-person value for others: $398.5M moves between records in 2025 (1,709 down, 59 up) and $2,071.7M in 2026 (5,210 down, 62 up).aca_ptcfalls by $48.8M in 2025 (8 records) and $342.8M in 2026 (10 records), all decreases. Net income including health benefits changes by −$43.9M and +$18.8M; net income without health benefits rises by $0.03M and $5.8M (7 and 8 records).Comparison files are in
fixes/9860-impact/on the hub host.