Repository navigation
Ignore dependent separation when inferring the tax unit spouse - #9932
Conversation
is_tax_unit_spouse dropped the spouse whenever any member of the tax unit had is_separated set, so a separated adult dependent (or any other separated member) turned a married couple's return into head of household or single. Separation under 26 U.S.C. 7703 concerns the filer's own marriage, and filing_status and head_of_household_eligible already limit it to the head and spouse. The spouse is now dropped only when the head or the would-be spouse is separated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Hypothesis test (plus a seeded population) draws tax units of one to five people with tied ages, children and separated members, with no role inputs, input dependents or an input head. It checks that there is at most one spouse, never the head or a child; that head and spouse match a pure-Python statement of the rule; and that flipping the separation of anyone but the head and the would-be spouse never changes the spouse. New YAML cases cover an input head with a separated dependent, the all-dependent fallback with a separated third adult, and a younger separated adult beside an older non-separated one. The filing-status case now gives the spouse wages, so it exercises the income main dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Review: Ignore a dependent's separation when inferring the tax unit spouse (26 U.S.C. 7703)PR #9932 (author: MaxGhenis, head SummaryWhen roles are not supplied, Is it still needed? Yes. After #9617 (merged 2026-10-08), Does it conflict? Yes, in two ways. GitHub reports the PR as The logic itself is correct and well tested:
Source documents
Critical (must fix)1. After the rebase onto
Should address1. Two
Suggestions1. Pin or remove the member-order dependence the PR introduces for tied ages.
2. Use one reference implementation for the two Hypothesis files after the rebase.
3. Give the variable a
4. Refresh the PR body after the rebase.
Verified correct
Out of scope (not counted)
Axiom line assessment
CI statusAll 35 checks pass on
These runs predate #9617. GitHub now reports the PR as Branch status
Verdict: REQUEST_CHANGES |
DTrim99
left a comment
There was a problem hiding this comment.
The fix is still needed: main's age-order fallback keeps the unit-wide is_separated gate for households without supplied roles. The law supports gating only on the head and the would-be spouse (7703(a)(2), Reg. 1.7703-1(a), and 152(b)(2)), and the new tests are functional. One critical (details in the comment above): the branch conflicts with #9617, and with the conflict resolved as the PR body prescribes, 2 of main's 4 role property tests fail, because _age_rule still encodes the any-member gate. Rebase, then update _age_rule and docstring invariant 3; all 4 then pass. One should item: reword tax_unit_role_input.py:18 and docs/usage/microsimulation.md:155-157, which still describe the old rule.
Preserve supplied tax roles and marital-partner selection while limiting the separation check to the head and selected spouse. Update both property references and the fallback documentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover both member orders for equal-age candidates and preserve the marital couple beside an older separated adult. Cite the marital-status statute and document the continuous bracket calculation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
David, here's where each item of your review stands at
The branch still merges cleanly with main, and all 39 checks pass at 🤖 Generated with Claude Code |
|
US + core hub merge audit, us#9932 at
🤖 Generated with Claude Code |
Main's PolicyEngine#9932 has is_tax_unit_spouse pick its spouse before checking separation, and drop that spouse only when the head or the spouse is separated, without promoting another adult (26 USC 7703(a)(2)). Step 4 now applies the same rule instead of pairing no one in any tax unit with a separated member, so a couple with a separated adult dependent still shares a marital unit and the units keep matching the roles. Two hook tests pin both parts of the rule. Conflicts were wording only: the head formula's comment, the tax_unit_role_input documentation and the microsimulation guide keep main's separation text with this PR's sentence on built marital units, and is_tax_unit_spouse.yaml keeps the cases from both sides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #9620.
When it infers a tax unit's spouse, PolicyEngine now checks separation only on the head and the selected spouse candidate. On main, it drops the spouse whenever a separated person belongs to the tax unit, excluding that spouse's income from the return.
Congress ties legal separation to the individual's own marriage in 26 U.S.C. 7703(a)(2). Treasury applies the same condition in 26 CFR 1.7703-1(a).
The fallback retains main's marital-partner preference and qualifying-child age filter from #10555. Supplied tax-unit roles and explicit role inputs retain their precedence.
Invariants
Tests
is_tax_unit_spouse.yamlnow holds 27 cases, 12 of them new, andfiling_status.yamlholds 15. Each property module runs four tests.Pull request run 43437444278 at
25a420d251passed all 38 jobs on GitHub's merge with main47c4e8720b.For the 2024 joint-filing example, wages of $50,000 and $30,000 less the $29,200 standard deduction give $50,800 taxable income. Applying 10% to $23,200 and 12% to $27,600 gives $5,632 before credits, or $5,132 after the $500 other-dependent credit. Sources: Rev. Proc. 2023-34, 26 U.S.C. 24(c), (h).
Methodology choices
Microsimulation impact
We estimate no change in population results. The default dataset supplies a tax-unit role for every person, and the model carries those roles into each later year, so
is_tax_unit_spousetakes every spouse from them and never from the age-order fallback this PR edits.impact: none on the default dataset, which supplies every person's tax-unit role, so the spouse fallback this PR edits decides no record; household calculations without supplied roles change
Axiom parity
axiom: us:statutes/26/7703#taxpayer_married_under_general_rule encoded-correct. rulespec-us takes legal separation as the taxpayer's own tax-unit input (
input.legally_separated_under_decree_of_divorce_or_separate_maintenance), so no other member's status can enter. Companion testlegal_separation_prevents_married_statusinus/statutes/26/7703.test.yaml.🤖 Generated with Claude Code