Repository navigation
docs: say that fctl hosts rely on the revision label - #3
Merged
Merged
Conversation
fctl hosts now pull their tag again every 6 hours, so new sessions start from the newest build, and remove other versions' images and latest. They do both only for images with org.opencontainers.image.revision, which only the Image workflow sets: an image without it was built on the host. AGENTS.md lists the label among what fctl relies on, and README.md says that images built elsewhere have none.
kalaspuff
deleted the
fctl/43-can-you-look-into-https-github-com-hyper
branch
October 18, 2026 18:44
kalaspuff
pushed a commit
to hyperstructure/fctl
that referenced
this pull request
Oct 18, 2026
Hosts on the default sandbox image pulled their tag once and kept it. hyperstructure/sandbox's Image workflow rebuilds the newest release's image when Claude Code has a newer release, since fctl turns off Claude Code's auto-updater. But a host that already had the tag kept its first pull until it was upgraded or someone ran `fctl host image pull`, so its sessions' Claude Code aged between upgrades anyway. And every upgrade left the previous version's image on the host, as did the `latest` a host pulls while its release's image isn't published yet. Nothing removed them. The two decisions #47 left to a person were made in this session, and are recorded in [the issue](#47 (comment)). The host tells a local build from the published image by the `org.opencontainers.image.revision` label, which only the Image workflow sets. It pulls again at start and every 6 hours. ## What changed **Refreshing** (`crates/fctl-host/src/refresh.rs`, `daemon.rs`). The host's background pull used to run once, at start, and only for a missing image. Now it runs at start and every 6 hours: - An image that isn't here is pulled as before, falling back to `latest` while the version's image can't be pulled. - On the default image, the host pulls its tag again, so new sessions start from the newest build. Sessions never wait for it: they start from the build that is there. When the tag hasn't changed, the pull costs one manifest request. - It never pulls over an image without the revision label. That covers builds from `fctl host image build` or by hand: the sandbox's `Dockerfile` sets no labels, and its base, `debian:bookworm-slim`, has none. An image whose description can't be read counts as a local build, so the host leaves it alone, as it did before. - A host whose `host.toml` sets another image pulls it only when it isn't there, as before. **Removing** (`refresh::clean_up`). At start, after each pull and after sweeps that remove sandboxes, the host removes these, without force: - builds that a newer one replaced; - other versions' images (`X.Y.Z` tags); - `latest`, once the version's image is here. Until then, sessions start from it. Images without the revision label stay, and so do tags hosts don't pull, like `0.5`, which projects may use. A host on another image removes nothing. **How a replaced build stays findable.** A pull that moves a tag leaves the old build without a name. Docker keeps it as `<none>`, and with the containerd image store nothing finds that again by name. Apple's `container` keeps its blobs and snapshot orphaned until an `image delete` runs its cleanup. So before a pull (or `fctl host image build`) replaces a published build, the host gives that build a second name, `<tag>-replaced-<the start of its ID>`, and removes the name right after: - If the build is unchanged, removing the name only untags it. - If it was replaced and nothing uses it, the build goes. - With Docker, if it was replaced and a sandbox still uses it, Docker refuses. The name stays until a cleanup after the sweep removes that sandbox (`keep_stopped_hours`). This needs no state file, and a host that stops halfway leaves a name the cleanup finds. A name whose build is still the one sessions start from is left alone, so a cleanup that runs during a pull can't strand the build. **Apple.** `container image delete` doesn't check whether a container uses the image. It's still safe: each container gets a clone of the image's filesystem when it is created (`Bundle.cloneContainerRootFs` in apple/container), and starting it again uses only that clone. So on Apple the host removes these right away, and stopped sandboxes still start. **Driver** (`driver/container.rs`, `driver/mod.rs`): - `image`: ID and labels from `image inspect`, in Docker's, Podman's and both of Apple's shapes (its JSON changed at 1.0). - `tag_image`. - `remove_image`: `image rm` or `image delete`, never forced. - `images`: `image ls --format …` or `image list --quiet`. **CLI** (`crates/fctl/src/cmd/host.rs`): - `fctl host image pull` also removes what sessions no longer start from, and says what it did: ``` ✓ Pulled ghcr.io/hyperstructure/sandbox:0.5.0, a newer build (Claude Code 2.1.310) Removed ghcr.io/hyperstructure/sandbox:0.4.0 The build it replaced stays until no sandbox uses it; the host removes it then. ``` `--json` adds `newer` (whether the pull brought a newer build) and `removed` (the names it removed) to `image` and `instead_of`. - `fctl host doctor` shows the image's Claude Code version, or that the host doesn't pull over a local build: ``` ✓ sandbox image ghcr.io/hyperstructure/sandbox:0.5.0 (Claude Code 2.1.310) ✓ sandbox image ghcr.io/hyperstructure/sandbox:0.5.0 (built here: the host doesn't pull over it) ``` **Docs:** - `docs/sandbox-images.md` says when the host pulls again, how it tells a local build, and what it removes and when, with Docker and with Apple. - `docs/architecture.md` and `docs/cli.md` say the same briefly. - AGENTS.md lists the revision label among what the host relies on in hyperstructure/sandbox. hyperstructure/sandbox#3 does the same there. **Tests.** The driver tests' stand-in for the `docker` and `container` CLIs moved to `driver/fake.rs`, shared by the driver tests, these tests and #88's build tests. It gained image IDs, labels, tags, listing, and Docker's refusal to remove an image's last name while a container uses it. It keeps #88's builds, image sizes and failing builds. **With #88.** `main` gained #88 (projects' own images and builds) while this was open, and is merged in. Both added the same `remove_image` to the driver, so one stays. Project images and builds aren't the default image, so the host doesn't pull them again here or remove them in this cleanup: #88 keeps each project's newest build itself. ## Compatibility This changes only the host: no protocol or control-plane change, and it reaches hosts with the next release. `fctl host image pull --json` gains two fields. - At its first start after the upgrade, a host removes the previous version's image, unless a stopped sandbox uses it (Docker). - Builds that earlier pulls left as `<none>` stay: nothing tells them from other unnamed images. - Two hosts sharing one Docker daemon on different versions would each remove the other's image when no sandbox uses it, and pull it again later. That costs extra downloads; nothing breaks. ## Verification - **Unit tests:** 14 new; fctl-host has 57 with #88's. - `removable`: what goes and what stays, including `latest` before and after the version's image arrives, local builds, `X.Y` tags, and a replaced name whose build is still current. - Version tags, replaced names, and inspect output from Docker, Podman, Apple 0.x and Apple 1.x. - Flows against the stand-in: - a newer build replaces one a stopped sandbox uses, which goes once the sandbox is gone; - an unchanged build is only tagged and untagged; - the host never pulls over a local build, and `fctl host image pull` does; - a build over the published image (and a failed one); - `latest` going once the version's image is published; - other versions going after an upgrade, unless in use; - Apple removing a replaced build that a sandbox was made from; - a host on another image doing nothing. - **The published image** (read from ghcr.io anonymously): the config of `ghcr.io/hyperstructure/sandbox:0.5.0` has `org.opencontainers.image.revision` (`12685ad…`) and `sh.fctl.claude-code.version` (`2.1.302`). `debian:bookworm-slim`, the base of local builds, has no labels. - **With real Podman** (rootless, `FCTL_DOCKER_BIN=podman`): I imported images of a few KB under the default image's names. The host's `0.5.0` was a local build, and a stopped `fctl-ses-…` container used `0.3.0`. `fctl host run`: - logged that it doesn't pull over the local build; - removed `0.4.0` (only untagged, since `0.4` names the same build), `latest`, and a `0.5.0-replaced-…` build; - kept `0.3.0` because Podman refused ("image is in use by a container"), and kept the local `0.2.0` and the `0.4` tag. `fctl host doctor` said "built here: the host doesn't pull over it". - **With the stand-in CLI** (`FCTL_DOCKER_BIN`), the real binary: - `fctl host image pull` printed the output above. - Once the sandbox was gone, `fctl host image pull --json` printed `{"image": "ghcr.io/hyperstructure/sandbox:0.5.0", "instead_of": null, "newer": false, "removed": ["ghcr.io/hyperstructure/sandbox:0.5.0-replaced-0a1d00000000"]}`. - `fctl host run` logged `pulled a newer build of ghcr.io/hyperstructure/sandbox:0.5.0 (Claude Code 2.1.310)`, kept the replaced build while a sandbox used it, and removed `0.4.0`. - `doctor` showed the Claude Code version. - `cargo xtask check --quick` passes, before and after merging `main`. I reran the Podman check on the merged binary, with the same result. - **Not run here:** Docker itself (this sandbox can't run a Docker daemon) and Apple's `container` (that needs a Mac). The commands are the documented ones. I read the behaviors this relies on in their sources: - Docker refuses, without force, to remove an image's last name while a container uses it, in both image stores, and moby's containerd store counts its `moby-dangling@…` records as that same name (`daemon/images/image_delete.go`, `daemon/containerd/image_delete.go`). - In apple/container, a container keeps its own clone of the image's filesystem, a pull leaves the old build orphaned until `image delete` cleans up, and `image tag` overwrites an existing name. Trying the first release on a Docker host and on a Mac is the check that's left. Fixes #47 Session: https://app.fctl.sh/s/ses_01M5813Y3P1VY7K0ZSS6PKRS9V --------- Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
2 tasks done
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.
fctl hosts now pull their own version's tag again every 6 hours, so new sessions start from the newest build, with the newest Claude Code. They also remove the images sessions no longer start from: other versions' images, builds that a newer one replaced, and
latestonce their own version's image is there (hyperstructure/fctl#89, for hyperstructure/fctl#47).A host tells a published image from one built on the host by
org.opencontainers.image.revision, which only the Image workflow sets (docker buildx build --label …). TheDockerfilesets no labels, and its base,debian:bookworm-slim, has none. A host never pulls over or removes an image without the label. So the label, and theDockerfilenot setting it, are now part of what fctl relies on:This is documentation only: the Image workflow doesn't run, and the image doesn't change.
Refs hyperstructure/fctl#47
Session: https://app.fctl.sh/s/ses_01M5813Y3P1VY7K0ZSS6PKRS9V