Repository navigation
Conversation
ak_hap_base_benefit reads zip_code, then county_str, and no longer reads place_fips. Each ZIP code or borough takes the oil points, natural gas points and tribal marking held by the most 2020 Census residents. Military base ZIP codes are the four Addendum A rows marked 0/USA. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11229 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 24 48 +24
=========================================
+ Hits 24 48 +24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Restore main's place tables as the first key, and keep the ZIP code and borough tables as fallbacks for a household with no listed Census place. A military base place or ZIP code excludes a household. ZIP 99567 takes Chugiak's 7 oil points, which Addendum A and Appendix A to 7 AAC 44 both list. ZIP 99703 (Fort Wainwright) joins the military base ZIP codes under 7 AAC 44.040(b)(3)(B); the register candidate us-ak:hap-fort-wainwright-military-base records that Addendum A leaves its Served By column blank. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Addendum A and Appendix A to 7 AAC 44 give Chugiak 7 oil points, and Chugiak lies inside the Anchorage municipality (place 03000, 8 points) with no Census place of its own. A new list, place_refining_zip_codes, lets ZIP 99567 supply the points when a household also sends the place. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Convert zip_code to text, trim it and keep its first five characters before the ZIP code lookups, so a number or a ZIP+4 reads the same row, tribal routing and military base exclusion as the five-digit text. Add cases for those formats and for the default borough that a request with no place, ZIP code or county takes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PavelMakarchuk
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (head 556eb69fea)
PR #11229, "Add ZIP code and borough fallbacks to Alaska HAP community points". Fixes #11228. The head did not move during the review (last commit 9:17am EST, November 23, 2026).
Summary
ak_hap_base_benefit now finds community points by place_fips, then zip_code, then the borough from county. Tribal routing and the military base exclusion use the same keys. ZIP 99567 (Chugiak) refines the Anchorage place. The fallback order is correct and the formula is vectorized. The ZIP and borough tables agree with Addendum A and with the Census ZCTA files. All tests pass at head, after a merge with main, and after a merge with #11243.
I found no CRITICAL or SHOULD ADDRESS issue. One behavior is a design choice, listed as a suggestion: a household that sends no geography now gets the Aleutians East Borough value ($1,925 for the PR's case) instead of $0.
Findings
CRITICAL
None.
SHOULD ADDRESS
None.
SUGGESTION
- A request with no geography takes Aleutians East Borough's 11 oil points.
policyengine_us/variables/gov/states/ak/dpa/hap/ak_hap_base_benefit.py:16, 30-35. The sharedcountyvariable gives the state's first county alphabetically when the caller sends nothing. Case 96 tests this ($1,925). An API request with onlystate_code: AKis a common shape. For a typical Anchorage household it pays 11 × $175 = $1,925, where the correct community value is 8 × $175 = $1,400 (37% higher). Onmainthe same request pays $0. The PR body lists this limit. Options: use the statewide modal value (Anchorage, 8) when no place, ZIP orcounty_fipsinput exists, or keep $0 for that case. - ZIP 99613 does not use an Addendum A community.
zip_code_points/oil.yamlgives 99613 King Salmon's 13 points. Addendum A lists Igiugig (12) and Solomon (26) under 99613 and King Salmon under 99549. The Census ZCTA 99613 contains King Salmon CDP, and Solomon is a Nome-area village, so the Addendum A row looks like a state error. The YAML comment explains the choice. Consider a source-conflict note for it, like the Fort Wainwright note. - Spelling.
military_base_zip_codes.yamlcomments say "Eilson AFB". The base name is Eielson. Addendum A uses the same misspelling, so this is optional.
What I checked
- Head and state. Head
556eb69fea. Mergeable, merge state BLOCKED only for a required review. All 40 CI checks pass. The branch is 23 commits behindmain. A local merge withmainauto-mergesak_hap_base_benefit.py, its test file andsource_conflicts/candidates.yaml(main changed them in #11231) with no conflict. - Formula, line by line. Order: place, then ZIP, then borough, with
place_refining_zip_codes(99567) placed before the place key. Oil and gas tables share keys, and every table has anUNAVAILABLErow with 0.zip_code(typestr, defaultUNKNOWN) is stripped and cut to five characters, so an integer, " 99709 " and "99709-1234" read the same row. The military check reads place or ZIP, so a listed place with a base ZIP is excluded. Tribal routing follows the same key as the points. - ZIP table against Addendum A (FFY2027, 2026-02 revision, all rows). I parsed all 309 Addendum A rows (233 ZIP codes). All 233 are in the PR table. All 187 single-community ZIP codes match Addendum A on oil points and on the all-resident tribal mark, except four military ZIP codes (99505, 99506, 99702, 99731), which the PR excludes anyway. For all 46 multi-community ZIP codes, the PR value is one of the listed communities' values, except 99613 (suggestion 2). Gas points match where Addendum A prints them. The 15 extra ZIP codes (nine Anchorage ZCTAs, 99519 and 99734 Prudhoe Bay, 99635 Tyonek, 99652 Big Lake, 99694 Houston, 99775 College) take the Census place that the ZCTA-to-place file shows.
- Spot checks beyond Addendum A (more than 30). 99510 with Anchorage borough gives $1,400; 99559 Bethel routes to the tribe; place 24230 with ZIP 99703 gives $0; 99780 Tok gives 12 points; 99901 with Prince of Wales-Hyder borough uses the ZIP (Ketchikan, 4); 99567 with place 03000 gives 7 points;
county_fips: 02020alone gives Anchorage's 8. All 12 of my hand cases pass. - Borough table (30 rows). The 30 keys equal the 30 Alaska entries in the county enum and the county FIPS file (Chugach and Copper River, not Valdez-Cordova). For the 26 boroughs whose named community is in Addendum A, the oil value equals that community's Addendum A oil points, and its ZIP falls in that borough in the Census ZCTA-to-county file. The four CDP names (Kalifornsky, Knik-Fairview, Deltana, Utqiaġvik) are in the existing place table.
- ZIP codes that span boroughs. The Census ZCTA-to-county file shows 12 Alaska ZIP codes in two or three boroughs: 99503, 99588, 99613, 99701, 99729, 99737, 99738, 99760, 99780, 99827, 99833, 99901. The ZIP key wins over the borough key, so each takes one value (for example 99701 Fairbanks 10, 99737 Delta Junction 11, 99827 Haines 6). This agrees with the PR's "largest community" rule.
- Regulation and manual. 7 AAC 44.040(b)(3)(B) excludes a household that "resides ... on a military base". Appendix A to 7 AAC 44 gives Chugiak 7/5, Eklutna 8/5 and Peters Creek 8/5, and Loring 5 and Tetlin 16. Manual 3004-5 gives $175 per point for FY2027.
- Tests. Alaska HAP folder: 175 passed at head, 165 at
main, 181 after a merge withmain, and 187 after a merge with #11243 (with the nationalliheapfolder).test_source_conflicts.py: 251 passed on the merge withmain. Partner files that mention Alaska: 27 passed (I did not edit any partner file). - Format, changelog and data size.
ruff format --checkandruff checkpass.changelog.d/ak-hap-zip-county-points.changed.mdis a top-level file with a valid type. The largest new data file is 12 KB of YAML with comments; the sizes are reasonable. - Overlap. #11243 (under parallel review) changes
ak_hap_eligible.pyand its test in the same folder. It does not touch the files of this PR, and the two merge with no conflict.
Not verified
- The population-weighted counts in the PR body (97%, 99.8%, 83%) and the borough "most common points" picks. I did not rebuild the 2020 block-level join. I checked the chosen community and its value instead.
- HUD or USPS ZIP-to-county files. I used the Census ZCTA files, which are not identical to USPS ZIP codes.
- Microsimulation impact on Alaska totals.
Fixes #11228
What and why
Alaska assigns heating cost points to each community by name (7 AAC 44.080(a) and Appendix A to 7 AAC 44). The manual's Addendum A prints a ZIP code and a community name on each row.
ak_hapmatches those communities to Census places, and it paid $0 unless the caller sent a listedplace_fips. API callers rarely send one, and about 2% of Alaskans live outside any Census place.This PR keeps the place table as the first key and adds two fallbacks.
ak_hap_base_benefitnow readsplace_fips, thenzip_code, thencounty_str:The place stays first because a Census place is the closest match to the community Alaska names, and because the population dataset carries
place_fipsandcounty_fipsand no ZIP code. The place tables and the tribal place list are unchanged frommain, and so is every place-based result except a household that sends ZIP 99567 with the Anchorage place.A military base place or a military base ZIP code excludes a household, since some bases have no Census place and others share a ZIP code with a town.
The formula reads
zip_codeas text, trimmed to its first five characters, so a number or a ZIP+4 reads the same row as the five-digit text.How the fallback tables are built
Each ZIP code or borough takes the oil points, natural gas points and tribal marking held by the most 2020 residents living in Census places, with each place's values taken from the existing place table. Resident counts come from the 2020 Census P.L. 94-171 block file, joined to ZIP Code Tabulation Areas.
zip_code_points/oil.yaml,natural_gas.yamlcounty_points/oil.yaml,natural_gas.yamltribal_service_zip_codes.yamltribal_service_counties.yamlmilitary_base_zip_codes.yamlplace_refining_zip_codes.yamlTwo rows do not come straight from the Census counts:
place_refining_zip_codes.yamllets this ZIP code supply the points when a household sends both.Accuracy of the fallbacks
Shares of Alaskans living in a Census place, from 2020 Census block counts:
main, under manual 3004-5 step 1.Behavior changes
Limits that remain
countyvariable supplies the state's first county.Test plan
ak_hap.yamlandak_hap_income_factor.yamlare unchanged frommain.ak_hap_base_benefit.yamlkeeps the 87 cases onmain. Cases 62 and 63 now name a borough and move from $0 to $1,750. Cases 64 and 79 addcounty: UNKNOWNand keep $0.ak_hap_base_benefit.yamlandak_hap.yaml, and all matched; the YAML runner was not rerun. No other tests ran locally.us-ak:hap-fort-wainwright-military-base, which follows the regulation, and one sentence on ZIP-only households to theus-ak:hap-loring-oil-pointsnote.test_source_conflicts.pydid not run locally.make format:ruff format --checkandruff checkpass on the changed variable file.changelog.d/axiom: n/a: adds ZIP code and borough fallbacks to PolicyEngine's derived community points crosswalk; 7 AAC 44.040, 7 AAC 44.080 and Addendum A are unchanged.
🤖 Generated with Claude Code