Skip to content

Conversation

@hua7450
Copy link
Collaborator

@hua7450 hua7450 commented Nov 17, 2025

Fixes #6842

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (45ca8b6) to head (20f4c1c).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master    #6843      +/-   ##
===========================================
- Coverage   100.00%   97.18%   -2.82%     
===========================================
  Files            2        4       +2     
  Lines           26       71      +45     
  Branches         0        1       +1     
===========================================
+ Hits            26       69      +43     
- Misses           0        1       +1     
- Partials         0        1       +1     
Flag Coverage Δ
unittests 97.18% <100.00%> (-2.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

hua7450 and others added 2 commits November 19, 2025 15:23
…dual FBR

This commit fixes a critical bug in SSI spousal deeming calculations and improves code organization:

1. **Main Fix: Use couple FBR when deeming applies**
   - Modified `ssi_amount_if_eligible.py` to use couple rate ($1,450) instead of individual rate ($967) when spousal deeming applies
   - This corrects a $483/month ($5,796/year) underpayment for couples where only one spouse is eligible and the other has income exceeding the deeming threshold
   - Added mathematical proof in comments explaining why the regulatory cap is redundant

2. **New variable: is_ssi_spousal_deeming**
   - Created helper variable to determine when spousal deeming applies (spouse's countable income > $483/month)
   - Consolidates threshold logic in one place to avoid duplication
   - Clear boolean naming convention consistent with other SSI variables

3. **Bug fix: Child allocation consistency**
   - Fixed `ssi_unearned_income_deemed_from_ineligible_spouse.py` to multiply child allocations by `is_ssi_aged_blind_disabled`
   - Now consistent with `ssi_earned_income_deemed_from_ineligible_spouse.py` and parent deeming pattern

4. **Code improvements**
   - Refactored `ssi_income_deemed_from_ineligible_spouse.py` to reuse `is_ssi_spousal_deeming` instead of duplicating threshold check
   - Eliminated nested `where()` in `ssi_amount_if_eligible.py` for better readability
   - Better variable naming: `individual_earned` instead of `indiv_earned`

5. **Test updates**
   - Updated integration test expectations to reflect correct SSI amounts with couple FBR
   - All 102 SSI tests passing

Fixes PolicyEngine#6842

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@hua7450 hua7450 marked this pull request as ready for review November 19, 2025 20:34
hua7450 and others added 3 commits November 20, 2025 11:54
This commit refines the SSI spousal deeming fix with better code organization
and additional test coverage:

1. **Move cap logic from uncapped_ssi to ssi**
   - Makes uncapped_ssi truly "uncapped" (just amount - countable)
   - Consolidates all final logic (floor and cap) in the ssi output variable
   - Clearer separation of concerns

2. **Refactor is_ssi_spousal_deeming for clarity**
   - Use add() to combine earned and unearned deemed income
   - Rename variables for consistency (spouse_deemed_income)
   - Break out nested where() statements for readability

3. **Update comments with corrected understanding**
   - Clarify that deeming threshold compares GROSS income (not countable)
   - Explain why cap is necessary (not redundant)
   - Document that exclusions apply to COMBINED income after threshold check

4. **Add comprehensive test cases**
   - Case 8: Spouse earns $967 - demonstrates cap is necessary
   - Case 9: Spouse earns $3,000, no child - shows $0 benefit
   - Case 10: Spouse earns $3,000, with child - shows $234 benefit
   - Case 11: Single parent scenario with two children
   - All tests include detailed calculation step comments

5. **Fix child allocation consistency**
   - Added missing is_ssi_aged_blind_disabled filter to unearned income variable
   - Now consistent with earned income and parent deeming patterns

All 105 SSI tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link
Collaborator

@PavelMakarchuk PavelMakarchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, LGTM after

Copy link
Contributor

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR correctly implements the SSI spousal deeming rules per 20 CFR §416.1163 and SSA POMS SI 01320.400.

Key points:

  • Correctly uses the couple FBR when deeming applies.
  • Accurately implements the deeming threshold (spouse's income > difference between couple and individual FBR).
  • Properly caps the benefit at the individual FBR when deeming applies.

Comprehensive tests cover various scenarios, including the cap and child allocations. The code is well-refactored and addresses the bug effectively.

@MaxGhenis MaxGhenis merged commit 6edb9e7 into PolicyEngine:master Nov 21, 2025
6 of 7 checks passed
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.

SSI spousal deeming uses wrong FBR: couples lose benefit when deeming applies

3 participants