Repository navigation
Closed
Labels
Description
What is wrong or missing. With #39, a host on the default image pulls ghcr.io/hyperstructure/fctl-agent:<its version> once and keeps it:
- The Image workflow rebuilds the latest release's image when Claude Code has a newer release, so that sessions don't run an old Claude Code (fctl turns off its auto-updater, Prebuilt sandbox images #2). A host that already has the tag keeps its first pull until fctl is upgraded or someone runs
fctl host image pull, so between upgrades its sessions' Claude Code ages anyway. - Each upgrade leaves the previous version's image on the host, and nothing removes it.
fctl host image buildalready left behind the image it replaced, untagged, but now every upgrade does it.
How it works now.
- The daemon pulls the host's image at start only when it is missing (
prefetch_imageincrates/fctl-host/src/daemon.rs), and a session pulls a missing image (ContainerDriver::createincrates/fctl-host/src/driver/container.rs). Nothing pulls over an image that is there, becausefctl host image buildtags its local build with the same name and a pull would replace it. docker image ls ghcr.io/hyperstructure/fctl-agenton a host lists one image per version it has run, anddocker image rm(Apple:container image delete) is the only way to remove them.
What should happen
- A host on the default image pulls its tag again from time to time, and its new sessions start from the newer build. A local build is never replaced. (feat(host): refresh the default sandbox image and remove old ones #89)
- When a pull replaces the host's image, or after an upgrade, the host removes the default images it pulled before that no sandbox uses. It removes them without force, so stopped sessions' sandboxes keep theirs until they are removed (
keep_stopped_hours). (feat(host): refresh the default sandbox image and remove old ones #89)
Compatibility. Host only: no protocol or control-plane change, and it reaches hosts with a release.
Decisions for a person.
- How the host tells a local build from a pulled image: a note that
fctl host image buildwrites in the host's data directory, or the image'sorg.opencontainers.image.revisionlabel, which only the Image workflow sets. - How often to pull: at start and once a day, or before each new session (
docker pullof an unchanged tag only fetches its manifest, but needs the registry to answer).
Split from #2.
Activity
feat(host): pull the sandbox image from GHCR instead of building it (#39
fix(host): fall back to latest when the sandbox image isn't published (…
fctl-sh commentedon Oct 18, 2026
#62 (released in v0.5.0) doesn't refresh or remove images, so this stays open. It adds one more image that stays behind: a host whose version's image isn't published yet pulls
ghcr.io/hyperstructure/sandbox:latestinstead, and keeps it after the next session pulls the version's image. The removal in the second item should cover thatlatesttoo, but only once the version's image is on the host: until then, sessions start fromlatest.The default image is also named differently since this was written:
ghcr.io/hyperstructure/sandbox:<version>, notghcr.io/hyperstructure/fctl-agent(#39, ADR 0012).Session: https://app.fctl.sh/s/ses_01M57GZ9DXXAGA0CF8QW9DS5XZ
fctl-sh commentedon Oct 18, 2026
The person who started https://app.fctl.sh/s/ses_01M5813Y3P1VY7K0ZSS6PKRS9V decided the open questions:
org.opencontainers.image.revisionlabel. Only hyperstructure/sandbox's Image workflow sets it (docker buildx build --label …); the Dockerfile sets no labels, sofctl host image buildand builds by hand have none. It needs no state, covers builds made by hand or by older versions of fctl, and when it can't be read (Apple'simage inspectJSON has changed shape between releases) the host leaves the image alone, as it does now. An image builtFROMthe published one inherits the label, so a derived build tagged with the default image's own name would be replaced.container.What I found while looking into the second item, which shapes how removal works:
<none>; with the containerd image store nothing finds it again by name. So the host keeps the IDs of the builds it replaced in its data directory, and tries them again after the sweeps that remove sandboxes.container image deletedoesn't check whether a container uses an image, but each container gets a clone of the image's filesystem when it is created (Bundle.cloneContainerRootFsin apple/container), and starting it again uses only that clone. So a stopped sandbox still starts after its image is removed. A pull that moves a tag leaves the old build's blobs and snapshot orphaned until animage deleterunscleanUpOrphanedBlobs.I'm implementing both items on that basis.
docs: say that fctl hosts rely on the revision label (#3)
feat(host): refresh the default sandbox image and remove old ones (#89)
fctl-sh commentedon Oct 18, 2026
#89 is merged (12e285e) and ships with the next release: it changes only the host, and no release contains it yet. hyperstructure/sandbox#3, which lists the revision label among what fctl relies on, is merged too.
Once hosts run that release:
org.opencontainers.image.revision(a local build).fctl host doctorshows the image's Claude Code version, or says the host doesn't pull over a local build.<tag>-replaced-<the start of their ID>while a Docker sandbox uses them), other versions' images, andlatestonce the version's image is there. It does this at start, after each pull and after sweeps that remove sandboxes.fctl host image pulldoes the same and says what it removed.Verified with unit tests, with rootless Podman running the real
fctl host run, and with the stand-in CLI (details in #89). Still to try on real hosts after the release: Docker, where a stopped sandbox should keep its image until the sweep removes the sandbox, and a Mac with Apple'scontainer, where old images go right away and stopped sandboxes still start.Session: https://app.fctl.sh/s/ses_01M5813Y3P1VY7K0ZSS6PKRS9V