Repository navigation
Certify a Microcosm build of either country by release and build name - #794
Merged
Merged
Conversation
Tests for a scripts/bundle.py check-compatibility command that checks one Microcosm build against one model version, the record it writes, certify-data certifying on that record, and load-time acceptance of only the recorded build, model and core. They fail before the change: the modules they import do not exist yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/bundle.py check-compatibility checks one UK or US build against one model version: certify-data's metadata checks, the input columns of every microdata H5 file against the build's model and the new one, and a 2,000-household sample run through .py under the new model's PyPI wheel and the chosen core. A pass writes a record bound to the SHA-256 of the build's release_manifest.json and of the wheel. certify-data --compatibility-record (and --regional-compatibility-record) certifies on that record, on the basis compatibility_checked_exact_pair, and stores it in src/policyengine/data/compatibility/<country>.json. Loading a model accepts such a certificate only for the recorded build, wheel and core, with or without network access to the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The probe installs the checkout editable, so uv cannot run an earlier cached build of it. - A malformed probe result refuses with a reason instead of raising a validation or attribute error. - A regional release's compatibility record holds only for the installed core, whatever the national build's basis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Install the .py checkout editable in the probe environment, so the run imports the checkout's current source rather than a wheel uv cached. - Refuse a probe result with no policyengine_version, a file entry that is not a mapping, or no SHA-256 of the sampled household IDs, with a CompatibilityCheckError naming the field. - Match the regional release's compatibility record against the running model and the installed core, not the national certificate's. - Docs: the fingerprint basis is a planned further basis; the module docstring names the tagged-layout check and the missing built_at case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check-compatibility must import .py without building the installed country models, whose bundle certificate need not cover the installed model version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- check-compatibility sets POLICYENGINE_SKIP_COUNTRY_IMPORTS before it imports .py, as the TRO commands do, so importing .py does not build the installed country models and check their bundle certificate. - The regional refusal says no installed record covers the running model and core, which also covers an installed record for another model or core. - The data-certification guide describes check-compatibility and certify-data --compatibility-record, and that a record binds its core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the round 3 review's code-quality notes: - _microdata_artifacts returns each file with the revision and SHA-256 it is pinned to, so mypy checks them where the record and the input-column evidence take them. - The data-certification guide says a regional record names its core instead of the core claims check, and that a qualified pair or a compatibility check's record admits a core no release claims. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for a `bundle.py certify-build` command that certifies a build of either country, named by release and build: it reads each build at the commit that published it, runs the compatibility check, certifies, and regenerates the lock and provenance files on a new branch or in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`scripts/bundle.py certify-build` takes a build of either country by release and build name and does what Microcosm's UK-only certification script did, for both countries: - reads each build at the commit on `main` that published its folder, after checking `releases.json` lists it and has not withdrawn it; - runs the compatibility check on the national build and on the local-area build, and certifies on the check's record when a build was made with another model version; - runs `certify-data`, relocks, regenerates the provenance files and the household snapshots, and runs `bundle.py check` with the TRO files; - for the UK, runs the Universal Credit floor and leaves a failure to a person in the pull request body; - commits only certification files on a new branch in a new worktree, and optionally pushes it and opens a draft pull request. `--in-place` changes the current checkout instead, for a workflow that commits the result itself, and lists the changed paths in the output directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for: the US region and model pins a US certification must move; a kept local-area build on the old national commit; values the other country also certifies; the core a compatibility record binds the certificate to, and a build without a record outside it; a branch left by a failed run; command failures and Hub answers that are not JSON as refusals; relative paths; --pr-base; and importing the script without the country models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A US run now rewrites the US region test pins and the bundle tooling test's model version, not only the UK script's three test files. - A compatibility record binds the certificate to the core the check ran, as certify-data does: the plan and body now report that binding, read from the new certificate, and a build without a record that was not made with that core and does not claim it is refused before any worktree or download, naming --core-version. - A kept local-area build on the old national commit, and any value the other country also certifies, is left to a person in the body instead of being rewritten. - A branch left by an earlier run is refused before the worktree, a failed run names the commands that remove what it made, and failures of the programs it runs, and Hub answers that are not JSON, are refusals (exit 2) instead of tracebacks. - Relative --worktree and --output-dir paths are read where the command runs; --pr-base is back from the UK script; importing the script no longer loads the country models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The compatibility check refuses a build made with the model version it is asked about, and the fake check now does the same. A build made with the target model is certified on that basis without a check, and the free-disk check counts only the builds the check downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The compatibility check refuses a build made with the model version it is asked about, so a default run (the national build's own model) always failed at its first check. Each build made with another model version is checked and certified on its record; a build made with the target model is certified on that basis, and the pull request body says it needed no check. The free-disk check counts only the builds the check downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for: the fake builds' core in the pinning test; the compatibility basis assertion in the test that pins the country's certificate; an old value that stands for two new ones (the UK's model and built-with version); keeping a committed certification when the push or the pull request fails; and the order of the cleanup commands for a leftover branch. The fake certify-data now records the basis it would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The compatibility basis assertion moves with the certificate, in the one test that pins the country's certificate only, since the same literals name other bases and fixture keys elsewhere in that file; a missing test or literal is left to a person in the body. - An old value that now stands for two new values (the UK's model and built-with version, certified for a new model on the same build) is left to a person instead of being rewritten to one of them. - A failure after the commit keeps the certification: the refusal says how to push it and open the pull request, not to remove it. - A leftover branch's cleanup removes its worktree first; other errors after the worktree exists print what the run left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rewritten literal can change a line's length, and the pull request's CI checks the format, so the command runs ruff format on the files it rewrote before regenerating the household snapshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scheduled workflow names both builds in its branches; a hand-run certification must use the same name, and another local-area build must not count as the same certification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Branches are now certify/<country>/<national>/<local area>/<package>-<version>, the name the scheduled workflow gives its own, so a hand-run certification and the workflow find each other's pull requests, and a model version is certified again once a new local-area build is pinned. The open-pull-request check also matches on the local-area build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for: the UK release-bundle test's basis assertion, which reads the packaged bundle too; how to push a finished run made without --push, and a leftover branch from such a run; and recovery commands that name the clone with git -C. The fake certify-data now takes the national basis from the national record alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rewrite the basis literal in every test that asserts a country's packaged basis, which for the UK includes the release-bundle test. - Name the clone with `git -C` in every recovery command, and give the real path of a leftover branch's worktree. - When an earlier run's branch exists, say how to push it if that run finished, before saying how to remove it. - After a run without --push, or with --push but without --open-pr, print the commands that push the branch and open the pull request. - Describe the shared local-area commit box and the certify() docstring as the code behaves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Dec 3, 2026
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>
anth-volk
added a commit
that referenced
this pull request
Dec 3, 2026
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>
anth-volk
added a commit
that referenced
this pull request
Dec 3, 2026
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>
anth-volk
marked this pull request as ready for review
December 3, 2026 23:59
anth-volk
added a commit
that referenced
this pull request
Dec 4, 2026
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
added a commit
that referenced
this pull request
Dec 4, 2026
certify-build (#794) and the compatibility workflow name the local-area build in the certification branch, check the disk only for the builds the compatibility check downloads, and certify-build gains --pr-base. The workflow queues waiting runs, still checks one country when the other can't be planned, and fails a certification step after 270 minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #793
What this changes
python scripts/bundle.py certify-buildcertifies a Microcosm build of either country by release and build name. It does in .py what Microcosm's UK-onlytools/certify_uk_cut_in_policyengine_py.pydoes today, for the US as well, without depending on Microcosm's code.bundle.pyhandscertify-buildtoscripts/certify_build.pybefore building its own parser, so .py's country models load only when the command runs. Importing the script setsPOLICYENGINE_SKIP_COUNTRY_IMPORTSonly around its twopolicyengine.provenanceimports and then restores the caller's value.In order, the command:
releases.jsonlists the build and has not withdrawn it, then reads the build's folder (releases/<release>/<build>/) at the Hugging Face commit that last changed it, or at--national-data-commit/--local-area-data-commit, which must be inmain's history. The manifest must name the release and build and record the model and core it was made with. Release names default to the releases the bundle pins now.--core-versionbinds the certificate to that core and moves the pin.bundle.py check-compatibility(Check one Microcosm build against one model version and certify on the result #789), and its record is passed tocertify-data(--compatibility-record/--regional-compatibility-record). A build made with the target model is certified on that basis with no check, and the PR body says so. Because a record binds the certificate to the checked core, a build without a record that this core does not cover is refused before anything is written. One free-disk check before the first download is sized from the checked builds' folders.originbranch already certifies this national build (and local-area build, when given) for this model version, or when the certification branch already exists in the clone.certify/<country>/<national build>/<local-area build>/<model package>-<version>(the local-area part is left out without a local-area build; the same format as Check each country's newest model release on Tuesdays and Fridays #792), it runsuv sync, the compatibility checks from step 3,certify-data,uv lock, the lock and provenance regeneration (release_lock.py,generate), moves the test constants that name the old build, commit, model and basis in five test modules, runsruff formaton the modules it changed, regenerates the snapshots, and runsbundle.py check --published-spm --include-tros --strict-tros. For the UK it also runs the Universal Credit floor and adds a checklist item when it fails.--pushand--open-pr; otherwise it prints the commands that push the branch and open the pull request.--in-placemakes the same changes in the current checkout without committing, and writes the body and a sorted list of changed paths (<output dir>/<checkout name>.changed-paths.txt) for the scheduled workflow in #792.--dry-runprints the plan.Failures are refusals with exit 2, never tracebacks. A failure before the commit names the commands that remove the worktree and branch; a failure after the commit names the commands that push the branch and open the pull request instead. A leftover branch from an earlier run is refused with both: how to push it if that run finished, and how to remove it otherwise.
Tests
tests/test_certify_build.py(new), with stand-ins for the Hugging Face Hub and for every command exceptgit(which runs for real, apart fromgit push). Each set was committed before its change and run by node ID with-o addopts= --noconftest(the repository'sconftest.pyimports country models). No other test was run locally.bundle.pyexits 2 and does not listcertify-build)ruff formatstep)Earlier tests were not re-run after later changes; CI runs them all. The basis rewrite was also checked by hand on a copy of the real
tests/test_release_manifests.py: it changes lines 288 (US) and 319 and 1055 (UK) only.ruff format,ruff checkand mypy pass on the changed files.Review rounds
Three rounds of adversarial review, each by a fresh reviewer.
Round 1 (at 79d5d6a): 1 high, 2 medium, 2 low.
tests/test_us_regions.pyandtests/test_spm_bundle_tooling.py.Round 2 (at 60f62c0): all round 1 fixes confirmed; 2 medium, 1 low.
ruff formaton the modules it changed (CI runsruff format --check).Round 3 (at f317337): all round 2 fixes confirmed; 1 medium, 1 low.
test__given_manifest_certification__then_release_bundle_exposes_it) asserts the packaged basis and was not rewritten. Fixed: each country lists every test that asserts its packaged basis.--pushprinted no command to publish it, and a re-run told the operator to delete it. Fixed: it prints the push and pull-request commands, and the leftover-branch refusal says how to push a finished run.git -C, the refusal gives the real worktree path, and the shared local-area commit item andcertify()docstring describe what the code does.Not covered by a review round: the branch-name change (d4bf6fb, f6d1e3f, from #792's format), the round 3 fixes (8e9c1ee, d4d36f5), a test docstring and the changelog entry, all made after round 3's commit.
Left, none of them a bug in a run today:
pr_bodyandshell_factoryare loosely typed.AttributeErrorin two places; the Hub does not send one.What the merge waits for
check-compatibilityandcertify-data --compatibility-record): merged is enough. This command calls both from the same checkout, so it needs that code inmain, not a published release.This branch starts from #789's branch, so until #789 merges, this PR's diff also shows #789's commits.
No deployment code is changed.
🤖 Generated with Claude Code