Skip to content

Commit f239721

Browse files
fctl-sh[bot]claude
andauthored
feat(host): pull the sandbox image from GHCR instead of building it (#39)
Every host built the default sandbox image itself with `fctl host image build`, and its Claude Code stayed as old as that build, since fctl turns off Claude Code's auto-updater. #2 asks for CI to publish the image instead, for arm64 and amd64, under a stable name with version tags and labels, rebuilt when Claude Code moves on, with a documented layout that custom images (#16) can build `FROM`; hosts on the default image pull the tag of their own version. The image now lives in a public repository of its own, [hyperstructure/sandbox](https://github.com/hyperstructure/sandbox) (set up in hyperstructure/sandbox#1), which publishes it as `ghcr.io/hyperstructure/sandbox`. This pull request makes hosts pull it and takes the image out of this repository. ## What changed **The image moves to hyperstructure/sandbox.** `images/agent` (the Dockerfile, `provision.sh`, `check.sh`) and the Image workflow leave this repository; hyperstructure/sandbox#1 adds them there, with a README, AGENTS.md, skills, lint and title checks. Its Image workflow keeps what this pull request had built: each architecture builds on a native runner and is checked with `check.sh`, then both are tagged as one image. - `ghcr.io/hyperstructure/sandbox:<version>` for every fctl release, plus `:<major>.<minor>` and `:latest` when that release is the newest they cover. Each is the sandbox's `main` with that release of fctl and the newest Claude Code. - It looks for new fctl releases on fctl.sh every hour, rebuilds the newest release's image as soon as a change to the image merges there, and every day when Claude Code has a newer release or the image is a week old. Only its `main` publishes; its pull requests build and check both architectures. - Labels and index annotations as before: `sh.fctl.version`, `sh.fctl.claude-code.version`, and the commit and date it was built from, which the workflow reads back to decide whether an image is current. The Release workflow no longer starts an image build: its token can't start workflows in another repository, so the sandbox's hourly run notices the release. Why a separate repository: [ADR 0012](docs/adr/0012-the-sandbox-image-lives-in-its-own-public-repository.md) (the image has to be public, and it has a cadence of its own). It's 0012 because #55 adds 0011. **Hosts: `crates/fctl-host`, `crates/fctl`** - `image` in `host.toml` is optional. Unset, sessions start from `ghcr.io/hyperstructure/sandbox:<the host's version>`, so upgrading a host moves its new sessions to the new version's image. `fctl-agent:latest`, which every host installed so far has in its `host.toml`, also means the default, in `host.toml` and in project settings. - The daemon pulls the host's image in the background when it starts and the image is missing. A session pulls a missing image itself. Nothing pulls over an image that is already there, so a local build is kept. - When the version's image can't be pulled (the hour between a release and its image, or a development build), a session on the default image starts from `:latest` and says so in its log. A failure that isn't about the image (the image is there but `run` fails) no longer tries a pull. - Apple's `container image pull` gets `--platform linux/<the host's architecture>`. Without it, Apple's CLI downloads every platform of a multi-arch image (`DefaultPlatform.resolve` in apple/container). - `fctl host image build` downloads an archive of the sandbox's `main` from GitHub and builds its Dockerfile with the host's driver, under the host's image name so sessions use the build, or gives the Lima VM its `provision.sh`. `--source DIR` builds from a checkout instead, to try changes to the image with fctl. The binary no longer carries the files. - CLI: `fctl host image pull` (new, `--json`) pulls the host's image again, for a newer build of its tag. `install` says which image sessions start from, `status` (and `--json`) shows it, `doctor` says whether it's there, and `install --image ""` goes back to the default. - A sandbox without fctl now says in its log that the default image has one, instead of suggesting `fctl host image build`. **Docs:** `docs/sandbox-images.md` (new) covers the image, its tags and labels, how hosts get it, and its layout as an interface for images built `FROM` it: the `agent` user (uid 1000, passwordless sudo), `~/.local/bin`, `~/.cargo/bin`, `~/.bun/bin` and `/opt/fctl/bin` first on the PATH, and the tools. It's the "Sandbox images" page #16 asks for, which #16 can extend; the image's README in hyperstructure/sandbox lists the versions. Getting started, the CLI, self-hosting, security, architecture, development and the top-level README say that hosts pull the image instead of building it. AGENTS.md lists hyperstructure/sandbox among the other repositories (what the host relies on there, and that its Rust follows `rust-toolchain.toml`), and the release and issues skills point to it. The roadmap item is ticked. **Web:** the runner dialog drops step 3 ("Build the sandbox image"), and the project's image field shows `ghcr.io/hyperstructure/sandbox` as its placeholder instead of `fctl-agent:latest`. ## For a person 0.3.0 shipped without this pull request, so the next release (0.4.0) is the first whose hosts pull the image. 1. **Merge hyperstructure/sandbox#1.** Its Image workflow then publishes `ghcr.io/hyperstructure/sandbox:0.3.0`, `:0.3` and `:latest` from the sandbox's `main`, which creates the package. 2. **Make hyperstructure/sandbox public** and apply its settings: the commands are in hyperstructure/sandbox#1. 3. **Make the package public**: the organization's Packages → sandbox → Package settings → Change visibility. A package starts private even when its repository is public, and hosts pull without signing in. The organization's settings must allow public packages. Until then, sessions on hosts of 0.4.0 fail with "ghcr.io/hyperstructure/sandbox:0.4.0 is not on this host and can't be pulled (`fctl host image build` builds it here)". 4. **Merge this pull request**, then hyperstructure/fctl-site#7 once fctl's CI has pinned fctl.sh past it (`gh pr update-branch 7 -R hyperstructure/fctl-site`). ## Compatibility - No protocol or control-plane change. `HostHello.image`, already optional, now carries the image the host actually uses. Hosts pick up the new behavior with the release that includes it; hosts of 0.3.0 and earlier keep building `fctl-agent:latest` from the files in their binary. - `image = "fctl-agent:latest"` in `host.toml` now means the published image. A host that ran a modified image under that name should rename it and set `image`, or rebuild it with `fctl host image build`, which tags it with the default name. - `fctl host image build` needs to reach github.com, as its build already needed Debian's mirrors and the tools' installers. - Hosts keep the images of earlier versions until someone removes them (`docker image rm …`), as they kept the images `fctl host image build` replaced. Removing them automatically, and refreshing a tag when its image is rebuilt, is #47. ## Verification - **The sandbox's Image workflow** ran on hyperstructure/sandbox#1: both architectures built natively (amd64 in 2m56s, arm64 in 2m20s) and `check.sh` passed in each with fctl 0.3.0 and Claude Code 2.1.302 ([run](https://github.com/hyperstructure/sandbox/actions/runs/39123588178)). Its lint (ShellCheck, actionlint) and title checks pass too. - **Its planning step**, run locally against stubbed fctl.sh, downloads.claude.ai and registry responses, decides correctly in 19 cases: a pull request; hourly with no image (build), a current image with an older Claude Code (skip: hourly runs ignore Claude Code), an image built from the last change to the image (skip) and one from before it (build), an index without annotations (build); daily with an older Claude Code or a week-old image (build) and a current one (skip); a push after a change (build); dispatches of 0.2.0 (no `:0.2`: 0.2.1 exists), v0.2.1 (`:0.2`), a current image with an older Claude Code (build), a forced rebuild, another branch (build without publishing), a version fctl.sh doesn't have and a malformed one (errors); and odd answers from fctl.sh and downloads.claude.ai (errors). - **`fctl host image build`** with a stand-in `docker`: `--source` with a checkout builds it with `FCTL_VERSION=0.3.0` and `FCTL_DOWNLOAD=https://fctl.sh/releases`. The download path, pointed at a `git archive` of the sandbox served locally (GitHub's format, with its pax header), unpacks it, builds `…/sandbox-main` and removes the temporary directory; pointed at a real GitHub archive of a public repository, it follows the redirect, unpacks it and says the result has no `provision.sh`; against the real URL while the repository is still private, it fails with HTTP 404. Unit tests cover unpacking a GitHub-style archive and refusing a checkout without `provision.sh`. - **End to end with the stand-in:** an old `host.toml` with `fctl-agent:latest` resolves to `ghcr.io/hyperstructure/sandbox:0.3.0` in `status` and `status --json`; `doctor` reports it "not here yet", then ✓ after `fctl host image pull --json`. - **Unit tests:** the config tests cover unset, empty and old-default images, a custom image and saving. The driver tests use a stand-in `docker`/`container` CLI with an image store and a registry: an image already there, a pull, Apple's `--platform`, falling back to `:latest`, both images missing (with and without a fallback), and a `run` failure that isn't about the image. - `cargo xtask check --quick` passes locally on the move and on the merges with `main` (#48, #50, #52, then #54, #57, #58), and CI's full `cargo xtask check` passes. The merge with #57 keeps its startup retry loop and starts the background pull once the runtime answers; a `run` that times out under #57's limits now fails at once instead of being taken for a missing image and trying a pull. - hyperstructure/fctl-site#7, with its `main` merged, builds against this branch's docs: 8 pages, Sandbox images among them, linking to hyperstructure/sandbox. - Earlier on this pull request, before the move: the publish step's commands against a local registry (one OCI index for both architectures that all three tags point to, with the annotations) and `fctl host install --driver docker` with a stand-in, which writes no `image` and says which image sessions start from. - **Not verified here:** pushing to GHCR with the sandbox workflow's token, creating the package and its visibility. They need `packages: write` on the sandbox's `main`, so merging hyperstructure/sandbox#1 is their test, well before a release depends on them. ## Screenshots Sessions can't attach screenshots yet (#40), so here is what they show. Taken at 7771600 with Playwright against `cargo xtask dev` (before: `main` from a worktree), in both themes and at 390 px: - **Runner dialog, "Bring studio mac online":** before, three numbered steps: 1. Install fctl, 2. Register it as a runner and start the service, 3. Build the sandbox image (once, a few minutes) with `fctl host image build`. After, steps 1 and 2 only, and the note under them reads "It shows up here as online within seconds and pulls the sandbox image in the background. With Lima, prepare the base VM once with `fctl host image build`. `fctl host doctor` checks everything, including whether the Mac is set to never sleep." Both themes and the phone width wrap cleanly. - **Project → Settings → Sandbox:** the Image field's placeholder reads `ghcr.io/hyperstructure/sandbox` (at 7771600 it read `ghcr.io/hyperstructure/fctl-agent`; `main` has `fctl-agent:latest`). Nothing else in the section changes. The move changed only this placeholder's text, which wasn't screenshotted again. Refs #2 Sessions: https://app.fctl.sh/s/ses_01M56C4589JCHJ2W8TXC8V2S4P, https://app.fctl.sh/s/ses_01M56FZDD6WY8J56E3TA0SEMZX for merging #45 and v0.3.0, and https://app.fctl.sh/s/ses_01M57B991V0YYBRJFN0WKEW118 for moving the image to hyperstructure/sandbox --------- Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 9587c2b commit f239721

34 files changed

Lines changed: 922 additions & 341 deletions

‎.claude/skills/issues/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ links in someone else's text.
123123

124124
## Other repositories
125125

126-
hyperstructure has three repositories: fctl (this one), fctl-site (fctl.sh)
127-
and design (`@hyperstructure/design`). An fctl session's GitHub token covers
126+
hyperstructure has four repositories: fctl (this one), fctl-site (fctl.sh),
127+
design (`@hyperstructure/design`) and sandbox (the default sandbox image,
128+
public). An fctl session's GitHub token covers
128129
only its own repository. When a change needs work in another one, name it
129130
in your pull request or issue ("fctl-site needs the new docs page in
130131
`PAGES`") and tell the person. Only open the change there yourself when you

‎.claude/skills/release/SKILL.md‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: release
3-
description: Release a new version of fctl through the Release workflow, which publishes the archives to GitHub and fctl.sh/releases, updates the CHANGELOG and redeploys app.fctl.sh. Only for people and agents with release access (write access to Actions on hyperstructure/fctl). Use when asked to release, publish or ship fctl, to preview what the next release contains, or to fix a failed release.
3+
description: Release a new version of fctl through the Release workflow, which publishes the archives to GitHub and fctl.sh/releases, updates the CHANGELOG and redeploys app.fctl.sh; hyperstructure/sandbox then publishes the release's sandbox image to GHCR. Only for people and agents with release access (write access to Actions on hyperstructure/fctl). Use when asked to release, publish or ship fctl, to preview what the next release contains, or to fix a failed release.
44
---
55

66
# Releasing fctl
@@ -59,6 +59,14 @@ It runs in three steps:
5959
the installer as a check, and starts CI on `main`, which redeploys
6060
app.fctl.sh.
6161

62+
Within the hour, the Image workflow of
63+
[hyperstructure/sandbox](https://github.com/hyperstructure/sandbox) finds
64+
the release on fctl.sh and publishes its sandbox image,
65+
`ghcr.io/hyperstructure/sandbox:X.Y.Z`, for arm64 and amd64, moving `X.Y`
66+
and `latest`. Hosts of the new version pull it; until it is there, their
67+
sessions start from `latest`. To publish it at once:
68+
`gh workflow run image.yml -R hyperstructure/sandbox`.
69+
6270
Follow it with `gh run watch` or in the Actions tab; it takes about 10
6371
minutes.
6472

@@ -68,6 +76,10 @@ minutes.
6876
`fctl self update --check` sees it.
6977
- The GitHub release and `CHANGELOG.md` on `main` have the notes.
7078
- `https://app.fctl.sh/api/v1/health` reports the version once CI is done.
79+
- Within the hour, `docker buildx imagetools inspect
80+
ghcr.io/hyperstructure/sandbox:X.Y.Z` lists linux/amd64 and linux/arm64
81+
(`gh run list -R hyperstructure/sandbox --workflow image.yml` shows the
82+
runs).
7183
- Hosts update with `fctl self update` (it restarts the host service;
7284
running sessions keep going).
7385

@@ -82,6 +94,12 @@ minutes.
8294
tag from the start with
8395
`gh workflow run release.yml --ref main -f tag=vX.Y.Z`. If the code is
8496
broken, fix it and release a patch.
97+
- **The image** (hyperstructure/sandbox's Image workflow failed, or the
98+
release has no image after an hour): its `publish` skill says what to do.
99+
Start it for the release with
100+
`gh workflow run image.yml -R hyperstructure/sandbox -f version=X.Y.Z`.
101+
The image is built from that repository's `main`, so fixing it takes a
102+
pull request there, not an fctl release.
85103
- Never move or delete a published tag or its files on fctl.sh: installed
86104
CLIs and hosts download releases by version.
87105

@@ -90,3 +108,5 @@ minutes.
90108
- **hyperstructure/design** releases are tags as well; see its AGENTS.md
91109
and release skill.
92110
- **hyperstructure/fctl-site** deploys from `main` and has no releases.
111+
- **hyperstructure/sandbox** publishes the sandbox image from `main`, for
112+
every fctl release; see its AGENTS.md and publish skill.

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
# then cross-compile the release binaries, all at once (`cargo xtask dist
88
# build`), and "Publish" makes the archives from them, makes the GitHub
99
# release with the notes, publishes to https://fctl.sh/releases and starts CI
10-
# on main, which redeploys app.fctl.sh. `tag` rebuilds an existing release tag
11-
# from main; `dry_run` only shows what would ship. Tags pushed by hand do not
12-
# publish anything: starting this workflow takes write access to Actions,
13-
# which agents running in fctl sessions do not have.
10+
# on main, which redeploys app.fctl.sh. Within the hour, hyperstructure/sandbox
11+
# publishes the release's sandbox image, ghcr.io/hyperstructure/sandbox:<version>.
12+
# `tag` rebuilds an existing release tag from main; `dry_run` only shows what
13+
# would ship. Tags pushed by hand do not publish anything: starting this
14+
# workflow takes write access to Actions, which agents running in fctl
15+
# sessions do not have.
1416
name: Release
1517

1618
on:

‎AGENTS.md‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,17 @@ fake-claude's behaviors are listed in [docs/development.md](docs/development.md)
9090
policy (`legal/privacy.md`) says what app.fctl.sh stores, who receives it
9191
and how long it is kept: a change here that alters any of that needs a
9292
matching change there.
93-
94-
Both are private for now: `npm ci` reaches the design package over git, so
95-
it needs GitHub access (CI uses a read-only deploy key).
93+
- [hyperstructure/sandbox](https://github.com/hyperstructure/sandbox): the
94+
default sandbox image, `ghcr.io/hyperstructure/sandbox`, published for
95+
every release. Hosts pull it, and `fctl host image build` builds its
96+
`main`. The host relies on its layout (the `agent` user, the PATH,
97+
`/opt/fctl/bin`) and on `Dockerfile` and `provision.sh` at its root:
98+
change those there, together with `docs/sandbox-images.md` here. Its Rust
99+
is the one in `rust-toolchain.toml`; bump the two together.
100+
101+
design and fctl-site are private for now: `npm ci` reaches the design
102+
package over git, so it needs GitHub access (CI uses a read-only deploy
103+
key). sandbox is public.
96104

97105
## Commits, pull requests and releases
98106

@@ -137,8 +145,8 @@ it needs GitHub access (CI uses a read-only deploy key).
137145
#13, and add labels. Add to other people's issues (a comment or a new
138146
section) instead of rewriting them.
139147
- An fctl session's token covers only this repository: name what
140-
hyperstructure/fctl-site or hyperstructure/design need, and tell the
141-
person.
148+
hyperstructure/fctl-site, hyperstructure/design or hyperstructure/sandbox
149+
need, and tell the person.
142150
- The procedures: [.claude/skills/issues/SKILL.md](.claude/skills/issues/SKILL.md).
143151

144152
## After opening a pull request

‎Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ anyhow = "1.0.104"
4343
base64 = "0.23.1"
4444
bytes = "1.12.1"
4545
clap = { version = "4.6.7", features = ["derive", "env", "wrap_help"] }
46+
flate2 = "1.1.10"
4647
futures = "0.3.34"
4748
getrandom = "0.4.3"
4849
hex = "0.4.3"
@@ -60,6 +61,7 @@ serde = { version = "1.0.229", features = ["derive"] }
6061
serde_json = "1.0.154"
6162
serde_with = { version = "3", default-features = false, features = ["macros"] }
6263
sha2 = "0.11.1"
64+
tar = "0.4.46"
6365
thiserror = "2.0.21"
6466
tokio = { version = "1.53.3", features = ["full"] }
6567
toml = "1.1.8"

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sessions with your team.
2727
```sh
2828
curl -fsSL https://fctl.sh/install | sh
2929
fctl login app.fctl.sh
30-
fctl host install --build-image # this machine now runs agents
30+
fctl host install # this machine now runs agents
3131
fctl run -p my-app "Add a dark mode toggle"
3232
```
3333

‎ROADMAP.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ this file is the overview. Order within a section is priority.
4848
container driver (DNS, clock, disk, caches) from what they show (#1)
4949
- [x] CI on GitHub Actions: checks on pull requests, deploys from `main`,
5050
releases from tags
51-
- [ ] Prebuilt sandbox images (GHCR) so `fctl host image build` is a pull (#2)
51+
- [x] Prebuilt sandbox images (GHCR) so `fctl host image build` is a pull (#2)
5252
- [ ] Shared caches per project (npm, cargo, uv) mounted into sandboxes (#3)
5353
- [x] Notifications when a session waits for you or fails: web push, with
5454
followers, per-person settings and digests (#4)

‎crates/fctl-agent/src/supervisor.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl Supervisor {
657657
self.log(
658658
LogSource::Agent,
659659
LogLevel::Info,
660-
"This sandbox has no fctl that can rename the session, so it keeps the title it started with. Rebuilding the default image (fctl host image build) installs one.",
660+
"This sandbox has no fctl that can rename the session, so it keeps the title it started with. The default image, ghcr.io/hyperstructure/sandbox, has one; an image of your own needs fctl on the PATH.",
661661
);
662662
}
663663
let setting_sources = match claude::project_settings_are_unsafe(&paths.workdir) {

‎crates/fctl-host/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ base64.workspace = true
1313
fctl-client.workspace = true
1414
fctl-domain.workspace = true
1515
fctl-proto.workspace = true
16+
flate2.workspace = true
1617
futures.workspace = true
1718
regex.workspace = true
1819
serde.workspace = true
1920
serde_json.workspace = true
2021
sha2.workspace = true
22+
tar.workspace = true
2123
hex.workspace = true
2224
tokio.workspace = true
2325
tokio-tungstenite.workspace = true

0 commit comments

Comments
 (0)