Skip to content

Fix SNAP expected contribution rounding per 7 CFR 273.10(e) - #9318

Draft
hua7450 wants to merge 3 commits into
mainfrom
fix/snap-expected-contribution-rounding
Draft

Fix SNAP expected contribution rounding per 7 CFR 273.10(e)#9318
hua7450 wants to merge 3 commits into
mainfrom
fix/snap-expected-contribution-rounding

Conversation

@hua7450

@hua7450 hua7450 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the rounding in snap_expected_contribution, which previously computed floor(net_income) * 0.3 with no rounding of the product.

Fixes #9312

Legal basis

  • 7 CFR 273.10(e)(1)(ii)(A): net income is rounded to the nearest dollar — 1–49 cents down, 50–99 cents up (half-up, so np.floor(x + 0.5) rather than np.round's half-to-even).
  • 7 CFR 273.10(e)(2)(ii)(A)(1): 30 percent of net income is rounded up to the next higher dollar — equivalent to rounding the allotment down to the nearest lower whole dollar (7 U.S.C. 2017(a)).
  • The product is rounded to cents before np.ceil so float32 noise (e.g. 50 * 0.3 = 15.0000009) cannot push an exact dollar amount up to the next dollar.

Impact

Benefits shift weakly downward only (EC_new >= EC_old always): at most ~$1.10/month (up to ~$0.99 from rounding 30% up, plus up to ~$0.30 when net income rounds upward), i.e. $1–$13 per year on annual totals.

Tests

  • New snap_normal_allotment_basis_of_issuance.yaml (13 cases): 3-person allotments at net-income boundaries validated against the FNS Basis of Coupon/EBT Issuance table (Oct 1, 2025), including the net income $3.49 vs $3.50 half-up boundary and the exact-multiple $50/$51 rows.
  • New snap_categorical_eligibility_ceiling.yaml (3 cases): categorically eligible units above the issuance-table maximum (2-person gets the minimum allotment, 3-person gets $0 but stays flagged eligible per 7 CFR 273.10(e)(2)(iii) not converting to denial in the model).
  • Updated 16 existing baseline expectations whose old values carried fractional cents (e.g. 230.40 → 230) — artifacts of the missing rounding.

Partner contract tests (updated with approval)

64 SNAP pins under tests/policy/baseline/partners/analytics_coverage/ shift by $1–$13/year under the corrected rounding and were updated with Ziming's approval:

  • edge_cases (8 files, 31 pins): pins updated and every arithmetic comment rewritten to the new chain (round net half-up → 30% rounded up), e.g. EC 337.20 → ceil(1,124 × 0.3) = 338.
  • signatures (ca/federal, 33 pins): raw model-output pins updated (these were masked in the first CI run because the job aborted on the edge-case failures).

The change responds directly to the API partner's own rounding report, which serves as partner notice.

Test plan

  • 16 new tests pass locally
  • Updated baseline files pass locally
  • Updated partner files pass locally (29 + 18 + 46 cases)
  • CI fully green

🤖 Generated with Claude Code

Round net income to the nearest dollar (1-49 cents down, 50-99 cents up,
7 CFR 273.10(e)(1)(ii)(A)) and round 30 percent of net income up to the
next higher dollar (7 CFR 273.10(e)(2)(ii)(A)(1)), replacing the prior
floor-then-multiply formula. Add boundary tests against the FNS Basis of
Issuance table and categorical-eligibility ceiling tests.

Fixes #9312

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (57743a2) to head (8df8c50).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #9318   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         1    -2     
  Lines           65        14   -51     
=========================================
- Hits            65        14   -51     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Harness.
📢 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 August 20, 2026 09:37
The 31 SNAP pins in the analytics-coverage partner tests shift by $1-$11
per year under the legally correct rounding (net income to the nearest
dollar, 30 percent rounded up to the next dollar). Approved by Ziming.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…g fix

The 33 signature-replay SNAP pins (masked in the first CI run by the
edge-case failures) shift under the corrected rounding, and the
edge-case comments now show the ceil-of-30-percent arithmetic that
produces the updated pins. Approved by Ziming.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

SNAP expected contribution: round net income to nearest and 30% product up per 7 CFR 273.10(e)

1 participant