Skip to content

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

Merged
MaxGhenis merged 6 commits into
mainfrom
report-logger-labels-ca
Nov 11, 2026
Merged

MaxGhenis merged 6 commits into
mainfrom
report-logger-labels-ca

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

report-logger files each US and UK data issue in PolicyEngine/microcosm or PolicyEngine/policyengine-uk-data, and its issue-filing bash passed --label "calibration,auto-filed" to gh issue create. On 2026-11-08 neither repo had either label. gh looks up each label name before it creates an issue and stops when the repo lacks one, so every auto-filed data issue failed. The bash also sent ca data issues to policyengine-ca-data, the prose sent them to policyengine-canada-data, and neither repo exists. And the shell broke the issue's text: macOS's /bin/bash 3.2 stopped on a body holding an odd number of apostrophes, and every shell expanded $40B and backticks in the title.

report-logger now passes only the labels the target repo has, files no data issue for Canada, and hands gh the title and body as written:

Run Data issue goes to Labels it gets today
US, or UK on a Microcosm dataset PolicyEngine/microcosm none, since the repo has neither
UK on a named Enhanced FRS or FRS file PolicyEngine/policyengine-uk-data none, since the repo has neither
Canada no issue; the archive keeps the report

Labels

The block asks gh for the repo's labels and passes --label for each of calibration and auto-filed that it finds. It compares names in lower case, because gh matches them regardless of case. It calls command grep, which skips the grep shell function Claude Code defines. That function runs ugrep, which reads a trailing CR as a line end. It would match a repo label calibration\r, and gh would then reject --label calibration. If gh can't list the labels, the block files the issue without them. Creating the two labels in microcosm and policyengine-uk-data would also unblock filing, but it would change two other teams' repos. If either repo adds one, report-logger applies it from then on. Dropping --label altogether would unblock filing too, but it would also lose calibration where a repo has it. policyengine-us and policyengine-uk both do, and an analyst can send an issue to either with --log-to issue:<repo>.

Canada

PolicyEngine has no Canada microdata. policyengine.py's 6.16.0 bundle lists uk and us as its only countries, policyengine-canada's one dataset holds three people, and microsim-runner supports only household calculations for Canada. No repo builds the data a Canada issue would concern, so report-logger files none and the archive keeps the report. An analyst can still file one with --log-to issue:<repo>. report-logger and analyze-policy's --open-issue now name PolicyEngine/policyengine-canada for structural Canada issues, because filling policyengine-{country} with ca gives policyengine-ca, which doesn't exist either.

Title and body

The block passed the body as --body "$(cat <<'EOF' … EOF)". bash 3.2 can't parse a quoted heredoc inside "$(...)" when the heredoc holds an odd number of apostrophes. A body line such as CBO's score made the whole block a syntax error, and it filed nothing. zsh parses it. The title sat in double quotes, so the shell read $4 in $40B as an empty parameter and ran anything in backticks.

The block now reads the title with IFS= read -r from one quoted heredoc and pipes the body to gh issue create --body-file - from another, so no shell expands either one. A heredoc still ends at the first line that matches its closing word, and the shell runs the lines after it. report-logger.md tells the agent to check that the title isn't END_TITLE and that no body line is END_BODY. The old form had the same hole, with the likelier word EOF. Writing the body to a file with the Write tool would close it, but the suite couldn't then run the agent's path end to end.

The block also sets country and dataset from placeholders, and prints report-logger: no data repo for country '<value>' for any country but us, uk and ca. report-logger.md tells the agent to write an apostrophe in either value as '\'', to report the unknown-country message under errors, and to run the block without set -e or set -u.

What changes

  • In report-logger.md, the issue-filing bash leaves DATA_REPO empty for ca and calls gh not at all. For us and uk it runs gh label list --repo "$DATA_REPO" --limit 1000 --json name --jq '.[].name | ascii_downcase' and passes --label for each wanted name in the output. It takes the title and body through quoted heredocs, as above. The routing prose, the shortlist and verdict-default tables and the frontmatter description say the same, and tell the agent to list a Canada data issue under skipped in its output.
  • The differential tests in test_country_routing.py run the whole block with a stand-in gh that records each call and the body it reads. They check the issue's repo, labels, title and body against the Python reference. They run under bash and, when the machine has it, zsh, since Claude Code on a Mac can run the agent's shell commands in zsh. Each run fills the title and body with apostrophes, $ amounts, backticks, parentheses and tab-led lines. Two tests write the country and dataset into the block as the agent does, quoted as report-logger.md says, apostrophes included. One property test makes the stand-in fail gh label list and checks that the block still files the issue. A trap grep function stands in for the one Claude Code defines: a block that calls it loses its labels, so the label tests fail. The strict xfail for ca goes.
  • report-logger.md also tells the agent to file a structural or issue:<repo> issue with the same block, pointed at that repo, so that issue gets the same heredocs and label check. For a structural issue the agent loops over auto-filed alone, since policyengine-us and policyengine-uk use calibration for calibration work.
  • CI had skipped all 69 zsh runs. test.yml now installs zsh before the tests, and in CI a missing zsh fails those runs instead of skipping them.
  • The workflow's log_to description, reform-pipeline.md, analyze-policy.md, docs/structured-output-and-chaining.md and tests/pipeline/README.md repeat the new routes.
  • scripts/build_manifest.py writes report-logger's new description and overlap scores into dashboard/src/data/manifest.json.

create-pr.md and create-new-component.md pass bodies through the same "$(cat <<'EOF' …)" form, and audit-seo.md passes --label "seo,audit". structural-implementer.md, implement-structural.md, reform-pipeline.md's /implement-structural line, calibration-diagnostics.md, parameter-locator.md and docs/structured-output-and-chaining.md's uv pip install line still fill policyengine-{country}, which gives policyengine-ca for Canada. This PR leaves them for follow-ups.

Evidence

Claim Source
gh resolves --label names in LabelsToIDs, which compares them with strings.EqualFold and returns '<name>' not found for a missing one, and AddMetadataToIssueParams wraps that error as could not add label params.go:106-109, queries_repo.go:809-823
gh issue create returns on that error before it calls api.IssueCreate create.go:451-474
gh reads --label as a pflag string slice and splits each value at commas create.go:186, pflag v1.0.10 string_slice.go:22-29
gh label list fetches 30 labels unless --limit says otherwise, and policyengine-us has 113 label/list.go:74; gh label list --repo PolicyEngine/policyengine-us --limit 1000, 2026-11-08
microcosm and policyengine-uk-data have neither label; policyengine-us and policyengine-uk have calibration and not auto-filed GET /repos/PolicyEngine/<repo>/labels, 2026-11-08 and 2026-11-11
For every letter of calibration and auto-filed, strings.EqualFold matches nothing beyond its ASCII upper and lower case, so a lower-case comparison of ASCII names agrees with gh a scan of every Unicode code point with Go 1.27.1, 2026-11-08 (only k and s match more, U+212A and U+017F)
gh issue create --body-file - reads the body from standard input, and gh uploads files only for --attach create.go:137-142, file_input.go:9-13, create.go:299-301
/bin/bash 3.2.57 stops on x="$(cat <<'EOF' with a body line CBO's score (unexpected EOF while looking for matching), zsh 5.9 prints it, and bash 3.2 runs the new form macOS 26, 2026-11-11
PolicyEngine/policyengine-ca-data, policyengine-canada-data and policyengine-ca return 404, and policyengine-canada exists GitHub API, 2026-11-08 and 2026-11-11
policyengine.py's bundle lists uk and us as its only countries manifest.json:9-16
policyengine-canada's one dataset, CountryTemplateDataset, holds three people in two households country_template_dataset.py
microsim-runner tells the analyst that Canada has no microdata and supports only household calculations microsim-runner.md:310

Invariants

test_country_routing.py checks these for any dataset string, any set of repo labels, and any title and body that Hypothesis generates:

  • routing returns None or one PolicyEngine/<repo> name;
  • only INVESTIGATE and structural verdicts open an issue, and INVESTIGATE opens one only for us and uk;
  • structural routing and US INVESTIGATE routing ignore the dataset;
  • UK INVESTIGATE routing lands in microcosm or policyengine-uk-data, and reads only the last path segment left after it cuts at the last @;
  • the issue carries each wanted label the repo has in any letter case and no other label, so gh never meets a label the repo lacks;
  • adding labels to the repo never removes one from the issue, and swapping a label's ASCII case changes nothing;
  • report-logger's block files the issue in the reference's repo with the reference's labels, reads that same repo's labels first, and calls gh not at all for ca;
  • when gh label list fails, the block still files the issue, without labels;
  • gh gets the title and body as written, byte for byte, under bash and zsh;
  • for any country but us, uk and ca, the block files nothing and names the country on stderr;
  • a dataset written into the block as report-logger.md says routes the same as that string read from the environment.

Each of these edits to the block makes the tests fail:

  • restoring --label "calibration,auto-filed";
  • restoring the old ca route;
  • dropping ascii_downcase, or grep's -x;
  • reading labels from a fixed repo;
  • passing "${LABEL_ARGS[*]}";
  • dropping --limit 1000, the frs_* pattern or the @revision strip;
  • exiting when gh label list fails;
  • skipping an unknown country without a message;
  • putting the title back in double quotes, leaving $ISSUE_TITLE unquoted, or dropping read's -r or IFS=;
  • passing the body through "$(cat <<'EOF' …)" again;
  • turning either heredoc into <<-, which strips leading tabs;
  • adding set -e before the block;
  • calling grep in place of command grep.

Adding grep's -i passes, since jq has lowered the names and the edit changes nothing.

Tests

uv run pytest --ignore=tests/test_skill_examples.py passes all 415 tests in CI, with none skipped now that CI installs zsh. On main the same command passes 296 and xfails the ca case. scripts/build_manifest.py --check passes on the rebuilt manifest, and scripts/build_claude_wrapper.py copies report-logger.md into the wrapper byte for byte.

Before merge

  • Get an independent review that agrees at head.
  • Squash-merge on green checks and confirm that the Sync Claude Wrapper run carries the change to policyengine-claude.

🤖 Generated with Claude Code

@MaxGhenis
MaxGhenis force-pushed the uk-data-issue-routing branch from 597ab30 to b4f7854 Compare November 8, 2026 20:30
@MaxGhenis
MaxGhenis force-pushed the report-logger-labels-ca branch from 3175ce7 to c3a5ffc Compare November 8, 2026 20:38
@MaxGhenis
MaxGhenis force-pushed the uk-data-issue-routing branch from b4f7854 to a65c848 Compare November 11, 2026 06:06
@MaxGhenis
MaxGhenis force-pushed the report-logger-labels-ca branch from 97fa083 to 4fea952 Compare November 11, 2026 06:14
@MaxGhenis
MaxGhenis deleted the branch uk-data-issue-routing November 11, 2026 13:54
@MaxGhenis MaxGhenis closed this Nov 11, 2026
@MaxGhenis MaxGhenis reopened this Nov 11, 2026
@MaxGhenis
MaxGhenis changed the base branch from uk-data-issue-routing to main November 11, 2026 13:55
MaxGhenis and others added 4 commits November 11, 2026 08:58
…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>
…ne'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>
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>
…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>
@MaxGhenis
MaxGhenis force-pushed the report-logger-labels-ca branch from 4fea952 to 7daffd2 Compare November 11, 2026 14:14
MaxGhenis and others added 2 commits November 11, 2026 14:32
- 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>
…on 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>
@MaxGhenis
MaxGhenis marked this pull request as ready for review November 11, 2026 19:58
@MaxGhenis
MaxGhenis merged commit 7398ea0 into main Nov 11, 2026
4 checks passed
@MaxGhenis
MaxGhenis deleted the report-logger-labels-ca branch November 11, 2026 20:00
anth-volk added a commit that referenced this pull request Nov 12, 2026
Brings in #111. 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