Skip to content

Give US household examples a county for policyengine 6.x - #93

Open
MaxGhenis wants to merge 3 commits into
mainfrom
fix/spm-county-household-examples
Open

MaxGhenis wants to merge 3 commits into
mainfrom
fix/spm-county-household-examples

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Why

skill-examples fails on 8 US examples against policyengine 6.x (e.g. run 36597005380 on #92). pe.us.calculate_household(household={"state_code": "CA"}) raises SPMInputError: County selection has no county FIPS input.

This is an intended API change, not a regression. The error first appears in policyengine 6.0.0 (2026-09-15), which pins policyengine-us 2.2.1 and spm-calculator 1.0.0:

  • policyengine 6.0.0 CHANGELOG, Breaking changes: "require explicit geography for SPM-dependent outputs".
  • policyengine-us 2.0.0 CHANGELOG, Breaking changes: "Require county FIPS by default, or an explicit national or fixed SPM area selection". PR Use canonical SPM measurements and immutable population default policyengine-us#9428 names state-only callers as a coordinated-rollout item.
  • policyengine.py's tests/test_spm_household.py asserts this exact error for a state-only household.
  • spm-calculator 1.0.0 deliberately removed its national fallback, and a test pins that removal.

Bisect: 5.3.1 passes; 6.0.0, 6.1.0, 6.1.1 and 6.1.2 fail. No upstream fix is pending: neither policyengine.py main nor policyengine-us up to 2.17.0 changes this.

What changes

  • Every US calculate_household example passes county_fips as a five-digit string: 06037 Los Angeles, 48201 Harris, 36001 Albany.

  • The policyengine skill gains a "US geography" section:

    • the county vs spm={"geography_kind": "national"} vs metro selections, and the error codes;
    • validation happens only in county mode;
    • provenance;
    • the 2022–2035 year limit;
    • county-dependent rules fall back to first_county_in_state, and county_fips is never checked against state_code.
  • Asserted values that moved were re-pinned from real runs, and each move is attributed:

    Value Old New Cause
    CA net income 46,358 46,369 school-meal CPI-U refresh
    CalEITC 410.16 401.89 phase-out amounts re-indexed on published CA CPI (policyengine-us 1.776.2)
    NY net income 62,681 46,246 Head Start gated out of net income (1.819.0)
    NY SNAP 7,364 7,398 re-pinned from a real run; not separately attributed
    TX PTC 6,250.38 6,635.45 real Harris County rating area instead of the Anderson County fallback
  • New verified examples:

    • the ACA rating-area fallback;
    • NY county effects (SNAP $7,398 vs $8,061, NYC tax, SPM poverty);
    • ABAWD weekly_hours_worked_before_lsr now defaulting to 0 (SNAP $298 vs $3,607.57).
  • Household templates (backend-builder, new-tool, policyengine-tools, household-calc) and the YAML-test reference (quote county_fips; unquoted 06037 is octal 3103) now carry the new requirement. Version floors move to >=6.0.0.

  • New lint, tests/test_us_household_geography.py: any pe.us.calculate_household( without county_fips or spm= now fails the plain test job.

Checks

  • uv run pytest --ignore=tests/test_skill_examples.py: 181 passed. Wrapper build OK.
  • tests/test_skill_examples.py at commit 4b97588: 20 passed, 1 skipped on policyengine 6.1.2, and the same on 6.0.0 after the rating-area fix.
  • The last commit's two new verify blocks (NY county, ABAWD) were executed standalone on 6.1.2 with those exact values. CI's skill-examples job is their first run through the harness.
  • Require every reported number to come from a model run #92 rebases onto this branch with no conflicts (trial rebase: 181 passed). It should rebase after this merges; its 4.0.3 plugin release then ships both.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits September 29, 2026 13:12
policyengine 6.0.0 (policyengine-us 2.2.1, spm-calculator 1.0.0) made SPM
geography explicit: the default outputs of pe.us.calculate_household
include SPM poverty, and a household with only state_code raises
SPMInputError. Eight fast examples failed in skill-examples.

- Pass county_fips (a five-digit string) in every US household example.
- Document the requirement and the spm={"geography_kind": "national"}
  alternative, with a verified example of both and of the first-county
  fallback that county-less households get for county-dependent rules.
- Re-pin values that moved for located model changes: school-meal CPI-U
  refresh (+$11), CalEITC phase-out re-indexed on published CA CPI, Head
  Start gated out of net income (policyengine-us 1.819.0), and the Harris
  County ACA rating area.
- Add a lint that fails any pe.us.calculate_household call without
  county_fips or spm=, so the plain test job catches this next time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine 6.0.0 returns enum outputs as indices; names arrived in 6.1.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- US geography section: extra_variables cannot avoid the SPM defaults;
  county validation applies only in county mode (national silently maps a
  malformed county to the state's first county); metro selections,
  SPMSelection, error codes; provenance["spm"]; the 2022-2035 year limit;
  SNAP utility regions and NYC tax read the county; county vs state is
  unchecked.
- policyengine-us: correct the default-column list; verified examples for
  the NY county effect on SNAP/poverty and for ABAWD hours defaulting to 0;
  SPM rule on the country Simulation used for tracing.
- Head Start exception to budgetary-impact scoring; spm-calculator and the
  SPM measurement pin in "Checking what you're running".
- YAML tests: quote county_fips (unquoted 06037 is octal 3103); SPM outputs
  need a county.
- Household templates (backend-builder, new-tool, policyengine-tools,
  household-calc): collect a county or choose national SPM, year range,
  ABAWD hours. Version floors to >=6.0.0.

Every claim executed on policyengine 6.1.2 / policyengine-us 2.2.1.

Co-Authored-By: Claude Opus 5.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.

1 participant