Skip to content

Add a readiness lookup: calibration and scorecard evidence for a reform in a state - #242

Merged
DTrim99 merged 2 commits into
mainfrom
readiness-lookup
Dec 3, 2026
Merged

DTrim99 merged 2 commits into
mainfrom
readiness-lookup

Conversation

@DTrim99

@DTrim99 DTrim99 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

A lookup that says, without running a microsimulation, how well the data supports scoring a reform in a state. It covers Teamverse milestone p304 ("Baseline checked for each kind of bill") and will be the calibration and scorecard half of the comparison step when bills are scored through App v3 (p451).

What it does

scripts/readiness_lookup.py takes a state and either a kind of bill or a reform dict (reform_impacts.reform_params), and reports two views:

  1. Calibration. The reform's parameter paths reach model variables through the dependency map App v3 traces from the model (policyengine-app-v2 app/src/data/flagship/parameterDependencies.json, used by its calibration panel). The variables that read a path, what they move downstream, and the inputs upstream are matched to the state's targets in the Microcosm release, which is ACS local-area by default (the release a state report runs on). Each target group, a variable in one measure (a count of returns or a dollar amount), gets its fit. The inputs and totals no target measures are flagged, with the national release's coverage beside them. No target in either release is held out, so the output says a close fit is expected by construction.
  2. Scorecard. Claims in the scorecard's published feed for the state, and the nearest scored bills of the same kind anywhere, with PolicyEngine's value over the outside estimate and the dataset it ran on. Claims the release was calibrated to are left out.

scripts/data/readiness_kinds.yaml adds what a trace can't say: each kind's parameter patterns, the key inputs that decide who a reform reaches (each with the reason), the totals a target could anchor, and the words that find comparable bills. There are 10 kinds: income tax rate, brackets, standard deduction and exemptions, EITC, CTC, retirement income exclusion, property tax and homestead credit, renter's credit, child and dependent care credit, and SNAP. A kind the trace never read for a state falls back to listed variables, and the output says so. A reform dict whose paths the trace never recorded is marked not resolved, and each path is listed with its cause: no kind matched it, or the trace records other parameters of its kind in the state, so the path is likely mistyped.

--all-kinds runs every kind for a list of states, by default the states of the published bills (read from Supabase, read only). It writes a gap list: each uncalibrated input or total, each target that misses by more than 10%, and each comparable claim outside 0.75 to 1.25. Every gap has a proposed owner and an evidence link. A state counts toward a calibration gap only where the trace records the kind's parameters. Each result and gap list records the version of every source: the release ids, the dependency map's ref and generation date, and the scorecard feed's build date.

How to run it

python scripts/readiness_lookup.py --list-kinds
python scripts/readiness_lookup.py --state GA --kind retirement_exclusion
python scripts/readiness_lookup.py --state KS --reform-json reform.json
python scripts/readiness_lookup.py --all-kinds --markdown gaps.md --json gaps.json
python scripts/readiness_lookup.py --all-kinds --states GA,CO,KS
python scripts/readiness_lookup.py --state GA --kind snap --app-ref <commit SHA>
python scripts/readiness_lookup.py --save-fixtures scripts/test_data/readiness

It needs pyyaml only. Downloads are cached for a day under ~/.cache/policyengine-tracker/readiness (--refresh refetches). The dependency map and the scorecard feed come from main unless --app-ref or --scorecard-ref names a commit. --all-kinds without --states needs SUPABASE_URL and SUPABASE_KEY in the environment or the gitignored .env. An unresolved reform exits 1.

Example: Georgia retirement income exclusion

Readiness: GA, Retirement income exclusion

Release microcosm-us-2024-local/populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z: 85 state targets, 0 held out. Every target in this release was fitted, so a close fit is expected by construction: it shows these inputs are anchored, not that a reform's result is right.

Sources: local release microcosm-us-2024-local/populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z; national release microcosm-us-2024-national/populace-us-2024-spm-20260915; dependency map at policyengine-app-v2 main, generated 2026-10-15 on policyengine-us 2.2.1; scorecard feed at policyengine-scorecard main, built 2026-11-26.

Target Role Targets Median abs. error Worst abs. error
Business net profits (amount) input (2 hops) 1 0.0% 0.0%
Business net profits (returns) input (2 hops) 1 0.0% 0.0%
Employment income (amount) input (2 hops) 1 0.0% 0.0%
Employment income (returns) input (2 hops) 1 0.0% 0.0%
Gross capital gains (amount) input (3 hops) 1 0.2% 0.2%
Gross capital gains (returns) input (3 hops) 1 27% 27%
IRA distributions (amount) key input 1 0.3% 0.3%
IRA distributions (returns) key input 1 0.2% 0.2%
Ordinary dividend income (amount) input (3 hops) 1 0.0% 0.0%
Ordinary dividend income (returns) input (3 hops) 1 0.1% 0.1%
Qualified dividends (amount) input (3 hops) 1 0.0% 0.0%
Qualified dividends (returns) input (3 hops) 1 0.0% 0.0%
Rent and royalty net income (amount) input (1 hop) 1 0.0% 0.0%
Rent and royalty net income (returns) input (1 hop) 1 0.1% 0.1%
Tax-exempt interest income (amount) input (2 hops) 1 0.0% 0.0%
Tax-exempt interest income (returns) input (2 hops) 1 0.0% 0.0%
Taxable interest income (amount) input (2 hops) 10 0.1% 0.4%
Taxable interest income (returns) input (2 hops) 10 0.1% 0.4%
Taxable pension income (amount) key input 1 0.1% 0.1%
Taxable pension income (returns) key input 1 0.2% 0.2%
Taxable Social Security (amount) key input 1 0.2% 0.2%
Taxable Social Security (returns) key input 1 0.3% 0.3%

Not targeted in this release:

  • state_income_tax (outcome): collections, the total an exclusion lowers. The national release has 1 state target(s) for it.
  • age (key input): eligibility starts at an age threshold (62 or 65 in most states). The national release has 18 state target(s) for it.
  • social_security (key input): total benefits, not only the federally taxable part.
Comparable claim State Outside PolicyEngine Ratio Dataset
CO HB1062 — retirement income deduction expansion CO −$530.0M −$701.8M 1.32 acs_local

Taxable pensions, IRA distributions and taxable Social Security fit within 0.3% in both measures. Capital gains split by measure: the number of returns with gains misses by 27%, while the dollar amount fits within 0.2%. The ACS local-area release has no age targets, while the national release has 18 for Georgia, and it has no state income tax target. Colorado's retirement bill, the nearest comparable, is 1.32 times its fiscal note on ACS-local.

Baseline gaps across 23 states

Sources: local release microcosm-us-2024-local/populace-us-2024-buildo-acs-local-766b7c7-20261017T030317Z; national release microcosm-us-2024-national/populace-us-2024-spm-20260915; dependency map at policyengine-app-v2 main, generated 2026-10-15 on policyengine-us 2.2.1; scorecard feed at policyengine-scorecard main, built 2026-11-26.

A state counts toward a calibration gap only when the trace records the kind's parameters there. "+N untraced" counts the states where every kind behind the gap fell back to its listed variables: the state may not have the program in the model.

Gap Subject States Kinds Proposed owner Evidence
untargeted outcome state_income_tax: collections, the total a rate change moves; the national release has 1 state target(s) for it 23 states brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, renters_credit, retirement_exclusion, standard_deduction_exemptions Microcosm (calibration) link
uncalibrated input SNAP recipients (people): no calibration target counts SNAP recipients (people); the release targets households and benefit dollars 23 states snap SNAP PRs (microcosm #1714, #1835) link
uncalibrated input age: dependent and senior exemptions depend on age; the national release has 18 state target(s) for it 23 states cdcc, ctc, eitc, property_tax_homestead, renters_credit, retirement_exclusion, standard_deduction_exemptions Microcosm (calibration) link
uncalibrated input spm_unit_size: allotments scale with household size 23 states snap Microcosm (calibration) link
uncalibrated input takes_up_snap_if_eligible: take-up decides how many eligible households receive SNAP 23 states snap Microcosm (calibration) link
uncalibrated input social_security: total benefits, not only the federally taxable part 16 states (+7 untraced) retirement_exclusion Microcosm (calibration) link
uncalibrated input rent: several states extend the credit to renters 14 states (+9 untraced) property_tax_homestead, renters_credit Microcosm (calibration) link
uncalibrated input tax_unit_childcare_expenses: the credit is a share of care spending 11 states (+12 untraced) cdcc Microcosm (calibration) link
target misses Gross capital gains (returns): worst abs. error 36% in NE; 17% to 36% across 23 states 23 states brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, renters_credit, retirement_exclusion, standard_deduction_exemptions Microcosm (calibration) link
target misses Individual income tax returns: worst abs. error 85% in NY; 12% to 85% across 23 states 23 states brackets, income_tax_rate, standard_deduction_exemptions Microcosm (calibration) link
target misses Taxable interest income (amount): worst abs. error 64% in UT; 14% to 64% across 9 states 9 states brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, renters_credit, retirement_exclusion, snap, standard_deduction_exemptions Microcosm (calibration) link
target misses Rent and royalty net income (amount): worst abs. error 7203% in NY; 198% to 7203% across 5 states CT, DC, NJ, NY, RI brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, renters_credit, retirement_exclusion, snap, standard_deduction_exemptions Microcosm (calibration) link
target misses Taxable interest income (returns): worst abs. error 60% in NY; 12% to 60% across 3 states CT, NY, UT brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, renters_credit, retirement_exclusion, snap, standard_deduction_exemptions Microcosm (calibration) link
target misses SALT deduction (amount): worst abs. error 12% in UT; 11% to 12% across 2 states UT, WV brackets, income_tax_rate, standard_deduction_exemptions Microcosm (calibration) link
target misses Medical expense deduction (amount): worst abs. error 319% in DC DC (+1 untraced) brackets, income_tax_rate Microcosm (calibration) link
target misses Business net profits (amount): worst abs. error 202% in ND ND brackets, income_tax_rate, property_tax_homestead, renters_credit Microcosm (calibration) link
target misses Assigned ACA PTC (amount): worst abs. error 417% in DC; 149% to 417% across 3 states none (+3 untraced) ctc, eitc, retirement_exclusion Microcosm (calibration) link
target misses Assigned ACA PTC (returns): worst abs. error 433% in DC; 280% to 433% across 3 states none (+3 untraced) ctc, eitc, retirement_exclusion Microcosm (calibration) link
target misses EITC (amount): worst abs. error 14% in NC none (+1 untraced) brackets, eitc Microcosm (calibration) link
target misses Medical expense deduction (returns): worst abs. error 158% in UT none (+1 untraced) brackets, standard_deduction_exemptions Microcosm (calibration) link
comparable claim off CA AB 397 — young child tax credit age limit: PolicyEngine / outside estimate = 1.65 (national) CA ctc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off CO HB1062 — retirement income deduction expansion: PolicyEngine / outside estimate = 1.32 (acs_local) CO retirement_exclusion Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off IA HF1020 — child and dependent care credit expansion: PolicyEngine / outside estimate = 0.13 (acs_local) IA cdcc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off Idaho Child Tax Credit ($205/child nonrefundable): PolicyEngine / outside estimate = 1.51 (national) ID ctc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off Illinois Child Tax Credit: PolicyEngine / outside estimate = 1.59 (national) IL ctc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off Individual income tax collections, Nebraska: PolicyEngine / outside estimate = 1.42 (national) NE brackets, cdcc, ctc, eitc, income_tax_rate, property_tax_homestead, retirement_exclusion, standard_deduction_exemptions Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off Individual income tax collections, North Dakota: PolicyEngine / outside estimate = 0.69 (national) ND brackets, ctc, eitc, income_tax_rate, retirement_exclusion, standard_deduction_exemptions Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off New Jersey Child Tax Credit: PolicyEngine / outside estimate = 1.44 (national) NJ ctc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off People eligible for SNAP, District of Columbia: PolicyEngine / outside estimate = 0.59 (national) DC snap SNAP PRs (microcosm #1714, #1835) link
comparable claim off People eligible for SNAP, Hawaii: PolicyEngine / outside estimate = 0.66 (national) HI snap SNAP PRs (microcosm #1714, #1835) link
comparable claim off People eligible for SNAP, New Jersey: PolicyEngine / outside estimate = 1.27 (national) NJ snap SNAP PRs (microcosm #1714, #1835) link
comparable claim off People eligible for SNAP, North Dakota: PolicyEngine / outside estimate = 0.73 (national) ND snap SNAP PRs (microcosm #1714, #1835) link
comparable claim off People eligible for SNAP, Utah: PolicyEngine / outside estimate = 1.37 (national) UT snap SNAP PRs (microcosm #1714, #1835) link
comparable claim off Utah Child Tax Credit ($1,000/child ages 1-3, nonrefundable): PolicyEngine / outside estimate = 0.07 (national) UT ctc Diagnose: policyengine-us (rules) or Microcosm (data) link
comparable claim off Wisconsin Earned Income Credit: PolicyEngine / outside estimate = 1.25 (national) WI eitc Diagnose: policyengine-us (rules) or Microcosm (data) link

This is --all-kinds --states AL,CT,DC,GA,HI,ID,IL,KS,MI,MN,MS,NC,ND,NE,NJ,NY,OK,OR,RI,UT,VA,WI,WV, the 23 states with published bills on 2 December, run on 3 December: 35 gaps on the ACS local-area release.

The calibration owner is Microcosm. The SNAP gaps go to the SNAP PRs (microcosm #1714, #1835); no target counts SNAP recipients, which p304 names. A comparable bill outside the band needs a diagnosis, since the cause can be the rules (policyengine-us) or the data (Microcosm).

The capital gains gap is about the number of returns: the return count misses by 17% to 36% in all 23 states, and the dollar total misses by more than 10% in none. Rent counts 14 states; in the other 9, neither the renter's credit nor the property tax credit is traced. Child care expenses count 11 states and total Social Security 16. Four target rows (Assigned ACA PTC in both measures, the North Carolina EITC total and the Utah medical expense return count) come only from kinds untraced in those states, so they count no state. One row needs a look at the target before it counts as a data gap: NY rent and royalty income misses by 7,203%, with a target of $40M against an estimate of $2.9B.

Checks

  • pytest scripts/test_readiness_lookup.py: 31 passed, with no network, on slices of the live sources that --save-fixtures cut on 3 December. A test checks that the fixtures are still what it cuts.
  • ruff check and ruff format --check on the changed Python files.
  • Live runs: Georgia retirement, the 23-state --all-kinds run above, Indiana income tax rate, and two unresolved reform dicts (CT gov.contrib.states.ct.refundable_ctc.in_effect, and a Kansas rates.single path that does not exist).

Not in this PR

  • Wiring into /encode-bill and the review PR (p451).
  • The traced map is App v3's, built on policyengine-us 2.2.1 from a 2,000-household sample. A parameter the sample never reads falls back to the kind's listed variables, or, in a reform dict, is not resolved. Regenerating the map is app/scripts/build-parameter-dependency-map.py in app-v2.
  • The age and state income tax gaps are already in flight upstream: microcosm #1531 (ACS local age groups) and the missing state income tax target noted in tracker Score new bills on the ACS local-area release; keep 2026 scores on theirs #240.
  • A CI job for the Python tests in scripts/; none runs today, for this file or the others.

🤖 Generated with Claude Code

…rm in a state

scripts/readiness_lookup.py answers, without a microsimulation, whether the
data is good enough to score a reform in a state. It reaches model
variables from the reform's parameter paths through App v3's traced
dependency map, matches them to the state's calibration targets in the
Microcosm release (ACS local-area by default), flags the inputs and totals
no target measures, and lists the nearest scorecard claims with their
ratios. --all-kinds runs every bill kind in scripts/data/readiness_kinds.yaml
for a list of states and writes a gap list with proposed owners (Teamverse
p304). Tests run on saved slices of the live sources.

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 8011dbc

This PR adds scripts/readiness_lookup.py, a lookup that tells, without a microsimulation, how well the data supports a reform in a state. It traces the reform's parameter paths through App v3's dependency map, matches the variables to the state's calibration targets in the ACS local-area release, and lists comparable scorecard claims. --all-kinds writes a gap list with owners. Of the 4,114 added lines, 2,716 (66%) are test fixtures cut from live sources, 170 are the hand-written kinds file, 993 are code and 235 are tests. The PR stands alone on main (#240 is merged). It shares no files with #239, #241, #243, #244 or policyengine-app-v2#1646, and it does not need them. It reads parameterDependencies.json from the app-v2 main branch, which exists today.

The structure is clear and the tests run offline. Two output problems can mislead the people who act on the gap list.

Verdict: REQUEST_CHANGES

CRITICAL

None.

SHOULD ADDRESS

1. A target group mixes return counts and dollar totals, so the "Gross capital gains" miss is a count miss, not a dollar miss.
scripts/readiness_lookup.py:436-448 groups targets by variable_label only. The dashboard gives each target a measure field (count or total). The two measures go into one group and one worst error.

  • Case: Georgia. net_capital_gains_returns (measure count) misses by 26.8%. net_capital_gains_amount (measure total) fits within 0.2%. The table shows "Gross capital gains, worst 27%", and the PR description says "capital gains miss by 27%".
  • Across all 51 states in the release, the capital gains return count misses by more than 10% in every state (median 31%). The dollar total misses by more than 10% in no state. So the "Gross capital gains, 23 states" gap row is about the number of returns with gains, not the amount of gains. That changes what a retirement-exclusion or rate-cut owner must fix.
  • The same mix is in other rows. For example, "Medical expense deduction" has misses in both measures.
  • Fix: group by (variable_label, measure), or show the measure in the label (for example "Gross capital gains (returns)"). Carry the measure into the gap subject. Add a test that the Georgia count and total are separate rows. Correct the description text.

2. A reform whose paths match no kind and no traced reader gives an empty report with no warning.
scripts/readiness_lookup.py:337-342 and :798-802. When kinds_for_paths finds no kind and readers_of_path finds no reader, readers is empty, the walks reach nothing, and the result has 0 target groups, 0 untargeted items and 0 gaps. The markdown says that "the kind's fallback variables are used", but there are none.

  • Case: {"gov.contrib.states.ct.refundable_ctc.in_effect": {...}} for CT. The tracker uses this path today. The output has no kind, no targets and no gaps. A reader can take this as "no gaps".
  • Case: a mistyped or nonexistent path, for example gov.states.ks.tax.income.rates.single[0].rate (Kansas uses rates.other). The result is the same: a fallback to nothing, or to the kind's fallback variables with the message "The state may not have this program in the model". The model has the program; the path is wrong.
  • Fix: when no reader and no kind are found, stop with a clear message, or mark the result as "not resolved" and print the unmatched paths. In the markdown, tell "the trace did not record this path" apart from "no kind matched". Add a test for each case.

3. The income_tax_rate patterns miss Indiana, so the lookup says Indiana may not have an income tax.
scripts/data/readiness_kinds.yaml:24-27. Indiana's rate is gov.states.in.tax.income.agi_rate. No pattern (rate, rates*, main.*) matches it. On the live dependency map, income_tax_rate is untraced in AK, FL, IN, NV, NH, SD, TN, TX, WA and WY. Indiana is the only one of these with a wage income tax.

  • Fix: add "gov.states.{st}.tax.income.agi_rate", or a broader rate pattern. Add a check that every state with a modeled income tax resolves income_tax_rate as traced.

SUGGESTION

4. The gap list counts gaps for kinds that a state does not have. scripts/readiness_lookup.py:589-679 and :959-963. --all-kinds runs every kind for every state and records the gaps even when the kind falls back (traced is false). For example, the renter's credit is traced in only 9 states, but "rent" is an uncalibrated input in "23 states". The state_income_tax outcome gap also appears for a no-income-tax state such as Texas. Each gap is true as a data fact, but the state count overstates the reach. Mark untraced gaps, or skip them in the state count.

5. Two of the four sources are not pinned, and the output does not record their versions. scripts/readiness_lookup.py:71-78 and :934-938. The dependency map and the scorecard feed come from main of their repositories. The national release is the dashboard's default. The local release is pinned, which is good. The JSON keeps the dependency map's model block, but it does not keep the national release id, the dependency map's generatedAt, or a scorecard date. A gap list from a later day can differ with no sign of why. Add these to the payload and the markdown header. As an option, accept a commit SHA for the two GitHub sources.

6. The local release id is a second copy of the scoring dataset. scripts/readiness_lookup.py:61-63 repeats DATASETS["acs-local-766b7c7"] and DEFAULT_STATE_DATASET from scripts/compute_impacts.py:175-198. When scoring moves to a new release, the lookup will keep the old one. Move the release id to a small shared module that both scripts import, or add a test that the two agree.

7. The fixtures have no script that makes them. The 2,716 fixture lines match the live sources today (I compared all 89 local targets, the dependency map readers and the scorecard rows). But the next person cannot cut a new slice in the same way. Add a small --save-fixtures option or a script, or describe the cut in the test docstring.

8. Small items.

  • --state with --all-kinds is ignored with no message (:949-957). Reject it or use it as --states.
  • load_targets loops forever if the API returns has_next: true with returned: 0 (:216-219). Stop when a page is empty.
  • _role takes the role of the first variable in a group by alphabetical order (:456). A group with more than one variable can get the wrong role.
  • The gap table in the description has columns (Detail, no Kinds, no Evidence) and text ("worst error") that differ from what gaps_markdown prints ("worst |error|"). Paste the real output, or change the code to match.
  • No CI job runs the Python tests in scripts/. This is true for the repository in general, not only for this PR.

What I checked

  • Read the description, the full diff, the kinds file and the tests. There are no comments or reviews yet.
  • pytest scripts/test_readiness_lookup.py: 14 passed, offline. ruff check and ruff format --check on the two new Python files: clean (ruff 0.14.14). npm run build: passes (this PR changes no front-end code).
  • Live run of --state GA --kind retirement_exclusion: the output matches the description.
  • Fixtures against live sources: all 89 local targets have the same values. The dependency map readers in the fixture are the same as live (generatedAt 2026-10-15, policyengine-us 2.2.1). The scorecard rows have the same values. The national release is populace-us-2024-spm-20260915 in both.
  • Spot checks: the Georgia capital gains rows (count 26.8%, total 0.2%), which gave item 1. The NY rent and royalty amount (relative error 72.03, that is 7,203%), which matches the description.
  • Edge cases on live data: an unknown path, an empty reform, a federal CTC path, two gov.contrib paths, Texas and Washington with tax kinds, an unknown kind (gives a clear ValueError), and which states each kind traces in.
  • Dependencies: the files of #239, #241, #243, #244 and policyengine-app-v2#1646. There is no overlap.

…cord sources

Addresses the review of #242:

- Target groups are keyed by variable and measure, so a return count and a
  dollar total are separate rows ("Gross capital gains (returns)" misses by
  27% in Georgia; "(amount)" fits within 0.2%). The measure is in the gap
  subject.
- A reform whose paths the trace never recorded is "not resolved" (exit 1)
  and lists each path: no kind matched it, or the trace records other
  parameters of its kind in the state (likely mistyped, with examples), or
  none (the kind's fallback variables stand in). Partly traced reforms list
  the unrecorded paths.
- income_tax_rate matches Indiana's agi_rate; a test checks that all 41
  states and DC with a wage income tax resolve it as traced.
- Gaps carry a traced flag; a state counts toward a calibration gap only
  when the kind is traced there ("+N untraced" in the table).
- Results and the gap list record the national release id, the dependency
  map's ref and generatedAt, and the scorecard feed's ref and build date.
  --app-ref and --scorecard-ref take a commit SHA.
- A test checks LOCAL_AREA_RELEASE against compute_impacts.py's default
  state dataset (read with ast, not imported).
- --save-fixtures cuts the test slices (cut_fixtures says what each keeps);
  the fixtures are regenerated with it and a test checks they still match.
- --state with --all-kinds (and --states without it) is an error; target
  paging stops on an empty page; a group's role is its most direct
  variable's; table cells say "worst abs. error" and escape pipes.

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

DTrim99 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, Pavel. Fixed in 1c1b333; line numbers refer to that commit. rl = scripts/readiness_lookup.py, test = scripts/test_readiness_lookup.py.

  1. Measures. Targets now group by variable label and measure (rl:551-566). measure_label (rl:482) names a count by what it counts (returns for tax units, households, people) and calls a total "amount". A label that already names its unit, like "Individual income tax returns", stays as it is (rl:497). The gap subject is the label with its measure, and each gap carries measure (rl:755-756). Georgia now shows "Gross capital gains (returns)" at 27% and "Gross capital gains (amount)" at 0.2%. test:277 checks the two rows, the gap and the table. The fixtures now keep measure and the counted entity. Corrected description text is below.

  2. Unresolved reforms. Each reform path gets a report: its readers, the kinds it matches and, when it has no reader, the parameters of those kinds the trace records in the state (rl:354). resolve gives each result a status (rl:398-418):

    • "traced"
    • "partly traced"
    • "fallback": no reader, and the kind has no recorded parameter in the state.
    • "not resolved": no reader, and either no kind matched or the kind has other recorded parameters in the state.

    A not-resolved result reaches no variables and has no gaps (rl:727-728). The CLI exits 1 and prints a line to stderr (rl:1472-1478). The markdown header ends in "not resolved", and the text says this is not a finding of no gaps. Each unrecorded path gets its cause (rl:1018): "no kind matched it", or "it records 4 parameter(s) of its kind (Income tax rate, Brackets) in KS: … Check the path: it may be mistyped". Tests cover the CT gov.contrib path (test:137), the Kansas rates.single path (test:165), a partly traced reform (test:189) and a reform of a kind the state lacks (test:203). The "Kansas rate-cut reform dict" live run in the description used that same mistyped path, so the corrected description drops it.

  3. Indiana. I added gov.states.{st}.tax.income.agi_rate to income_tax_rate (scripts/data/readiness_kinds.yaml:30). I did not use a broader *rate* pattern because it would also match deduction phase-out rates, AMT rates and Washington's capital gains rate. test:213 resolves income_tax_rate in the 41 states and DC that tax wages and requires each one to be traced. It also requires the nine states without a wage tax (AK, FL, NV, NH, SD, TN, TX, WA, WY) to fall back. The test runs on the fixture map, which now holds every recorded path whose first segment under gov.states.<st>.tax.income names a rate or the main schedule, in every state. That is 148 paths, chosen without using the kinds' patterns.

  4. Untraced gaps. Each calibration gap carries traced (rl:743, rl:759, rl:773). aggregate_gaps counts a state only when a kind behind the gap is traced there and lists the other states in untraced_states (rl:821). A row's kinds, summary and worst error come from the traced gaps. The table shows, for example, "14 states (+9 untraced)", with a note on what that means (rl:1138, rl:1145). Comparable-claim gaps always count (rl:811), because each is filed under the claim's own state, where a bill of the kind was scored. In the 23-state run, rent falls from 23 states to 14 (+9 untraced), child care expenses to 11 (+12) and total Social Security to 16 (+7). The ACA PTC, NC EITC and UT medical-expense return-count misses now count no states. Tests: test:360, test:383.

  5. Source versions. source_versions (rl:903) records:

    • the local and national release ids
    • the dependency map's ref, generatedAt and model
    • the scorecard feed's ref and built date

    They go into each result's sources and the --all-kinds payload, and a "Sources:" line goes under each markdown header (rl:991). --app-ref and --scorecard-ref take a branch or a commit SHA (rl:1380-1389). A SHA download is cached under its own name and never expires (rl:252-270). Tests: test:438, test:459.

  6. Release id. test:477 parses scripts/compute_impacts.py with ast and checks that LOCAL_AREA_RELEASE equals dataset_name/dataset_version of STATE_DATASETS[DEFAULT_STATE_DATASET]. It doesn't import compute_impacts.py, which pulls in numpy, dotenv and the Supabase helpers. compute_impacts.py is unchanged, so Score bills through the Public API App v3 uses (p451 groundwork) #246 is unaffected, and Score bills through the Public API App v3 uses (p451 groundwork) #246's own tests pass on this commit (43 passed). The comment at rl:71-75 points to the test.

  7. Fixtures. --save-fixtures DIR writes the four slices (rl:1361, rl:1415-1425), and cut_fixtures (rl:1220) says what each keeps. I regenerated the fixtures with it from today's live sources. The 85 Georgia targets, the dependency map's generatedAt and the CO HB1062 row are unchanged from the 12/2 fixtures. test:75 re-cuts the fixtures and requires the same files. The test module docstring gives the command and the date.

  8. Small items.

    • 8a. --state with --all-kinds is now an error, and so is --states without it (rl:1395-1398, test:518).
    • 8b. load_targets stops on an empty page and advances by the number of targets received (rl:233-239, test:495).
    • 8c. _role takes the most direct role among a group's variables, in this order: outcome, key input, reader, moved, input, fewest hops first (rl:506-528, test:296).
    • 8d. The code now prints "worst abs. error". The old |error| also split the markdown cell. Table cells now escape | (rl:968). The real output is pasted below.
    • 8e. CI is not changed here. No workflow runs any Python test in scripts/, including test_auto_triage, test_compute_impacts_datasets and test_publish_analysis. One job for all four belongs in its own PR.

The description is replaced: the Georgia and 23-state output in it is what the lookup printed today. #246, which is stacked on this branch, takes these changes next.

DTrim99 added a commit that referenced this pull request Dec 3, 2026
After #242's review, the readiness lookup marks a reform whose paths the
dependency trace never recorded as "not resolved" (or "partly traced").
The comparison step's markdown for the review PR now says so, so an empty
check doesn't read as no gaps.

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 1c1b333

This PR adds scripts/readiness_lookup.py, a lookup that tells, without a microsimulation, how well the data supports a reform in a state. It traces the reform's parameter paths through App v3's dependency map, matches the variables to the state's calibration targets, and lists comparable scorecard claims. --all-kinds writes a gap list with owners. Commit 1c1b333 answers the review at 8011dbc. It splits targets by measure, reports unresolved reform paths, adds Indiana's rate path, marks untraced gaps, records source versions, and adds a fixture cutter and 17 tests.

All three SHOULD ADDRESS items are fixed. I checked each fix on live data. Two small items remain, both suggestions.

Verdict: APPROVE

Earlier items

# Item Status
1 Count and dollar targets in one group Fixed
2 Empty report for an unresolved reform Fixed
3 Indiana income tax rate not traced Fixed
4 Gaps counted for kinds a state does not have Fixed, with one remaining case (new item A)
5 Sources not pinned or recorded Fixed
6 Second copy of the local release id Fixed
7 No script for the fixtures Fixed
8 Small items (8a to 8d) Fixed; 8e (CI) stays out of scope, as agreed
  1. Fixed. Groups now use (variable_label, measure) (readiness_lookup.py:551-566). Live Georgia retirement run: "Gross capital gains (returns)" 27% and "Gross capital gains (amount)" 0.2% are two rows. In the gap list, the subject is "Gross capital gains (returns)". I checked all 4,765 targets in the local release: no two (label, measure) pairs give the same printed label. The description text is corrected.
  2. Fixed. resolve now gives a status (:374-418), and the CLI exits 1 with a line on stderr. Live runs:
    • CT gov.contrib.states.ct.refundable_ctc.in_effect: "not resolved", exit 1, and a note that gov.contrib paths are recorded only when a baseline formula reads them.
    • KS rates.single[0].rate: "not resolved", exit 1. The output lists the 4 KS rate parameters that the trace records and says the path may be mistyped.
    • KS rates.other[0].rate: traced, exit 0, a full table.
  3. Fixed. agi_rate is in income_tax_rate (readiness_kinds.yaml:30). On the live map, income_tax_rate falls back only in AK, FL, NV, NH, SD, TN, TX, WA and WY. Indiana resolves to gov.states.in.tax.income.agi_rate with readers in_agi_tax and in_withheld_income_tax. The new test checks the 41 states and DC.
  4. Fixed, with one remaining case. Untraced gaps now show as "+N untraced" and do not count toward the reach. In a seven-state run (GA, TX, IN, NY, CO, KS, WA), rent shows "IN, NY, TX (+4 untraced)" and the ACA PTC rows show "none (+1 untraced)". The Texas example from the earlier review still counts, by a different route. See item A.
  5. Fixed. The payload and each markdown header record both release ids, the map's ref, generatedAt and model, and the feed's ref and build date. --app-ref and --scorecard-ref take a branch or a full commit SHA. A bad SHA fails with the URL and HTTP 404.
  6. Fixed. A test reads STATE_DATASETS[DEFAULT_STATE_DATASET] from compute_impacts.py with ast and compares it to LOCAL_AREA_RELEASE.
  7. Fixed. --save-fixtures DIR writes the four slices. I cut them again from today's live sources: all four files are byte-for-byte equal to the committed fixtures.
  8. Fixed. --state with --all-kinds and --states without it are now errors (I ran both). load_targets stops on an empty page. _role takes the most direct role in a group. The output prints "worst abs. error", and table cells escape |.

CRITICAL

None.

SHOULD ADDRESS

None.

SUGGESTION

A. A traced kind still adds its outcome gap in a state where the outcome does not apply.
scripts/readiness_lookup.py:714-728 sets traced for each result from the kind's trace. The kind's outcomes come from the kinds file and do not depend on the state.

  • Case: Texas. property_tax_homestead is traced in TX through the school district homestead exemption. That trace reaches 2 variables, and neither is an income tax variable. But the kind lists state_income_tax as its outcome ("a refundable credit lowers net collections"). So the "untargeted outcome: state_income_tax" row counts TX as a traced state. In the seven-state run, the row shows "7 states" and includes TX and WA.
  • WA is a weaker case: its traced eitc (Working Families Tax Credit) does reach household_state_income_tax.
  • Fix: count an outcome gap only where the traced readers reach an income tax variable, or only where income_tax_rate is traced in the state. Another option: give property_tax_homestead per-state outcomes. Add a TX test.

B. An empty reform dict gives a "not resolved" report with no path.
scripts/readiness_lookup.py:1472-1478. With {}, stderr says "not resolved: the trace recorded no reader for " and the markdown lists no path. Reject an empty reform dict with a clear message, for example "the reform dict has no parameter paths".

What I checked

  • Read the author's reply, the diff 8011dbc..1c1b333 (code, kinds file, tests) and the new description. The branch contains the current main.
  • pytest scripts/test_readiness_lookup.py: 31 passed, offline. pytest scripts/test_compute_impacts_datasets.py: 29 passed. ruff check and ruff format --check on the two Python files: clean (ruff 0.14.14). npm run build: passes.
  • Live runs on fresh downloads: Georgia retirement exclusion; CT contrib, KS mistyped, KS correct and empty reform dicts (with exit codes); income_tax_rate in all 50 states and DC; --all-kinds for GA, TX, IN, NY, CO, KS and WA; the two argument errors; a nonexistent --app-ref SHA; --save-fixtures compared to the committed fixtures.
  • Label check across all 4,765 local-release targets for clashes between measures.
  • Callers: only the PR's own files use the lookup on this branch. The stacked PR that uses it takes these changes next, as the author says.

@DTrim99
DTrim99 merged commit ee7a73d into main Dec 3, 2026
DTrim99 added a commit that referenced this pull request Dec 3, 2026
readiness_lookup reports an empty reform dict as "not resolved" with no
path (Pavel's review of #242, suggestion B). calibration_check strips the
_ keys, so a reform with only those reached lookup() empty. It now returns
None before any download, as with --no-calibration, and says why on stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DTrim99 added a commit that referenced this pull request Dec 4, 2026
Readiness lookup follow-ups from the #242 review: outcome gaps, empty reform dict
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