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.
Design
Section titled “Design”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..
Out of scope
Section titled “Out of scope”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