Skip to content

S04-08 - Records, Versions and Bounds

Purpose: The records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs.

wb-netd and wb-proxyd send wb-hostd two kinds of record, on inherited sockets of type SOCK_SEQPACKET or SOCK_DGRAM. macOS uses SOCK_DGRAM (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…, “Descriptor channels”), a socket per kind.

wb-hostd treats these as a crash of the process that sent them: a malformed record, an oversized record, and one received with MSG_TRUNC (accounting-record-malformed). It ends that process, and counts the exit toward the restart limit. wb-hostd sends nothing on these sockets after its version record. A record or refused message from it after that ends wb-netd’s accounting channel, logged with control-message-refused, and later writes fail.

Accounting records carry the counts and the name mapping of S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages. (“What a restart keeps”, “The kept name mapping”):

  • each wildcard budget debit (WildcardDebit);
  • each new or renewed MappingEntry, with its name and address;
  • each release (MappingRelease).

From wb-proxyd they carry each ProxydWildcardName, which wb-hostd keeps in memory per VM and active period and gives back in ProxydStart (S07-06-name-mappingS07-06-name-mapping: Name MappingHow wb-proxyd keeps its own checked copy of the names wb-netd gave synthetic addresses: name reports, releases, replay, lifetime, the second count of the wildcard budget, and the copy wb-hostd keeps.). They also carry the Go clock’s accepted calibration point, each new verified tree head, and a go-sumdb-inconsistent finding. wb-hostd checks each of those, stamps it with its receipt time, keeps it in state.db, and passes it back at start (S07-13-publish-timeS07-13-publish-time: Publish TimeWhere the dependency gate gets each version's publish time, and how it builds a clock for Go modules from the checksum database., “Persisted state”).

They aren’t audit events. Nothing rate-limits, suppresses or drops them, with one exception: the read after wb-netd exits is bounded, and records past the bound are refused unread (S07-06-name-mappingS07-06-name-mapping: Name MappingHow wb-proxyd keeps its own checked copy of the names wb-netd gave synthetic addresses: name reports, releases, replay, lifetime, the second count of the wildcard budget, and the copy wb-hostd keeps., “Kept by wb-hostd”).

wb-netd derives the names from guest queries. So wb-hostd checks each entry before it keeps it:

An entry that fails a check here or in S07-06-name-mappingS07-06-name-mapping: Name MappingHow wb-proxyd keeps its own checked copy of the names wb-netd gave synthetic addresses: name reports, releases, replay, lifetime, the second count of the wildcard budget, and the copy wb-hostd keeps. (“Kept by wb-hostd”) is logged with mapping-entry-invalid, rate-limited. It ends the wb-netd that sent it, as a malformed record does. So wb-netd never runs on with a mapping that differs from wb-hostd’s.

wb-hostd stamps each entry with its own receipt time. It never uses a time from wb-netd.

Placeholder records carry a VM, a binding, and one placeholder that wb-proxyd generated (S09-05-credentialsS09-05-credentials: CredentialsHow credentials are stored and bound to requests, and how the model credential reaches the model API without entering the guest., “Model credential”).

At a session start that needs a binding with a placeholder:

  1. wb-hostd asks wb-proxyd for the VM’s placeholder on its control channel.
  2. wb-proxyd fetches the binding, and generates a placeholder if the VM has none for it.
  3. wb-proxyd replies with a placeholder record on the same control channel, not on the one-way accounting socket. The record has the size limit and fixed format of the records above.
  4. The session start waits for that reply before wb-guestd starts claude (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., “Claude Code in the guest”). It waits as it does for a locked secret store (S15-least-privilegeS15-least-privilege: Least Privilege on the HostThe security design for SEC12-least-privilege: which rights Wraith Box takes on the host, where credentials are held, and how each host process gets only the credentials it needs, for only as long as it needs them.).

wb-proxyd also sends a record on the control channel for each placeholder it draws after a failed check.

wb-hostd checks the form of each record before it keeps the placeholder or puts it in a guest’s environment:

  • letters, digits and - only;
  • 32 to 256 characters;
  • at most 8 kept per binding per VM, with the oldest dropped past that.

A record that fails the check is a malformed record. wb-hostd ends wb-proxyd, and counts the exit toward the restart limit. It refuses the waiting session start with the rule placeholder-record-invalid.

Event records carry what goes to the audit log (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.). Each has a sequence number: 1 for the first on its channel, and one more than the last after that. A gap or a repeat ends the sender with event-record-invalid. A restarted wb-netd or wb-proxyd gets a new channel, and its sequence starts again at 1 (S07-21-vm-endS07-21-vm-end: A VM's End in wb-proxydHow wb-hostd ends a VM's hand-off sockets in the one wb-proxyd, and how the VM's last event records reach its stop record without one VM's stop or backlog taking the other VM's network down.).

An event write can block for more than 100 ms, or fail without blocking (ENOBUFS or EAGAIN on a SOCK_DGRAM socket). Then, with the rule event-channel-blocked, wb-netd refuses new lookups and connections, and wb-proxyd new streams and requests. It keeps the record and retries it until a write succeeds, so no event is lost. So a slow or hung wb-hostd makes the VM’s network refuse, not run without records. A full queue stalls guest input (S09-13-event-sendersS09-13-event-senders: Event SendersHow wb-hostd tells the senders of event records about the audit budgets, what it holds back, and when it stops a VM for its records., “The hold”).

Every host program comes from one bundle with one build version. Every build task sets it in the Go and the Swift code alike, the dev build and CI included (S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps.). wb is linked from that bundle as well.

  • The version includes the VCS revision, and marks a modified working tree.
  • Only a bare toolchain build (go build, go run, swift build) is unstamped. It has no version, and two unstamped builds refuse each other. Versions match only when they are equal as bytes.

The first message on every host connection, gRPC or not, is the sender’s version record (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.). A peer of another build version is refused, and the connection closed. Both versions are logged, and the installed bundle is checked (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Upgrades”). So there are no compatibility rules between host processes.

  • When wb-hostd refuses wb, wb prints a wraith box: line that names both versions, and exits with 255.
  • When wb-hostd exits because the bundle was replaced, the line says that Wraith Box is restarting after an upgrade, and to run the command again.

Each package name ends in its major version (wraithbox.<area>.v1). A change that an older peer can’t read is a new major package next to the old one, never an edit of the old one (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".).

After the host opens a connection, the first message from wb-guestd gives its build version, and the major version of each package it serves.

In V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there., wb-hostd accepts only its own build version:

The package list is refused unless it holds at most 16 names of at most 64 bytes, each wraithbox.<lowercase letters>.v<number>, and equals the host’s own list. The host uses it only to refuse.

A wb-guestd that reports another version is refused before any session request. wb-hostd logs both versions. A session start in that VM is refused with a message that names both versions (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). It says to stop and start the VM, and to rebuild the image with wb image build if that doesn’t help.

wb-guestd runs as root in the guest, which T00-indexT00-indexboundary 6 is the host terminal stream. takes as the adversary. The version string is checked against a fixed form first:

  • printable ASCII, at most 64 bytes;
  • MAJOR.MINOR.PATCH, with an optional - prerelease part and + build part of letters, digits, dots and hyphens.

Any other string is refused with the rule guest-version-form. Wherever the string is shown, in a log record or in wb’s message, it is escaped and cut to 64 bytes.

The host uses the reported version only to refuse. It never uses it to allow something, or to pick how a message is parsed. Each message gets the same checks whatever the version (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. caps each VM, and also the host work each VM can cause. Every host handler that takes input from a guest has:

  • a per-VM rate limit;
  • a size limit on each input;
  • a bound on the work it runs at once.

A request over a limit is refused or dropped, never queued without bound, and logged with the limit’s rule. For the refusal classes that S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections., “Events and rate limits”, aggregates, a run of refusals is logged as one record with its count. A new handler gets its limits before it merges.

Guest input Process Limits Where
Host-guest socket connections wb-vmd, wb-hostd connections opened whose copy wb-vmd hasn’t closed, a passed one until wb-hostd acknowledges it or 5 s pass, connections per VM and per project, reconnects per minute 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., “The VM provider passes descriptors, not bytes”, 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., “Reconnect”
RPCs from wb-guestd, with the guest requests multiplexed on them wb-hostd, wb-guestd message size and streams per connection, set on whichever side wb-hostd is, client or server, and never left at the library default, requests per second per VM, entries in the reconnect session list, and for a debug shell 64 KiB per received message, 64 shells per VM and 16 frames after the shell’s last one. An agent session has 64 KiB per received message, 64 sessions and shells per VM, 16 messages after a failure, 7 minutes from the hangup to the report and 10 seconds for the ack. Its start is sent in at most 1 MiB + 64 KiB. wb-guestd takes a start of that size and no other message over 64 KiB, and refuses and logs a larger one with guestd-recv-size values in code, 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., “Reconnect”, 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., “Debug shells in V1-M2-walking-skeletonV1-M2-walking-skeleton: Walking skeletonwb-vmd boots a fixture VM bundle in its confined process, wb-guestd answers over vsock, a data disk made on the host holds the homes, and wb shell opens a PTY as a project user, with its output through the terminal fi…”, 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.
The version wb-guestd reports wb-hostd 64 bytes, fixed form “Version skew”
The package list wb-guestd reports wb-hostd 16 names of at most 64 bytes, fixed form, refused with guest-packages-form, or guest-packages-mismatch when it isn’t the host’s own “With wb-guestd”
Ethernet frames, DHCP and DNS wb-netd per-VM caps, query rate, name length, wildcard budget, synthetic pool S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections.
Held DNS queries wb-netd 1,024 held queries per VM by default (configuration), each sent after 4 seconds, over the cap dropped with dns-hold-full S07-04-dns-refusalsS07-04-dns-refusals: DNS RefusalsHow wb-netd refuses a name: approval events, the hold before each refusal, quiet refusals, and the answer that is the same for every reason., “Hold limits”
Connections and streams wb-netd, wb-proxyd connections in flight, stream resets and refusals per rule, and on an inspected HTTP/1.1 stream: one upstream connection, deadlines for a request head, between requests, per pause in a request or response body, per write and for a response head, 1 ms for the read of the kept connection before a later request, a 1 MiB cap on a response head and at most 16 interim responses 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., S07-15-non-http-streamsS07-15-non-http-streams: Non-HTTP StreamsHow wb-proxyd checks the protocol of each stream, and what it does with SSH, other protocols and raw TCP. (“HTTP/1.1 connections”)
Dependency gate clock lookups to sum.golang.org wb-proxyd “Clock lookup limits”, below S07-12-dependency-gateS07-12-dependency-gate: Dependency GateHow wb-proxyd keeps young and vulnerable package versions from the guest on the gated registries., S07-13-publish-timeS07-13-publish-time: Publish TimeWhere the dependency gate gets each version's publish time, and how it builds a clock for Go modules from the checksum database.
Placeholder scan of requests on inspected hosts wb-proxyd a 64 KiB cap on the request head (http-header-size); per request, a held-back window three times the length of the VM’s longest placeholder, at most 768 bytes with the 256-character cap; at most 8 placeholders per binding per VM S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones. (“Request form”, “Header cap”), S07-09-placeholder-bindingS07-09-placeholder-binding: Placeholder BindingWhere a credential placeholder may go in a request, how wb-proxyd scans for it, and what it refuses. (“Bounds”)
Upstream name resolution wb-proxyd one lookup per stream, so bounded by the connections in flight 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.
Leaf certificates wb-proxyd a leaf only for a name the VM resolved, cached per VM, CA and name, so at most the allowlisted names plus the wildcard budget 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.
Pushes and fetches wb-hostd, wb-git the pack scanner’s caps, git’s memory limit, deadlines, one push per project at a time S08-04-push-checksS08-04-push-checks: Push ChecksThe checks that bound the memory and work of a push before git unpacks it: git's allocation limit, the pack scanner, and the pre-receive check., “Pack scanner”, and S08-05-push-limitsS08-05-push-limits: Push LimitsCleanup after a push that failed, the size cap of landing.git, and the time and memory bounds of the git gateway., “Bounds”
Leftover-process results wb-hostd “Leftover-process limits”, below 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., 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. (“Reconnect”) and 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. (“Deadlines”)
Recovery pushes wb-hostd, wb-git one per lost session, to its own branch only, under the same limits as other pushes 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., “Recovery”
Approval requests wb-netd, wb-hostd, wb-prover 16 pending requests and 10 new requests a minute per VM, one open request per name, prover runs at once S09-10-approval-flowS09-10-approval-flow: Approval FlowHow an approval request for a name behaves, from the lookup that raises it to its answer or its expiry., and S09-09-approvalsS09-09-approvals: ApprovalsWhat an approval adds, the checks that each request goes through, and approvals for a joining project.
Native notifications wb-hostd and the notification helper one per pending approval request, one per daemon outage S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Restarting a daemon”, and S09-09-approvalsS09-09-approvals: ApprovalsWhat an approval adds, the checks that each request goes through, and approvals for a joining project.
Audit events wb-hostd a budget per class and per VM, refusals of new work instead of lost records, a byte budget per VM per day, a cap of 4096 records the audit writer holds, queued or not yet synced, and no read of an event channel while the writer holds its cap. While a VM is over a budget, each sender’s records of it are counted on their own, and a sender that passes the margin of 8192 records a minute, or over the byte budget also 32 MiB of log lines a day, has the VM stopped with event-budget-ignored. After that decision the VM’s wb-netd channel is held until its stop begins, and wb-proxyd’s records of the VM are late. So the writer holds at most the cap, plus one record per channel, plus one stop allowance for each stop read in progress. Once a VM’s stop begins, its wb-netd channel is read past the hold for at most 8192 records, one sender queue and as many again for the socket’s buffer. wb-proxyd’s channel is read the same way up to the record its end names, with room for the records the closes of every VM’s sockets may queue past the cap (S07-21-vm-endS07-21-vm-end: A VM's End in wb-proxydHow wb-hostd ends a VM's hand-off sockets in the one wb-proxyd, and how the VM's last event records reach its stop record without one VM's stop or backlog taking the other VM's network down.). The records past that are left unread, logged with event-stop-allowance. Late wb-proxyd records of a VM whose events ended, or whose stop is decided, are written up to 8192 per end of its slot, and dropped past that with event-vm-ended, their count written as one record. These are the two exceptions to no lost record S09-13-event-sendersS09-13-event-senders: Event SendersHow wb-hostd tells the senders of event records about the audit budgets, what it holds back, and when it stops a VM for its records.
Accounting and event records wb-hostd 4 KiB per record, fixed format, a malformed record ends the sender, and the read of an accounting channel after wb-netd exits is bounded at more records than its socket’s buffer holds “Accounting and event channels”
Daemon log lines wb-hostd 100 lines per second per process, 4 KiB per line “Logs and health”

The dependency gate’s clock lookups to sum.golang.org, in wb-proxyd:

  • In flight: 4 requests per VM, lookups and their tile fetches. 8 requests per wb-proxyd, with one kept for the timer’s calibration and its tiles.
  • Rate and queue: 6,000 uncached lookups a minute per VM, and a queue of 2,000 per VM. Requests are served first in, first out.
  • Time: one retry, and 10 s per upstream request. A deadline per request of 42 s, plus 125 ms per uncached lookup and per lookup queued ahead, counted at admission, and at most 5 minutes.
  • Size: 2,000 versions per @v/list. 100,000 cached records and 16 MiB of cached tiles per VM. 1 MiB of calibration tiles.
  • Calibration runs on its own timer only.
  • Refusals: over a cap, a request is refused with go-clock-lookup-rate, go-clock-deadline or go-list-too-long.
  • Stored state: wb-hostd checks the stored heads, points and findings. It keeps at most 192 heads of 1 KiB.

Leftover-process results, in wb-hostd:

  • one per kill loop, kept until acknowledged, in a session report or a cleanup record;
  • at most one record per project user in the VM, apart from the 64 session entries;
  • accepted only on an exact kill ID that wb-hostd sent, before the kill’s 7-minute deadline. When none has arrived by then, that counts as processes left.

An image build, which the user starts, takes input from the internet through wb-download (S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet.) and Apple’s installation service:

Internet input Process Limits
Apple’s catalog, a HEAD, the manifest and its signature wb-download 4 MiB for the catalog, 1 MiB and 64 KiB for the manifest and signature, 2 minutes per request, 30 s to connect, 60 s without a byte
The restore image and the Claude Code binary wb-download the size from the catalog’s entry, at most 40 GiB, and 1 GiB; a file size limit wb-download sets on itself; 12 hours and 30 minutes; free space checked before the run
The result records wb-hostd a fixed form per field, at most 16 requests per run
Audit records of downloads wb-hostd one per request or refusal, at most 16 per run, never dropped
Apple’s signing server’s replies to the TSS requests (S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release.) Apple’s installation service, outside Wraith Box none set by Wraith Box, and not audited

wb-hostd writes its own log, and the lines the other daemons send it, to <logs>, in one file per process, apart from the audit log.

  • It writes at most 100 lines per second per process.
  • It cuts a line at 4 KiB, with a truncation marker.
  • It writes one record with the count of lines it dropped over the rate.
  • Each file is rotated at 10 MiB, and the last 5 are kept.

A daemon log isn’t the record of a decision. The audit log is (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.).

For each host process, wb-hostd keeps:

  • its state: running, waiting to restart, given up, or stopped;
  • its version, and when it started;
  • its restarts in the last 10 minutes;
  • its last exit reason: the exit code or signal.

wb status shows them. For each VM without network, it shows which process is down and why (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).

When wb can’t reach wb-hostd, wb status says so. It says to run wb setup, which installs and starts the service (S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands.).

Status: Draft