Skip to content

Check each country's newest model release on Tuesdays and Fridays - #792

Draft
anth-volk wants to merge 12 commits into
mainfrom
claude/7c-3-compatibility-workflow
Draft

anth-volk wants to merge 12 commits into
mainfrom
claude/7c-3-compatibility-workflow

Conversation

@anth-volk

@anth-volk anth-volk commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #787
Do not merge: (author's step) once tracker task 7c · 2 (scripts/bundle.py certify-build --in-place) has a pull request, merge its branch into this one and add a test that certify-build's parser accepts every option this workflow passes.

What this changes

On Tuesdays and Fridays at 06:17 UTC, and by hand, a new workflow, .github/workflows/check-model-compatibility.yaml, checks each country's newest model release against the Microcosm builds the bundle manifest pins. It replaces certify-uk-release.yaml, which checked policyengine-uk wheels only against policyengine-uk-data releases, and which #761 already limited to manual runs.

Plan job (ubuntu-latest, reads only). scripts/compatibility_workflow.py plan reads src/policyengine/data/bundle/manifest.json and PyPI. For each country it takes the newest policyengine-us or policyengine-uk release, or the version typed into a manual run (country: both, us or uk; model_version: needs one country). It reads the pinned national and local-area builds from the manifest's release_manifest_uri and regional_release_manifest_uri, and names the branch certify/<country>/<national build>/<model package>-<version>. It leaves a country out when:

  • the bundle already pins that model version;
  • a pull request from that branch already exists, open or closed; or
  • the branch is already on GitHub without a pull request (a run whose pull request step failed after its push).

It writes the countries left as the check job's matrix and a summary table to the run page. Each country is planned separately: if PyPI, gh, git or a country's manifest entry fails, that country is listed with its error and the other is still checked; a later step then fails the plan job, so the run shows as failed. Runs share one concurrency group with queue: max, so a run queued behind a waiting run waits too instead of cancelling it.

Check job (one per country left, run unless the run was cancelled, on the CERTIFY_RUNNER_X64 runner expression, so ubuntu-latest while that variable is unset):

  1. Checks out main without keeping a token.
  2. On a GitHub-hosted runner, deletes tool folders this job does not use (.NET, Android SDK, GHC, CodeQL). The US builds are about 11 GB and certify-build wants 5 GB more free; the runner starts with about 14 GB.
  3. Installs the locked environment for the country.
  4. Runs scripts/bundle.py certify-build --in-place with the planned model version and the pinned builds, for at most 270 minutes (the job's limit is 300, and GitHub cancels a job at its limit rather than failing it). Only HUGGING_FACE_TOKEN is passed to this step. It runs the compatibility check, and on a pass writes the compatibility record, the changelog fragment and the pull request body, plus a list of the files it changed.
  5. On a pass, makes a GitHub App token (after the check, since App tokens last an hour), commits only the listed files to the new branch, pushes it and opens a draft pull request with certify-build's title and body. Each run opens its own pull request and leaves earlier ones open, so any checked version can be merged.
  6. Always writes and uploads a compatibility-<country> result file: the model version, the pinned builds, passed, failed (naming the step: setup, certification or pull_request) or cancelled, the pull request and the run. The drift report (8b · 2) reads it.
  7. Always updates the country's issue "Model compatibility check failed: US" or "…: UK": a failure opens it or comments on it, a pass closes it, and a cancelled run leaves it alone. These are plain gh calls, with no AI involved.

Also removed:

  • certify-uk-release.yaml;
  • the tests that read its YAML: nine in tests/test_uk_qualification_workflow.py and two in tests/test_uk_qualification_pipeline.py, with two fake pull request listings only they used;
  • its runbook, docs/engineering/runbooks/uk-qualification.md.

Docstrings that pointed at the runbook or the workflow are updated. The rest of the UK pipeline, its Python code and qualification-ledger.sh, stays for now. A later task removes it, keeping uk_uc_floor.json.

Decisions (Anthony's)

  • Scope: this PR removes only the workflow, the tests that read it and its runbook.
  • Schedule: 17 6 * * 2,5.
  • Failures: one issue per country, opened, updated and closed by plain gh calls.
  • The workflow passes only the model version. policyengine-core stays at the bundle's pin.
  • Pull requests are opened by the GitHub App, on a new branch per run, one pull request per run, left open.
  • Result files are uploaded as compatibility-<country> artifacts.

Tests

tests/test_model_compatibility_workflow.py (new) covers:

  • the plan: newest release, already pinned, existing pull request, existing branch, named version, refused inputs, the committed bundle;
  • the plan command's matrix output, and the gh and git ls-remote commands it runs;
  • how the steps' outcomes and the job's status become passed, failed or cancelled;
  • the result file;
  • the failure issue (open, comment, close, untouched when cancelled);
  • the workflow's triggers, permissions, jobs and step order, and the absence of ${{ inputs.* }}, ${{ matrix.* }} or ${{ github.event.* }} inside any run script;
  • the pull request step's script, run under bash with stand-in git and gh commands.

tests/test_ci_runner_variables.py now lists the new workflow's two jobs.

Local results. Only the added or changed tests were run, each by node ID:

Commits Before the change After the change
52b4924 tests, 2e91435 change 29 failed on assertions 29 passed
ba76563 tests, 693a7b9 change (certify-build --in-place) 6 failed on assertions 7 passed
47fda41 tests, 38716ca change (review round 1) 18 failed: missing functions and options, assertion failures, and bash's "bad substitution" for ${COUNTRY^^} 19 passed, plus the runner-variable tests
7c45d3f test, 89df93f change (review round 2) the new test failed on its assertion it and the 8 changed tests passed
9aac84b tests, 444a83f change (review round 3) 7 failed: the queue setting, the per-country plan and the check job's condition (an 8th, that the plan step passes --model-version, is new coverage and passed) 8 passed

main was merged in once (cd050c2) to resolve a conflict with #761. #761 had edited the old workflow, its runbook and its YAML tests, all of which this PR removes, including the test #761 added. After the merge, the bundle test and the runner-variable tests passed again. ruff format and check on the changed Python files report nothing. actionlint reports nothing except the queue key, which GitHub documents but actionlint 1.7.12 does not know yet (rhysd/actionlint#657); .py's CI does not run actionlint.

Review

Three rounds of adversarial review, each by a fresh reviewer. The files are kept outside the repository.

Round 1 (head 93be013), five bugs, all fixed in 47fda41 (tests) and 38716ca (change):

  • High: the US check needs about 16 GB free and ubuntu-latest starts with about 14 GB. A step now frees disk space on GitHub-hosted runners.
  • Medium: the App token was made at the start of the job and lasts an hour, but the check can take several. The token is now made after the check, and the checkout keeps no token.
  • Medium: a failure before the checkout left no result file and no issue. The checkout is now the first step.
  • Low: a cancelled run was recorded as a setup failure and opened the issue. It is now recorded as cancelled, and the issue is left alone.
  • Low: a branch pushed without a pull request made every later run for that version fail at the push. The plan now leaves such a version out.

Round 2 (head 38716ca) confirmed round 1's fixes and answered four questions: gh auth setup-git works with only GH_TOKEN; job.status is cancelled in always() steps after a cancellation; runner.environment exists; and the plan job can run git ls-remote. One bug, fixed in 7c45d3f and 89df93f:

  • Medium: GitHub cancels a job that reaches its time limit, so a check that ran too long was recorded as cancelled and opened no issue. The certification step now has its own 270-minute limit.

Round 3 (head 89df93f) confirmed round 2's fix. Three bugs:

  • Medium, fixed in 9aac84b and 444a83f: by default a newly queued run cancels the run already waiting in the concurrency group, so a second manual run dropped the first, or a waiting scheduled run. The group now sets queue: max.
  • Medium, fixed in the same commits: an error while planning one country (PyPI, gh, git, its manifest entry) stopped the other country's check too. Countries are now planned separately, as described above.
  • Low, left: the branch name holds the national build but not the local-area build. A version that already has a certification pull request, in any state, is not checked again after a new local-area build is pinned, until a newer model release appears. The branch format is shared with certify-build's own branches (7c · 2). Fixing it means adding the local-area build to the name in both places, or documenting the limitation; that choice is open.

Bugs left, by priority

  1. Low: the local-area build is not in the branch name (round 3, above).
  2. Code quality, from the reviews:
    • failed also covers a certify-build refusal (for example too little disk) and a failed pull request step after a passing check; the result file's failed_step tells them apart only as certification or pull_request.
    • The failure issue is per country, not per version, so a manual pass of an older version closes an issue opened for the newest version.
    • A typed version that is not on PyPI is reported as a failed check.
    • The plan entry and the result file are untyped dictionaries.
    • Hardening: code run during the check (the new model release) could write git hooks or settings into the checkout that the commit and push then run with the App token in their environment. Exploiting this requires a compromised model release, and that code already sees HUGGING_FACE_TOKEN.

What the merge waits for

  • 7c · 1 (scripts/bundle.py check-compatibility and the compatibility record): merged is enough. The workflow runs from this repository's main; nothing it needs is published or deployed.
  • 7c · 2 (scripts/bundle.py certify-build --in-place): merged is enough, for the same reason. This PR does not build on its branch yet, because 7c · 2 has no PR. The "Do not merge" step above merges that branch in once it exists.

Environment variables and secrets

Name Used by Provider Wiring Verified
HUGGING_FACE_TOKEN check job, certify step only (reads the private UK builds) GitHub Actions repository secret (an organization secret of the same name also exists) step env: from secrets.HUGGING_FACE_TOKEN The secret exists, and CI's bundle check reads the private UK data with it. Whether it reads the full builds this job downloads is unverified.
APP_ID, APP_PRIVATE_KEY check job, App token step GitHub Actions organization secrets, visible to all repositories with: of actions/create-github-app-token@v1 The same secrets opened #716 as the App. No ruleset covers certify/*. Whether the App's installation still has contents and pull-request write access here is unverified.
GH_TOKEN plan step (job token); pull request step (App token); issue step (job token) github.token and the App token step step env: The job token's permissions are set per job: pull-requests: read for the plan, issues: write for the check.
CERTIFY_RUNNER_X64, CI_RUNNER_EVENTS check job's runs-on GitHub Actions variables vars. expression Neither is set at repository or organization level, so the job runs on ubuntu-latest.
UV_VERSION, PYTHON_VERSION, UV_PYTHON all steps the workflow's own env: workflow env: Set in the file.

Other notes

🤖 Generated with Claude Code

anth-volk and others added 12 commits December 3, 2026 22:02
Tests that fail before the change: a workflow checks each country's newest
model release against the Microcosm builds the bundle pins on Tuesdays and
Fridays and by hand, opens a draft certification pull request per run on a
branch named after the country and model version, uploads a result file per
country and opens or updates one failure issue per country. The UK-only
certify-uk-release.yaml is gone, and the runner-variable tests cover the new
workflow's jobs instead of the old one's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add .github/workflows/check-model-compatibility.yaml. On Tuesdays and
Fridays at 06:17 UTC, and by hand for a named version, it picks each
country's newest policyengine-us or policyengine-uk release, leaves out a
country whose version the bundle already pins or already has a pull request,
and runs scripts/bundle.py certify-build on the pinned national and
local-area Microcosm builds with that version. A pass pushes a new branch
certify/<country>/<model package>-<version> and opens a draft pull request
as the GitHub App; earlier pull requests stay open. Every run uploads a
compatibility-<country> result file, and a failure opens or comments on one
issue per country, which the next pass closes.

scripts/compatibility_workflow.py holds the plan, the result file and the
issue handling, reading only the bundle manifest, PyPI and GitHub.

Remove certify-uk-release.yaml, which read only policyengine-uk-data
releases and so never promoted a Microcosm build, together with its runbook
and the tests that read its YAML. The UK qualification script, modules,
ledger script and data files stay for now; their docstrings no longer say the
workflow runs them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests that fail before the change: the certification branch also names the
national build (certify/<country>/<national build>/<package>-<version>), as
certify-build names its own branches, so a newly pinned build is checked
again for a version already checked against an older one. certify-build
runs with --in-place, --output-dir and --pr-body-footer, and the pull
request step commits only the files certify-build lists, with its pull
request body and its title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The check job now runs scripts/bundle.py certify-build with --in-place,
--output-dir and --pr-body-footer, then commits only the files certify-build
lists as changed and opens the draft pull request with its body and its
title. The certification branch names the national build as certify-build's
own branches do: certify/<country>/<national build>/<package>-<version>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These tests fail until the workflow and its script change:

- A GitHub-hosted runner frees disk space before installing, because the
  US check needs about 16 GB free and the runner starts with about 14 GB.
- The checkout comes first and keeps no token; the App token is made after
  certification, just before the push, because App tokens last an hour.
- The pull request step's script, run with stand-in git and gh commands,
  sets up gh as git's credential helper before pushing, and runs under
  bash 3.2 as well.
- A cancelled run is recorded as cancelled and leaves the issue alone.
- The plan leaves out a version whose branch is already on GitHub without
  a pull request.

Also tests the gh and git commands the plan uses, and removes two fake
pull request listings that no test uses since the UK workflow's tests went.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 1:

- The check job checks out first, without keeping a token, and makes the
  GitHub App token after certification, just before the push. App tokens
  last an hour and the US check can take several. gh sets itself up as
  git's credential helper for the push.
- A GitHub-hosted runner deletes tool directories this job does not use
  before installing, so the US builds and certify-build's 5 GB margin fit.
- A cancelled job is recorded as cancelled, with the job's status passed
  to the result steps, and leaves the failure issue alone.
- The plan leaves out a version whose branch is already on GitHub without
  a pull request, since pushing it again would fail.
- The pull request step upper-cases the country with tr, which bash 3.2
  also runs, and the result steps use the runner's python3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 2: GitHub cancels a job that reaches its own time limit,
so a check that ran too long would be recorded as cancelled and leave the
failure issue alone. The test fails until the certification step has a
time limit at least 20 minutes below the job's.

Also runs the pull request step's script with `bash -e`, as GitHub runs a
step that names no shell, and drops a monkeypatch option that was needed
only before remote_branch_exists existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 2: the certification step now stops after 270 minutes,
30 before the job's limit. A check that runs too long is then recorded as
a failed certification and opens or updates the failure issue, instead of
being cancelled with the job.

Also corrects two comments: which pull requests make the plan leave a
version out, and what else certify-build writes to its output directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 3. These tests fail until:

- the workflow's concurrency group queues waiting runs (queue: max)
  instead of letting a newly queued run cancel the one already waiting;
- an error while planning one country (PyPI, gh, git or its manifest entry)
  leaves the other country in the matrix, names the failed country in an
  `unplanned` output, and a later step fails the plan job;
- the check job runs for the planned countries even when the plan job
  failed for another.

Also checks that the plan step passes --model-version.

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

From review round 3:

- The concurrency group sets queue: max, so a newly queued run waits
  behind the one already waiting instead of cancelling it. Two manual
  runs, one per country, no longer drop the first.
- The plan plans each country separately. A country whose lookup fails
  (PyPI, gh, git or its manifest entry) is listed in the run summary with
  its error and named in a new `unplanned` output; the other country stays
  in the matrix. A step after the outputs then fails the plan job, and the
  check job runs for the planned countries unless the run was cancelled.

actionlint 1.7.12 does not yet know the documented queue key
(rhysd/actionlint#657); .py's CI does not run actionlint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pull request conflicted with main. main's #761 turned off
certify-uk-release.yaml's schedule and dispatch triggers and edited its
runbook and YAML tests; this branch removes all three, so the
resolution keeps them removed, including the test #761 added for the
turned-off triggers.

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

This branch has not been deployed

No deployments
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.

Check each country's newest model release on Tuesdays and Fridays, replacing certify-uk-release.yaml

1 participant