Skip to content

Restore three_digit_zip_code formula (fixes ACA PTC regression)#7774

Merged
MaxGhenis merged 2 commits intoPolicyEngine:mainfrom
MaxGhenis:fix-three-digit-zip-code-regression
Mar 13, 2026
Merged

Restore three_digit_zip_code formula (fixes ACA PTC regression)#7774
MaxGhenis merged 2 commits intoPolicyEngine:mainfrom
MaxGhenis:fix-three-digit-zip-code-regression

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • Restores the three_digit_zip_code formula that was incorrectly removed in Remove dead ZIP_CODE_DATASET infrastructure #7695 as part of ZIP_CODE_DATASET cleanup
  • The formula derives the 3-digit ZIP prefix from zip_code (e.g. 90019900) and has no dependency on ZIP_CODE_DATASET
  • Its removal silently broke ACA PTC for all LA County households (aca_ptc = $0 instead of ~$5,055)

Root cause

PR #7695 removed ZIP_CODE_DATASET infrastructure, but the three_digit_zip_code formula was pure arithmetic (zip_code // 100) with no dataset dependency. Without it, slcsp_rating_area_la_county can't look up rating areas → slcsp = 0 → aca_ptc = 0.

Reported by Paul Huntsberger (Amplifi) in #partner-amplifi.

Test plan

  • Unit test: 90019"900" derivation
  • Unit test: 01234"012" (leading zero preserved)
  • Integration test: LA County zip 90019 produces nonzero aca_ptc
  • CI passes

🤖 Generated with Claude Code

The formula derives the 3-digit ZIP prefix from zip_code (e.g. 90019 → 900)
and is independent of ZIP_CODE_DATASET. Its removal silently broke ACA PTC
calculations for all LA County households that provide zip_code but not
three_digit_zip_code, causing aca_ptc to return 0 instead of ~$5,055.

Adds regression tests for the derivation and an integration test reproducing
the Amplifi-reported ACA PTC bug.

Fixes the regression introduced in 9d05912.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (752fae4) to head (ad4478c).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7774   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         1    -1     
  Lines           13        10    -3     
=========================================
- Hits            13        10    -3     
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 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.

- Use integer division (// 100) instead of float (// 1e2) in three_digit_zip_code
- Import Simulation from policyengine_us public API, not policyengine_core internals
- Add code deletion safety rule to CLAUDE.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit cf1e539 into PolicyEngine:main Mar 13, 2026
9 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.

1 participant