Skip to content

Publish run_uk_cut.py builds through the emitter and refuse new direct Hugging Face imports - #1743

Merged
anth-volk merged 15 commits into
mainfrom
claude/hub-access-cleanup
Nov 27, 2026
Merged

anth-volk merged 15 commits into
mainfrom
claude/hub-access-cleanup

Conversation

@anth-volk

@anth-volk anth-volk commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1742 (tracker task 5a · 4 of "1. Collector/Emitter": Microcosm reaches Hugging Face and the collector only through the emitter, apart from the agreed exceptions). Draft: the merge waits for the items under "What the merge waits for".

What changes

tools/run_uk_cut.py publishes through the emitter

Since the UK switch (#1537), the UK assembler (tools/assemble_uk_release_dir.py) prints release and build and no tag, and the tagged publisher (microcosm.data.publish_cli) refuses microcosm-uk-2024-25-national in prepare_release. run_uk_cut.py still expected both, so reading the code, a full run stops at step 9 with "assembly printed no cut tag", and its publication steps call a publisher that refuses the release. Its tests passed because their fake assembler printed a cut_tag. Nothing here was run against real data.

Now:

  • The assembly step takes the build the assembler prints (assemble_done and the receipt record build).
  • The publication pre-flight and the publication run python -m microcosm.build.release_publication <release dir> --repo-id policyengine/populace-uk-private --artifact-root <national run dir> (the microcosm-publish-release-build command, which hands the build to the emitter), with --preflight-only for the pre-flight and never --make-current. The artifact root is the candidate's folder, where the assembler leaves the dataset and its calibration.
  • A rerun publishes nothing once the repository's releases.json lists the build (build_published, a read of release metadata).
  • The printed promotion is ... release_publication <release dir> --repo-id ... --promote.
  • The Hub pre-flight checks only write access through the emitter. It no longer lists the repository's refs for a release-staging/... branch, which only the tagged publisher used.
  • The signing key still goes to the publication steps: the build-folder publisher runs the same release contract, which verifies the gate reports' signatures.
  • docs/uk-cut-anyone.md, the agent guide and docs/release-contract.md describe this. The UK guide's policyengine.py section now says that tools/certify_uk_cut_in_policyengine_py.py still reads a national build by its tag, so it cannot yet certify a build published into its own folder. That tool is not changed here (see "Found, not changed").

Ruff refuses new direct Hugging Face imports

pyproject.toml selects TID251 and bans huggingface_hub. per-file-ignores lists every module that may still import it, grouped by the exception that covers it:

Exception Modules
Datasets and the release metadata that selects and verifies them microcosm-data loader, release_publication.py (repository listing, recertification parent and annual base checks), uk_runtime/cut_reference.py, tools/run_uk_cut.py, tools/certify_uk_cut_in_policyengine_py.py, tools/build_us_compatibility_recertification.py, examples/quickstart_us.ipynb
Build inputs us_runtime/asec_sources.py, us_runtime/sipp_financial_assets.py, tools/modal_us_stage.py, tools/modal_rebuild_uk_chronicle_artifact.py, tools/build_uk_efrs_parity_reference.py, tools/build_uk_release_input_coverage_manifest.py, experiments/**
Operator tools with the operator's own token tools/provision_uk_staging_repository.py, tools/fetch_uk_staged_dataset.py, staging_storage.py
BE's publication tools, which substage 5b removes build_folder_switch.py, microcosm-data/release.py
Tests and their stand-ins packages/*/tests/**, test_support/**, conftest.py

ruff check --select TID251 . found 59 imports in 39 modules before the list and none after; a scratch module importing huggingface_hub under microcosm/build/ is refused, and so is a conftest.py outside the repository root (./conftest.py exempts only the root one). The rule sees imports only: the SIPP donor readers that fetch huggingface.co URLs with urllib (build inputs) are outside it.

The retired Orrery upload flags are gone

--publish-orrery and --no-publish-orrery have changed nothing since builds stopped uploading their graph (#1590). 5a · 1 (#1748) kept them for this task. The UK full build (uk_runtime/full_build_cli.py) no longer defines them or prints the first one's warning, so argparse refuses either as an unrecognized argument (exit 2). tools/run_uk_cut.py stops passing --no-publish-orrery. docs/orrery-publication.md says the options are gone, and docs/uk-cut-anyone.md drops its sentence about the runner passing one (bf2b42dd6's message says both docs describe the removal; only the first does). Nothing else in the repository passes them; a launcher outside it that still does now stops at argument parsing. The changelog fragments and an evidence README that record earlier runs keep their text.

The emitter version check goes through the interface

microcosm-build requires microcosm-emitter-interface>=0.18.0 (5a · 3, PolicyEngine/microcosm-emitter#100), uv.lock moves only that package, and APPROVED_UV_LOCK_SHA256 follows the lock. The installed-emitter job tests emitter 0.18.0 beside the minimum, 0.17.0, which does not change (tools/installed-emitter/requirements.txt).

telemetry_emitter._version_description calls the interface's emitter_version instead of running microcosm-emitter version with subprocess and parsing its JSON. Each CommandFailure maps onto the kinds the refusals already use (timed_out to version_timeout; unusable output to "printed no JSON object"; an exit code to "exited N"; a command that could not run or was not found to "could not be run (...)"), so the warning and every refusal read as before. _protocol_refusal reads the answer's protocol_versions, which the interface reports as None unless version printed a list of integers.

Smaller

  • The comment above MINIMUM_EMITTER_VERSION keeps only the current minimum's reason and the cost of refusing an emitter; the emitter's changelog has the history of earlier releases.

Tests

Failing commit 9cfa2354a, passing commit 7a136a99e, review fixes 63eabebd7. For the Orrery flags: failing commit 5bc88ff45, passing commit bf2b42dd6. For the version check: dependency 0232d7367, failing commit e9a2ac482, passing commit 9c48f40d8. For review round 3's bugs: failing commit c871907de, passing commit 30e9e8fc1. In packages/microcosm-build/tests/engine_free/uk/test_run_uk_cut.py, on the failing commit:

Test Failure before the change
test_the_hub_checks_ask_the_builds_emitter assertion: a third check, which lists the Hub's refs
test_a_complete_run_executes_each_step_once_and_resumes_to_nothing, test_the_assembled_build_publishes_once_through_the_emitter, test_without_publish_only_the_publication_preflight_runs CutError: assembly printed no cut tag, the bug itself, once the fake assembler prints what the real one prints
test_publication_hands_the_build_to_the_emitter_without_making_it_current (2), test_the_printed_promotion_makes_the_published_build_current TypeError: the old functions need a tag
test_a_build_is_published_once_releases_json_lists_it (4) AttributeError: build_published did not exist

For the Orrery flags, on 5bc88ff45, all on their assertions: test_uk_orrery_inputs.py::test_the_retired_orrery_upload_flags_are_refused (2, DID NOT RAISE SystemExit), test_uk_orrery_inputs.py::test_a_build_request_has_no_orrery_upload_setting, and test_run_uk_cut.py::test_the_national_build_passes_no_orrery_upload_flag (2, the argv held --no-publish-orrery). They replace test_publish_orrery_only_warns_that_the_build_uploads_no_graph and test_the_national_build_never_publishes_to_the_orrery.

For the version check, on e9a2ac482, all on their assertions: test_emitter_adapter.py::test_the_version_check_asks_the_interface_for_the_installed_release, ::test_a_required_build_s_error_for_each_failure_the_interface_reports (6: timed_out, could_not_run, command_not_found, usage_error, exited, unusable_output) and ::test_a_required_build_refuses_a_version_answer_without_protocol_versions. The existing stand-in-command tests of the version check are unchanged and now run through the interface.

For review round 3, on c871907de, all on their assertions: test_route_a_driver.py::test_undecodable_standard_error_does_not_fail_the_check_as_in_the_release (2), ::test_an_undecodable_version_answer_is_no_json_object_as_in_the_release (2; they replace test_undecodable_version_output_is_a_failed_run_as_in_the_release) and test_emitter_adapter.py::test_a_time_limit_the_interface_refuses_is_named_instead_of_the_command. test_emitter_adapter.py::test_bytes_that_are_not_utf_8_on_standard_error_do_not_stop_a_valid_answer passed already; it records the interface's decoding.

Changed without a new failure: test_the_receipt_names_the_cut_signer, test_the_receipt_records_the_reference and test_a_reference_withdrawn_after_certification_stops_the_cut pass a build instead of a tag. Only these node IDs ran locally, once, before the change; CI runs the rest.

Not in this PR yet

  • Nothing from 5a · 2 (staging run files, microcosm#1749, now in main): its own PR removed the upload interval option and force_upload, and the staging version 1 writer moves to version 2 in 5a · 5 (microcosm#1135).
  • The US Modal runner's emitter calls stay on the emitter's commands (Anthony's decision, 2026-11-26): tools/modal_us_stage.py runs version and status on the image's own interpreter, which has neither the build's environment nor the interface, and tools/modal_us_stage_plan.py, standard-library only by design, runs telemetry-token under the Modal client's interpreter on the operator's machine. Their docstrings say so (3f76b25a3, 30e9e8fc1). tools/route_a/check_emitter.py runs under a standalone python3 -I before the build's environment exists, so it keeps its own version call; it now decodes the output as the interface does.

Found, not changed

  • tools/certify_uk_cut_in_policyengine_py.py reads releases/<release>/release_manifest.json at a tag (--national-tag), so it cannot certify a UK build published into its own folder. Changing it is outside this task.
  • From review round 1: the Modal launcher for this tool (tools/modal_uk_cut.py) installs no microcosm-emitter in its image, so, reading the code, a Modal run fails the pre-flight's write-access check through the emitter and could not publish through it either. This predates the PR.

Review

  • Round 1 (7a136a99e): microcosm-1743-review-round1-2026-11-26.md in the review handoffs folder. No bugs. Code-quality points fixed in 63eabebd7: stale text in the agent guide, docs/release-contract.md and the UK guide's opening; the conftest.py exemption now covers only the root one; the exemption comments name the pointer-file refusal and the tool's input fetch; the comment above MINIMUM_EMITTER_VERSION keeps the Orrery graph publication a refused emitter costs; one test message. Not changed: the fake assembler is written by hand (the real one needs full build inputs); a Hub error in build_published ends main with a traceback, as the old tag check did; a withdrawn build is logged as published without saying it is withdrawn.
  • Round 2 (bf2b42dd6, covering the review fixes, the merge of main and the Orrery flags): microcosm-1743-review-round2-2026-11-26.md. No bugs. It recomputed the merge and found it differs from the automatic result only in the resolved comment, ran the five new tests at 5bc88ff45 (each fails as stated) and bf2b42dd6 (all pass), and found nothing else that passes, reads or documents the flags. Fixed in 7b784c889: test_the_national_build_passes_no_orrery_upload_flag checks only arguments that start with --, so a path containing "orrery" cannot fail it. This description now says what each doc does.
  • Round 3 (3f76b25a3, covering both merges of main, the interface 0.18.0 requirement, the version check and the Modal docstrings): microcosm-1743-review-round3-2026-11-26.md. Two low-priority bugs, both fixed test-first (failing c871907de, passing 30e9e8fc1): (1) tools/route_a/check_emitter.py decoded version's output strictly, so it refused an answer with undecodable bytes on standard error that the release, through the interface, accepts; it now decodes with replacement characters and reports undecodable standard output as no JSON object, as the release does. (2) A startup time limit the interface refuses (invalid_arguments) was reported as a command that could not run, with advice to check the command; it now names the time limit. No caller passes such a limit. Also fixed: the interface floor in docs/orrery-publication.md and docs/release-contract.md, and two docstring statements about the Modal interpreters. Left: the "exited -9" refusal for a killed version keeps the existing advice about releases before 0.4.0, as before this PR. That was the last round.

Deployment

No workflow, image or deployment change. The changed tool reads HF_TOKEN and MICROCOSM_UK_TERMINAL_GATE_SIGNING_KEY from the operator's shell, as before.

What the merge waits for

🤖 Generated with Claude Code

anth-volk and others added 3 commits November 26, 2026 00:24
The UK national build tool still assembles, publishes and promotes as the
tagged publisher did: it needs a "tag" in the assembler's summary, which the
assembler has not printed since the UK switch, then calls
microcosm.data.publish_cli, which refuses microcosm-uk-2024-25-national. These
tests describe the build-folder path instead: the assembler's "build", the
publication and its pre-flight through microcosm.build.release_publication
without --make-current, a printed --promote command, a rerun that publishes
nothing once releases.json lists the build, and Hub checks that list no
release-staging branch.

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

tools/run_uk_cut.py takes the build the assembler prints, runs its
publication pre-flight and publication through
microcosm.build.release_publication (microcosm-publish-release-build)
without --make-current, skips publication once releases.json lists the
build, prints a --promote command, and no longer lists the repository's
refs for a release-staging branch or a tag. Its docs say the policyengine.py
certification tool still reads tagged builds only.

Ruff's TID251 bans huggingface_hub imports except in the modules
pyproject.toml lists, grouped by the exception that covers each.

The comment above MINIMUM_EMITTER_VERSION keeps only the current minimum's
reason and the cost of refusing an emitter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The agent guide, the release contract and the UK guide's opening no longer
describe run_uk_cut.py's tagged publication or promise a policyengine.py
certification its tool cannot yet make. The exemption for conftest.py
covers only the root one, the datasets group names the pointer-file refusal
and run_uk_cut.py's input fetch, and the comment above
MINIMUM_EMITTER_VERSION keeps the Orrery graph publication a refused
emitter costs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the conflict in the comment above MINIMUM_EMITTER_VERSION: this
branch's shorter comment, with #1748's wording that a refused emitter costs
the Orrery inputs in a build's staged bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 3 commits November 26, 2026 17:15
--publish-orrery and --no-publish-orrery have changed nothing since builds
stopped uploading their graph (#1590); #1748 kept them for this cleanup.
These tests ask the UK full build to refuse both as unknown options and to
carry no publish_orrery setting, and run_uk_cut.py to pass neither.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UK full build no longer defines --publish-orrery or --no-publish-orrery
or prints the warning the first one gave; argparse refuses both as
unrecognized. tools/run_uk_cut.py stops passing --no-publish-orrery, and
docs/orrery-publication.md and docs/uk-cut-anyone.md say the options are
gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_the_national_build_passes_no_orrery_upload_flag looked for "orrery"
in every argument, paths included, so a temporary directory named after
the test could fail it. It now looks only at arguments that start with
"--" (review round 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the conflict in the comment above MINIMUM_EMITTER_VERSION: this
branch's shorter comment, now saying, as #1744 does, that every BE build
has parent_build_manifest.json and reform_validation.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 7 commits November 26, 2026 22:46
Interface 0.18.0 (PolicyEngine/microcosm-emitter#100) adds typed calls for
the emitter's version, status and telemetry-token commands. microcosm-build
requires it; uv.lock moves only that package, APPROVED_UV_LOCK_SHA256 follows
the lock, and the installed-emitter job tests emitter 0.18.0 beside the
minimum, 0.17.0, which does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adapter runs `microcosm-emitter version` and parses its JSON itself.
These tests stand in for the interface's emitter_version (0.18.0) and ask
the adapter to take the installed release from its answer, to turn each
CommandFailure reason into the existing refusal (version_timeout, or
version_failed with what happened), and to refuse an answer without
protocol versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_version_description calls microcosm-emitter-interface's emitter_version
instead of running `microcosm-emitter version` with subprocess and parsing
its JSON. Each CommandFailure maps onto the kinds the refusals already use:
timed_out to version_timeout, unusable output to "printed no JSON object",
an exit code to "exited N", and a command that could not run or was not
found to "could not be run (...)". _protocol_refusal reads the answer's
protocol_versions, which the interface reports as None unless version
printed a list of integers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main moved uv.lock (policyengine-uk 2.180.0 and the US base's lock check)
and APPROVED_UV_LOCK_SHA256 with it; this branch moved the lock to
microcosm-emitter-interface 0.18.0. uv.lock merged without conflict, `uv
lock --check` accepts it, and APPROVED_UV_LOCK_SHA256 is the merged lock's
SHA-256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plan module uses only the standard library and requests the telemetry
token under the Modal client's own interpreter, and the runner's version and
status calls run on the image's interpreter; neither has
microcosm-emitter-interface, so they keep running the commands (Anthony's
decision, 2026-11-26). Comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd 3)

The release now reads `version` through the interface, which decodes its
output with replacement characters, so the Route A check must accept a valid
answer with undecodable bytes on standard error and report undecodable
standard output as no JSON object, as the release does. A time limit the
interface refuses (invalid_arguments) must be named as the cause, not
reported as a command that could not run. The adapter test for undecodable
standard error passes already; it records the interface's behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/route_a/check_emitter.py reads `version` with errors="replace", as
microcosm-emitter-interface does, so it accepts what the release accepts.
The adapter reports a CommandFailure("invalid_arguments") as the time limit
the interface refused, without advice to check the command. The Emitter
dependency section of docs/orrery-publication.md and docs/release-contract.md
name the >=0.18.0 floor, and the Modal runner's docstrings say what the
image's interpreter and the Modal client are known to have (review round 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review November 27, 2026 13:11
@anth-volk
anth-volk merged commit d2c1ca4 into main Nov 27, 2026
12 checks passed
@anth-volk
anth-volk deleted the claude/hub-access-cleanup branch November 27, 2026 13:12
anth-volk added a commit that referenced this pull request Nov 27, 2026
Merges main after #1743, which moved tools/run_uk_cut.py onto build-folder
publication. The one conflict was run_uk_cut.py's closing message: it keeps
#1743's build variable and promote command, and replaces #1743's "cannot
certify this build yet" with the certification command for the build,
--national-build <build>. #1743's matching caveats in docs/uk-cut-anyone.md
("Certifying into policyengine.py") and in docs/release-contract.md's list
of leftovers merged without a conflict and are removed, since this branch
certifies build folders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Nov 27, 2026
main's root pyproject.toml (from #1743) exempts the removed module from
ruff's TID251 rule; the merge lets this branch remove that entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Nov 27, 2026
Review round 1: main's root pyproject.toml, merged in from #1743, still
exempts the removed module from ruff's TID251 rule, and the scan did not
read it. The scan now also reads the root and package pyproject.toml
files, the root conftest.py and the CI workflows, and a second test
checks that every scanned directory and file exists, so a wrong path
cannot make the scan pass without reading anything. The scan fails on
pyproject.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Nov 27, 2026
Bug (medium): remove the root pyproject.toml's TID251 exemption for the
removed module, which #1743 added on main, and reword its comment so it
names only the tagged publisher.

Also from the review's quality points:
- the refusal test checks that the refusal names neither the `copy` nor
  the `switch` step;
- the loader again has a test that it certifies a moved build's
  manifest carrying migrated_from, from a tag or an untagged folder; the
  only such test was in a deleted module;
- docs/release-contract.md says the switch tool was a fourth reader of
  pointer files, and that the fixture generator sets `default` only in
  the C5 golden records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 added a commit that referenced this pull request Nov 27, 2026
…mitter, the Chronicle rebuild image's roots and US base changes (#931)

Main took six pull requests since 5589fae: #1743 (UK cuts publish their
build into its own folder through the emitter, and the retired Orrery upload
flag goes), #1747, #1737, #1770 and #1773 (the US base build's hash inputs,
final export carry, memory profile and system-only JCT reform) and #1769 (the
UK Chronicle rebuild's image distrusts the eMudhra roots). The emitter
interface moves to 0.18.0; no feed or engine pin moves.

Two files conflicted.
- tools/run_uk_cut.py: main replaced the staging-branch constant with the
  emitter publisher; this branch's spine inputs, build-inputs repository and
  disk and memory floors for dense-spine stay beside it.
- docs/agent-guide.md: main's account of publishing through the emitter,
  with this branch's dense-spine command and the national step's refusal
  until the atomic-area basis exclusion applies on the national line. The
  sentence on the tagged publisher's arguments goes, since the cut no longer
  builds them.

The gate contract pins, the stage table, the coverage manifest, the US F0
report and the US pins are current on the merged tree.

Checks: with policyengine-uk hidden, as in CI's engine-free job, the tests
main's six pull requests change, the cut and full-build CLI tests, the
spec-engine loader and the UK graph's binding rules (1,556 pass); the US
coverage report and pins, the gate pins, the stage table and the coverage
manifest (--check); CI's test plan verify.

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