Skip to content

Add Fiscal Lab's Memo Bill Scores as an external source - #261

Draft
MaxGhenis wants to merge 7 commits into
mainfrom
sources/fiscal-lab-20261124
Draft

MaxGhenis wants to merge 7 commits into
mainfrom
sources/fiscal-lab-20261124

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds Fiscal Lab's Memo Bill Scores (released 2026-11-24) as an external US source. All 110 bills are staged, including the 101 that PolicyEngine can run little or none of.

What it adds

  • 248 claims on primary_deficit_change, against current law: 110 FY2027–2036 federal deficit totals, plus the low and high cases on 69 bills. H.R. 4849 also carries the 3 superseded values from the November 21 build, which was the build released on the 24th. The staged build is November 25's, and only H.R. 4849's score differs between them. That makes 251 figures in all.

  • sources/fiscal-lab-memo-scores/

    • adapter.py rebuilds the extract from the fetched page, whose hash is pinned, and checks the rebuilt CSV against the hash of the captured copy.
    • It checks each bill's score-table total against the bill's figure and range.
    • It flags the 6 bills whose CSV range rounds that total to $0.1 billion. The app's source column says so on those rows.
    • source.json records every raw file by URL, fetch date and SHA-256, with stored_in_repo: false.
    • NOTES.md documents the source.
  • pe_status.json marks each bill against the policyengine-us 2.2.2 source:

    • 9 bills are not_computed, all partial.
    • 101 are pe_gap: 92 none and 9 partial.

    A bill is partial when some of its score has a PolicyEngine lever. A lever means a reform can apply Fiscal Lab's assumption, as stated, to an amount PolicyEngine computes, and the amount needs a base in 2.2.2's certified default dataset. That dataset has no employer-paid or pre-tax premium amounts, so a stated employer premium rise is not a lever, though a structural reform could move it out of taxable wages.

  • scorecard_db/ingest_fiscal_lab.py writes the claims, the valueless pe_gap result rows and the fiscal-lab-memo-scores lane, and build_db runs it.

    • A rerun keeps other runs' results and diagnoses.
    • The lane follows the NZ Treasury ingest's stage rules. It counts a claim as computed only when its latest result carries a value, as the feed and the app do.
  • Feeds: 248 new US rows in populations.json and the new lane in lanes.json, plus their app copies.

No PolicyEngine number is recorded. H.R. 4849 and H.R. 1428 stay not_computed until the results in PolicyEngine/fiscal-lab-comparison pass review.

Fiscal Lab's terms

Fiscal Lab's terms let anyone share links and quote short excerpts with attribution. They also ask anyone republishing to use its contact form first.

  • Not committed: the page, the CSV, notes, narrative, annual paths, components and State tables. The adapter reads the CSV's closing source line from the fetched page at build time, so that line is not in the repository either.
  • Committed: the figures, bill titles, Fiscal Lab's model and effect labels, links, and the few short phrases the adapter matches to read each bill's version and Congress.

Max ruled on 2026-11-26 (decision d3450) to publish these 251 figures in this public repository. source.json records the ruling.

Checks

These were run on 6155472.

  • Python: the full suite on 3.12 passed at 01b1ca5 (5,863 passed, 19 skipped); at 5851df4 and 65f0635, which change only the adapter's fetch and tests, the Fiscal Lab, build-chain and export tests give 80 and 82 passed, and CI runs the full suite. ruff format --check is clean.

  • Build: two fresh build_db runs give the same content hash (ff5d25b7… at 01b1ca5), and the build and the suite leave the tree clean.

  • App: bun test src (65 pass), lint and build pass.

  • Fresh clone of the pushed branch: the Fiscal Lab, build-chain and export tests give 64 passed and 2 skipped. The two skip because they need the fetched page and the PE source, which CI doesn't have.

  • In-session review: two rounds of adversarial review covered terms, values, code, statuses and docs, and every confirmed finding is fixed. The second round found that PolicyEngine's benchmark premium parameter also moves its Medicaid cost index. So the 7 reasons that use that lever now put the premium change on slcsp, the tax-unit benchmark that aca_ptc reads.

  • Independent review, round 1 (Subfleet job 20261126-195439-scorecard-261-review) requested changes: 2 P1s and 5 P2s. In-session skeptics confirmed all 7, and a sweep of all 110 reasons found more of the same kind. 2db0bc6 answers them:

    • 30 reasons are reworded against the 2.2.2 source, and 2 more now cite the right Medicare file. Medicaid has two match rates per state, and its cost per enrollee is split by a benchmark-premium cost index, not a state average. The Part B premium is computed per enrollee. Medicare spending cites the gross per-capita parameter.
    • H.R. 3257's and H.R. 6455's levers are restated to what a reform can apply.
    • H.R. 9833 moves from pe_gap partial to none.
    • The lane counts only results that carry a value.
    • The ingest locks before reading and refuses timestamp ties.
    • fetch replaces the pinned page only on a hash match.

    Each code fix has a test that fails without it.

  • Independent review, round 2 (Subfleet job 20261126-213745-scorecard-261-review-r2) closed every round-1 finding except the fetch overlap, and requested changes: 4 P1s and 5 P2s. 6155472 answers them, and no status or scope changes:

    • A structural reform can move pay from taxable wages into employer-paid premiums. But 2.2.2's certified default dataset has no employer-paid or pre-tax premium amounts, so the employer exclusion line has no base. The method and the pe_gap legend now say a lever needs its base in that dataset. 11 reasons (H.R. 5509, 5448, 3415, 9257, 7227, 9941, 3762, 6423, 3069, 7023, 9702) now place that gap in the data.
    • H.R. 3415 and H.R. 9257 name the Basic Health Program's premium adjustment factor as a lever.
    • S. 4886's reason says the federal Medicare Savings Program cost leaves out full Medicaid enrollees.
    • H.R. 3257's below-poverty credit needs a state-limited override. H.R. 4206, 711 and 6609 get narrower wording.
    • NOTES.md's two wrong counts are fixed.
    • fetch stages each page in a file of its own. The gap-row refresh clears every classifier run's rows, so a later dated reclassification leaves no stale gap. Each fix has a test that fails on the old code.
    • The fourth P2, a lane-feed race in the shared sync_lane_feed, is filed as sync_lane_feed: overlapping ingests can lose or tear data/lanes.json #262.
  • Independent review, round 3 (Subfleet job 20261127-012145-scorecard-261-review-r3-scoped), scoped to the four P1s, found all four closed. Its verdict line says approve, but the levels decide: it raised two new P1s, in code this PR adds, and under the review rules those are open like any other. 01b1ca5 and 5851df4 answer them and the round's two P2s, and no status or scope changes:

    • The rerun delete matched any run id starting with the classifier's prefix, so it could remove a counterpart. It now matches only the classifier's own rows: a run id of the prefix and an ISO date, pe_gap, no value and the "no run" bundle. The ingest refuses a status run id the delete would not find.
    • fetch named its staging file after the page, 14 bytes longer, so a long but valid --dashboard name failed. The staging name is now short and fixed. The copy of a changed page kept beside the pinned one had the same flaw (13 bytes longer); its stem is now cut, on a character boundary, to fit 255 bytes.
    • H.R. 3069 names the payroll-tax pre-tax list as well as the income-tax one. H.R. 9702 names the Basic Health Program's premium adjustment factor, since that program's reference premium reads slcsp_age_0, not slcsp. A sweep of every bill with a Basic Health Program line adds the program's lever to Medicare for Kids (its minimum age), H.R. 1589 and H.R. 9432 (its immigrant status list).
    • All 14 tests added since 6155472 fail on its code. 01b1ca5's message overstates its mutation check: there, dropping the status clause or the value clause alone failed no test. 5851df4 adds a case for each column, and now dropping any one clause of the delete fails that clause's case.
  • Independent review, round 4 (Subfleet job 20261127-115939-scorecard-261-review-r4b-scoped, at 5851df4), the last scoped round, closed the rerun-delete P1. It found two P1s still open, both in how fetch names the copy it keeps when the live page differs from the pinned one:

    • With a long --dashboard name that has a long suffix, the copy's name passes the 255-byte limit.
    • A crafted 255-byte name equal to the shortened copy name lets a changed page overwrite the pinned copy. 5851df4 introduced this one when it shortened the name.

    Both need an unusual --dashboard path. The default raw/dashboard.html is unaffected, and nothing reaches the database, the feeds or the live site.

    The review rules cap review at four rounds, so this went to Max as decision d3497, and he ruled yes: apply the prepared fix and run a fifth scoped round. 65f0635 is that fix. It goes back to 01b1ca5's copy name, which is always 13 bytes longer than the page's and so never the page's own, and it stops with an error before writing anything when that name would not fit. It also adds the run-ID test round 4 asked for.

    Round 4's two P2s:

  • Independent review, round 5 (Subfleet job 20261127-140038-scorecard-261-review-r5-scoped, at 65f0635) is scoped to round 4's two P1s and the run-ID test. It is running. No merge happens while a P1 is open, and the merge itself is Max's call (d3461).

Follow-up

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits November 26, 2026 16:04
Stage all 248 claims from Fiscal Lab's Memo Bill Scores, released on
2026-11-24 and staged from the November 25 build: 110 FY2027-2036 federal
deficit totals, plus the low and high cases on 69 of them. They sit on
primary_deficit_change, held out, against current law. Every bill is
staged, including the 101 that PolicyEngine can run little or none of.

- sources/fiscal-lab-memo-scores:
  - adapter.py rebuilds the extract from the fetched, hash-pinned page and
    checks the rebuilt CSV against the hash of the captured copy. It reads
    the CSV's closing source line from the page's own code, so the line is
    not in the repository. It also checks each bill's score-table total
    against its figure and range, and flags the 6 bills whose CSV range
    rounds that total to $0.1 billion.
  - source.json records every raw file by URL, fetch date and SHA-256, with
    stored_in_repo false.
  - pe_status.json marks each bill not_computed (9, all partial) or pe_gap
    (101: 91 none, 10 partial), judged against the policyengine-us 2.2.2
    source.
  - NOTES.md documents the source.
- data/externals/fiscal-lab-memo-scores.json holds, per bill, identifiers
  and the bill's title, Fiscal Lab's model and effect labels, the printed
  values and links: 251 figures, 248 current plus H.R. 4849's 3 superseded
  values from the November 21 build. No raw Fiscal Lab file is committed;
  raw/ is git-ignored.
- scorecard_db/ingest_fiscal_lab.py writes the claims, valueless pe_gap
  result rows and the fiscal-lab-memo-scores lane. build_db runs it. A
  rerun keeps other runs' results and diagnoses, and the lane follows the
  NZ Treasury ingest's stage rules, counting what the feed shows.
- The feeds gain 248 US rows in populations.json and the new lane in
  lanes.json.

No PolicyEngine number is recorded. H.R. 4849 and H.R. 1428 stay
not_computed until the results in PolicyEngine/fiscal-lab-comparison pass
review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Max ruled on 2026-11-26 (decision d3450) to publish the 251 Fiscal Lab
figures in this public repository. The terms note in source.json and
NOTES.md now records that ruling in place of the open question.

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

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-scorecard Ready Ready Preview Nov 27, 2026 2:00pm UTC

Request Review

The independent review of #261 found reasons that misstate how
policyengine-us 2.2.2 works, and four ingest and fetch defects. A sweep
of all 110 reasons found more of the same kind; 32 are reworded against
the source:

- Medicaid: ACA expansion adults get one national expansion match and
  every other enrollee the state's regular match, not one rate per state.
  Cost per enrollee is each state's spending total split by a
  benchmark-premium cost index, not a state average.
- Each enrollee's Part B premium is computed (the standard premium plus
  the income-related adjustment, less Medicare Savings Program
  coverage); only the standard premium is a parameter.
- Medicare spending reasons cite medicare_gross_cost and per_capita_cost,
  not medicare_cost, which nets out each person's premiums.
- H.R. 3257's and H.R. 6455's levers are restated to what a reform can
  apply. H.R. 9833 moves from pe_gap partial to none: its one score line
  is the dental wraparound, which the only lever would price as full
  CHIP. The tally is 9 not_computed (partial) and 101 pe_gap (92 none,
  9 partial).

Code:

- The lane counts a claim as computed only when its latest result
  carries a value, as the populations feed and the app do.
- ingest() takes BEGIN IMMEDIATE before reading the registry, so
  overlapping ingests run one after the other.
- ingest() refuses two results on one claim at the same computed_at,
  which the feed would otherwise order by insert id.
- adapter.py fetch replaces the pinned page only when the body matches
  its hash, and saves a differing page beside it.

Each code fix has a test that fails without it. The feeds change only in
the reworded Fiscal Lab rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 2 of the independent review (Subfleet job
20261126-213745-scorecard-261-review-r2) raised 4 P1s and 5 P2s.

Status reasons (pe_status.json; no status, scope or gap class changed):
- A structural reform can move pay from taxable wages into employer-paid
  premiums, but policyengine-us 2.2.2's certified default dataset has no
  employer-paid or pre-tax premium amounts. The method and the pe_gap
  legend now say a lever needs its base in that dataset. H.R. 5509,
  5448, 3415, 9257, 7227, 9941, 3762, 6423, 3069, 7023 and 9702 place
  the employer exclusion gap in the data.
- H.R. 3415 and 9257 name the Basic Health Program's premium
  adjustment factor as a lever.
- S. 4886: msp_federal_cost leaves out full Medicaid enrollees.
- H.R. 3257's below-poverty credit needs a state-limited override.
- H.R. 4206, 711 and 6609: narrower wording.

NOTES.md gives the right counts: 9 pe_gap partial, and after round 1,
30 reworded reasons plus 2 path-only fixes.

Code:
- fetch stages each page in a temporary file of its own, so overlapping
  fetches cannot swap bodies.
- The gap-row refresh deletes every classifier run's rows (by run-id
  prefix), so a later dated reclassification leaves no stale gap.

Each code fix has a test that fails on the old code. The lane-feed race
in the shared sync_lane_feed is filed as #262.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 27, 2026
ingest_uk_childcare_100k read the registry's old claims before any write
lock, so two overlapping ingests could both read an empty registry. Both
then deleted nothing and each inserted every result, leaving each claim's
result twice per run. The ingest now takes BEGIN IMMEDIATE before the read,
as ingest_fiscal_lab does in PR #261, so overlapping runs serialise. The
connection now closes in a finally block, so a lock timeout or a failed
write no longer leaves it open.

The new test starts two ingests on one database and holds each at its
registry read until the other reads, then compares the rows with a single
ingest's. On the old code the two reads meet and every pe_results row is
doubled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 3 of the independent review (Subfleet job
20261127-012145-scorecard-261-review-r3-scoped) closed round 2's four
P1s and raised two new P1s and two P2s.

Code:
- The rerun delete now matches only the classifier's own rows: a run id
  of the prefix and an ISO date, status pe_gap, no value and the "no run"
  bundle. A counterpart survives a rerun whatever its run id. The ingest
  refuses a status run id that the delete would not find.
- fetch stages each page under a short fixed name, so a dest name of any
  length the filesystem accepts can be fetched to.

Each code fix has tests that fail on the old code, and a partial mutation
of each clause in the delete fails its own case.

Status reasons (pe_status.json; no status, scope or gap class changed):
- H.R. 3069 names the payroll-tax pre-tax list beside the income-tax one.
- H.R. 9702 names the Basic Health Program's premium adjustment factor:
  the program's reference premium reads slcsp_age_0, not slcsp.
- A sweep of every bill with a Basic Health Program line adds its lever
  to Medicare for Kids (minimum age), H.R. 1589 and H.R. 9432 (immigrant
  status list).

NOTES.md describes the round-3 changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
01b1ca5's message says a partial mutation of each clause in the rerun
delete fails its own case. That held for the run-id shape and the bundle
clause only: dropping the status clause or the value clause alone left
every test passing. The counterpart test now has a case for each column
that differs from a classifier row in that column alone, so dropping any
one clause fails its case.

fetch kept a changed page beside the pinned copy as
<stem>.<sha256[:12]><suffix>, 13 bytes longer than dest's name, so a
dest name over 242 bytes could not keep one. beside() now cuts the stem
on a character boundary when the name would pass 255 bytes.

All 14 tests added since 6155472 fail on its code.

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

Round 4 (Subfleet 20261127-115939-scorecard-261-review-r4b-scoped) closed
the rerun-delete P1 and left two P1s open, both in the name fetch gives
the copy of a changed page that it keeps beside the pinned one.

- 5851df4 introduced an overwrite. Its beside() cut the stem to fit 255
  bytes, so a 255-byte dest whose stem already ended in the new page's
  ".<sha256[:12]>" got back dest itself, and the changed page replaced
  the pinned copy. 01b1ca5's uncut name could never equal dest.
- The cut also left a long suffix overflowing: for "d." + "x" * 242 the
  copy still needed 256 bytes.

beside() goes back to the uncut <stem>.<sha256[:12]><suffix>, exactly 13
bytes longer than dest's name and so never dest. fetch works out the
target before staging and, when a changed page's copy would pass 255
bytes, raises ValueError before it writes anything. A pinned fetch to a
255-byte name still works.

Tests:
- test_the_kept_copy_is_never_dest: a Hypothesis property over names
  padded up to 255 bytes, including names that already carry the digest.
- test_a_changed_page_never_overwrites_dest_whatever_it_is_called:
  round 4's collision case.
- test_a_changed_page_is_kept_beside_only_where_its_name_fits: 242 bytes
  fits; 243 bytes and the long suffix are refused.
- A counterpart case, other-run-id-shape, isolates the run-id clause of
  the rerun delete (round 4's P2). Dropping that clause fails only it.
- 5851df4's truncation tests are removed.

On 5851df4's adapter the property, collision and both refusal tests fail
(4); with the length check removed, the collision and refusal tests fail
(3). Fiscal Lab, build-chain and export tests: 82 passed. Ruff is clean.

Round 4's other P2, that pe_results rows carry no producer, is filed as
#265. Max ruled yes on d3497 (apply this fix, run a scoped round 5).

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

This branch was successfully deployed

1 active deployment
Preview — 65f0635d Deployed Nov 27, 2026 by vercel[bot]
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