S06-17 - Named Images and Recipes
Purpose: The build of a named image from a recipe on a clone of the sealed base. The recipe, the built-in Homebrew recipe, the VM and network of a recipe build, what makes the result trusted, its provenance, and which image a VM runs.
Requirements: FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode)., FR07-toolchain-manifestFR07-toolchain-manifest: Declared toolchainA project's toolchain is declared host-side (on macOS guests, a Brewfile) and reconciled automatically before a session starts., NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host., SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy., SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter., SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.
Tests: C09-guest-and-sessionsC09-guest-and-sessions: Guest and SessionsThe test cases for what a project user can reach inside the guest, wb-guestd's update and the guest clock, the shared toolchain prefix, the guest admin password, and the session lifecycle., C11-host-daemonsC11-host-daemons: Host Daemons, Audit, and DisksThe test cases for the host daemons' own checks: wb-vmd's device set and slots, the image build bundle, supervision, the accounting and event channels, the daemon log pipes, the audit writer, free space, and the data…
Design
Section titled “Design”A named image
Section titled “A named image”A named image is a clone of the sealed base, with a recipe run on it, sealed again before any agent or project code runs (I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image.). Many sessions start from the same named image. Its Claude Code layer goes on top, as on the base (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Derivation”).
- Recipes only. No image configured by hand is ever sealed.
wb image shell(“Working out a recipe”) never seals. - One level. A named image derives from the base. A recipe may include other recipes, but images don’t chain.
- Rebuilds cascade. A new base rebuilds every named image from its recipe, then their Claude Code layers (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Only the layer”).
The recipe
Section titled “The recipe”A recipe is a TOML file in the user’s settings,
<config>/images/<name>.toml. The file name is the image’s name:
# <config>/images/python-dev.tomlinclude = ["homebrew"]formulae = ["python@3.13", "uv", "mise"]xcode = falseincludenames other recipes, the built-in ones included. Their steps run first, in the order listed, and each recipe runs once.formulaearehomebrew/coreformula names, with the name rule of S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The manifest is data”. They install from bottles only, as “The install” there says.xcodeasks for the Xcode step (S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.).
The keys are closed. wb-hostd refuses a recipe with any other key, a
name outside the rule, an include it can’t find, or an include cycle,
and logs the file, the rule and the line. It bounds the file’s size,
the include depth, and the number of names in code. A recipe with
formulae and no path to the homebrew recipe through its includes
is refused with recipe-needs-homebrew. The parser has a fuzz target.
An image’s name matches ^[a-z][a-z0-9-]{0,31}$. base and the names
of the built-in recipes are reserved for those, and a user recipe with
one is refused with recipe-name-reserved.
Only from user settings
Section titled “Only from user settings”An image is trusted by every session that uses it. So recipes come
only from <config>/images/. A repository’s .wraithbox/ never
defines one, whatever its config_trust (SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy.,
S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Closed keys”). Wraith Box has no
organization layer. Recipes an organization supplies wait for an organization
design.
The built-in Homebrew recipe
Section titled “The built-in Homebrew recipe”The base has no Homebrew (S06-16-base-layerS06-16-base-layer: The Base LayerWhat the base layer holds, how the image build installs Apple's Command Line Tools from a package the host fetched, and the toolchain user that named images and project layers install as.). The built-in recipe
homebrew adds it, compiled into wb-hostd, and never read from a
file. It runs these named operations of wb-guestd, as the toolchain
user:
install-homebrewfetches Homebrew fromhttps://github.com/Homebrew/brewat the pinned tag into the prefix. It refuses a checkout whose commit isn’t the pinned commit.write-formula-snapshotwrites the snapshot of Homebrew’s formula API that keeps project layers from upgrading kegs (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “A reconcile only adds”).
The tag and the commit are in one place in the code, which Renovate
bumps. A bump changes the recipe’s hash. The next build then rebuilds
every image that includes homebrew.
A plain wb image build builds the base, the homebrew image, and
the image of each recipe in <config>/images/. So every machine has a
package manager for FR07-toolchain-manifestFR07-toolchain-manifest: Declared toolchainA project's toolchain is declared host-side (on macOS guests, a Brewfile) and reconciled automatically before a session starts. (a project’s declared
toolchain) without a recipe of its own. wb image build <name> builds
one named image, and the base first when the base is out of date.
The recipe VM
Section titled “The recipe VM”A recipe’s steps run in wb-vmd-recipe, the wb-launcher entry of
the recipe slot (S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk.). It is a maintenance VM, so it
borrows the isolated VM’s slot, and one maintenance VM runs at a time
(S06-07-slot-admissionS06-07-slot-admission: Slot AdmissionHow wb-hostd admits every macOS VM it starts against the limit of two, and lends the isolated VM's slot to a maintenance VM., NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host.).
wb-hostdclones the sealed parent into a new, empty build bundle, with the identity check of S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Taking the sealed image”. The parent is the base, or the sealed result of the recipe’s Xcode step.- It starts
wb-vmd-recipe, which boots the clone with one network device, and no Xcode disk. - At first contact,
wbadmin’s password is rotated, as in the Claude Code layer build (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The Claude Code layer”). wb-guestdinstalls the recipe VM’s CA (“TLS during a recipe build”).wb-hostdsends the resolved recipe’s steps, one named operation at a time. A failed step fails the build.wb-guestdremoves the CA, and the image is sealed (“What makes a named image trusted”).- After
wb-vmd-recipeexits,wb-hostdtakes the sealed image as in S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Taking the sealed image”.
The named image is then the parent of its Claude Code layer.
The network of a recipe build
Section titled “The network of a recipe build”The recipe VM has its own wb-netd and wb-proxyd path, as a session
VM has, with the VM name recipe. Its policy is the build policy,
compiled into wb-hostd:
- the Homebrew rules of the package registries profile (S07-11-http-policyS07-11-http-policy: HTTP PolicyThe HTTP rules of inspected hosts, the built-in profiles, and the parts a user can turn off., “package registries”);
- reads of the git repository
github.com/Homebrew/brew.
No user, project or repository policy applies to it, and it gets
neither approvals nor learn mode. Every other destination is refused and
logged (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.). Each decision is an audit record of the build, not
of a session (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). Its only credential binding is the
anonymous ghcr.io value of S07-10-anonymous-credentialsS07-10-anonymous-credentials: Anonymous CredentialsHow wb-proxyd answers hosts that want a token even for public reads, without forwarding the guest's token..
wb-proxyd accepts the recipe VM’s hand-off in session mode only,
with the build policy only (S07-05-stream-hand-offS07-05-stream-hand-off: Stream Hand-offHow wb-netd hands each stream to wb-proxyd, and the checks that keep a compromised wb-netd from widening what a stream may reach.). The dependency
gate doesn’t check what a recipe fetches. A recipe installs
homebrew/core bottles, and bottles aren’t gated
(S07-12-dependency-gateS07-12-dependency-gate: Dependency GateHow wb-proxyd keeps young and vulnerable package versions from the guest on the gated registries., “Homebrew”, T08-homebrew-ungatedT08-homebrew-ungated: Young Homebrew bottlesHomebrew bottles from homebrew/core are not age-gated or checked against OSV.).
TLS during a recipe build
Section titled “TLS during a recipe build”The sealed image contains no Wraith Box CA (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Layers”). The recipe VM gets a CA of its own, as every VM does (S09-07-ca-certificatesS09-07-ca-certificates: CA CertificatesThe profile and scope of each TLS inspection CA, the leaf certificates it signs, and its rotation., “Scope”).
- At first contact,
wb-guestdwrites it to the trust files of S09-08-guest-trustS09-08-guest-trust: Guest TrustHow wb-guestd makes the guest's clients trust the VM's CAs., as for a session VM. - Before sealing, the named operation
remove-trustdeletes/etc/wraithbox/, without following symbolic links. It first checks that the directory belongs to root, isn’t a symbolic link, and holds onlytrust/. Otherwise it fails withtrust-remove-refused, and the build fails. - The sealing scan refuses an image that holds
/etc/wraithbox/, or the build CA’s certificate, in DER or PEM, in a file it reads.
The scan reads every regular file in the prefix, the toolchain user’s
home and /Users, which the comparison doesn’t cover. It also reads
every file the comparison finds added or changed elsewhere (“The
comparison” below).
The CA’s key goes on the removal list when the build ends (S09-06-ca-keysS09-06-ca-keys: CA KeysHow the key of each TLS inspection certificate authority is made, stored and restored, and when a CA is valid.).
What makes a named image trusted
Section titled “What makes a named image trusted”The recipe runs as the toolchain user. wb-guestd runs a recipe step
only through its named operations, and none of them takes a command, a
path or a URL. The privileged operations of a recipe build are only
the rotation, the CA’s install and removal, and the seal.
The comparison
Section titled “The comparison”Each seal ends with wb-guestd writing the seal manifest, a
root-owned file of mode 600. It lists every entry outside /Users:
its path, type, owner, group, mode, flags, change time, and a link’s
target. Every seal writes one, the base’s included (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage.,
“Sealing”). wb-hostd keeps the manifest’s SHA-256 in state.db: with
the image record, and for the sealed result of an Xcode step, which
isn’t an image, with the build record of its named image.
Before the recipe VM is sealed, wb-guestd compares the image with
the parent’s manifest. wb-hostd first checks that the manifest’s
hash equals the one it kept. The seal fails with
seal-changed-outside-toolchain, and names the first path, on an
entry added, removed or changed outside:
- the prefix and the toolchain user’s home (S06-16-base-layerS06-16-base-layer: The Base LayerWhat the base layer holds, how the image build installs Apple's Command Line Tools from a package the host fetched, and the toolchain user that named images and project layers install as.);
/Users;- the temporary folders of the toolchain user, in
/private/var/foldersand/private/tmp(S06-16-base-layerS06-16-base-layer: The Base LayerWhat the base layer holds, how the image build installs Apple's Command Line Tools from a package the host fetched, and the toolchain user that named images and project layers install as., “At sealing”); - the paths macOS writes on every boot, and the paths the build’s named
privileged operations write. Both are lists in code that a build
measures (I861I861 (open): Measure the paths macOS writes on a recipe VM's boot, for the seal comparisonS06-17-named-images, "The comparison" (from #150): before a recipe VM is sealed, wb-guestd compares the image with its parent's seal manifest, and fails on any entry added, removed or changed outside the toolchain…). The rotation rewrites
wbadmin’s record in/private/var/db/dslocal/nodes/Default/users/, and the CA’s install and removal change the change time of/private/etc.
Then the full sealing scan runs (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”).
A local privilege escalation from the toolchain user to root in the
recipe VM defeats these checks in the guest, as it would any seal.
The recipe narrows that to homebrew/core bottles and Homebrew’s own
code (T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain
prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix").).
Provenance
Section titled “Provenance”state.db records for each named image:
- its parent image;
- the SHA-256 of the resolved recipe, in a canonical encoding with the includes expanded;
- the path of its build log;
- the range of its build’s audit records.
wb image list shows the parent and the recipe hash next to each
image (S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands., “wb image”).
Working out a recipe
Section titled “Working out a recipe”wb image shell [<name>] boots a clone of the base, or of the named
image’s parent, in wb-vmd-recipe with the build policy. It runs
/bin/zsh -l as the toolchain user, with the environment of
S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The environment”. When the shell ends,
wb-hostd deletes the build bundle. It never seals or stores the image.
It takes the maintenance slot, as a build does.
The image a VM runs
Section titled “The image a VM runs”The work VM runs one image, which the user picks with wb image use work <name>. The isolated VM does too, with wb image use isolated <name>. A new VM runs the homebrew image.
A project may name the image it needs, in its image setting
(S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Settings contents”):
- In the work VM, a session start for a project whose image isn’t the
VM’s is refused with
image-mismatch. The refusal names--isolated(NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). - In the isolated VM, the project’s image is the VM’s. When the VM
runs another one and has no session,
wb-hostdupdates its system disk first (S06-03-image-updatesS06-03-image-updates: Image UpdatesHow a VM gets a new image's system disk while its data disk and project users stay, and the guest admin password of each VM.). When it has a session, the start is refused withimage-mismatch, naming that session.
The project layer still installs at session start, on top of the image (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Toolchain prefix”).
Decisions
Section titled “Decisions”A recipe VM of its own
Section titled “A recipe VM of its own”- Why: a recipe needs a network, and the Claude Code layer’s
wb-vmd-layerhas no network device. A slot of its own keeps that rule unconditional. - Rejected: a network flag on
wb-vmd-layer. It saves awb-launcherentry and a profile, but makes the layer slot’s “no network device” depend on a flag. - Decided: I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. (B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing.).
The build CA installed at runtime, and removed before sealing
Section titled “The build CA installed at runtime, and removed before sealing”- Why:
wb-proxydenforces the build policy’s request rules only on traffic it inspects: theghcr.iopath rule (/v2/homebrew/core/only), theregistry-tokenrefusal and the method limits (S07-11-http-policyS07-11-http-policy: HTTP PolicyThe HTTP rules of inspected hosts, the built-in profiles, and the parts a user can turn off., “package registries”). The audit then records each request, not only the host. The removal and the scan keep the CA out of the sealed image. - Rejected: pass mode for the build hosts. The guest then doesn’t
hold a CA. But
wb-proxydwould see host names only, and could enforce none of those rules. - Decided: I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. (B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing.).
Formulae only
Section titled “Formulae only”- Why: a recipe step that runs a command would let any code run as the toolchain user, and the toolchain is shared by every project in the VM (T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix").).
- Rejected: a command step run as the toolchain user. In return, a
tool outside
homebrew/corebottles can’t go in an image. - Decided: I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. (B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing.).
Status: Draft