Repository navigation
feat(env): set up the infra envs from their published images, building only what isn't published - #277
Merged
Conversation
…g only what isn't published A run on local stores now registers a kind's infra images from the ones the release workflow published for the sources installed, when GHCR has every one of them, instead of building them on this host. The digest is the one the release wheel records or, with no record, the one GHCR serves under the content tag, pinned when the image is registered. A stock env built here from unchanged sources switches to the published images once they exist; an env built from someone's own Dockerfile, or in stores that aren't local, is never touched. Registering needs no Docker here. DockerImageArtifact gains an optional digest: the image is named by its content tag, which its containers start from, and pulled by the digest, then tagged. A VM that can't pull it, after waiting out a rate limit twice, builds it from the build context the artifact keeps, under the same tag, so compose and docker run find it either way. The local provider skips the pull when its Docker already holds the tag, so later runs need no registry; Modal containers pull by the digest. The dry run says which envs it would build, pull, or switch. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Acceptance on admin VMs. Each run is the timing bundle's env task: the items MCP server through the gateway, with local Postgres. The baselines are the 2026-10-20 timing pass on v0.9.1336.
Notes
|
Collaborator
Author
|
@greptileai review |
…d drop a stale Modal pin A switch, a pull or a rebuild of an infra env in the store wrote its new version with only the metadata the put records afresh, dropping what was given with --metadata. The new version now keeps the env's own keys and records the generated ones (who built it, with which agent-env, from which Dockerfile, the git state, the build inputs) anew. Modal kept the digest it was told for an image name after the same name was prepared again without one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ge_digest The artifact already has source_digest, the digest of the sources an image is built from; a bare digest beside it didn't say which one it was. image_digest is the registry's digest of the built image, as Docker and the registries call it. The field hasn't been released, so no stored document has it under the old name. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…build context and digest A published image is an image already in a registry, which put_ref registers, so it takes the two things that make one different instead of a constructor of its own: the build context, uploaded for a sandbox that can't pull the image to build it from, and the digest the tag is published under. Given them, the tag is recorded as image_name and the digest beside it, as given; without them, a ref is registered as before. The published path now also gets put_ref's checks that a ref names its registry and isn't on this machine's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@greptileai review |
…t of facts in one place - InfraBuild and infra_to_build are InfraSetup and infra_to_set_up: they pull and switch too. - How a run sets an env up is a Setup enum carrying what the run and a dry run say, in place of three strings and a reason constant; the digests it pulls and the metadata it keeps are plain mappings. - ServiceDBEnv.images lists its three images, which bootstrap and the local Postgres store read instead of each listing them; the keys detected() names are one tuple, and a test fails if detect_env_metadata records one it doesn't name. - The docstrings of put_ref, infra_to_set_up, ensure_default_envs and load_docker_images are down to their point. Co-Authored-By: Claude Opus 5.5 (1M context) <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.
Installs now pull the infra images the release workflow publishes on GHCR instead of building them on this host. Remote VMs pull them too, rather than taking a push of the host's tarballs, or rebuilding all four when the host is arm64.
Bootstrap (
env/bootstrap.py). These rules apply on local stores only.published_images.json). An install with no record (editable, git, CodeArtifact) uses the one GHCR serves under the source tag; it's pinned when the image is registered.would build,would pull its published image(s), orwould switch to ….Images (
DockerImageArtifact)image_digest: the registry's digest of the built image, besidesource_digest, the digest of its sources. It's written as null otherwise, asplatformandsource_digestwere when they were added.ghcr.io/scaleapi/agentenv-<name>:src-<hex>. Compose anddocker runstart containers from that tag, so nothing that starts containers changed.put_ref, given the build context and the digest the tag is published under, registers the tag asimage_namewith the digest beside it, and uploads the context. Without them, it registers a ref as before.pinned_nameistag@image_digest.Loading (
VmSandbox.load_docker_images)tag@digest, then tagged with its tag.docker pulldoesn't showRetry-After, so the waits are fixed.VmSandbox, since they override only how a tar.gz reaches the VM. A gateway stack runs in containers only on Modal, the one provider with a private network. One path isn't pinned: an infra env deployed on its own as a server (env_server_provider) on a provider other than Modal is pulled by its tag, without the digest and with no fallback build. Published tags are never moved, and infra envs aren't deployed that way in practice. Pinning it would mean checking each provider's by-name start (some turn a name into a template), so it's left for now.No defensive code was added for an image with a digest but no build context; nothing writes one.
Tests
test_an_armed_time_trigger_keeps_firing_after_a_client_leavesfails intermittently under-n autoand passes alone; it's timing-based and untouched here.Acceptance on admin VMs (amd64 and Graviton: the timing harness, a burst, and the fallbacks) is in the comment below. A modal_vm env deploy took 46–48 s from Linux (baseline 64–76 s) and 46–62 s from arm64 (a Mac's took 108–131 s). 20 concurrent deploys all passed with no 429s.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new blocking issue was found.Summary
Infra environments use published images when every image for their installed sources is available. Otherwise, they build locally.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Check required infra environment] --> B{Needs setup?} B -->|No| C[Keep current version] B -->|Yes| D{All images published?} D -->|No| E[Build locally] D -->|Yes| F[Register tags, digests, and build contexts] F --> G[VM pulls by digest] G -->|Pull succeeds| H[Tag image for containers] G -->|Pull fails| I[Build from stored context]Reviews (5) · Last reviewed commit: "refactor(env): name the infra setup for ..." · Reviewed by Greptile