Skip to content

Pool each state's congressional-district rows of one concept into one national loss budget - #1232

Draft
MaxGhenis wants to merge 3 commits into
mainfrom
cd-concept-budget-pooling
Draft

MaxGhenis wants to merge 3 commits into
mainfrom
cd-concept-budget-pooling

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On the national full surface, the #195 per-concept loss budget never pooled a congressional-district (CD) row. This PR makes it pool them again and adds a guard so a new per-row key cannot silently disable it a second time.

Changes

  • LEDGER_PER_ROW_LABEL_METADATA names the three labels, and the national exclusions now include them.

    • The ACS local key inherits them, so its own extra set shrinks to state_cd_cd_file_value.
    • Its effective exclusions are therefore the old set plus diagnostic_target_label.
  • validate_district_concept_groups now guards the national mapping, renamed us_fiscal_ledger_metadata.v2. The ACS local guard calls it too. It refuses:

    • district rows of one concept in one state (district_concept_identity) that land in more than one group; the error names the differing keys;
    • a district group that spans states;
    • a district row without state_fips.

    A future per-row key now fails the weights loudly.

  • Spec bundle: us/spec/calibration.yaml is regenerated with tools/generate_us_bundle_from_constants.py. Its exclusion list gains the three labels. The spec-engine pins move with it:

    • authored and configuration field counts (+3);
    • the calibration pointer claim (312 → 315 pointers);
    • the pointer-inventory digest;
    • the legacy-behaviour mode counts;
    • the US spec_sha256 (fbf25dba… → fe6d751d…);
    • docs/evidence/spec-engine/us-f0-coverage.json.

    Every new value was observed from the code, not transcribed.

  • The formula id US_FISCAL_TARGET_LOSS_WEIGHTING is unchanged. On the full surface the loss-vector digest in target_loss_basis moves, so the exact-k incumbent gate refuses to compare old-weighted runs with new ones.

Effect on loss weights (pinned feed 965a29ac…, --target-surface full, 33,249 targets)

These figures come from experiments/us-national-cd-concept-budget-20261012/ (script, results.json, README).

District rows (24,340) Groups Singletons Largest
Before 24,340 24,340 1
After 3,125 665 52 (CA)

After the fix, each group is exactly one concept identity. The 665 singletons are the seven single-district states (AK, DE, DC, ND, SD, VT, WY), 95 concepts each.

Share of the loss Targets Equal weights Before After
District 24,340 73.2% 45.6% 11.0%
State 8,409 25.3% 42.1% 68.8%
Country 500 1.5% 12.3% 20.2%
  • Non-district targets: every weight is multiplied by one factor per basis, ×1.6373 for amounts and ×1.6332 for counts.

  • District targets: the median weight is 0.157× what it was. The minimum, 0.033×, is in California's 52-district groups. Single-district states change by the basis factor only.

  • By family: irs_soi goes from 90.5% to 84.5%. Every other family rises by about 1.63×.

  • Unchanged:

    • Route A and any national_state run. They have no district rows, and the recorded weights and loss-basis hash 206ada09… still reproduce bit for bit.
    • The ACS local weights. acs_local_unchanged.py checks this against the pre-change module, bit for bit, on two kinds of surface:
      • the 09-23 release registry, whose digest is still ba36f887…;
      • the state, totals, full and state_cd surfaces of the pinned feed.
    • Target values and every published release.

    Only future --target-surface full calibrations change. Certified releases use national_state (d122).

Invariants (each tested)

  1. Differential. For every registry Hypothesis draws, the shared module returns, bit for bit, what the frozen pre-move helpers (test_support/.../us_target_loss_weights_reference.py) return for the same registry with the per-row labels removed. On label-free registries that is the pre-move result itself. Route A's 5,694 recorded weights still reproduce.

  2. Key invariance. A district row's national key does not change when any metadata naming its place, record or label is dropped or rewritten. These are all exclusions except state_fips and ledger_geography_level, which the key reads on purpose.

  3. Partition = identity. District rows share a national key if and only if they are one concept in one state (district_concept_identity). This is tested on random registries, on 31 real compiled rows from the pinned feed (new fixture, written by the experiment script), and on the whole pinned compile.

  4. Guard. The national weights refuse:

    • a per-row key that splits a concept, and the error names it;
    • a stateless district row;
    • a group that spans states.

    Non-district rows are never checked.

  5. The labels are real. The compiler's own _ledger_metadata and _diagnostic_target_label_metadata stamp exactly LEDGER_PER_ROW_LABEL_METADATA on a district fact. The diagnostic label appears only when the periods match. The pre-change key split two such districts, and the new key pools them.

  6. Feed-gated count (skips on CI). The pinned compile gives:

    • 24,340 district rows and 3,125 groups, max 52;
    • singletons of 95 per single-district state;
    • district loss share 0.456 → 0.110;
    • each basis's non-district rows rescaled by one common factor.

Merge rationale

This restores the behaviour that #195 documented and #1104 already applied to ACS local. It does not move target values or any release surface. Under the "obvious bug fix" rule it needs no ruling, so it merges on the usual gates: green CI, mergeable, and an independent review in agreement.

axiom: n/a: calibration loss-weighting infrastructure, no policy rule.

Review

Pending: independent GPT-6.1 Sol review (Subfleet review/hard, job 20261012-111905-cd-budget-review-r1) at 89c9c28; the later commits add only experiment evidence. Local runs: the 57 loss-weight tests pass, including the feed-gated one, and tools/spec_engine_coverage.py --check passes (42,187/42,187 fields, 41/41 inventory checks). A broader targeted run over the US release-tool and spec-engine test files is paused by a host hold.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits October 12, 2026 10:49
… national loss budget

The #195 concept budget never engaged on the full surface: since efa6052
(2026-09-05) the ledger compiler stamps per-row labels (ledger_fact_label,
ledger_layout_groupby_value_label, diagnostic_target_label) that the
district key read, so all 24,340 district rows were singleton groups.

- Exclude the three labels from the national concept key
  (LEDGER_PER_ROW_LABEL_METADATA); the ACS local key inherits them.
- Guard the national mapping (us_fiscal_ledger_metadata.v2) with
  validate_district_concept_groups, shared with the ACS local guard, so a
  per-row key that splits a district concept fails loudly.
- Regenerate the US spec bundle's concept-budget exclusion list and move
  the spec-engine field counts (+3 authored fields).
- Tests: differential against the frozen pre-move helpers with labels
  stripped, key invariance to place/record/label metadata, partition equals
  district concept identity, guard refusals, a real-row fixture from the
  pinned feed, and a feed-gated count of all 3,125 groups.

On the pinned feed the district rows' loss share falls from 45.6% to 11.0%;
national_state (Route A) weights are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…usions

The regenerated calibration.yaml lists three more metadata_exclusions, so
three more authored configuration fields. Every new value below was
observed from the code (tools/spec_engine_coverage.py, load_bundle("us")):

- EXPECTED_AUTHORED/CONFIGURATION_FIELD_COUNT 32_404/42_184 -> 32_407/42_187
- calibration pointer claim 312 -> 315 pointers (digest 1d499082...)
- EXPECTED_POINTER_INVENTORY_SHA256 -> bc18b1e1...
- legacy_behavior mode / generation-0 counts +3 (14_013, 38_501)
- US spec_sha256 fbf25dba... -> fe6d751d... (multispine pool tool test)
- docs/evidence/spec-engine/us-f0-coverage.json regenerated (42187/42187
  fields, 41/41 inventory checks)

Also note in the 10-04 ACS experiment README that its national finding is
fixed and that its state_cd national_as_is column would now be refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acs_local_unchanged.py loads the pre-change target_loss_weights.py (at
51a2637) beside the current one and compares the ACS local weights on the
09-23 release registry (digest still ba36f887...) and on the state, totals,
full and state_cd surfaces of the pinned feed: identical on all five.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

1 participant