Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`tools/certify_uk_cut_in_policyengine_py.py` certifies a UK build published into its own folder. It takes the national build by name (`--national-build`) and a local-area build the same way (`--dense-build`), refuses a build that `releases.json` at `main` does not list or has withdrawn, pins each build at the commit that published its folder (or a commit in `main`'s history named with `--national-data-commit` or `--dense-data-commit`), and hands policyengine.py's `certify-data` each build's folder manifest at that commit. `--keep-regional-release` reads the kept local-area build at the folder and commit the bundle pins, the regional microdata is read from the build's folder, and the certified-constant rewrite moves the local-area build's commit as well as its name. A Hub failure is a refusal, a policyengine.py base that cannot read build folders (policyengine.py#683) is refused before anything is downloaded, and a resumed worktree that pins another national commit or regional route is refused. Tags (`--national-tag`, `--dense-tag`) are no longer accepted, since policyengine.py refuses a tagged manifest from a repository with `releases.json`. The certificate follows the bundle's shared core pin (`core_binding: bundle_pin`, policyengine.py's default) unless `--core-version` names a core to bind, and the pull request body shows its commands without the operator's paths or the bundle records the constant rewrite is passed.
10 changes: 4 additions & 6 deletions docs/release-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -1144,14 +1144,12 @@ work.
without looking for `releases.json`, and `publish_release`, which writes
it. They leave once no registered repository lacks `releases.json`. The
plan names no owner or milestone for them yet.
- *The policyengine.py certification tool.*
`tools/certify_uk_cut_in_policyengine_py.py` still reads a national
build's manifests at its tag (`--national-tag`), so it cannot certify a
build published into its own folder, such as one `tools/run_uk_cut.py`
publishes through `microcosm-publish-release-build`.
- *policyengine.py's pins.* Its bundle, read on 2026-11-11 at 5b6d7901c,
pins builds by tag; version 1 pins each by release and build in its
folder.
folder. Its UK national and local-area builds have been pinned that way
since policyengine.py#759 (merged 2026-11-16), and
`tools/certify_uk_cut_in_policyengine_py.py` certifies a UK build only
from its folder (#1762).
- *The default.* The loader takes each country's default release from the
registry. `releases.json` also names a `default`: in this repository only
the switch tool sets it, and no loader reads it. The gap: no check at
Expand Down
81 changes: 59 additions & 22 deletions docs/uk-cut-anyone.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,40 @@ anyone verify; that is tracked in microcosm#1406.

## Certifying into policyengine.py

`tools/certify_uk_cut_in_policyengine_py.py` still reads a national build by
its tag (`--national-tag`, the manifests at that revision), and builds
published into their own folders carry no tag, so it cannot yet certify a
build `run_uk_cut.py` publishes. The command it takes:

```bash
uv run --no-sync python tools/certify_uk_cut_in_policyengine_py.py \
--national-tag microcosm-uk-2024-25-national-<ts>-<id> \
(--dense-tag <tag> | --keep-regional-release | --area-coded-national-uri <uri> | --drop-regional-release) \
--national-build uk-frs-calibration-attempt-<ts>-<id> \
(--dense-build <local-area build> | --keep-regional-release | --area-coded-national-uri <uri> | --drop-regional-release) \
--pepy-repo <your clone of PolicyEngine/policyengine.py> \
[--national-data-commit <commit>] [--dense-data-commit <commit>] \
[--max-load1 <load>] [--min-free-gb <GB>] [--push --open-pr]
```

Builds are named as `releases.json` names them, the national build in
`microcosm-uk-2024-25-national` and the local-area build in
`microcosm-uk-2024-25-dense`. `policyengine/populace-uk-private` publishes
each build into its own folder, `releases/<release>/<build>/`, with no tag,
and policyengine.py refuses a tagged manifest from a repository with
`releases.json` (policyengine.py#683), so the script takes no tag. A build
need not be current: a certificate pins one build.

Each build is certified from its folder at the commit that published it,
which the script asks the Hub for: the last commit of the build's
`release_manifest.json` on `main`, since a build folder never changes. To pin
another commit that holds the folder, such as the `commit` that
`microcosm-publish-release-build` printed, pass `--national-data-commit` or
`--dense-data-commit`: a full 40-character commit in `main`'s history, since a
commit on another ref may hold an edited copy of the folder.
`--keep-regional-release` reads the local-area build at the folder and commit
the current bundle pins. `--resume-worktree` refuses a worktree whose modified
bundle pins another national commit, or routes regions elsewhere than this
run would (including none), because the first attempt's constant rewrite
already moved the constants to its own builds.

The policyengine.py base (`--base-ref`) must read builds in their own folders
(`read_build_folder`, policyengine.py#683); a base without it refuses before
anything is downloaded.

Each heavy step first checks the host. The disk floor defaults to 55 GB
(`--min-free-gb`). There is no load limit unless you set one with
`--max-load1`, because a sensible limit depends on the machine.
Expand All @@ -412,9 +433,7 @@ For an accepted mismatch (see [Regions](#regions-the-dense-cut)), add
`--audited-by "<who ran the audit>"` (it appears in policyengine.py's public
bundle) and at least one `--regional-limitation "<text>"`. The base needs
policyengine.py#699's audit, and a base without it refuses before anything
is downloaded. Until #699 merges, test the route with `--base-ref
origin/accept-regional-model-mismatch --pr-base accept-regional-model-mismatch`.
The audit and `certify-data` also need `uv` and PyPI: both read the build
is downloaded. The audit and `certify-data` also need `uv` and PyPI: both read the build
model through a pinned `uv` probe, and `certify-data` re-reads both models
rather than trusting the evidence's lists.

Expand All @@ -424,34 +443,51 @@ git identity that commits. An agent session adds its own credit:
commit trailer, and `--pr-body-footer "🤖 Generated with [Claude Code](https://claude.com/claude-code)"`
for the body.

The script does the mechanical part of what policyengine.py#685 did by hand,
on a new branch from policyengine.py's main.
The script does the mechanical part of what policyengine.py#685 and #766 did
by hand, on a new branch from policyengine.py's main.

**Before writing anything:**

- It refuses if another writer is already certifying the cut: an open pull
request that names the tag, or any open pull request or branch whose name
- It refuses if another writer is already certifying the build: an open pull
request that names the build, or any open pull request or branch whose name
contains `certify-uk-<id>`, including suffixed ones such as
`certify-uk-a133f37a-national`. If it cannot read either listing, it
refuses rather than passing.
- It reads both manifests at their tags.
- It refuses a regional cut built on another policyengine-uk, naming the
routes.
- It refuses a build that `releases.json` at `main`, downloaded afresh, does
not list or has withdrawn, as `certify-data` would.
- It reads each build's manifest from its folder at its commit, and refuses
one that names another release or build.
- It refuses a regional build made with another policyengine-uk, naming the
routes, and a kept regional release in `populace-uk-private` that is not a
build in its own folder.

**Then:**

1. `certify-data` at the cut's own model and core.
1. `certify-data` at the national build's own model, with each build's
folder manifest at its commit
(`hf://dataset/policyengine/populace-uk-private@<commit>/releases/<release>/<build>/release_manifest.json`).
The certificate follows the bundle's shared core pin
(`core_binding: bundle_pin`), policyengine.py's default, so the pin can
move with another country without re-certifying the UK. `--core-version`
binds the certificate to one core and moves the pin to it
(`core_binding: certified`); use it only when the release must not run on
any other core.
2. `uv lock` and `release_lock.py`.
3. `generate --include-tros`.
4. policyengine.py's own certified-constant rewrite, plus the local-area tag.
4. policyengine.py's own certified-constant rewrite, plus the local-area
build's name and commit. If the previous local-area build shared a commit
with a national build, its commit constants are left for a person, and the
pull request body says so.
5. The household snapshots.
6. `check --published-spm --include-tros --strict-tros`.
7. The UC floor.
8. The tests.

It commits. It pushes and opens a draft only when asked. The pull request
body lists what needs a person: the UC floor acceptance, any dataset overlays
certification dropped, warnings and failing tests.
certification dropped, warnings and failing tests. Its commands show paths
relative to the worktree and the home directory, and the bundle records the
constant rewrite is passed only by their size.

## Regions: the dense cut

Expand Down Expand Up @@ -501,8 +537,9 @@ rehearsal probe agrees.
through any of these inputs would be wrong.
- `tools/certify_uk_cut_in_policyengine_py.py` measures this whenever a
mismatch is accepted, with policyengine.py's own audit:
- it downloads every regional microdata H5 at its manifest pin and checks
its sha256;
- it downloads every regional microdata H5 from the build's folder at the
build's commit (a file in another repository at its own revision), and
checks its sha256;
- in the certification worktree it installs the target policyengine-uk
and core, and runs `scripts/audit_regional_input_surface.py`, which reads
only column names and measures them against the regional cut's build
Expand Down
Loading
Loading