Skip to content

Add ZIP code and borough fallbacks to Alaska HAP community points - #11229

Open
hua7450 wants to merge 4 commits into
mainfrom
ak-hap-zip-county-points
Open

hua7450 wants to merge 4 commits into
mainfrom
ak-hap-zip-county-points

Conversation

@hua7450

@hua7450 hua7450 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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_hap matches those communities to Census places, and it paid $0 unless the caller sent a listed place_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_benefit now reads place_fips, then zip_code, then county_str:

Household sends Key Result
A listed Census place Place table, unchanged Its own community's points and tribal routing, unless the ZIP code refines the place (ZIP 99567, below)
No listed place, a listed ZIP code New ZIP code table The points and routing of the community where most of the ZIP code's residents live
Neither New borough table The most common points and routing among the borough's residents

The place stays first because a Census place is the closest match to the community Alaska names, and because the population dataset carries place_fips and county_fips and no ZIP code. The place tables and the tribal place list are unchanged from main, 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_code as 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.

Table Rows Where each row comes from
zip_code_points/oil.yaml, natural_gas.yaml 248 ZIP codes 242 Census ZIP areas with residents in Census places, plus 6 Addendum A ZIP codes with no Census area (99545, 99716, 99731, 99821, 99928, 99950)
county_points/oil.yaml, natural_gas.yaml 30 boroughs and census areas The most common points among residents' communities
tribal_service_zip_codes.yaml 101 ZIP codes Most residents live in a community that Addendum A marks 0 (the tribe serves all residents)
tribal_service_counties.yaml 9 boroughs and census areas Bethel, Bristol Bay, Dillingham, Kusilvak, Yakutat and Yukon-Koyukuk (at least 99% of residents), Prince of Wales-Hyder (79%), Lake and Peninsula (78%) and Hoonah-Angoon (61%)
military_base_zip_codes.yaml 5 ZIP codes 99505 Fort Richardson, 99506 Elmendorf AFB, 99702 Eielson AFB, 99703 Fort Wainwright and 99731 Fort Greely
place_refining_zip_codes.yaml 1 ZIP code 99567 Chugiak, a community with its own points inside the Anchorage municipality

Two rows do not come straight from the Census counts:

  • ZIP 99567 takes Chugiak's 7 oil points. The ZIP code lies wholly inside the Anchorage municipality, one Census place, so the counts cannot rank the three communities Addendum A lists there. Addendum A and Appendix A both give Chugiak 7 and Eklutna and Peters Creek 8, and the Postal Service names the ZIP code Chugiak. Because the Anchorage place (03000, 8 points) cannot identify Chugiak, place_refining_zip_codes.yaml lets this ZIP code supply the points when a household sends both.
  • ZIP 99703 is Fort Wainwright. 7 AAC 44.040(b)(3)(B) makes a household residing on a military base ineligible. Addendum A marks four installations 0/USA and leaves Fort Wainwright's Served By column blank. The 2020 Census puts all 8,749 residents of the ZIP area in special land-use tract 9800, as it puts the residents of the other base ZIP codes in tracts 9801 and 9802.

Accuracy of the fallbacks

Shares of Alaskans living in a Census place, from 2020 Census block counts:

Key Own community's oil points Own community's tribal routing
ZIP code About 97% outside ZIP 99567 (686,948 of 707,141 residents); 95.9% counting it 99.8% (1,212 of 716,177 residents differ)
Borough About 83% 99.5% (3,699 of 716,681 residents differ)
  • Census counts cannot tell Chugiak from Eklutna and Peters Creek inside ZIP 99567, so the 95.9% figure counts its 9,036 residents as not matching.
  • All 187 ZIP codes that Addendum A lists with one community match it on oil points and tribal marking. Addendum A prints natural gas points for 14 of them, and all 14 match. The other 173 hold the nearest gas community's points (6, 8 or 5) from the place table on main, under manual 3004-5 step 1.
  • 30 ZIP codes hold communities with different oil points. Every household that sends only the ZIP code takes the largest community's points.
  • 7 of the 30 boroughs have one oil value throughout.

Behavior changes

Household Before After
Sends a listed place Its community's points Unchanged
Sends no listed place and a listed ZIP code $0 The ZIP code's points and routing
Sends no listed place or ZIP code, and a borough $0 The borough's points and routing
Sends no place, ZIP code or county $0 Takes the shared default county, Aleutians East Borough: 11 oil points
Sends ZIP 99505, 99506 or 99703 Paid as Anchorage or Fairbanks when it sent the place, else $0 Excluded as living on base
Sends ZIP 99567 Anchorage's 8 oil points when it sent place 03000, else $0 Chugiak's 7 oil points, with or without the place

Limits that remain

  • A Tetlin household that sends only ZIP 99780 follows Tok: 12 oil points and state routing. Addendum A marks Tetlin as served by its tribe. With place 76590 the household is routed to the tribe, as before.
  • A Loring household that sends only ZIP 99901 takes Ketchikan's 4 oil points. With place 45020 it takes Appendix A's 5, as before.
  • A Beluga household that sends only ZIP 99695 follows Ivanof Bay: tribal routing and $0. Addendum A lists Beluga as state-served with 7 oil points. Edna Bay, Hollis and Whale Pass (ZIP 99921, with Craig) and Annette (ZIP 99926, with Metlakatla) are routed to the tribe the same way. All sit inside the 1,212 residents counted above.
  • A ZIP code outside the table, such as the Anchorage post office box ZIP code 99510, falls to the borough the household sends, or to the default borough when it sends none.
  • Place 03000 gives the whole Anchorage municipality 8 oil points, so a Chugiak household that sends the place and no ZIP code takes 8. Nothing else identifies Chugiak.
  • The formula cannot tell a household with no geography from one in the Aleutians East Borough, because the shared county variable supplies the state's first county.

Test plan

  • YAML tests whose expected values come from an external source: Addendum A points times the $175 point value in manual 3004-5.
    • ak_hap.yaml and ak_hap_income_factor.yaml are unchanged from main.
    • ak_hap_base_benefit.yaml keeps the 87 cases on main. Cases 62 and 63 now name a borough and move from $0 to $1,750. Cases 64 and 79 add county: UNKNOWN and keep $0.
    • Cases 88 to 97 are new: the ZIP code key for oil, gas and tribal routing, the borough key, which key wins, ZIP 99567 with and without the Anchorage place, the military base ZIP codes, the default borough for a request with no geography ($1,925), and a ZIP code sent as a number or as ZIP+4.
    • 136 cases in the three Alaska test files passed locally with policyengine-core 3.36.0 at 82de336. At the current head a script computed all 115 cases in ak_hap_base_benefit.yaml and ak_hap.yaml, and all matched; the YAML runner was not rerun. No other tests ran locally.
  • Source-conflict register: this PR adds the candidate us-ak:hap-fort-wainwright-military-base, which follows the regulation, and one sentence on ZIP-only households to the us-ak:hap-loring-oil-points note. test_source_conflicts.py did not run locally.
  • make format: ruff format --check and ruff check pass on the changed variable file.
  • Changelog fragment in 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

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

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8999568) to head (556eb69).
⚠️ Report is 314 commits behind head on main.

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     
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.

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>
@hua7450 hua7450 changed the title Key Alaska HAP community points on ZIP code with a borough fallback Add ZIP code and borough fallbacks to Alaska HAP community points Nov 23, 2026
hua7450 and others added 2 commits November 22, 2026 23:07
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>
@hua7450
hua7450 marked this pull request as ready for review November 23, 2026 14:20

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

  1. 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 shared county variable gives the state's first county alphabetically when the caller sends nothing. Case 96 tests this ($1,925). An API request with only state_code: AK is 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). On main the same request pays $0. The PR body lists this limit. Options: use the statewide modal value (Anchorage, 8) when no place, ZIP or county_fips input exists, or keep $0 for that case.
  2. ZIP 99613 does not use an Addendum A community. zip_code_points/oil.yaml gives 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.
  3. Spelling. military_base_zip_codes.yaml comments 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 behind main. A local merge with main auto-merges ak_hap_base_benefit.py, its test file and source_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 an UNAVAILABLE row with 0. zip_code (type str, default UNKNOWN) 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: 02020 alone 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 with main, and 187 after a merge with #11243 (with the national liheap folder). test_source_conflicts.py: 251 passed on the merge with main. Partner files that mention Alaska: 27 passed (I did not edit any partner file).
  • Format, changelog and data size. ruff format --check and ruff check pass. changelog.d/ak-hap-zip-county-points.changed.md is 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.py and 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.

This branch has not been deployed

No deployments
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.

Add ZIP code and borough fallbacks to Alaska Heating Assistance community points

2 participants