Skip to content

Send no dataset to policyengine-api and read the run's dataset from its bundle - #112

Merged
MaxGhenis merged 11 commits into
mainfrom
us-api-dataset-param
Nov 13, 2026
Merged

MaxGhenis merged 11 commits into
mainfrom
us-api-dataset-param

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

The analyze-policy agents sent dataset to economy routes that reject undeclared query parameters with HTTP 400. This PR removes that argument from the runner and corroborator, and sends explicitly named datasets through policyengine.py's local path.

The executor selects data by region. The gateway's policyengine_bundle describes the app's default dataset even when a state or district run loads ACS-local data. The runner now preserves the worker's explicit top-level dataset and data_version, leaves an unreported regional dataset name unknown, and compares only provenance the response supports. UK local-area breakdowns report their dataset even when the request keeps region=uk. National runs use the bundle's dataset identity and prefer the worker's release. Budget-window results leave dataset and model versions null; current metadata does not establish what computed an earlier result.

The gateway contract comes from build_policyengine_bundle, with regional selection in simulation_runtime.py and worker release reporting in simulation_output_provenance.py.

The budget-window helper passes the requested region, polls transient failures, gives each request a 120-second timeout, and falls back to annual calls when a batch fails or remains computing past 45 minutes. HTTP 400 and 404 surface as refused requests. The API/app skills, analyze-policy command, comparator and structured-output example follow those contracts. The dashboard manifest was rebuilt after integrating main's report-logger changes.

Validation at 5623d35:

  • uv run pytest --ignore=tests/test_skill_examples.py: 506 passed, 6 skipped in 69.30 seconds. The skips cover five opt-in live-API checks and the installed-policyengine differential.
  • Dataset, budget-window and stale-reference checks: 183 passed, 6 skipped. Twenty new provenance and call-site cases failed before the first helper change and passed afterwards. Independent review then found the UK local-area case; three additional regressions reproduced it and passed after the correction.
  • The tests execute the helpers and API recording example from the agent Markdown. They cover national and regional results, explicit UK local-area dataset identity, worker/bundle release disagreement, absent provenance and budget-window results.
  • scripts/build_manifest.py --check and the Claude wrapper build pass. Ruff formatted the changed dataset test before the final passing suite. A subsequent docstring clarification changed no executable code.
  • No microsimulation or fresh live scoring request ran during this continuation. Historical live-API probes and mutation results describe the earlier head; they do not certify this head.

The independent continuation review approves 5623d35 with no open findings. It found the UK local-area case on the first pass and verified the correction on the final head. All four GitHub checks pass at that head: the repository tests, both manifest jobs and the executable skill examples. An additional explicitly named GPT-6.1 Sol review independently approves the exact final head with zero findings, including 183 passing focused tests and six optional skips. The PR is ready for review. An independent in-chat GPT-6 Astra reviewer also approved this exact head with no findings, passed 183 focused tests with six optional skips, and verified the manifest check and wrapper build. I authorized this review to supersede the old Fable peer requirement and unapproved durable gate 20261112-041825-pr-ef23bb3d. The historical peer job never launched and supplied no Subfleet approval. No merge or Sync Claude Wrapper propagation has occurred.

axiom: n/a: agent guidance, API request handling and provenance tests; no policy rule changes.

MaxGhenis and others added 6 commits November 11, 2026 08:56
…ts bundle

policyengine-api's economy routes reject query parameters they don't
declare, so microsim-runner's `dataset=enhanced_cps`, its budget-window
helper and model-corroborator's mirror call each got HTTP 400 "dataset:
Extra inputs are not permitted". The routes run every economy request on
the one dataset /{country}/metadata lists: Microcosm's `populace_us_2024`
for the US on 2026-11-08.

- microsim-runner: drops `dataset` from the annual and budget-window calls
  and lists the parameters each route takes. `run_dataset` replaces the
  advertised-dataset table and the "populace" substring check: it names the
  dataset and data version from the result's `policyengine_bundle` and
  falls back to the metadata default. The runner takes the local path for a
  named dataset and passes it to `pe.us.ensure_datasets`. The budget-window
  section describes the live result (`annualImpacts` and `totals`, no
  bundle), and `run_horizon` takes a region and raises on an error status.
- model-corroborator: drops `dataset` from the mirror call.
- reform-comparator: records the dataset, data version and model version
  from the runner's output and flags a run off the default.
- policyengine-api and policyengine-app skills: the economy query
  parameters, the budget-window route and the status envelope.
- test_dataset_naming: example, property and differential tests of
  `run_dataset`, which the test runs straight from microsim-runner.md, and a
  scan that fails when any doc sends `dataset` to an economy route.
  `PE_SKILLS_LIVE_API=1` checks the metadata snapshots and the 400 against
  the live API.
- test_no_stale_references: drops the runner's frozen "populace" span and
  the dataset test's exclusion.

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

On 2026-11-08 a live two-year US budget window for policy 97853 still read
"Scoring 2026, 2027 (0 of 2 complete)..." after more than half an hour, and
run_horizon would have polled it forever. It now raises TimeoutError at the
first poll at or after max_wait_minutes (45 by default) and sets a timeout on
each request, and the runner falls back to single-year calls in that case too.

- test_budget_window_polling: runs run_horizon from microsim-runner.md against
  scripted answers and a fake clock, with example and property tests of the
  polling contract.
- test_dataset_naming: pins the URI-revision fallback for a missing data
  version and a revision with dots in it; no earlier test failed when either
  broke.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Scoring 2026, 2027 (0 of 2 complete)" first came back at 19:27Z; the
19:26Z answer still read "Queued 2026". The batch later moved on, so the
comment drops "never moved".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#110's 597ab30 made this paragraph take both values from the metadata
default when a result has no policyengine_bundle. The rebase kept this
branch's rewrite of the paragraph, which now names that case and the
budget-window results it covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One full-suite run at 905b4dd failed one test with the host at load 81,
and the rerun passed; the run's log kept only the counts. These nine
property tests check run_dataset's and run_horizon's logic, not their
speed, so a busy host shouldn't fail them on Hypothesis's 200 ms default
deadline. test_build_manifest.py already sets deadline=None the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/build_manifest.py reads the skill, agent and command files this
branch edits, so their body lengths and overlap scores move. The
manifest comes from `uv run python scripts/build_manifest.py`, and
`--check` passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis force-pushed the us-api-dataset-param branch from 4b06ff5 to 17eb1ae Compare November 11, 2026 14:02
MaxGhenis and others added 5 commits November 11, 2026 14:11
…ed poll

Three independent reviews of 17eb1ae asked for these changes.

run_dataset no longer copies the metadata's data version into a result that
names none. A budget-window result, a bundle that reads `default` with no
data version and an unpinned URI of the default file now give
`data_version` null and `dataset_matches_default` null, and reform-comparator
notes the run as unverified. The function reads the metadata default's
`data_version` with `.get`, since policyengine-api omits it when its bundle
records no release. The local path runs the same check on the URI
policyengine.py resolves, so a named dataset there reads false.

run_horizon imports what it uses, keeps polling through a request timeout,
a broken connection or a body that isn't JSON, and raises ValueError on an
HTTP 400 or 404, so the runner reports a refused request instead of falling
back to single-year calls that would hit the same refusal. The runner, the
policyengine-api skill and analyze-policy now say which parameters the
budget-window route takes, that a failed batch answers HTTP 200, that a UK
window ends by 2032, and how long the 2026-11-08 runs took.

The tests pin each mutant the reviewers found surviving: the poll interval
and request timeout, the country in the URL, a failure body with only a
message, a default bundle with its own release, another dataset at the
default's release, names with two `@` signs or a non-.h5 suffix, and the
local path. The doc scan reads unquoted `dataset:` keys, `["dataset"] =`
assignments, `~~~` fences, `%26dataset=` and the root README. The UK metadata
snapshot moves to the 2026-11-11 release, and the opt-in live check now
compares everything but the release, which moves with each certified build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/build_manifest.py reads the skill, agent and command files the
previous commit edits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…file none for Canada (#111)

* Keep report-logger's data issues from failing on missing labels, and file none for Canada

gh looks up every --label name among the target repo's labels before it
creates an issue, and stops without creating one when a name is missing
(cli/cli pkg/cmd/pr/shared/params.go, api/queries_repo.go). report-logger
passed --label "calibration,auto-filed", and on 2026-11-08 neither
PolicyEngine/microcosm nor PolicyEngine/policyengine-uk-data had either
label, so every auto-filed data issue failed. The block now lists the
repo's labels and passes only the ones it has. It compares names in lower
case, because gh ignores case when it matches them.

The block sent ca data issues to policyengine-ca-data and the prose to
policyengine-canada-data, and neither repo exists. PolicyEngine has no
Canada microdata: policyengine.py's bundle holds data for us and uk only,
and policyengine-canada's one dataset is a three-person template. So
report-logger files no data issue for ca, and the archive keeps the
report. The prose now names policyengine-canada for structural ca issues,
since policyengine-{country} gave policyengine-ca, which doesn't exist
either.

test_country_routing's differential tests now run the whole issue-filing
block, under bash and zsh, with a stand-in gh that records its calls, and
compare the issue's repo and labels with the Python reference. The strict
xfail for ca goes.

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

* File the data issue when gh can't list labels, and drop reform-pipeline's Canada data route

reform-pipeline still sent other countries' data issues to
policyengine-{country}-data, which gives policyengine-canada-data for ca, a
repo that doesn't exist. It now says report-logger files none for ca.

report-logger's block already files the issue without labels when
`gh label list` fails; report-logger.md now says so, and a property test
fails the stand-in's label lookup for any country, dataset and label set
and checks that the block still files the reference's issue.

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

* Rebuild the dashboard manifest for report-logger's new routes

scripts/build_manifest.py reads each agent's description and text, so report-logger's new label and Canada wording changes its description and its overlap scores. build_manifest.py --check passes on the result.

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

* Hand gh the issue's title and body unchanged, and name a country the block can't route

report-logger's block passed the body as --body "$(cat <<'EOF' ...)". bash 3.2, macOS's /bin/bash, can't parse a quoted heredoc inside "$(...)" when the body holds an odd number of apostrophes, so a body with "CBO's" or "doesn't" made the whole block a syntax error and filed nothing. The title sat in double quotes, so the shell expanded "$40B" and backticks in it. gh now reads the body on standard input (--body-file -) from a quoted heredoc, and `read -r` takes the title from another.

The block now sets country and dataset from placeholders, and prints an error for any country but us, uk and ca instead of skipping it silently. analyze-policy's --open-issue names policyengine-canada for ca, since policyengine-ca doesn't exist.

The tests fill the title and body with apostrophes, $ amounts, backticks and parentheses, and check that gh gets them as written, under bash and zsh, for fixed cases and any text Hypothesis draws.

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

* Close the gaps the r5 review found in report-logger's issue block

- Tell the agent to check that no title or body line matches a heredoc's
  closing word, to write an apostrophe in a filled value as '\'', and to
  run the block without set -e or set -u.
- Move the country and dataset comments off their assignment lines.
- Call `command grep`, so Claude Code's grep function (ugrep) can't
  match a label that ends in CR.
- Tell the agent to give a structural or issue:<repo> issue only labels
  the repo has, and never `calibration` on a structural one.
- Add tab-led lines to the test body, so a <<- heredoc fails the suite,
  and two tests that fill the country and dataset as the agent does.
- Install zsh in CI, and fail the zsh runs there when zsh is missing.
- Rebuild the dashboard manifest.

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

* File structural issues through the same block, and trap a grep function in the tests

- Tell the agent to file a structural or issue:<repo> issue with the
  block from `if [ -n "$DATA_REPO" ]` on, with DATA_REPO set to that
  repo, so it gets the same heredocs and label check, and to loop over
  `auto-filed` alone for a structural issue.
- Define a trap grep function ahead of the block in the tests, as
  Claude Code defines one, so a block that drops `command` fails.
- Drop the apostrophe from the country comment.
- Rebuild the dashboard manifest.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis marked this pull request as ready for review November 12, 2026 04:09
@MaxGhenis
MaxGhenis merged commit 23506a1 into main Nov 13, 2026
4 checks passed
anth-volk added a commit that referenced this pull request Nov 13, 2026
The only conflict was the generated dashboard/src/data/manifest.json,
rebuilt with scripts/build_manifest.py; --check passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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