Folders are shared and withdrawn while the machine runs

Synod’s machine boots with no folder. Every folder, the first included, arrives through one path, Machine::mount, and leaves through Machine::unmount, while the machine runs. A withdrawal is certified in the guest by a non-lazy umount2 before the host takes the folder away. A change that cannot be confirmed ends the machine. Each sharing is accounted separately, and the agent learns of changes through a typed harness preface, kept apart from the human’s text.

Amends windows-runs-openvmm (the folder is no longer a boot-time device, and its RPC surface grows) and boot-contract-is-versioned (CONTRACT 5).

Context

Synod shared one folder, fixed at boot: MachineSpec { folder, read_only } became a virtio-fs device whose tag the guest read from ral.workspace and mounted at /work. Adding a folder meant starting again; there was no way to take one back.

Taking a folder back from a running machine raises two questions that a boot-time folder never did:

  • Who might still hold it? The guest’s engines and the commands they detach can hold a directory, a descriptor or a mapping inside it.
  • What does the hypervisor prove? OpenVMM answers RemoveVpciDevice only after the device’s units are gone. Virtualization.framework (VZ) offers a settable share on the running VZVirtioFileSystemDevice, with no completion and no documented semantics for a running guest.

Decision

Laws

  1. One mount path. MachineSpec, MachineFiles.folder, Boot.workspace, ral.workspace and layout::WORKSPACE_NAME are gone. Hypervisor::boot(&self) takes nothing. vm_manager::Share { folder, read_only } is a request to Machine::mount(name, &share), and Share::resolve is the old folder judgement.
  2. Changes are ordered, and uncertainty ends the machine.
    • Expose on the host, then mount in the guest. Certify the guest’s unmount, then withdraw on the host. Report success only after both.
    • A definite refusal leaves the sharing as it was, rollback included.
    • An exposure or withdrawal that may or may not have happened, a passed deadline, a malformed or unexpected reply, or a failed host withdrawal ends the machine at once. The refusal is Ended { why, stop: StopEvidence }, of MountError or UnmountError, and every later call on that machine returns the same refusal.
    • There is no watchdog.
  3. Fence the producers; let the kernel certify.
    • Host: exarch::host::Host::try_hold succeeds only while no agent is taking up an item. While the Hold lives, no agent takes up an item: no exchange or command runs and no engine is dialled. An open job stays open and may settle.
    • Guest engines live in the cgroup /sys/fs/cgroup/ral-engine, beside ral-exec. Maintenance freezes it. An engine spawned during a frozen window joins it before exec and stops there until the thaw.
    • The certificate is umount2(/work/<name>, 0). It succeeds only if nothing in the mount namespace references the mount. MNT_DETACH is never used.
    • It covers the whole guest, because the guest has one mount namespace: jailed children run unprivileged with no_new_privs, user namespaces are off, and engines never unshare CLONE_NEWNS.
    • Engines never pin a folder: their working directory is /work.
    • The freeze and kill waits are bounded (2 s and 5 s). FROZEN_BUDGET (10 s), under the engine liveness deadline (25 s), is checked once, after the in-window syncfs and before umount2; that flush, the unmount and the holder scan may overrun it. Nothing in the guest ends the window early: the host’s REQUEST_PATIENCE (60 s) bounds the request, and its expiry ends the machine. Liveness is never suspended and no reply is manufactured, so a window that outlasts the liveness deadline reads as the engines’ loss.
  4. Names, roots and tags.
    • A folder name (guest_abi::mounts::FolderName) is one path component: 1–255 bytes of UTF-8, not . or .., no / and no control character. It is unique among live folders.
    • A new root may not equal, contain or lie inside a live root (Grant::clear_of, compared under every spelling), and every root passes Grant::open. This rule is load-bearing for authority: no component of a new root’s path is then writable by the guest when the hypervisor opens it by path, so the guest cannot redirect a hot-add with a symlink.
    • Tags are internal to vm-manager and never reach a product type.
  5. /work is a read-only directory of folders. A tmpfs at /run/ral/work (mode 0755), under the root-only /run/ral (0700), is bound onto /work and remounted RDONLY | NOSUID | NODEV; propagation is private. PID 1 makes mountpoints through the writable alias. A write to /work itself fails with EROFS.
  6. One account per tenure. A tenure is one sharing, from addition to withdrawal, with a stable id. A writable tenure settles its baseline before exposure, is walked after each certified job settlement, and takes one closing walk after a successful withdrawal. A read-only tenure keeps no account. A failed walk is an unavailable account, never an empty one; an uncertain withdrawal records no closing account.
  7. One ordered ingress. Human messages and folder changes enter one FIFO in Synod. Messages ahead of the first pending change go to the root’s mailbox. The rest wait behind it until the root’s work has settled and been certified, its accounts walked, and Host::try_hold granted. Stop and recall withdraw the mailbox’s messages, then the held ones; folder changes stay queued.
  8. The filesystem is the authority; the preface is a courtesy. Only a human gesture in Synod’s window changes folders; no path open to the agent does. When the shared map name → (root, access) differs from what the agent was told, a harness preface rides the next human message, separate from its text.

Transports

macOS VZWindows OpenVMM
BootMAX_FOLDERS (8) virtio-fs devices tagged s0…s7, each on the idle share: a read-only share of <session>/idle/, holding one empty file named by the boot’s idle mark (128 bits from getentropy, 32 hex digits)No virtio-fs device
ExposeTake a free slot k; on the machine’s queue, setShare on device k to the folderAddVpciDevice with a virtio-fs device: tag s{n}, root in Windows’ plain spelling, metadata or metadata;ro, instance id instance_id(n)
Evidence of exposureThe guest’s staged mount does not show the markThe tag arrives and mounts
WithdrawsetShare on slot k back to the idle shareRemoveVpciDevice { instance_id(n) }
Evidence of withdrawalA fresh guest mount of s{k} does show the mark (Vacated)The answer, sent only after the device’s units are removed
WithdrawnVacatedRemoved
endCommand::Force on the worker: Confirmed only on the Stopped state or a nil-error stop completion within STOP_GRACE; the worker then endsA checked kill of the job (or an observed exit) is Confirmed
  • Devices and tags. Exposure::Device is the backend’s own name for a device: a u32 index on OpenVMM, a usize slot on VZ. Exposure::tag maps it to the guest’s tag through shares::numbered (s<n>), the one total tag constructor; no tag is parsed back into a device.
  • VZ slots are reused only after Vacated has shown them idle. The host frees a slot when its withdrawal is applied, and Shares ends the machine unless the following Vacated confirms it, so a free slot is always an idle one.
  • The mark is staged privately (below), so no unprivileged guest process can learn it or plant it in a writable folder to fake a Vacated.
  • OpenVMM never reuses a tag or an instance id within a machine. instance_id(n) fills exactly the bits WHP builds its device id from (data2 << 16 | data3 & 0xfff8), so distinct n < 2²⁹ never collide; the id space is DEVICES = 1 << 29.
  • Neither hypervisor bounds its half, so PLUG_PATIENCE (15 s, shares.rs) is ours, client-side, on both backends.
    • OpenVMM ignores deadlines on these calls. A Status answer changed nothing (Outcome::Refused); I/O failure, timeout or a malformed answer is Outcome::Unknown, which is terminal.
    • VZ: it bounds every wait on the machine thread: share, unshare, force, and the stop on shutdown or drop. An unanswered share or unshare is Outcome::Unknown; an unanswered force is Unconfirmed. A compile-time check keeps it above twice STOP_GRACE.
  • One process and disk, two stops. On Windows, Devices owns the boot’s RPC client and live: Option<(Vmm, SessionDisk)>. Devices::end takes them when a sharing change ends the machine; Guest::stop reaches them through Shares::exposure(). Whichever stop comes first takes them, the process before its disk. Shutting down a machine a sharing change has already ended is Ok(()) on both backends.

The mounts wire

  • Port: guest_abi::ports::MOUNTS = 1733. PID 1 binds it before it dials control; the ral-mounts thread accepts host peers only and serves one connection’s requests in order. The host dials it once, at the end of boot, so Booted implies the wire. A failed dial is Error::MountsUndialled, a fault in the machine’s socket transport, since the guest listens on MOUNTS before it dials control. An image built at an older contract refuses the boot line and never dials control; that is Undialled or EndedBeforeDial, whose wording (stale_image) names the rebuild.
  • Framing: guest_abi::packet, at most link::MTU bytes per frame. The host allows REQUEST_PATIENCE (60 s) for a request and its reply together, which covers the bulk flush, the frozen budget and arrival. Each read and write re-arms the socket timeout to what is left. XNU refuses that setsockopt with EINVAL once the peer has hung up, even with its reply still buffered; no I/O on such a socket can block, so on macOS Timed reads that refusal as success, and the read then drains the reply or reports EOF.
  • Encoding (guest_abi::mounts): little-endian; a kind byte from 0 (Mount, Unmount, Vacated; Done, Busy, Failed, InDoubt), then the fields in order. A bool or Survivors is one byte; Option<Mark> is a presence byte, then the mark; text is a u16 length and UTF-8. Text over MAX_TEXT (1024 bytes) is cut at a character boundary and marked … when sent; oversize text received is refused. Decoding refuses bad discriminants, short input, trailing bytes and invalid UTF-8, naming the field and byte offset.

Mount { tag, name, read_only, idle }:

  1. The name must not be live. Wait up to 10 s for tag in /sys/fs/virtiofs/*/tag.
  2. Mount the tag at the root-only stage /run/ral/stage, NOSUID | NODEV, plus RDONLY for a read-only folder.
  3. With idle (VZ), the staged root must not hold the mark; if it does, unstage and answer Failed (“the hypervisor did not apply the share”).
  4. Make /run/ral/work/<name> and move the stage onto /work/<name> (MS_MOVE); the flags travel with it.
  5. statfs every other live folder; then Done.

Unmount { name, survivors }:

  1. syncfs the folder before any freeze; an error is Failed.
  2. Under the fleet lock, and only while the fleet is open, write 1 to ral-engine/cgroup.freeze; wait up to 2 s for frozen 1.
  3. Under Survivors::Stop, write 1 to ral-exec/cgroup.kill and wait up to 5 s for populated 0.
  4. syncfs again. Only now is FROZEN_BUDGET checked: if the engines have been frozen past it, thaw and answer Failed.
  5. umount2(…, 0):
    • ok: remove the mountpoint, then Done;
    • EBUSY: while still frozen, scan /proc/*/{cwd,root,fd} for holders.
      • A holder outside ral-exec, such as an engine, gives Failed, naming every such holder and marking engines; engines are never stopped to free a folder.
      • Otherwise, with no detached command running, Failed says a memory mapping may hold it.
      • Otherwise Busy, whose text is only the list of detached commands, each with what it holds if the scan found it. Synod frames that list once, in its own words;
    • anything else: InDoubt.
  6. Thaw on every path. A failed thaw is InDoubt.

Vacated { tag, idle } (VZ, after every host withdrawal, rollbacks included): stage the tag read-only. The mark present: unstage, statfs the other live folders, Done. Absent, or any failure: InDoubt.

InDoubt is terminal: PID 1 replies, then powers the machine off. Halt closes the fleet under its lock, then thaws, so no freeze can follow; it kills ral-engine beside ral-exec.

How the host reads a reply (vm-manager/src/shares.rs):

ReplyMountUnmountVacated
Donelivewithdraw on the host (VZ: then Vacated), then Ok(Withdrawn)slot free
BusyEndedUnmountError::Busy under Spare; Ended under StopEnded
Failedwithdraw on the host (VZ: then Vacated), then Refused(MountRefused)Refused(UnmountRefused)Ended
InDoubt, deadline, EOF, malformedEndedEndedEnded

Before anything changes, Shares::mount refuses a root that does not resolve, then a name already live (MountRefused, naming the resolved root), then a ninth folder (TooManyFolders); Shares::unmount refuses an unknown name (UnmountRefused).

Exarch: the hold, the gate and the preface

  • The barrier (exarch/src/bus/barrier.rs) is one atomic counter: the leases out, or HELD. AgentMailbox::next takes a lease for every item it takes up (inputs, commands and Gone alike) and keeps it in the cell until the owner next calls next. Host::try_hold succeeds only at zero and never blocks; dropping the Hold releases it. While held, an admissible item waits: the agent neither takes it up, settles nor idles out. Parked owners see the release at their next PARK_POLL (100 ms); waking them on drop would need the registry, which sits above bus.
  • Host::revoke(root) -> Result<Gate, Ended> withdraws a gated root’s unused release: Revoked if one was pending, Shut if none was. It answers Busy, changing nothing, only while an input that may open a job is in hand or a job is open; a Command or Gone taken up does not make it Busy.
  • Transient::ExchangeEnded is emitted by the owner after each exchange, however it ended.
  • Prefaces: Port::submit(agent, text, preface) and Input::Human { text, preface }. Post, Transcript::UserPrompt and Transcript::Steering carry an optional preface, omitted from JSON when absent. The model reads it wrapped in the harness reminder, a blank line, then the human’s text; no human projection shows it. The mailbox’s run grouping (Part, Group) carries a run’s preface in its head, so only a run’s head is prefaced, by type, and prefaces never coalesce across runs. Agent::deliberate takes an arrival::Prompt, which carries it.

Synod

  • Start: every chosen folder is judged and named before boot; more than MAX_FOLDERS is refused. Writable baselines walk beside the boot. Once the guest runs, each folder is admitted through the hot-add path; any refusal ends the start, reported as FolderChanged { request: None, outcome } with the same confirmed or unconfirmed ending as a later change. Ready follows only once all are shared.
  • The gate (assistant/gate.rs) tracks the root’s release as Shut, Open or Taken; only Control::JobOpened marks it Taken. A change at the head of the queue lets messages already in the mailbox go first, and waits for a taken release’s job to settle and be certified. An open release is revoked; any answer but Revoked is retried at the next poll. Then the gate takes the hold and makes the change.
  • A change is prepared, then made. Seat::ready needs no hold: it counts, opens and clears the root, refuses one a vacated tenure may still reach, mints its name and walks a writable folder’s baseline. Seat::change runs under the hold and only exposes or withdraws. A prepared change is kept while the hold is refused.
  • What the agent is told: the system prompt names no folder. told starts empty, so the first human message’s preface lists every folder. It advances to the shared map only once a prefaced human message was taken up, that exchange ended, and its job’s settlement was certified. A preface attached to a recalled message is owed again.
  • The window receives Folders { tenures } and FolderChanged { request, outcome }. JobDone { job, stopped } follows the Folders that carry the job’s accounts. Each TenureDto carries its own account, Kept or Unavailable. A change is numbered by the window (RequestId, at most 2⁵³ − 1) and echoed with its outcome. When the conversation ends while the window still shows it (a failure, a folder change, the root’s death or a driver panic), every account of a folder still shared is voided (Ledger::Void, shown as Unavailable) before Folders is published again; a withdrawn folder’s closing account stands.
  • Survivors (Q2): a Busy withdrawal names the commands that may hold the folder. Withdrawing again with Stop stops every one of them, not only those named, and the Busy outcome’s message says so before anything is stopped.

Withdrawn sets the wording

  • Removed (OpenVMM): the hypervisor removed the device; nothing in the machine, its kernel included, reaches the folder.
  • Vacated (VZ): no guest process holds the folder, and a fresh mount reaches nothing. VZ gives no evidence about handles the guest kernel obtained before setShare. Synod says only that no program in the machine holds it and the machine cannot reach it afresh, and that while the machine runs, macOS gives no confirmation that it has let go of the folder completely.
  • Only a Confirmed ending completes Vacated. Synod rewords vacated tenures as revoked once a sharing change, or the start’s admission of a folder, ends the machine with Confirmed evidence. An ordinary shutdown is not such evidence, and publishes no rewording.
  • A vacated tenure fences its root (Tenure::reachable): until the machine is confirmed stopped, a root equal to, inside or around it (Grant::meets) is refused for the rest of the session, as L4 refuses a live one.
  • An ending says whether the machine was seen to stop. When it was not, Synod tells the user to treat every folder it shared as still within reach.

Decided

  • Q1: fixed slots on VZ, at most 8 folders on both platforms. One guest mount path, no shares in Boot, and siblings isolated by device. Replacing one VZMultipleDirectoryShare on every change was dropped.
  • Q2: Survivors::Stop stops every survivor (ral-exec/cgroup.kill). Neither choice can falsify revocation, whose certificate is the non-lazy unmount. They differ in whether “stop sharing” completes: a /proc scan is a snapshot that a fork, a passed descriptor, an mmap or a chdir can escape, and a missed holder leaves the folder shared against the user’s wish. Killing the cgroup leaves no exec process to miss. The cost is that unrelated survivors stop too. Engines are never killed.
  • Q4: no native spike before implementation. Where VZ’s behaviour is unknown, the design confirms the outcome through the guest, fails closed, or words its claim down.

Open

  • Q3: how strong is revocation on macOS?
    • Proven on both platforms: after a withdrawal no guest process holds the folder, and a fresh mount reaches nothing.
    • Proven only on Windows: that the guest’s kernel has lost it too.
    • Who it matters to: only a compromised guest kernel.
    • Options: (a) live withdrawal worded per platform; (b) withdrawal by restarting the machine on macOS, which loses the root engine’s state; (c) word macOS withdrawals as Removed if native acceptance shows VZ revoking held handles, resting the guarantee on undocumented behaviour.
    • Still open; (a) is in force. A macOS withdrawal reads: no program in the machine holds the folder, and the machine cannot reach it afresh; while the machine runs, macOS gives no confirmation that it has let go of the folder completely. It reads as revoked only after a Confirmed ending, and its root stays fenced until then. It never says more than is proven.

Not yet shown

No part of this has run on a real machine. Native acceptance is outstanding on macOS arm64 and on Windows 11 x64 under a standard account, after both guest media are rebuilt at contract 5:

  • boot-smoke with two to eight folders: boot empty, mount A, hold a file in A from a detached command, mount B and read A, unmount A under Spare (Busy) and under Stop, re-add A; /work and a read-only folder refuse writes with EROFS.
  • Fencing under a fork loop, an engine holding a descriptor, a dial during a frozen window, and a shutdown racing one.
  • Synod end to end: several folders, changes queued behind a streamed reply, survivor withdrawal, per-tenure accounts, prefaces, overlap refusals, and Ended with the right StopEvidence when the VMM is killed mid-request.
  • VZ: eight slots validate and boot (V1); setShare takes effect live (V2); open files in other folders survive changes (V3); whether I/O through a held descriptor fails after setShare(idle) (V4, which informs Q3 only); a reused slot shows the new folder (V5); a forced stop’s completion arrives (V6).
  • OpenVMM: arrival latency against the 10 s wait, and remove latency (O1); re-adding under a fresh id, and the Status for an unknown id (O2).

Known risk. If VZ never applies setShare to a running machine, every macOS addition is refused, the initial folders included, because they take the same path. The failure is closed and explicit. The remedy, boot-time exposure of the initial folders, would come back as a decision.

Consequences

  • CONTRACT is 5. ral.workspace is gone and ports::MOUNTS is new; media built at contract 4 is refused, so both media must be rebuilt. boot-smoke’s silent port moves to 1734.
  • vm-manager’s public boundary changed: Share, MAX_FOLDERS, MountError, UnmountError, StopEvidence, Withdrawn, and FolderName and Survivors re-exported from guest-abi, which is now an unconditional dependency. Error gains TooManyFolders, MountRefused, UnmountRefused and MountsUndialled.
  • VZ’s forced stop is observed. Its completion was discarded; a graceful stop whose force is unconfirmed now refuses.
  • The session directory holds VZ’s idle/. SessionDisk’s Drop and the sweep recognise it; an idle/ holding anything but mark files is kept.
  • Exarch gains a fleet barrier, a revocable gate, an end-of-exchange transient and prefaced human posts; no exarch frontend uses them. wrap_reminder moved, crate-private, to record/context.rs.

Amended 2026-12-01 — the host runtime. synod and exarch-gui can also run the assistant on the host (Runtime::Host): the session boots once with its opening folders, and a later change rebinds the root’s engine through Host::rebind_engine, asked under the Hold. A pending rebind wakes the held root, which serves it before taking up any item. The new engine boots under the new GrantStack, cwd and system prompt, the prompt is recorded, and only then are helpers dismissed and the old engine retired; the transcript stays. RebindMode::SpareBusy (an addition, or a withdrawal under Survivors::Spare) refuses with RebindOutcome::Busy while a worker or helper runs; DismissAll (Survivors::Stop) ends them. Failed changes nothing; LogRefused ends the root; Rebound with any teardown failure ends the conversation with StopEvidence::Unconfirmed (Law 2). Host stacks withhold ShellVerb::Detach (all but exarch’s dangerous), so a rebind reaches every command the session started. A host withdrawal never claims a Withdrawn: the rebound stack is its only proof. If that stack no longer admits reading the folder, the session can no longer reach it; if it still does (dangerous, or a profile grant covering the folder), the withdrawal says exactly that.

Where

  • guest-abi/src/mounts.rs (Tag, FolderName, Mark, Survivors, Request, Reply); ports.rs (MOUNTS); boot.rs (CONTRACT).
  • ral-guest/src/folders.rs (staging, the mark, MS_MOVE, Vacated, siblings, unmount, holders); maintenance.rs (freeze, thaw, survivors, FROZEN_BUDGET); init/mounts.rs (the ral-mounts thread); mount.rs (/run/ral, the alias, /work, cgroups); engine.rs (ENGINE_CGROUP, the pre_exec join); init/fleet.rs (while_open); init/halt.rs.
  • vm-manager/src/shares.rs (Shares, Exposure, Outcome, Timed, numbered, REQUEST_PATIENCE, PLUG_PATIENCE); machine.rs (MAX_FOLDERS, StopEvidence, Withdrawn, MountError, UnmountError, Machine::{mount, unmount}); spec.rs (Share); error.rs; lifecycle.rs (SessionDisk::idle, the sweep).
  • vm-manager/src/vz/{mod,config,queue}.rs (Slots, slot devices, set_share, force_stop).
  • vm-manager/src/openvmm/hypervisor.rs (Devices, its live process and disk); proto.rs (add_vpci_virtio_fs, remove_vpci, instance_id, DEVICES); ttrpc.rs (Method::{AddVpciDevice, RemoveVpciDevice}).
  • exarch/src/bus/barrier.rs (Barrier, Hold); bus/mailbox.rs (Gate, Input::Human, RebindMode, RebindOutcome, the rebind wake); host.rs (try_hold, revoke, rebind_engine); agent/build.rs (rebind); agent/nursery.rs (unjoined_names); record.rs (Transient::ExchangeEnded, the prefaces); record/context.rs (wrap_reminder, chat_messages); vm.rs (Guest, Folder::{clear_of, meets, mint}); policy.rs (for_workspace).
  • desktop/src/assistant/{runtime,conversation,gate,prompt}.rs (Runtime, Proof, Tenure, Ledger, Seat, the gate, preface); window/state.rs (Inlet); folder/grant.rs (admit); wire.rs (TenureDto, Withdrawal, FolderChange, FolderOutcome, RequestId).
  • synod/src/grant.rs (vm_ceiling, host_stack).

See also

windows-runs-openvmm, boot-contract-is-versioned, session-disk-outlives-its-machine, agents (the barrier and gated admission), session-record (prefaces in the record), two-enforcers (the machine is the outer ceiling), synod, desktop, agent.