Who restarts the host processes, and what happens to running VMs when one fails?
Decided 2026-10-04: C. VMs stop with wb-hostd, for V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. The decision and its reasons are in the I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded: comment that starts Decision (2026-10-04):. Source: I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded:. Affects S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does., S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice. and SEC00-indexSEC00-index: Security requirementsThe security controls Wraith Box enforces. (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.). The spec change is awaiting review, with the choices made while writing it listed under “The spec change” below.
The problem
Section titled “The problem”Figure 1. Who starts and restarts whom. A VM made with the Virtualization framework runs inside the wb-vmd process, so what happens to wb-vmd when wb-hostd stops decides what happens to running sessions. The red arrows are the guest driving host work: SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped. caps the VM, but not the host processes that serve it.
Options
Section titled “Options”These cover the one real fork: what running VMs do when wb-hostd stops, crashes or is upgraded.
Sub-decisions
Section titled “Sub-decisions”| Item | Recommendation |
|---|---|
| Supervisor | wb-hostd runs under the service manager with keep-alive (S12-01-platform-interfacesS12-01-platform-interfaces: Platform InterfacesHow platform-specific code is isolated behind interfaces, and what each host OS uses for each., “Service manager”). It starts and restarts wb-netd and wb-proxyd with backoff. A VM whose wb-netd keeps failing has no network until the VM stops, and wb status says why. |
| Fail closed, visibly | When wb-netd or wb-proxyd is down, the guest gets resets and refusals, never a path around them. wb prints one wraith box: line on stderr and wb status shows the process state. That line never asks for input, so SEC14-no-fake-approvalsSEC14-no-fake-approvals: Approvals cannot be spoofed by the guestApproval prompts are never rendered in the agent's terminal stream. is untouched. |
| Skew between host processes | They ship in one bundle at one version. Each refuses a host peer of a different build version at connect, so there are no host-to-host compatibility rules to keep. |
Skew with wb-guestd |
Each .proto package name ends in a major version (v1). wb-guestd reports its version at connect. The host refuses a version outside its supported range and updates the guest from the guest tools disk image (S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does.). The reported version is a guest label: the host uses it only to refuse, never to allow. |
| Upgrades while running | Option A’s path: save VMs, replace the bundle, restart, restore. The install side is I49I49 (closed): S10-tech-stack: installation, restore image download, upgrades and migrationsS10-tech-stack "Packaging and signing" gives the shape of the macOS app bundle.. |
| Host resource limits | Each guest-facing handler gets a rate limit and a size limit per VM: host-guest socket RPCs, DNS queries, new connections, receive-pack size and time, audit events, approval requests. Extend SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped. to say so. That is a stricter control, and still a SEC00-indexSEC00-index: Security requirementsThe security controls Wraith Box enforces. change. |
| Logs and health | Each daemon logs to <logs>. wb status lists each process, its restart count, and its last exit reason (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). |
The spec change
Section titled “The spec change”The spec pull request for I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded: adds “Supervision and failure” to S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., with option C and the sub-decisions above, and the wb-launcher duties from the I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded: comment on the X23-sandboxed-daemonsX23-sandboxed-daemons: Self-sandboxed Go daemons on macOSCan wb-netd, wb-proxyd and wb-hostd confine themselves at start with a sandbox profile, as S04-architecture says, while the Go runtime, inherited descriptors, and Keychain and Secure Enclave access in wb-proxyd keep w… result. Approving it also approves these choices, which neither the decision nor this brief made. Each row says what the spec chose and the alternative it passed over.
| Choice | The spec says | Passed over |
|---|---|---|
| Guest version rule | wb-hostd accepts only a wb-guestd of its own build version. Under C the running bundle started each running VM and gave it its guest tools disk. A range adds nothing in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. |
A supported range, which needs compatibility rules now. It returns if option A is adopted later. |
| Guest version string | Printable ASCII, at most 64 bytes, semver form, refused otherwise with guest-version-form, and escaped and cut wherever it is shown. |
Logging the string as sent, which lets guest root write into host logs and wb output. |
| Build stamp | Every build task stamps the version, the dev build and CI included: the VCS revision, plus a modified flag and a nonce for a modified tree, made once per mise run build and shared by every language task, so a partial rebuild of a modified tree needs a full build. Only a bare toolchain build (go build, go run, swift build) is unstamped, and every peer refuses it. Tests set the version explicitly, and integration tests build through the stamping task. The code change is I174I174 (closed): Stamp the VCS revision into the build version, and treat an unstamped build as no versionFollow-up from the security review of #171 (#48, finding L5).. |
The current 0.0.0-dev default, which would make every unstamped build match every other, or stamping only release builds, which would make every dev build and CI run refuse itself. |
| Upgrades | Same path as a crash: the VMs stop and their sessions are lost and recovered later. The “Upgrades while running” row above assumed option A. | Saving VMs across an upgrade (option A). |
| Upgrade window | wb-hostd reads the installed bundle’s version when a peer reports another version and before it starts a daemon, and exits with bundle-replaced when it isn’t its own. The service manager then starts the new one, and wb says Wraith Box is restarting after an upgrade. A version it can’t read is logged as bundle-version-unreadable, counts as its own, and shows in wb status, so a damaged bundle can’t make it exit in a loop. |
Leaving the window to I49I49 (closed): S10-tech-stack: installation, restore image download, upgrades and migrationsS10-tech-stack "Packaging and signing" gives the shape of the macOS app bundle., during which new daemons would be refused until wb-hostd gave up on them. |
Refusing wb |
wb-hostd refuses a wb of another build version. wb names both versions and exits with 255. |
Compatibility rules between wb and wb-hostd. |
Losing wb-hostd |
wb-launcher, wb-vmd, wb-netd and wb-proxyd read end of file on their control channel as wb-hostd gone. wb-vmd stops its VMs, wb-netd and wb-proxyd exit, and wb-launcher sends SIGTERM, then SIGKILL after 5 seconds, ends the per-run programs too, and exits. launchd’s process group kill is a second layer. The per-run programs don’t hold a control channel. |
Relying on launchd alone, which works on macOS only. A heartbeat to catch a hung wb-hostd, which would stop every VM while the hung process still runs. |
| Per-run programs | wb-git, wb-prover, wb-guestadmin and wb-build-ssh are never restarted. A run that ends early fails with the exit reason. On hosts without wb-launcher, how they end with wb-hostd is confirmed when those hosts are built (I176I176 (open): End per-run programs with wb-hostd on hosts without wb-launcher (Linux, Windows)Follow-up from the code re-review of #171 (#48, finding G).). |
Restarting them, which could repeat a push or a check. |
| Restart limits | Backoff from 0.5 seconds, doubling to 30 seconds. After 5 exits in 10 minutes wb-hostd gives up: the VM has no network until it stops, or for wb-proxyd, one more try at the next session start. Session starts are then refused with daemon-given-up, naming the process, the exit reason and what starts it again. |
Unlimited restarts, which turn a guest-triggered crash into an endless supply of fresh processes. |
Restarting wb-vmd |
Not in a loop. A new one starts when a VM is next needed, under the same backoff and limit. | Restarting it at once, which has no VM to serve. |
| Wildcard budget across a restart | wb-netd checks and debits the budget. wb-hostd only keeps the count across restarts, and does the same for every other count S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. has wb-netd or wb-proxyd keep for the active period. |
Keeping the counter in wb-netd only, which a crash resets (T02-dns-namesT02-dns-names: Data in DNS namesData encoded in DNS names under allowed wildcards, bounded by a lookup budget per VM (S07-03-dns).). |
| Accounting records | Debits, mapping entries and releases travel as accounting records: never rate-limited, suppressed or dropped, written before any drop decision and before the DNS answer, one whole record per message on a SOCK_SEQPACKET or SOCK_DGRAM socket (SOCK_DGRAM on macOS, I172I172 (closed): Measure the hand-off socket ordering and no-silent-drop properties on each host platformFollow-up from the code review of #170 (#68).). A write that fails or blocks over 100 ms refuses the name with accounting-write-failed. In S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. that rule, audit-budget, audit-bytes and event-channel-blocked get the same answer bytes as every refusal, and the last three raise no approval event and debit no wildcard budget. |
Sending debits with the audit events, which a flood can suppress. |
| Event channel | Records of at most 4 KiB in a fixed format, with a fuzz target. A malformed record, or one received with MSG_TRUNC, counts as a crash of its sender. An event write that blocks over 100 ms, or fails with ENOBUFS or EAGAIN, makes wb-netd and wb-proxyd refuse new work with event-channel-blocked and retry the record, so no event is lost. S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. “No host-side listener” names these channels as wb-netd’s peers. |
Trusting the daemons’ records because they are host processes, which parse guest bytes first. |
| Name mapping across a restart | wb-hostd keeps each live entry of each VM’s synthetic name mapping until its release record arrives, with its own receipt time, and hands the entries to the new wb-netd, which reuses none of those addresses before releasing them. wb-netd sends each entry as an accounting record before the answer that uses it, and each release before the address is reused. wb-hostd checks each entry’s name form, its address range and the 131,072 cap. A failed check is logged as mapping-entry-invalid and ends wb-netd, so its mapping never differs from the kept one. |
An empty mapping, which could give an address the guest still has cached to another name and send a raw or pass-mode stream to the wrong host. A TTL clock in wb-hostd, which would disagree with the release clock of I68I68 (closed): wb-proxyd must bind stream identity to the connection, not to wb-netd's tagsFound in the security review of #65 (X23-sandboxed-daemons result).. |
| Hand-off socket across a restart | A wb-netd restart within a VM generation gets a new hand-off socket for that VM and generation. A wb-proxyd restart gets one for every running VM, because one wb-proxyd serves them all. A running wb-netd gets its end on its control channel, one descriptor per message, checked for count, type, VM and generation. wb-netd replays the kept mapping on each new socket, the same set either way (the S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. side is in I68I68 (closed): wb-proxyd must bind stream identity to the connection, not to wb-netd's tagsFound in the security review of #65 (X23-sandboxed-daemons result).). |
Reusing the old socket, whose peer is gone. |
Restarting wb-netd without the VM |
wb-hostd keeps a copy of each VM’s packet transport descriptor in a type with no read or write path, hands it to the new wb-netd, and closes it at VM stop and at a restore. |
Stopping the VM whenever wb-netd exits. |
| Telling the user | A native notification once per outage, with the secret store accesses the restarts caused, a wraith box: line in non-interactive use, a line in the session summary, and wb status. In interactive use wb doesn’t write into the agent’s screen, where a line would garble the display. |
The wraith box: line in interactive use that the “Fail closed, visibly” row proposed. |
One wb-proxyd for both VMs |
Kept. A crash found from one VM takes the other VM’s network down until the restart, and the other VM also shares the given-up state, a blocked event channel and the store prompts of restarts. Recorded as T14-shared-proxydT14-shared-proxyd: One proxy process serves both VMsOne wb-proxyd serves the work VM and the isolated VM (S04-architecture, "Processes")., with the status “Accepted” like every threat in T00-indexT00-indexboundary 6 is the host terminal stream., so merging this pull request accepts T14-shared-proxydT14-shared-proxyd: One proxy process serves both VMsOne wb-proxyd serves the work VM and the isolated VM (S04-architecture, "Processes").. | One wb-proxyd per VM, which doubles its memory and secret store accesses. |
| SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped. text | Every guest-facing host handler limits per VM the rate and size of its input and the work it runs at once. | Rate and size only, which leaves concurrent work, such as prover runs, open. |
| Guest-facing handler table | Every handler is listed with its limits, including upstream resolution, leaf issuance, recovery pushes, notifications and the daemons’ own records. | Leaving the limits to each spec, which hides a handler without one. |
| Audit retention | Deleted by age only, after audit_retention_days (default 90, at least 30). |
A size cap, which a flood turns into deleted evidence. |
| Audit volume | 5019, 2004, approvals, returned work, recovery pushes, store accesses, VM and session records are never dropped. Network and HTTP Activity have a budget per VM, 6000 per UTC minute and 64 MiB per UTC day by default, and over it the VM’s lookups, connections and requests are refused (audit-budget, audit-bytes), not unrecorded. The budget is per VM, so in the work VM one project can use it up for all (T11-shared-vm-grantsT11-shared-vm-grants: Projects in one VM share network grantsThe host sees one guest address per VM, and can't tell which project user, session or program opened a connection.). The defaults are unmeasured, and I175I175 (open): Measure the audit budget defaults (events per minute, bytes per day) against real sessionsFollow-up from the code re-review of #171 (#48, finding C). measures them. Only the refusal classes S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. aggregates are written as runs, and each count is written when its window ends and in the VM’s stop record. |
One budget per VM with drops, which lets thousands of cheap events push out the record that matters. |
| Audit disk space | A free-space floor of 1 GiB checked at VM start, session start and every minute. A VM starts only with the floor plus the room its data disk can still grow, the disk the guest controls. The disk cap defaults are unmeasured too, and I175I175 (open): Measure the audit budget defaults (events per minute, bytes per day) against real sessionsFollow-up from the code re-review of #171 (#48, finding C). covers them. Below the floor, each VM whose data disk grew since the last check is stopped before any write fails, with a notification, a wb status line, and VM and session starts refused. A 64 MiB reserve file frees room for the stop records and is allocated again once space returns. A failed write stops the VM it belongs to first, and every VM only when it belongs to none. |
Stopping every VM on any failed write, which a guest could trigger within its own caps. |
| Daemon logs | One file per process, 100 lines a second and 4 KiB a line at most, with a count of dropped lines, rotated at 10 MiB with 5 kept. | Unbounded daemon logs, which a guest feeds through wb-netd. |
| Guest tools disk | wb-hostd clones it into the VM’s bundle before each cold start, because wb-vmd attaches no disk outside it. 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., “Devices”, lists it as read-only. A saved state from another build version is deleted before any restore. |
Attaching the image in place, which the device-set check refuses, or copying only on a version change, which keeps a copy wb-vmd could have changed. |
Left to I52I52 (closed): S04-architecture, S09-policy-credentials-audit, S10-tech-stack: first .proto contracts and settings schemaS04-architecture says all IPC is protobuf over gRPC and S10-tech-stack adds proto/ "with the first RPC".: the values of the message size, stream and request rate limits on the wb-guestd connection, and the version exchange message itself.
Impact
Section titled “Impact”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. (guest root doesn’t control enforcement) and SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. (default-deny egress) hold under every option, because a crash only removes the path out of the guest.
Evidence
Section titled “Evidence”- verified
wb-hostdspawnswb-vmd, onewb-netdper VM, andwb-proxyd, andwb-vmdhands it the guest socket descriptors (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., “Processes”, and S04-02-vm-providerS04-02-vm-provider: VM Provider and StreamsHow wb-vmd hands guest connections and the NIC endpoint to other processes, the fixed device set of a VM, and where wb-proxyd takes a stream's identity from.). - verified When a launchd job exits, “launchd kills any remaining processes with the same process group ID as the job”, unless
AbandonProcessGroupis set (man launchd.plist, macOS 27.0.1). - verified When the host-guest socket drops,
wb-guestdstops the session’s process group and resumes it when the link returns (S13-01-process-hardeningS13-01-process-hardening: Layer 1: Process Hardening (v1)How wb-guestd hardens every process it starts for a project user, and how it stops and kills a project user's processes.). - verified The specs already plan to save VM state on idle and restore it (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., “Warm start”), so A reuses that path.
- verified SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped. reads “CPU, memory and disk of each VM are capped”, and nothing bounds the host processes serving a VM (SEC00-indexSEC00-index: Security requirementsThe security controls Wraith Box enforces.).
- verified The audit log is “rotated and size-capped” (S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written.), and the wildcard DNS budget is per session (S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget.).
- verified The code has no supervision yet: every daemon under
packages/wraithbox-go/cmd/andwb-vmdprints its version and exits 2. Go and Swift each define their own version string (internal/version/version.go,WraithBoxVM/Version.swift), so the release build must set both to the same value. - assumed That a Virtualization framework VM stops when the process that owns it exits. Probable, and a VM run takes minutes to check: add it to X18-vsock-handoffX18-vsock-handoff: Host-guest socket and descriptor hand-offCan wb-guestd, written in Go, open AFVSOCK sockets in a macOS guest?.
- assumed That a macOS guest with a vsock device and a file-handle network attachment can be saved and restored. That is X02-warm-startX02-warm-start: Warm startMeasure time to restore a macOS guest from saved state with a vsock device and a file-handle network attachment.. If it can’t, A falls back to C.
What this unblocks
Section titled “What this unblocks”- I52I52 (closed): S04-architecture, S09-policy-credentials-audit, S10-tech-stack: first .proto contracts and settings schemaS04-architecture says all IPC is protobuf over gRPC and S10-tech-stack adds proto/ "with the first RPC".: the version rule for the
.protopackages and the supervision RPCs betweenwb-hostdandwb-vmd. - I49I49 (closed): S10-tech-stack: installation, restore image download, upgrades and migrationsS10-tech-stack "Packaging and signing" gives the shape of the macOS app bundle.: the upgrade path uses this decision’s restart sequence.
- The spec pull request that adds “Supervision and failure” to S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. and extends SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped..
- It waits on nothing for the decision. Option A’s implementation waits on X02-warm-startX02-warm-start: Warm startMeasure time to restore a macOS guest from saved state with a vsock device and a file-handle network attachment..
Details and glossary
What fails closed means here. The guest’s only network path is wb-netd, then wb-proxyd. If either is gone, guest connections are reset or time out. Nothing else on the host forwards guest traffic, so a crash can’t open egress. The decision is only about how visible the failure is and how fast it recovers.
A restarted wb-netd forgets its DNS answers. It hands out synthetic addresses per name and remembers them. After a restart, the guest still has cached addresses that the new wb-netd doesn’t know, so those connections are reset until the guest looks the names up again. This fails closed without special handling, and wb status should show it.
Why the host doesn’t trust the guest’s version. wb-guestd runs as root in the guest, and guest root is the adversary (T00-indexT00-indexboundary 6 is the host terminal stream.). A forged version can make the host refuse to talk, which only hurts the guest. It can never make the host accept a message it would otherwise reject, because the host validates each message the same way whatever the version.
Glossary
- Supervisor: the process that starts other processes and restarts them when they exit.
- launchd and LaunchAgent: the macOS service manager, and its per-user job definition. It keeps
wb-hostdrunning. - Saved state: a snapshot of a running VM’s memory and devices on disk, which restores the VM where it left off.
- Descriptor: a handle to an open socket or file that one process can pass to another (
SCM_RIGHTSon Unix). - Version skew: two parts of the system running different versions that must still talk to each other.
- Backoff: waiting longer after each failed restart, so a crash loop doesn’t use the whole CPU.