Skip to content

[codex] Add SNAP local proxy diagnostics scaffold#241

Draft
daphnehanse11 wants to merge 4 commits into
mainfrom
codex/snap-local-proxy-diagnostics
Draft

[codex] Add SNAP local proxy diagnostics scaffold#241
daphnehanse11 wants to merge 4 commits into
mainfrom
codex/snap-local-proxy-diagnostics

Conversation

@daphnehanse11

Copy link
Copy Markdown
Collaborator

Summary

Refs #240.

This starts the SNAP congressional-district validation path without changing calibration policy. It adds a validation-only snap_local_proxy diagnostics helper that can compare household-level Populace SNAP receipt/support against ACS S2201 district SNAP household estimates, including support and quality flags.

The release builder now recognizes an optional snap_local_proxy.json artifact in the release manifest when one is present, matching the optional diagnostics pattern used for demographics.json and reform_validation.json.

Notes

This PR intentionally does not promote ACS S2201 to a hard target and does not run formula SNAP by congressional district. It provides the testable payload builder and manifest hook so the next slice can wire the actual source/runtime inputs once we choose the cheapest build-time path.

Validation

  • uv run pytest packages/populace-build/tests/test_us_snap_local_proxy.py packages/populace-build/tests/test_us_fiscal_refresh_builder.py -q
  • uv run ruff check packages/populace-build/src/populace/build/us_runtime/snap_local_proxy.py packages/populace-build/src/populace/build/us_runtime/__init__.py tools/build_us_fiscal_refresh_release.py packages/populace-build/tests/test_us_snap_local_proxy.py packages/populace-build/tests/test_us_fiscal_refresh_builder.py

@daphnehanse11 daphnehanse11 force-pushed the codex/snap-local-proxy-diagnostics branch from 1510ad5 to 3b10a40 Compare July 2, 2026 14:55
Two fixes to the SNAP local proxy diagnostics against the rebased main:

Match calibration diagnostics to state SNAP target specs by diagnostic
name ({spec.name}@{period}), the same join _critical_target_fit_failures
uses. The positional zip it replaces silently misattributed every state
error after a skipped target.

Normalize congressional-district identifiers to the geography spine's
bare 4-digit SSDD vocabulary on both sides of the ACS join: household
spine values pass through, Census summary-level prefixed ids
(5001700US0601 / 5001900US0601) are stripped with the same parser the
CD distribution loader uses. Without this every district row flagged
missing_acs_reference in real runs. The builder's local copy of the CD
geoid column constant now imports from congressional_district_geography
instead of redeclaring it.

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

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (post #266/#277/#279/#245 — one conflict in the us_runtime export list, two in the builder import block and main flow), plus two behavior fixes from cross-PR review:

  1. Name-based diagnostics join. _state_snap_relative_errors now matches calibration diagnostics to state SNAP specs by {spec.name}@{period} — the same join _critical_target_fit_failures uses — instead of a positional zip(..., strict=False) that silently misattributed every state error after a skipped target. The fixture test now feeds diagnostics out of spec order (plus an unrelated row) to prove the join.

  2. CD geoid vocabulary normalization. Household spine geoids are bare 4-digit SSDD (per Carry the block-anchored US geography ladder as spine columns #277), while Census fact geography ids carry summary-level prefixes (5001700US0601). Both sides of the ACS S2201 join now normalize through the same parser the CD distribution loader uses; previously every district would have flagged missing_acs_reference in a real run. The builder also imports CONGRESSIONAL_DISTRICT_GEOID_COLUMN from congressional_district_geography instead of redeclaring it.

Full populace-build suite passes. Remaining review note (not addressed here): _is_snap_local_proxy_fact still identifies S2201 facts by substring haystacks rather than structured source/measure matching — workable for a validation-only artifact, but worth tightening if this ever feeds targets.

Sequencing note: the state_snap_outlier flag only lights up when per-state SNAP targets are active in the registry, which #256 makes mandatory — merging #256 first (or together) gives this diagnostic its state-error channel.

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