Skip to content

Install the emitter in the UK Modal launcher's image - #1758

Merged
anth-volk merged 6 commits into
mainfrom
claude/uk-modal-launcher-emitter
Nov 27, 2026
Merged

anth-volk merged 6 commits into
mainfrom
claude/uk-modal-launcher-emitter

Conversation

@anth-volk

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

Copy link
Copy Markdown
Contributor

Closes #1757. Tracked as task 5d · 2 of the "1. Collector/Emitter" project.

What changes

tools/modal_uk_cut.py runs tools/run_uk_cut.py all in a Modal container. Its image installed only uv. run_uk_cut.py's preflight starts the separately installed microcosm-emitter to check write access (#1460), and the workspace lock pins only microcosm-emitter-interface (#1410), so every Modal run stopped at preflight, with or without --publish.

The image now installs the emitter as the US Modal image does (image_emitter_requirement() and image_build_commands() in tools/modal_us_stage_plan.py):

  • Install step. UV_TOOL_BIN_DIR=/usr/local/bin uv tool install 'microcosm-emitter>=X.Y.Z', where X.Y.Z is the release packages/microcosm-build/src/microcosm/build/minimum_emitter_version.json names in the launching checkout (0.17.0 on main today). The emitter sits outside the environment the container syncs at run time. Modal reuses the layer while the minimum, every earlier image step and Modal's image builder version are unchanged, so an image keeps the release it was first built with until one of those changes.
  • Check. The next step runs /usr/local/bin/microcosm-emitter version, so a command that cannot run fails the image build rather than the paid run.
  • Command variable. The image sets MICROCOSM_EMITTER_COMMAND=/usr/local/bin/microcosm-emitter, which the build's interface reads to find the emitter (it also searches PATH).
  • Order. The install runs before the signing-key registry's copy, which stays the last step because Modal refuses build steps after a local file.
  • Unreadable minimum. emitter_requirement() refuses a missing file, or one that does not hold {"minimum_emitter_version": "X.Y.Z"}, naming the file.
  • Container side. In the container the module is imported at /root without a checkout, so, as before for the registry's copy, the image definition there skips the install and the copy and reads no file.
  • Plan. python tools/modal_uk_cut.py --commit … --label … now names the emitter requirement in its plan, and refuses a commit whose minimum_emitter_version.json (read with git show) names a higher release than the launching checkout's. Preflight would otherwise refuse the image's emitter in the paid container, with upgrade advice that cannot apply to an image. A commit without the file (before Record how many telemetry events a Modal stage's emitter left undelivered #1522) kept an older minimum in code, so it passes. The plan tells a missing file from an unreadable commit with git ls-tree first, since git show exits 128 for both, and refuses a commit whose tree or file it cannot read.
  • Certificate authorities. Before it downloads anything, the image drops the compromised eMudhra (emSign) roots as the US image does (changelog.d/emudhra-ca-trust.fixed.md): apt_install names ca-certificates, so the CA store git and the standard library read is upgraded; a hash-pinned pip 26.2.2 replaces the base's pip 25.3 before any other download; uv rises from 0.11.7 to 0.13.4; and the image's own Python, which Modal's client runs on, gets certifi 2026.10.19 or later. UV_PYTHON_DOWNLOADS=never keeps uv on the image's Python 3.13. They also fix exposures the image already had (the uv download and the clone), and they cover the emitter's HTTPS calls, which are new here. The tests compare the uv version, the certifi floor, the pip bootstrap command and the emitter requirement and command with tools/modal_us_stage_plan.py's, so the two launchers cannot drift apart unnoticed.

The emitter trades the run's HF_TOKEN for its own collector session, as on a workstation (microcosm_emitter.core.auth), so no new secret or collector token is needed.

Minimum releases at launch and in the build. The image's install step takes its minimum from the launching checkout, and the build enforces the minimum of the commit it clones. The plan refuses a commit whose minimum is higher, so the launcher's docstring and docs/uk-cut-anyone.md say to launch from a checkout at or after the commit. The US runner has the same split (docs/orrery-publication.md, which now says which image each sentence describes).

Docs: docs/uk-cut-anyone.md (the Modal section), README.md and docs/orrery-publication.md (which Modal images read the minimum file), and changelog.d/1757-uk-modal-launcher-emitter.fixed.md.

Tests

In packages/microcosm-build/tests/engine_free/uk/test_modal_uk_cut.py, against the stand-in modal module the file already uses. First pair: red commit 634fb42b5, change e376b4e5c. Review round 1: red commit bb2823ad1, fix 9b09e7f38. Review round 2: red commit f24ebf919, fix bd1a22381.

Test Failure before the change
test_the_image_carries_the_registry_for_the_container (changed: the registry's copy now follows the install step) assertion: add_local_file called 0 times on the new chain
test_the_image_installs_the_emitter_at_the_builds_minimum_release assertion: no run_commands step
test_the_build_is_pointed_at_the_installed_emitter assertion: MICROCOSM_EMITTER_COMMAND missing from the image environment
test_an_unreadable_minimum_release_stops_the_image_definition (6 cases) DID NOT RAISE SystemExit
test_the_plan_names_the_emitter_the_image_installs assertion: the plan line names no emitter
test_the_container_defines_the_image_without_the_checkout passes before the change; it checks that the container side reads no file
test_the_image_carries_the_registry_for_the_container (changed again: the pip bootstrap step is now in the chain) at bb2823ad1: assertion, no add_local_file on the new chain
test_the_image_trusts_no_compromised_certificate_authority at bb2823ad1: assertion, pip_install where the pip bootstrap belongs
test_uv_never_downloads_a_python_in_the_image at bb2823ad1: assertion, UV_PYTHON_DOWNLOADS missing
test_the_plan_refuses_a_commit_that_needs_a_newer_emitter, test_the_plan_refuses_a_commit_whose_minimum_it_cannot_read at bb2823ad1: DID NOT RAISE SystemExit
test_the_plan_refuses_a_commit_whose_tree_it_cannot_read (new), test_the_image_trusts_no_compromised_certificate_authority (changed: the certifi floor) at f24ebf919: DID NOT RAISE SystemExit; assertion, no certifi requirement
test_the_launchers_agree_on_the_emitter, test_the_plan_accepts_a_commit_the_image_emitter_satisfies (3 cases) pass before the fix; they keep the two launchers equal and the plan permissive where it should be
test_planning_contacts_no_modal_service, test_missing_credentials_are_asked_for_one_command, test_the_plan_names_the_emitter_the_image_installs, test_the_image_installs_the_emitter_at_the_builds_minimum_release, test_the_container_defines_the_image_without_the_checkout (changed: their stand-in git now answers git ls-tree and git show, or they select the emitter's install step by its text) pass before and after

Nothing ran on Modal. The tests check the image definition, not a built image. The round 1 and round 2 tests ran only before their fixes, where they fail as listed; CI runs them on the fixes. The round 2 reviewer ran all 21 cases at 9b09e7f38 and they passed.

Known gaps, not changed

Deployment

This changes a Modal image definition. Every environment variable and secret the changed code reads or declares:

Variable Provider Wiring
MICROCOSM_EMITTER_COMMAND (new) The image definition itself, modal.Image.env in _image(); a fixed path, not a credential Image environment → cut()'s env (copied from os.environ) → run_uk_cut.py → microcosm-emitter-interface in the build and the preflight. Verified in tests on the definition only; not on a built image
UV_TOOL_BIN_DIR (new) Set inline in the image's install command Read by uv during that image build step only
UV_LINK_MODE, PYTHONDONTWRITEBYTECODE The image definition (unchanged) Image environment
HF_TOKEN The operator's shell at modal run, sent as an ephemeral secret (modal.Secret.from_dict) only with MICROCOSM_UK_CUT_MODAL_RUN=1 (unchanged) Ephemeral secret → container environment → cut()'s env → run_uk_cut.py → the emitter, its child process, which writes to the Hub with it and exchanges it for a collector session. Withheld from uv sync. The emitter's use of it on Modal is unverified (never run)
MICROCOSM_UK_TERMINAL_GATE_SIGNING_KEY The operator's shell, in the same ephemeral secret (unchanged) As HF_TOKEN; preflight removes it from the environment while the emitter starts, and the runner gives it only to the steps that sign or verify
MICROCOSM_UK_CUT_MODAL_RUN The operator's shell (unchanged) Read locally by the launcher; not sent to Modal
UV_PYTHON_DOWNLOADS (new) The image definition, modal.Image.env in _image(); never, not a credential Image environment → the container's uv sync and any later uv call; verified on the definition only

The launcher sets no collector-token variables (MICROCOSM_COLLECTOR_TOKEN, MICROCOSM_COLLECTOR_TOKEN_EXPIRES_AT, MICROCOSM_COLLECTOR_ORIGIN), no XDG_CACHE_HOME and no MICROCOSM_TELEMETRY_REQUIRED, as before.

Review

  • Round 1 (head e376b4e5c): one high-priority bug, fixed. The emitter install resolved unhashed dependencies with uv 0.11.7, the base's pip 25.3 and an old CA store, all trusting the compromised eMudhra roots, so code swapped in there would run with HF_TOKEN and the signing key. The test is bb2823ad1 and the fix 9b09e7f38, as above. Of its code-quality points, the following are also done in 9b09e7f38:

    • the docs/orrery-publication.md drift is fixed;
    • tests keep the two launchers' values equal;
    • the plan now checks the commit's minimum;
    • UV_PYTHON_DOWNLOADS=never is set.

    The parsing stays duplicated in the UK launcher rather than shared, so the container needs no copy of the US plan module; the equality tests cover it.

  • Round 2 (head 9b09e7f38): one low-priority bug, fixed. The plan took any git show failure as "no minimum file", so an unreadable commit got through; the test is f24ebf919 and the fix bd1a22381. Its code-quality points are also done in bd1a22381: the certifi floor, the build adapter's comment, and when Modal rebuilds the emitter's layer.

  • Round 3 (head bd1a22381): no bugs. It checked git ls-tree and git show against real git (a present file, a commit before Record how many telemetry events a Modal stage's emitter left undelivered #1522, a missing commit), ran all 22 cases (pass), and found the certifi floor does not conflict with Modal's own client packages. Its code-quality points are left, so as not to restart CI again for them:

    • The stand-in git checks neither argument order nor working directory. The real call depends on both: run from tools/, git ls-tree would list nothing and the plan would let the commit through. Adding --full-tree, one constant for the repository root, and a stand-in that checks the exact argv and cwd would harden it. Also, no test covers ls-tree listing the file while git show fails.
    • A refusal from plan() inside modal run doesn't mention credentials. It doesn't say the credentials already reached Modal, unlike main()'s own refusal. That isn't a defect, since the operator opted in and passed --run.
    • Two in-file wording drifts:
      • docs/uk-cut-anyone.md keeps its earlier item "The app and its image, built from the pushed commit". The image is defined by the launching checkout, and the container clones the commit at run time. That item predates this PR, but the new bullet beside it makes the difference visible.
      • The launcher's comment on the emitter's layer names only the minimum as a reason Modal rebuilds the layer.

Found, not changed

  • The separate Chronicle rebuild app (tools/modal_rebuild_uk_chronicle_artifact.py) has the same certificate exposure: uv 0.11.7 through the base's pip, no ca-certificates upgrade, with HF_TOKEN on a deliberate upload. It is outside this PR.

What the merge waits for

Nothing in the tracker. Anthony marks it ready and merges it. Text conflicts are possible with #1743 and #1538 in docs/uk-cut-anyone.md; #1743's hunks there end before the Modal section. Whichever merges second resolves them.

🤖 Generated with Claude Code

anth-volk and others added 6 commits November 26, 2026 17:00
The launcher's image installs only uv, so run_uk_cut.py's pre-flight,
which starts the separately installed microcosm-emitter to check write
access, refuses every Modal run. These tests ask the image to install
microcosm-emitter at or above the release minimum_emitter_version.json
names, as the US Modal image does, to point the build at it, to refuse a
minimum file it cannot read, and to say in the plan what it installs.
They fail on this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
run_uk_cut.py's preflight starts the separately installed
microcosm-emitter to check write access (#1460), and the workspace lock
pins only its interface (#1410), so the launcher's image, which installed
only uv, stopped every Modal run there.

As the US Modal image does, the image now installs microcosm-emitter at
or above the release minimum_emitter_version.json names in the launching
checkout, into /usr/local/bin outside the environment the container
syncs, runs its version so a command that cannot run fails the image
build, and sets MICROCOSM_EMITTER_COMMAND to it. The launcher refuses a
minimum file it cannot read, and its plan names the requirement. The
container defines the image without reading the checkout, as before.

Closes #1757.

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

Review round 1 of #1758 found that the new emitter install step, which
resolves the emitter's dependencies without hashes, runs with uv 0.11.7
and the cached base's pip 25.3 and CA store, all of which trust the
compromised eMudhra (emSign) roots; the US Modal image left them for that
reason. These tests ask the UK image for the US image's measures in the
same order (ca-certificates upgrade, the hash-pinned pip bootstrap, uv at
the US image's version), for UV_PYTHON_DOWNLOADS=never, and for the plan
to refuse a commit whose minimum emitter release is above the launching
checkout's or cannot be read. Two more check that the two launchers agree
on the emitter requirement and command. The image-chain, ordering,
download, and both refusal tests fail on this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 of #1758: the new emitter install resolves the emitter's
dependencies without hashes, and the image downloaded with uv 0.11.7,
the base's pip 25.3 and the base's CA store, which all trust the
compromised eMudhra (emSign) roots; code swapped in there would run with
HF_TOKEN and the signing key. As in the US Modal image, the image now
upgrades ca-certificates, replaces pip with the hash-pinned 26.2.2 before
any other download, installs uv 0.13.4, and sets UV_PYTHON_DOWNLOADS=never.

The plan also reads the cloned commit's minimum_emitter_version.json with
git show and refuses a commit whose minimum is above the launching
checkout's, which preflight would otherwise refuse in the paid container
with upgrade advice that cannot apply to an image. docs/orrery-publication.md
now says which of the two Modal images each sentence describes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 of #1758: git show exits 128 alike for a path the commit
lacks and for a commit git cannot read, and the plan took either as "no
minimum file", so it could let through a commit it should refuse. The
stand-in git now answers ls-tree too, and a new test expects the plan to
refuse an unreadable commit. The certificate-authority test also asks for
the US image's certifi floor on the image's own Python. Both fail on this
commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 of #1758: git show exits 128 alike for a path the commit
lacks and for a commit git cannot read, so the plan took an unreadable
commit as one without a minimum file and let it through. It now asks
git ls-tree first, which lists nothing for a missing path, and refuses
when either command fails.

The image's pip install also asks for certifi 2026.10.19 or later, as
the US image does, so the image's own Python, which Modal's client runs
on, drops the eMudhra roots too and the docs' "as the US image does"
holds. The build adapter's comment and docs/orrery-publication.md now
name both launchers and say when Modal rebuilds the emitter's layer.

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

@juaristi22 juaristi22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at bd1a22381: the image's emitter install and version check work as written (replayed with uv 0.13.4 on Python 3.13, which installs 0.18.0), the pinned pip wheel's sha256 matches PyPI's, the plan's commit check reads the right file with real git even when launched from tools/, and the 30 tests pass here, so I have nothing to raise.

@anth-volk
anth-volk merged commit 163fd43 into main Nov 27, 2026
12 checks passed
@anth-volk
anth-volk deleted the claude/uk-modal-launcher-emitter branch November 27, 2026 18:15
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.

The UK Modal launcher's image installs no microcosm-emitter, so its runs stop at preflight

2 participants