Skip to content

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

Merged
anth-volk merged 18 commits into
mainfrom
claude/7c-3-compatibility-workflow
Dec 4, 2026
Merged

anth-volk merged 18 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

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>/<local-area build>/<model package>-<version>, so a version is checked again whenever either pinned build changes. 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
7c65aa0 tests, 6fd3ada change (local-area build in the branch name) 6 failed on assertions (3 more that don't depend on the branch name passed) 9 passed
a2a0c9d tests, after merging #794 — (these cover how this workflow and certify-build fit together; no code changed to make them pass) 4 passed: the certification step's command, filled in from a planned entry, parses as certify-build's arguments with the same values, and certify-build's branch_name gives the plan's branch, for both countries

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, fixed in 7c65aa0 and 6fd3ada (Anthony chose this fix): the branch name held the national build but not the local-area build, so a version that already had a certification pull request, in any state, was not checked again after a new local-area build was pinned. The branch now names both builds. certify-build's own branches (7c · 2, when run without --in-place) name only the national build; this workflow does not use them.

Bugs left, by priority

No bugs are left. Code-quality notes 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.

Earlier tasks

This PR was built on #794's branch, merged in as 214ba13. main was merged in again after #789 (657bfd0) and after #794 (a1f0e72): GitHub marked the PR as conflicting each time because the branch and main had two merge bases, though git merged them without a conflict, and neither merge changed any file. certify-build's own branches use the same name as this workflow's since #794's f6d1e3f, at Anthony's request.

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>
anth-volk and others added 2 commits December 4, 2026 01:08
Anthony's decision on review round 3's low-priority finding: a pull
request for a model version and national build stopped the plan from
checking that version again after a new local-area build was pinned. These
tests fail until the branch is named
certify/<country>/<national build>/<local-area build>/<package>-<version>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Branches are now
certify/<country>/<national build>/<local-area build>/<package>-<version>.
A pull request for a version checked against an earlier local-area build
no longer stops the plan from checking that version against a newly
pinned one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 4 commits December 4, 2026 01:50
The workflow runs scripts/bundle.py certify-build --in-place, which
#794 adds. Merging its reviewed branch lets this branch test that
certify-build accepts every option the workflow passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With #794 merged in, the certification step's command, filled in from a
planned entry, parses as certify-build's own arguments and reaches them
unchanged, for both countries. certify-build's branch_name also gives the
branch the plan computes, so a pull request opened by either one stops
the other from opening a second for the same check.

These cover how the two scripts fit together, so they passed when first
run; no code changed to make them pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub reported the pull request as conflicting after #789 (7c · 1)
merged into main. This branch already held #789's changes through #794's
branch, and git merges main without a conflict; the merge commit's
files are the same as the branch head's. It gives the two branches one
merge base again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub marked the pull request as conflicting after #794 merged,
because the branch and main had two merge bases. git merges main
without a conflict, and the result's files are the same as the
previous head's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review December 4, 2026 12:01
@anth-volk
anth-volk merged commit 8c3a57c into main Dec 4, 2026
20 of 31 checks passed
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