Skip to content

S06 - VM Lifecycle, Images and the Guest Agent

Purpose: How guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does.

Requirements: FR02-any-repoFR02-any-repo: Any git repositoryWorks in any git repository., FR05-parallel-sessionsFR05-parallel-sessions: Parallel sessionsSeveral sessions can run at once, in the same project and across projects. to 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., FR11-port-forwardFR11-port-forward: Port forwardingDev servers listening in the guest are reachable on host loopback. to FR14-ephemeralFR14-ephemeral: Ephemeral sessionsAn ephemeral mode runs a session with no persisted state., SEC01-separate-kernelSEC01-separate-kernel: Separate kernelThe agent runs in a hardware-virtualized guest with its own kernel, never sharing a kernel with the host or with another environment of the user (for example a WSL distribution)., SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise., SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another., SEC11-root-gains-nothingSEC11-root-gains-nothing: Guest root is not a privilegeFull control of the guest grants no control over enforcement, secrets, or policy., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too., NFR01-startupNFR01-startup: StartupGoals: a warm VM reaches the Claude prompt in about 4 s and a suspended VM in about 7 s, and no start takes more than 10 s (p95), excluding first-time project setup and the first boot after a host restart. to NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host..

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…, C06-model-apiC06-model-api: Model APIThe test cases for the model credential: its placeholder, the scan for the placeholder in whole requests, what is injected on the model API, the event log, and Claude Code end to end.

Briefs: B16-warm-startB16-warm-start: How fast does a suspended VM come back, and can one saved state be restored more than once?Yes, with conditions., B20-guest-xcodeB20-guest-xcode: Can Xcode builds, tests and simulators run for a project user without a GUI login?Yes, with conditions., B42-trust-placementB42-trust-placement: Where does a new project run, and what makes it the same project later?Split "trusted" into two named settings, start new projects in the isolated VM until the user moves them, and key project identity on the git directory rather than the remote URL., B43-vm-slot-admissionB43-vm-slot-admission: What gets one of the two macOS VM slots when everything wants one?The work VM keeps its slot., B45-claude-in-guestB45-claude-in-guest: How does Claude Code run in the guest, and which of the user's settings go with it?Carry in an allowlist of the user's Claude Code configuration with secrets and hooks removed, start in bypassPermissions mode, and pin Claude Code in the image with every in-guest update path off., B46-session-lifecycleB46-session-lifecycle: What happens to a running session when its terminal closes or its VM stops?Recommended that closing the terminal detaches an interactive session, which `wb attach` resumes, that a session ends only when claude exits, and that `wb` exits 255 when it loses a session., B60-model-credentialB60-model-credential: Can Claude Code in the guest hold only a placeholder while the proxy adds the real subscription token?Yes, for a long-lived token from claude setup-token., B194-xcode-imageB194-xcode-image: How does an image get full Xcode and the simulator runtimes?From the host., 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.

This spec describes macOS guests on a macOS host, the v1 target. The structure (image layers, sealing, work and isolated VMs, one guest user per project, worktree per session, the duties of wb-guestd) is the same for every guest OS. What differs per guest and per host is listed in S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL..

Page What it covers
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 layers of a guest image, and the toolchain prefix that project layers install into
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. wb image build: the build VM, provisioning, terminfo, sealing and storage
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. Replacing a VM’s system disk, recreating project users, and the guest admin password per VM
S06-04-vms-and-placementS06-04-vms-and-placement: VMs and PlacementThe work VM and the isolated VM, Xcode in them, and which VM a project's sessions run in. The work VM and the isolated VM, Xcode, and which VM a project runs in
S06-05-disksS06-05-disks: DisksA VM's system disk and data disk: how the data disk keeps what the guest flushes, and how the guest mounts it. The data disk: durability, and mounting in the guest
S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host. A VM’s devices and resources, saving and restoring it, and the guest clock
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. How wb-hostd admits macOS VMs against the limit of two
S06-08-projects-and-sessionsS06-08-projects-and-sessions: Projects and Sessions Inside a VMHow projects map onto guest users and sessions onto worktrees, and how Claude Code runs in the guest. Guest users, worktrees, conversation history and Claude Code in a VM
S06-09-session-lifecycleS06-09-session-lifecycle: Session LifecycleA session's states from wb claude to its summary, how it starts and ends, its deadlines, and when its VM may be saved. A session’s states, its start and end, deadlines and idle suspend
S06-10-leftover-processesS06-10-leftover-processes: Leftover ProcessesThe results of the kill of a project user, how wb-hostd accepts them, and what it does when processes are left. Results of the kill of a project user, and what wb-hostd does with them
S06-11-reconnect-and-recoveryS06-11-reconnect-and-recovery: Reconnect, Loss and RecoveryWhat happens when the host-guest link drops, when a session is lost, and how a lost session's work is recovered or discarded. Reconnecting after a dropped link, lost sessions and their recovery
S06-12-guest-agentS06-12-guest-agent: Guest AgentWhat wb-guestd, the service in the guest, does for the host, and how it updates itself. What wb-guestd does, and how it updates itself
S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk. How the host formats a new data disk, and the checks before a VM starts with it
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. Full Xcode and the simulator runtimes from the host, on a read-only disk the host builds, and who runs Xcode’s first launch
S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records. How the host builds the read-only Xcode disk under the wb-diskfmt shim, and what the build records
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 minimal base: Apple’s Command Line Tools from the host, and the toolchain user
S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base. Named images built from recipes: the recipe VM, its network, sealing and provenance

Port forwarding (FR11-port-forwardFR11-port-forward: Port forwardingDev servers listening in the guest are reachable on host loopback.) and the clipboard (FR12-clipboardFR12-clipboard: Opt-in clipboardText clipboard sharing is opt-in, per direction, with approval.) are out of scope for V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. (V1-08-no-forward-clipboardV1-08-no-forward-clipboard: No port forwarding or clipboardPort forwarding (FR11-port-forward) and the clipboard (FR12-clipboard) are out of scope for V1, so nothing new crosses the VM boundary for them (S06-vm-lifecycle)., decided on I38I38 (closed): S06-vm-lifecycle: design port forwarding and clipboard (FR11-port-forward, FR12-clipboard) and their threatsFR11-port-forward (dev servers on host loopback) and FR12-clipboard (clipboard) cross the VM boundary, but no spec designs them and S03-requirements's threat model does not list them.). wb-guestd does not report listening ports or bridge the clipboard, and nothing crosses the VM boundary for either. The analysis in B38-port-forward-clipboardB38-port-forward-clipboard: How should guest dev servers and clipboard text cross to the host?Forward HTTP through a host proxy that gives each forwarded port its own localhost site, plain TCP only on ports the user names, and the clipboard only through wb with an approval. is the input for their design once they are scheduled.

Status: Draft