Repository navigation
Let modified AGI for taxing Social Security go below zero - #11370
peyton-thalman wants to merge 3 commits into
Conversation
26 U.S.C. 86(b)(2) defines it as adjusted gross income with certain items added back, and the Form 1040 Social Security Benefits Worksheet combines the income lines, capital loss included, without a floor. Wisconsin's itemized deduction credit no longer needs to add back the hidden shortfall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DTrim99
left a comment
There was a problem hiding this comment.
Program review
Base repository: PolicyEngine/policyengine-us
PR number: 11370
Reviewed head SHA: d29b819
Merge base SHA: ab596b0
Mode: full
Scope: changed behavior and affected dependencies
Source manifest: /private/tmp/policyengine-command-runs/ea33c0bb2b64/pr-11370-review-sources.json
Review status: COMPLETE
Source Documents
- i1040gi-2025.pdf — cached original.
- i1040gi-2024.pdf — cached original.
- i1040gi-2018.pdf — cached original.
- p915-2025.pdf — cached original.
- wi-schI-2025.pdf — cached original.
- wis-71-07-5.html — cached original.
- usc86.html — cached original.
Critical
None.
Should Address
A1 — IRA 219(g) recomputation of taxable Social Security keeps the zero floor this PR removes (OPEN)
- Location:
policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/ira/ira_219g_taxable_social_security.py:55(ss_magi = max_(0, gross - total_deductions)). Its docstring says it uses the "same inputs and thresholds as the engine's taxable_ss_magi / tax_unit_taxable_social_security". Pub. 590-A Appendix B Worksheet 1, which it cites, combines the income lines with no floor, as the Form 1040 worksheet does. - Trigger and observed (executed): after this PR, the two copies disagree whenever MAGI before the IRA deduction is below zero. With no IRA contribution,
ira_219g_taxable_social_securityvstax_unit_taxable_social_security: case A 2,500 vs 1,000; case B 5,250 vs 4,150; case H 8,500 vs 7,225.ira_219g_magiin case A is -500, while AGI is -2,000. - Impact (traced, not executed): the single and joint phase-outs start at $81,000 and $129,000 (2026). With MAGI below zero, 219(g) MAGI is roughly taxable benefits, which are at most about $20,000, so those filers are unaffected. MFS filers living together have a phase-out from $0 to $10,000 (
phase_out/start.yamlSEPARATE: 0), and they are affected. Example: an MFS active participant age 68 living with the spouse, with 7,000 wages, a 10,000 rental loss, 20,000 benefits and a 7,000 IRA contribution. Correct 219(g) MAGI is -3,000 + 5,950 = 2,950, giving a deductible limit of about 6,070. The floored copy gives -3,000 + 8,500 = 5,500 and about 3,870, so the IRA deduction is understated by about 2,200. This defect predates the PR:ira_219g_*values are identical PR vs base in every executed case. The PR fixes the same statutory point in one copy and leaves the other inconsistent, which also makes its docstring wrong. - Fix: drop the
max_(0, ...)at line 55 (or reusetaxable_ss_magi_before_floorminus the 219(g)-excluded deductions), and add a test for MFS filers living together. - Proposed severity: SHOULD ADDRESS. It is a same-rationale consistency fix in the sibling path. The deduction impact is traced only, and it falls outside the changed lines.
Coordinator assessment: The policy review found the same thing independently. Section 219(g)(3)(A)(i) applies section 86 with the IRA deduction disregarded, 86(b)(2) has no floor, and the file's docstring says it mirrors taxable_ss_magi. The defect predates this PR. I'm asking for it here because the PR's premise, that 86(b)(2) has no floor, applies equally, and leaving the mirror floored makes the two section 86 computations disagree: 2,500 vs 1,000 taxable benefits in the single case. Dropping max_(0, ...) at line 55 and adding the MFS-living-together case from the report is a small change.
A2 — No test for Wisconsin modified AGI that stays below zero after the adjustment (OPEN)
- Location:
wi_itemized_deduction_credit_social_security_adjustment.py:64(wi_magi = magi + adjustment; the outermax_(0, ...)is removed). - Trigger:
taxable_ss_magi + wi_itemized_deduction_credit_income_adjustment< 0 with benefits high enough that a zero floor would cross the base. The only Wisconsin test that touches this haswi_magi= 2,000 > 0, so restoring the outer floor would not fail any test. - Observed (executed, case D): the adjustment is 1,000 on the PR (WI MAGI -1,000, combined 27,000, minus federal 0) and 0 on base. The contribution base is 0 on the PR and 500 on base. Restoring only the outer floor would give 1,500 (code trace). The PR value is the one consistent with the no-floor rule. The credit and WI tax are 0 and -115.60 on both, so this case changes no final tax.
- Fix: add case D (rental income -12,000,
social_security_disability56,000, otherwise the existing case): expectedtaxable_ss_magi-3,500,tax_unit_taxable_social_security0, adjustment 1,000, contribution base 0. - Proposed severity: SHOULD ADDRESS (missing coverage on a changed branch).
Suggestions
S1 — taxable_ss_magi_before_floor names a floor that no longer exists (OPEN)
- Location:
taxable_ss_magi.py:4. The only remaining caller is line 66, now that the Wisconsin import is removed. - Fix: inline it into the formula or rename it (for example,
taxable_ss_magi_amount). If code-1 is fixed by reusing the helper, rename it instead of inlining. - Proposed severity: SUGGESTION.
Evidence Gaps
No material gaps reported.
Notes
- Thanks for the careful write-up. The core change is right:
-
- 26 U.S.C. 86(b)(2) and the Form 1040 Social Security Benefits Worksheet have no floor on modified AGI.
-
- The PR's expected values follow the worksheet line by line. The single case gives combined 27,000, 2,000 over the base and 1,000 taxable. The joint case gives 40,300, 8,300 over 32,000 and 4,150 taxable.
-
- The Wisconsin change counts the negative once, so every Wisconsin output in the existing case is unchanged.
- Every reader of
taxable_ss_magihandles a negative value safely: combined income, the pre-1993 path,taxsim_v12, Wisconsin, and CT through the floored excess. Results with positive MAGI match main exactly in the executed cases, and each new test assertion fails under the old formulas. - In the data, the change can only lower taxable Social Security and AGI, or leave them unchanged. The records that move are high-benefit recipients with net losses, plus MFS filers living together.
- Optional: the unversioned
i1040gi.pdflink will move to the 2026 instructions. The pinnedirs-prior/i1040gi--2025.pdfwould keep the page number stable. - The axiom line is acceptable for an external contribution under CLAUDE.md.
Validation Summary
Local tests at the reviewed head (review venv, policyengine-core 3.37.2, matching uv.lock; imports resolved to the snapshot): 106 YAML cases (the seven files the PR lists plus the IRA 219(g), IRA phase-out and taxsim_v12 regressions) and 31 pytest tests passed, 0 failed. Diagnostics executed 8 households under the PR and merge-base formulas. Sources: 26 U.S.C. 86 and 219(g), the 2025 Form 1040 instructions (Social Security Benefits Worksheet), Pub. 915 and Wis. Stat. 71.07(5); manifest check passed. CI: 36/36 checks pass at d29b819.
Timing
setup seconds: 12.00s; scope seconds: 60.00s; parallel review seconds: 1330.90s; policy role seconds: 192.90s; code role seconds: 1330.90s; adjudication seconds: 90.00s; consolidation cleanup seconds: 34.70s; elapsed seconds: 1483.00s
Review Severity
COMMENT. Open findings: 0 critical, 2 should address, 1 suggestions.
…view tests - ira_219g_taxable_social_security: no floor on modified AGI, matching taxable_ss_magi (26 U.S.C. 86(b)(2), Pub. 590-A Worksheet 1). Tests for a single filer below zero and for separate filers living together. - Wisconsin: test where modified AGI stays below zero after the adjustment. - Rename taxable_ss_magi_before_floor to taxable_ss_magi_amount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the thorough review. All three points are addressed in 0f0be0d:
The changelog now mentions the 219(g) path. Locally, the IRA and Social Security YAML folders, the two edited files and the IRA pytest files all pass. |
|
Agent review for Max, written by Claude Code for Max Ghenis. Round 2 at 0f0be0d. The IRA change, Wisconsin case D and the rename read correctly. With the floor gone, two older omissions in
Suggested tests (hand values; both fail at this head): - name: Taxable basic income offsets a loss before section 86.
period: 2026
input:
gov.contrib.ubi_center.basic_income.taxable: true
age: 68
state_code: TX
basic_income: 3_000
long_term_capital_gains: -3_000
social_security_retirement: 60_000
output:
taxable_ss_magi: 0
tax_unit_taxable_social_security: 2_500
ira_219g_taxable_social_security: 2_500
- name: Section 86 disregards the tuition and fees deduction in 2020.
period: 2020
input:
age: 68
state_code: TX
qualified_tuition_expenses: 3_000
social_security_retirement: 60_000
output:
capped_qualified_tuition_expenses_ald: 3_000
taxable_ss_magi: 0
tax_unit_taxable_social_security: 2_500
adjusted_gross_income: -500Minor: CI hasn't run at this head. The fork run is waiting for a maintainer's approval. |
… 222 and 199 in their years From the round 2 review. With the floor gone these omissions change results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, both confirmed against the govinfo editions of section 86 and fixed in a1545a2.
Your two tests are added, plus one for section 199 in 2017. All three fail at 0f0be0d. The section 86 references now point to govinfo, and the 1040 instructions link is pinned to the 2025 edition. Locally, the Social Security, dependent income and IRA YAML folders (117 cases) and the IRA and capital gain pytest files (45) pass. |
|
Agent review for Max, written by Claude Code for Max Ghenis. Round 3 at a1545a2. Both round 2 fixes and the citations read correctly. By hand, the 2026 and 2020 fixtures give MAGI $0, combined income $30,000 and taxable benefits $2,500, and the 2017 section 199 fixture gives AGI -$500. One change before merge:
Not blocking:
CI hasn't run at this head. The fork run is waiting for a maintainer's approval. |
Fixes #11369
What
taxable_ss_magifloored modified AGI at zero. 26 U.S.C. 86(b)(2) and the Form 1040 Social Security Benefits Worksheet have no floor, so when income other than Social Security is below zero (for example a 3,000 net capital loss with nothing else), combined income and taxable benefits came out too high.Changes
taxable_ss_magi.pydrops themax_(0, ...)and cites 86(b)(2) and the worksheet (2025 Form 1040 instructions, file page 32).wi_itemized_deduction_credit_social_security_adjustment.pydrops theshortfalladd-back, which only existed to undo the floor and would otherwise count the negative amount twice. The Wisconsin modified AGI is nowmagi + adjustment.wi_itemized_deduction_credit.yamlchanges one expected value,taxable_ss_magiin "Wisconsin's dependent care difference is added to modified AGI below zero" (renamed from "...added before the floor..."), from 0 to -500. Its taxable Social Security (0), AGI (-500) and every Wisconsin output (2,500, 1,000, 3,000, 1,500) are unchanged.taxable_ss_magi.yaml(single and joint) with the worksheet arithmetic in comments.changelog.d/fix-ss-magi-negative.fixed.md.Expected values
taxable_ss_magitax_unit_taxable_social_securityadjusted_gross_incometaxable_ss_magitax_unit_taxable_social_securityTax-Calculator 6.8.5 gives 1,000 taxable and -2,000 AGI for the single case.
Tests run locally
taxable_ss_magi.yaml,dependent_taxable_ss_magi.yaml,dependent_taxable_social_security.yaml,tax_unit_combined_income_for_social_security_taxability.yaml,calcfunctions/taxable_social_security.yaml,wi_itemized_deduction_credit.yaml,tax_unit_taxable_social_security_pre_1993.yaml(85 cases) pass.test_capital_gain_distributions_loss_limit.py,test_modified_agi_add_backs.py,core/test_dependent_above_the_line_deductions_invariants.py(31 tests) pass.policyengine_us/tests/policy/baseline/partners, 144 files, 4 batches) pass unchanged.No partner case has income below zero.Correction by an agent for a maintainer:partners/analytics_coverage/edge_cases/federal/tax_credits/cdcc/federal.yamlexpects -5,000 AGI, but that case has no Social Security, so this change does not move it.axiom: needed
🤖 Generated with Claude Code