Skip to content

Score new bills on the ACS local-area release; keep 2026 scores on theirs - #240

Merged
DTrim99 merged 3 commits into
mainfrom
acs-local-new-scores
Dec 2, 2026
Merged

DTrim99 merged 3 commits into
mainfrom
acs-local-new-scores

Conversation

@DTrim99

@DTrim99 DTrim99 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

App v3 runs a state report on the Microcosm ACS local-area release, but the tracker scored every state bill on the archived policyengine-us-data state files. From now on, new scores use the ACS local-area release. The 2026 scores stay on the dataset they were computed on.

Which dataset a reform scores on

compute_impacts.py now chooses per reform (choose_state_dataset) and prints the choice and the reason for each:

  1. --state-dataset or TRACKER_STATE_DATASET, when given, decides for every reform in the run.
  2. A reform with a stored score keeps that score's source. An ACS local-area score matches on its build (dataset_version), so it stays on 766b7c7 after a later build becomes the default. A 2026 score matches on its name (policyengine-us-data) and stays on the us-data-cd119 files, including a recompute or another year (--multi-year). A stored build that STATE_DATASETS no longer lists is an error, not a silent move. The printed reason names the source and what was stored.
  3. A new score uses acs-local-766b7c7. That covers new bills from /encode-bill and new reforms from publish-reform.yml.

In compute_impacts.py, nothing recomputes the existing scores: the default still skips computed reforms, and rule 2 holds with --force. publish-reform.yml is the exception: it scores from a JSON config with no stored score to read, so every run there counts as new. For that path:

  • the workflow has a new optional state_dataset input, passed through as --state-dataset;
  • publish_analysis.py refuses to replace a stored score computed on another dataset unless state_dataset is set (--allow-dataset-change; publish-analysis.yml has an allow_dataset_change input for locally computed artifacts). Datasets whose stored version records only the installed data package (policyengine-us-data, populace-us) compare by name; ACS local-area builds compare by build.

A multi-year record now stores datasetName and datasetVersion in each impacts_by_year entry. Years written before this keep the stored row's dataset when a new year is added. The footer names each year's dataset when the years differ, and the row's otherwise.

The ACS local-area source

  • Release: populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z. policyengine.py 6.20.x names it for state regions, so App v3's state reports and these scores share a dataset. Its districts are the 119th Congress's.
  • Slices: loading the national file takes about 100 GB of memory, so the tracker reads the per-state slices child-poverty-impact-dashboard cut from it. They live on the Modal Volume cpid-populace-slices at 766b7c7/<ST>.h5; each holds one state's households and everyone in them, with weights unchanged.
  • Checks: a slice is downloaded once into ~/.cache/policyengine-tracker (override with TRACKER_DATASET_CACHE). It must match its SHA-256 in scripts/data/acs_local_766b7c7_slices.json, which pins all 51 slices. Together they hold 1,586,908 households, the release's own count.
  • Missing parent ids: current policyengine-us refuses missing inputs, so parent_1_id and parent_2_id, which the ASEC/PUF records leave missing, become 0 when a slice is opened. 0 is what the ACS records already store.
  • Model version: the tracker shares App v3's dataset but not its model. publish-reform.yml installs the newest policyengine-us; App v3 runs 2.2.2 through policyengine.py 6.20.0. The same reform can therefore give different numbers in the two. The parent-id fill is needed only because of the newer model.
  • At-large states: the release numbers an at-large state's one district 00 (Alaska 200, Delaware 1000); the 2026 files and the map use 01. For a one-district state the script now reads 00 as district 1. On the AK slice every household is in 200, which now maps to AK-01, so AK, DE, ND, SD, VT and WY get district results instead of a GEOID warning. (DC has no voting district in the tracker and stays skipped.)
  • Provenance: a score records dataset_name microcosm-us-2024-local and the build id as dataset_version, plus district_congress 119.

State income tax: what the release isn't calibrated to

The ACS local-area release is calibrated to each state's IRS SOI income distribution (AGI and filer counts by income range), so the tax base is constrained. It has no state income tax collections target for any state; the national release has one (Census STC FY2023) for 44 states. New scores' headline revenue numbers come from this release, so I checked the baselines.

On Modal, under policyengine-us 2.162.1 (what publish-reform.yml installs today), I computed the 2026 baseline state_income_tax total on each state's slice and on the 2026 files (us-data-cd119) for the 31 states with a scored 2026 bill, and compared both with Census FY2025 individual income tax collections (STC item T40). FY2025 ends mid-2025 for most states, so a 2026 tax year should run a few percent above it before any model difference. The last column is the national build's own 2024 fit to its FY2023 target, from the calibration dashboard. Amounts in $ billions.

State Bills ACS local-area 2026 files Census FY2025 ACS vs Census 2026 files vs Census National build vs its target
AL 1 6.83 6.65 5.80 +18% +15% +20%
AZ 1 6.28 5.15 5.49 +14% -6% +7%
CO 1 12.70 10.87 8.82 +44% +23% +15%
CT 8 14.61 10.12 11.22 +30% -10% +30%
DC 1 3.84 3.01 3.61 +7% -16% +6%
DE 1 2.40 2.03 2.75 -13% -26% -13%
GA 7 16.77 14.35 16.24 +3% -12% -0%
HI 2 3.11 2.63 3.29 -5% -20% -0%
IA 1 3.49 3.19 3.81 -8% -16% +3%
ID 1 2.86 2.30 3.10 -8% -26% +27%
IL 1 28.33 23.74 25.41 +11% -7% +16%
KS 2 5.62 4.81 4.68 +20% +3% +6%
MA 1 24.13 18.20 24.48 -1% -26% +8%
MD 1 15.02 12.30 11.70 +28% +5% +115%
MI 4 13.41 10.53 12.52 +7% -16% +11%
MN 6 17.36 13.91 13.96 +24% -0% +12%
MO 2 8.36 6.73 7.78 +7% -14% -3%
MS 1 2.05 1.84 2.37 -13% -23% -14%
NC 3 16.36 13.70 17.09 -4% -20% -4%
ND 1 0.31 0.27 0.43 -27% -36% -41%
NE 1 2.96 2.49 2.18 +36% +14% +3%
NJ 1 28.58 23.61 21.01 +36% +12% +31%
NY 6 69.24 43.58 61.20 +13% -29% +21%
OK 2 5.22 4.47 4.89 +7% -9% +10%
OR 1 14.99 12.64 13.07 +15% -3% +0%
RI 4 2.12 1.97 1.83 +16% +7% +12%
SC 2 7.69 6.61 6.75 +14% -2% +26%
UT 3 6.94 5.29 6.05 +15% -13% +3%
VA 2 23.20 18.38 19.03 +22% -3% +15%
WI 1 11.49 9.07 10.22 +12% -11% +14%
WV 2 2.20 1.84 2.16 +2% -15% -19%
  • ACS local-area baselines run a median 12% above Census collections (above it in 23 of 31 states); the 2026 files run a median 11% below. Each is within ±15% in 20 and 19 states.
  • ACS local-area exceeds the 2026 files in every state, by a median 19% (AL +3% to NY +59%).
  • The largest ACS gaps are CO (+44%), NE (+36%), NJ (+36%), CT (+30%) and MD (+28%); ND is 27% below.
  • A target is no guarantee: the national build misses its own target by more than 15% in 11 of these states (MD by 115%, likely a difference in definition, such as whether county income tax counts).
  • A rate change's revenue effect scales with the base, so a new score in, say, Colorado can come out higher than a 2026 score of a similar bill. KS HB2620 under the same model: −$4.98M on the ACS slice, −$4.71M on the 2026 files, against the fiscal note's −$5.0M. Its stored 2026 score, −$4.04M, came from an older model and data version, so most of that 23% gap is the model, not the dataset.

score-bill.md ("State Datasets") now says the release has no state income tax target and summarizes this check.

Bills on two datasets side by side

The home feed's cards show revenue, poverty and winners for each bill without naming the dataset; only the analysis footer does. After this PR a 2026 Kansas bill on the 2026 files can sit next to a new Kansas bill on the ACS release. A per-card label (or one sentence on the state page) is a follow-up, not in this PR.

Other changes

  • Workflows: publish-reform.yml installs modal, passes MODAL_TOKEN_ID and MODAL_TOKEN_SECRET to the compute step (the secrets deploy.yml and publish-bill.yml already use), and takes the optional state_dataset input. publish-analysis.yml takes allow_dataset_change.
  • Footer: the analysis footer names the dataset a score ran on (src/lib/datasetLabel.js): ACS-local scores read -microcosm:acs-local-766b7c7, linking the release on Hugging Face; the 2026 scores keep -us-data:v…. A multi-year analysis whose years ran on different datasets lists each year's.
  • Legacy pin fixed: the us-data-cd119 pin set in Draw district maps on the boundaries each analysis was computed on #235 (21280dca…) is not a commit of the Hugging Face repo, so every download of the 2026 files failed (404). It now pins the repo's head, 6c57bd60… (2026-05-31), which is the commit Draw district maps on the boundaries each analysis was computed on #235 meant. Recomputing a 2026 score was broken on main until this.
  • Docs: score-bill.md drops the PolicyEngine API polling steps: every result, statewide and district, comes from the local Microsimulation on the chosen state dataset, so the choice moves the headline number, not only the map. encode-bill.md lists the Modal prerequisite.

Checks

  • scripts/test_compute_impacts_datasets.py: 26 passed. New since the review: a stored ACS score stays on its own build after a later default; a stored build no source lists is an error; a 2026 score matches on its name whatever the package version, and the reason names the source; a pre-tracking name (enhanced_cps_2024) maps to us-data-cd119 with that said; multi-year writes record each year's dataset and backfill older years from the stored row; at-large 00 reads as district 1.
  • scripts/test_publish_analysis.py (new): 8 passed. The upload refuses to move a stored score, moves it with --allow-dataset-change, needs no flag for a new score, compares unpinned datasets by name and builds by build.
  • vitest: 80 passed in 8 files (3 new datasetLabels tests). eslint on the changed JS: clean. bun run build: passes. actionlint on both workflows: clean. ruff on compute_impacts.py: the 4 findings main already has, none new.
  • On Modal (policyengine-us 2.162.1, policyengine-core 3.39.0): the state income tax table above; the at-large district codes on the AK, DE, ND, SD, VT, WY and DC slices (all 00) against the 2026 files (all 01); KS HB2620 on both datasets. Earlier, under 2.156.9, the Kansas slice failed to load without the parent-id fill and loaded with it.

For review

  • The slices sit on the child-poverty dashboard's volume. The pinned hashes protect against changes there, but a shared volume owned by the data team would be a better home. The scorecard reads the same slices for its ACS-local state claims (policyengine-scorecard #278).
  • This assumes the repo's Modal token can read volumes in the policyengine workspace, where the tracker app deploys and the volume lives. A publish-reform dry run on a state reform would confirm it end to end.
  • Stored 2026 records with no dataset_name, or a name no source carries, count as us-data. Before this change, every state score was on those files.

🤖 Generated with Claude Code

…eirs

App v3 runs a state report on the Microcosm ACS local-area release
(policyengine.py 6.20.x routes state regions to
populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z), but the
tracker scored every state bill on the archived policyengine-us-data
state files. New scores now use the ACS local-area release; the 2026
scores stay on the dataset they were computed on.

- compute_impacts.py picks a dataset per reform (choose_state_dataset):
  --state-dataset or TRACKER_STATE_DATASET wins; a stored score keeps its
  dataset (a recompute or another year of a 2026 analysis stays on the
  us-data files); a new score uses `acs-local-766b7c7`. The run prints the
  choice and its reason for each reform.
- `acs-local-766b7c7` reads the per-state slices child-poverty-impact-
  dashboard cut from the release (Modal Volume cpid-populace-slices,
  766b7c7/<ST>.h5; each state's households, weights unchanged, 119th
  Congress districts). A slice is downloaded once into
  ~/.cache/policyengine-tracker (TRACKER_DATASET_CACHE) and must match its
  SHA-256 in scripts/data/acs_local_766b7c7_slices.json, which pins all 51
  (1,586,908 households, the release's count). Missing parent_1_id and
  parent_2_id on the ASEC/PUF records become 0, as current policyengine-us
  refuses missing inputs. Records store dataset_name
  microcosm-us-2024-local and the build id as dataset_version.
- publish-reform.yml installs modal and passes the Modal token to the
  compute step.
- The analysis footer names the dataset a score ran on
  (src/lib/datasetLabel.js): "-microcosm:acs-local-766b7c7" linking the
  release, or the "-us-data:v…" label the 2026 scores always had.
- score-bill and encode-bill docs describe the two datasets.

Checked on Modal: under policyengine-us 2.156.9 the Kansas slice fails to
load without the parent-id fill and loads with it; KS HB2620 (EITC 17% to
18%) changes state income tax by -$4.98M against the fiscal note's -$5.0M,
across KS-01 to KS-04.

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

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review at d72a679

This PR changes the state dataset that the tracker uses for new state scores. compute_impacts.py now chooses a dataset for each reform with choose_state_dataset. An explicit choice wins. A reform with a stored score keeps the dataset of that score. A new score uses the per-state slices of the Microcosm ACS local-area release populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z. The slices come from a Modal Volume and must match the SHA-256 values in a pinned manifest. Each score records the dataset name, the build and the Hugging Face revision. The analysis footer now names the dataset of each score.

Verdict: REQUEST_CHANGES

The dataset rule, the provenance and the release are correct. The release, revision and file hash agree with the policyengine.py 6.20.0 bundle that App v3 uses. One item blocks: the PR does not say that the release has no state income tax calibration target, and it gives one state as evidence for the main use.

SHOULD ADDRESS

  1. New state income tax scores run on a release with no state income tax target, and the PR does not say so. scripts/compute_impacts.py:593 (compute_budgetary_impact sums state_income_tax), scripts/compute_impacts.py:187 (DEFAULT_STATE_DATASET).
    • Case: the headline revenue number of every new state bill now comes from the ACS local-area slice. In the calibration dashboard, the local release has no state_income_tax row for any state. The national release has one for 44 states. The local release does calibrate the SOI income distribution by state (AGI and filer counts by income range), so the tax base is constrained, but total collections are not. The only evidence in the PR is one state: KS HB2620 gives -$4.98M against a fiscal note of -$5.0M. The same bill on the 2026 files gives -$4.0M, so the two datasets can differ by about 25% for one bill.
    • Fix: state the missing target in the description and in score-bill.md ("State Datasets"). Add a small check across more states: for example, the baseline state_income_tax total on the slice against Census collections and against the 2026 files, for the states of the open 2026 bills. Put the table in the description. No code change is necessary if the totals are close.

SUGGESTION

  1. publish-reform.yml always scores on the ACS local-area release, also for an existing reform id. .github/workflows/publish-reform.yml:159, scripts/compute_impacts.py:1202, scripts/publish_analysis.py:70.

    • Case: the offline path (--reform-json) sets "computed": False and has no dataset_name, so choose_state_dataset always returns "new score". If the router dispatches an id that already has a 2026 score (for example, after a correction), publish_analysis.py upserts the new row, and the 2026 score moves to the ACS release. The description says that "rule 2 holds even with --force" and that nothing recomputes the existing scores. This path is an exception.
    • Fix: add an optional state_dataset workflow input that the step passes as --state-dataset. Alternatively, make publish_analysis.py refuse to replace a row whose dataset_name is different. At a minimum, say in the description and in the workflow comment that this path always scores as new.
  2. A stored ACS score follows the default build, not its own build. scripts/compute_impacts.py:220.

    • Case: the rule compares only dataset_name (microcosm-us-2024-local). When a later build becomes DEFAULT_STATE_DATASET, a recompute of a 766b7c7 score moves to the new build. The 2026 scores stay pinned. This does not agree with "keeps the dataset it was computed on". Also, migrated rows that store enhanced_cps_2024 go to us-data-cd119, but the printed reason says "keeps its stored score's dataset (enhanced_cps_2024)".
    • Fix: match on dataset_version too (find the source whose dataset_version is the stored version), or document that "same dataset" means "same family". Print the source name in the reason, not the stored name.
  3. A multi-year record can mix datasets and record only one. scripts/compute_impacts.py:1011, :1052.

    • Case: impacts_by_year[year] stores no dataset name or version. The root dataset_name and dataset_version are overwritten by each write. The default rule keeps all years of one bill on one dataset, so this happens only with --state-dataset or TRACKER_STATE_DATASET. Then the year selector shows years from two datasets, and the footer names only the last one.
    • Fix: store datasetName and datasetVersion in each impacts_by_year entry. Alternatively, refuse an explicit choice that differs from the stored dataset when --multi-year is set.
  4. Bills on two datasets appear side by side with no label. src/components/RedesignHome.jsx:1112.

    • Case: the home feed shows revenue, poverty and winners for each bill. After this PR, a 2026 Kansas bill on the 2026 files and a new Kansas bill on the ACS release appear next to each other. Only the footer inside the analysis names the dataset. With the HB2620 gap above, a reader can compare two numbers that do not have the same basis.
    • Fix: say this in the description. As a follow-up, show the dataset (or "2026 data") on each card, or add one sentence on the state page.
  5. At-large states get no district results on the ACS release. scripts/compute_impacts.py:789.

    • Case: Microcosm gives at-large states and DC district 00, so Alaska is 200 and Delaware is 1000. The live district targets of this release use 0200, 1000, 1100, 3800, 4600, 5000 and 5600. The tracker expects state_fips * 100 + 1. A new bill in AK, DE, ND, SD, VT, WY or DC therefore prints a GEOID warning and stores no district_impacts. The map shows an at-large note for these states, so the page does not change. But the stored record has no district results, and the warning looks like an error.
    • Fix: for a one-district state, accept state_fips * 100 as district 1. Confirm on the AK slice.
  6. The data source table in score-bill.md is out of date. .claude/commands/score-bill.md:173.

    • Case: the row "Statewide (budget, poverty, deciles) | PolicyEngine API | Enhanced CPS (remote)" is not correct. compute_impacts.py computes all statewide results from the same state dataset as the district results. A reader can conclude that the dataset choice affects only the district map. The PR edits the next row, so this is a good time to fix it.
    • Fix: change the row to "Local Microsimulation" on the chosen state dataset, and remove the API polling steps above it.
  7. The tracker and App v3 share a dataset, but not a model version. Description and scripts/compute_impacts.py:160.

    • Case: policyengine.py 6.20.0 pins policyengine-us==2.2.2. publish-reform.yml installs the latest policyengine-us (the author used 2.156.9). The same reform can thus give different numbers in App v3 and in the tracker. The parent-id fill is necessary only because of the newer model.
    • Fix: add one sentence to the description and to the code comment.

What I checked

  • Diff. I read all 10 files and the full compute_impacts.py (loader, dataset choice, slice fetch, simulations, impact functions, Supabase write and main loop), publish_analysis.py and merge_research_metadata.py.
  • Dataset rule. Explicit choice, then a stored dataset_name equal to the ACS name, then any stored name or computed: true gives us-data-cd119, else ACS. "New" means no stored score. Recompute, --force and --multi-year on a 2026 bill stay on the 2026 files. Every write (single year, multi-year and offline) records dataset_name, dataset_version, and in model_notes the Congress and the source revision. The footer reads dataset_name through select('*').
  • Release against App v3. The policyengine.py 6.20.0 bundle uses this release for state regions, with revision 28f355b8931d14fd9705ebe818554f578f1719d6. The Hugging Face paths-info call for that revision gives LFS SHA-256 3ce781c4…838d6c and 9,819,603,807 bytes, as in the manifest. The footer link returns 200. The manifest has 51 slices (50 states and DC) with 1,586,908 households in total, the count in the PR.
  • Slice loading. Microsimulation in current policyengine-us accepts a USSingleYearDataset and extends it. parent_1_id and parent_2_id use 0 for "unknown" in the model, so the fill is correct. Each simulation gets its own loaded copy.
  • Failure behavior. A Modal error, a hash mismatch or a state that is not in the manifest raises an error for that reform. The run reports "error" and exits with 1. Nothing falls back to the 2026 files, so one score never mixes two datasets. A bad download leaves no file. A state that is not in the manifest gives only a bare KeyError, but all 50 states and DC are present.
  • Workflow. MODAL_TOKEN_ID and MODAL_TOKEN_SECRET exist as repository secrets, and deploy.yml and publish-bill.yml already use them. I could not confirm that the token can read the cpid-populace-slices volume. The dry run that the description proposes would confirm it.
  • Tests. pytest scripts/test_compute_impacts_datasets.py: 20 passed (one pandas FutureWarning from the test's object column). bun run test (vitest): 77 passed in 8 files. eslint on the changed JS files: clean. bun run build: passes. ruff on compute_impacts.py gives one new style finding (f.write in a loop) and the other findings are already on main.
  • CI. The repository has no workflow that runs on pull requests, so no checks are reported for this branch.
  • Related work. PR 239 (open) adds {state}-{bill}-{year} ids from the 2027 sessions on. These ids have no stored score, so they score on the ACS release, as the tests here expect (ky-hb1-2027).

…' pin

Addresses review of d72a679.

- A stored score matches its source on dataset_version (an ACS build stays
  on its build after a later default) or, for the 2026 files, on its name;
  a stored build no source lists is an error. The printed reason names the
  source and what was stored.
- publish-reform.yml takes an optional state_dataset input, and
  publish_analysis.py refuses to replace a stored score computed on another
  dataset unless that input (--allow-dataset-change) is set.
  publish-analysis.yml gets allow_dataset_change.
- Each impacts_by_year entry records its dataset; older years take the
  stored row's. The footer lists each year's dataset when they differ.
- An at-large state's district 00 (Microcosm) reads as district 1.
- The us-data-cd119 pin (21280dca) was not a commit of the Hugging Face
  repo, so every 2026-file download failed; pin the repo's head, 6c57bd60.
- score-bill.md: every result comes from the local Microsimulation on the
  chosen dataset; the release has no state income tax target (with the
  check's summary); model version and side-by-side notes.
- f.writelines for the slice download.

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

DTrim99 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All of it is addressed in 5c6986c; the description is updated to match.

Should address 1, state income tax target. score-bill.md ("State Datasets") and the description now say the release has no state income tax target and is calibrated to the SOI income distribution. I ran the check on Modal under policyengine-us 2.162.1: the 2026 baseline state_income_tax on each slice and on the 2026 files for the 31 states with a scored 2026 bill, against Census FY2025 collections (STC T40). The full table is in the description.

  • ACS local-area runs a median 12% above Census (above it in 23 of 31); the 2026 files run a median 11% below. Each is within ±15% in 20 and 19 states.
  • ACS local-area is above the 2026 files in every state, median +19% (AL +3% to NY +59%). The largest ACS gaps are CO +44%, NE +36%, NJ +36%, CT +30% and MD +28%; ND is −27%.
  • The national build misses its own FY2023 target by more than 15% in 11 of these states too, so having the target doesn't make it close.
  • KS HB2620 under the same model: −$4.98M on the ACS slice, −$4.71M on the 2026 files (fiscal note −$5.0M). The stored −$4.04M came from an older model and data version, so most of the 25% gap you noted is the model, not the dataset.

The totals aren't uniformly close, so I didn't call this settled; the description puts the table in front of the decision.

S1, publish-reform always scores as new. Added an optional state_dataset input, passed as --state-dataset. publish_analysis.py now reads the stored row and refuses to replace a score computed on another dataset unless that input is set (it passes --allow-dataset-change); publish-analysis.yml has an allow_dataset_change input for local artifacts. ACS builds compare by build; policyengine-us-data and populace-us, whose stored version is only the installed package, compare by name. The description no longer says rule 2 holds on every path.

S2, stored ACS score follows the default. A stored score now matches on dataset_version first, so a 766b7c7 score stays on 766b7c7 after a later default; a stored build that STATE_DATASETS no longer lists raises instead of moving. The 2026 files match on their name. The reason prints the source and the stored value, e.g. keeps its stored score's source, us-data-cd119 (stored: enhanced_cps_2024; scored before the tracker recorded its state files).

S3, multi-year mixes datasets. Each impacts_by_year entry stores datasetName and datasetVersion; when a year is added, older entries without them take the stored row's dataset. The footer lists each year's dataset when the years differ (the footer sits outside the year selector, so it names all of them rather than the selected one).

S4, cards side by side. Said in the description; a per-card label is listed as a follow-up.

S5, at-large districts. On the slices every household in AK, DE, ND, SD, VT, WY and DC is in district 00 (AK 200), and the 2026 files use 01. For a one-district state the script now reads 00 as district 1, with a test. DC has no voting district in the tracker and stays skipped.

S6, data source table. Fixed: statewide and district results both come from the local Microsimulation on the chosen dataset. I removed the API polling steps and the stale output sample.

S7, model version. One sentence in the description, score-bill.md and the code comments, including that the parent-id fill exists only because of the newer model.

ruff. The slice download uses f.writelines; ruff on compute_impacts.py now shows only the 4 findings main has.

One more fix. The check turned up that the us-data-cd119 pin from #235 (21280dca…) isn't a commit of the Hugging Face repo: every download of the 2026 files returned 404, so recomputing a 2026 score was broken on main. It now pins the repo's head, 6c57bd60… (2026-05-31), the commit #235 meant.

Checks: 26 + 8 Python tests, 80 vitest tests, eslint, bun run build and actionlint all pass. The repo has no PR CI.

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review at 5c6986c

This PR moves new state scores in the tracker to the per-state slices of the Microcosm ACS local-area release populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z. A stored score keeps the dataset it was computed on. The new commit answers the earlier review. It adds the state income tax check, a dataset guard in publish_analysis.py, a match on the stored build, per-year datasets, an at-large district fix and doc updates. It also fixes the us-data-cd119 Hugging Face pin, which pointed to a commit that does not exist.

Verdict: REQUEST_CHANGES

Thanks, David. The answer is thorough, and the 31-state table is good evidence. Eight of the nine earlier items are fixed. One fix does not reach the real code path: the loader never reads dataset_version, so a stored ACS score still follows the default build.

Earlier items

Item Status at 5c6986c
SHOULD ADDRESS 1: no state income tax target, one state as evidence Fixed. The description and score-bill.md state the missing target. The description has a 31-state table against Census FY2025 collections.
SUGGESTION 1: publish-reform.yml always scores as new Fixed. New state_dataset input. publish_analysis.py refuses to move a stored score without --allow-dataset-change.
SUGGESTION 2: a stored ACS score follows the default build Not fixed on the real path. The new function is correct, but load_reforms_from_db does not pass dataset_version to it. See SHOULD ADDRESS 1. The printed reason now names the source (fixed).
SUGGESTION 3: a multi-year record mixes datasets Fixed. Each impacts_by_year entry stores datasetName and datasetVersion. The footer lists each year when they differ.
SUGGESTION 4: bills on two datasets side by side Fixed as asked. The description and score-bill.md say it. A per-card label is a follow-up.
SUGGESTION 5: at-large states get no district results Fixed. at_large_district_geoids reads district 00 as district 1 for one-district states, with a test.
SUGGESTION 6: data source table out of date Fixed. Statewide and district rows both say "Local Microsimulation". The API polling steps are removed.
SUGGESTION 7: model version differs from App v3 Fixed. One sentence in the description, score-bill.md and two code comments.
ruff style finding (f.write in a loop) Fixed. f.writelines. ruff shows the 4 findings that main has.

SHOULD ADDRESS

  1. A stored ACS score still follows the default build, because the loader does not read dataset_version. scripts/compute_impacts.py:105 and :134, used by choose_state_dataset at :262.
    • Case: load_reforms_from_db selects reform_impacts(reform_params, computed, dataset_name) and builds each reform dict without dataset_version. Thus choose_state_dataset always gets stored_version = None for a reform from the database. For a stored ACS score, stored_state_dataset_source skips the version match, finds the ACS family by name, and returns DEFAULT_STATE_DATASET ("no stored version; matched on its name"). When a later build becomes the default, --force or --multi-year on a 766b7c7 score moves it to the new build. That is the earlier SUGGESTION 2 case. The guard for a retired build never raises on this path either. The new tests pass dataset_version in the reform dict directly, so they do not catch this. The docstring, score-bill.md and the description all say that the score "stays on 766b7c7 after a later build becomes the default". A later change of DEFAULT_STATE_DATASET can rely on that statement. Today only one ACS build exists, so no stored score moves yet.
    • Fix: add dataset_version to the select at line 105 and "dataset_version": impact_data.get("dataset_version") to the reform dict at line 134. Add a test that runs load_reforms_from_db on a stub Supabase client and then choose_state_dataset with a later default.

SUGGESTION

  1. Old years of a record with no stored version keep no dataset. scripts/compute_impacts.py:1081.
    • Case: the backfill of old impacts_by_year entries runs only when the stored row has a dataset_version. Older 2026 rows can have none. When --multi-year adds a year to such a row, the old years stay without a dataset, so datasetLabels falls back to the root row, which now names the new year's dataset. With the default rule both years use the 2026 files, so the label is correct. With an explicit --state-dataset the old years get the label of the new dataset.
    • Fix: also backfill when only dataset_name is stored, or when the row has neither (use "policyengine-us-data" and no version, as the loader rule does). This is a small case. A follow-up is enough.

New changes checked

  • Hugging Face pin. The Hugging Face revision API gives 404 for 21280dca5995e978d706740a8a4b9b7860cfd7b6 and 200 for 6c57bd6043d7ead3ea3e9bcc51ac509732a67cfe. The repo's current head is 6c57bd60…, last modified 2026-05-31. A range request for states/KS.h5 gives 206 at the new pin and 404 at the old pin. The fix is correct, and recompute of a 2026 score on main is broken without it.
  • publish_analysis.py guard. dataset_change returns no change for a row with no score, for the same unpinned name (policyengine-us-data, populace-us), and for the same pinned name and build. Any other change refuses without --allow-dataset-change. A legacy row with no name or with enhanced_cps_2024 refuses a new ACS artifact, which is correct. The Supabase import moved inside main, so --dry-run and the tests run without the package.
  • Workflows. state_dataset and allow_dataset_change reach the shell through env, not through direct ${{ }} in run. publish-reform.yml passes --allow-dataset-change only when state_dataset is set. An unknown state_dataset fails in state_dataset_source with the list of valid names.
  • At-large districts. num_districts and state_fips are set before the new calls. DC has 0 districts in STATE_DISTRICTS, so it returns before the mapping, as the description says. States with more than one district pass through unchanged.
  • Footer. datasetLabels lists one label per year only when every year has a version and the years differ. Each label key has the year prefix, so the React keys are unique. DataContext.jsx maps model_notes.impacts_by_year to impactsByYear.

What I checked

  • Diff. d72a679..5c6986c: 10 files, 517 insertions, 63 deletions. I read all of it, and the loader, the main loop and write_to_supabase in full.
  • Reply and description. I read David's reply comment and the updated description, with the 31-state table. The PR has no inline review threads.
  • Tests. pytest scripts/test_compute_impacts_datasets.py scripts/test_publish_analysis.py: 34 passed (26 + 8). bun run test (vitest): 80 passed in 8 files. eslint on the changed JS files: clean. bun run build: passes. ruff on compute_impacts.py and publish_analysis.py: 4 findings, the same 4 as on main. I did not run actionlint (not installed).
  • CI. The repository has no workflow that runs on pull requests.
  • Not checked. I did not run a microsimulation, read Supabase or open Modal slices. I did not reproduce the state income tax table or the KS numbers.

Address the second review on #240:
- load_reforms_from_db selects reform_impacts.dataset_version and passes
  it on, so choose_state_dataset matches a stored score on its build on
  the real path (and a retired build raises). Tested through the loader
  with a stub client and a later default.
- A multi-year write gives old years of a row with no stored version, or
  no name, the source the loader rule maps it to, with no version. The
  footer names each year when their dataset names differ, labeling an
  unversioned year by its name.

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

DTrim99 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, Pavel. Both items are fixed in 8e3641e.

Should address 1 (the loader drops dataset_version). load_reforms_from_db now selects reform_impacts(reform_params, computed, dataset_name, dataset_version) and puts dataset_version in each reform dict. A stored 766b7c7 score therefore matches on its version on the real path, and a stored build that STATE_DATASETS no longer lists raises. Two new tests go through the loader with a stub Supabase client:

  • a stored ACS score, then choose_state_dataset with a later ACS build as the default: it stays on 766b7c7 ("matched on its version"), and the test checks that the select names dataset_version;
  • a stored score on a build that isn't listed: it raises "no longer lists".

Suggestion 1 (old years of an unversioned row). A multi-year write now backfills old years whenever the stored row has no version, too. They get the dataset name of the source the loader rule maps the row to (the 2026 files' policyengine-us-data for a row with no name or enhanced_cps_2024) and no version. The footer then shows one label per year when the years' dataset names differ, and labels a year without a version by its name alone ("2026: -us-data"). Years that share a name, one with a version and one without, still show the stored row's single label. A Python test covers the backfill for a row with no dataset and for enhanced_cps_2024, and two vitest cases cover the footer.

Checks. pytest scripts/test_compute_impacts_datasets.py scripts/test_publish_analysis.py: 37 passed. bun run test: 82 passed. eslint on the changed files: clean. bun run build: passes. ruff on compute_impacts.py and publish_analysis.py: the same 4 findings as main.

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review at 8e3641e

This PR moves new state scores in the tracker to the per-state slices of the Microcosm ACS local-area release populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z. A stored score keeps the dataset it was computed on. The new commit answers the last review. The loader now reads dataset_version, and a multi-year write gives old years of an unversioned row a dataset name. The footer labels a year with a name and no version.

Verdict: APPROVE

Thanks, David. Both open items are fixed, and the new tests catch the bug on the real path.

Earlier items

Item Status at 8e3641e
SHOULD ADDRESS 1: the loader does not read dataset_version Fixed. The select and the reform dict both carry dataset_version. Two new tests run load_reforms_from_db on a stub client.
SUGGESTION 1: old years of an unversioned row keep no dataset Fixed. The backfill runs for any stored row with no version. Old years get the loader rule's source name and no version.
Items from the first review (eight) Still fixed. No change to that code in this commit.

SHOULD ADDRESS

None.

SUGGESTION

  1. Two years can show the same label twice. scripts/compute_impacts.py:1089 and src/lib/datasetLabel.js:49.
    • Case: a stored row has dataset_name = enhanced_cps_2024 and a version, for example 1.67.0. The backfill copies that raw name to the old years, because it maps the name only when the row has no version. A new year on the 2026 files writes policyengine-us-data with the same version. The names differ, so datasetLabels splits the footer, and both years show -us-data:v1.67.0. I reproduced this with a vitest probe. The label is correct, only repeated.
    • Fix: map the stored name through stored_state_dataset_source also when the row has a version. Or, in datasetLabels, split only when the label texts differ. A follow-up is enough.

New changes checked

  • Loader. load_reforms_from_db selects reform_impacts(reform_params, computed, dataset_name, dataset_version) and sets "dataset_version" in each reform dict. dataset_version is a column of reform_impacts in scripts/sql/001_create_tables.sql. The other selected columns are the same as on main. reform_impacts.id is the primary key and references research(id), so the embed can come back as one object. The loader handles an object and a list, and the two tests use one of each.
  • Loader tests. The tests call the real load_reforms_from_db on a stub client. The first test checks that the select names dataset_version. It then makes a later ACS build the default and checks that the score stays on 766b7c7 ("matched on its version"). The second test checks that an unlisted build raises "no longer lists". With the old two lines restored, both tests fail.
  • New raise on the real path. A stored ACS score on an unlisted build now raises in choose_state_dataset. The call is inside the per-reform try in the main loop, so a batch run skips that reform and continues. A 2026 row stored with a package version (for example 1.67.0) matches no pinned build. It then matches the 2026 files on its name and does not raise.
  • Backfill. stored_state_dataset_source(name, None) cannot raise, so the write path cannot fail on it. The entry check changed from "no version" to "no name". Old entries had neither, so a versioned row backfills the same entries as before. With the old condition restored, the new Python test fails.
  • Footer. namedLabel is used only for the per-year split. A year with no version shows -us-data or -microcosm:acs-local. A year with no name blocks the split, so the footer falls back to the stored row's label. Two years with the same name, one with a version and one without, show one label.

What I checked

  • Diff. 5c6986c..8e3641e: 4 files, 171 insertions, 7 deletions. I read all of it, and stored_state_dataset_source, choose_state_dataset, the main loop call and write_to_supabase in full.
  • Reply. I read David's reply comment. The PR has no inline review threads.
  • Schema. I compared the selected columns with the CREATE TABLE and ALTER TABLE statements in scripts/sql/. reform_params is not in those files, but main selects it too.
  • Tests. pytest scripts/test_compute_impacts_datasets.py scripts/test_publish_analysis.py: 37 passed. bun run test (vitest): 82 passed in 8 files. eslint on the changed JS files: clean. bun run build: passes. ruff on compute_impacts.py and publish_analysis.py: 4 findings, the same 4 as on main.
  • Mutation checks. I restored the old loader lines in a copy: the two loader tests fail. I disabled the new backfill branch in a copy: the backfill test fails.
  • CI. The repository has no workflow that runs on pull requests.
  • Not checked. I did not run the loader against the live Supabase database, run a microsimulation or open Modal slices.

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.

2 participants