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
RemoveVpciDeviceonly after the device’s units are gone. Virtualization.framework (VZ) offers a settableshareon the runningVZVirtioFileSystemDevice, with no completion and no documented semantics for a running guest.
Decision
Laws
- One mount path.
MachineSpec,MachineFiles.folder,Boot.workspace,ral.workspaceandlayout::WORKSPACE_NAMEare gone.Hypervisor::boot(&self)takes nothing.vm_manager::Share { folder, read_only }is a request toMachine::mount(name, &share), andShare::resolveis the old folder judgement. - 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 }, ofMountErrororUnmountError, and every later call on that machine returns the same refusal. - There is no watchdog.
- Fence the producers; let the kernel certify.
- Host:
exarch::host::Host::try_holdsucceeds only while no agent is taking up an item. While theHoldlives, 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, besideral-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_DETACHis 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 unshareCLONE_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-windowsyncfsand beforeumount2; that flush, the unmount and the holder scan may overrun it. Nothing in the guest ends the window early: the host’sREQUEST_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.
- Host:
- 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 passesGrant::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-managerand never reach a product type.
- A folder name (
/workis a read-only directory of folders. A tmpfs at/run/ral/work(mode0755), under the root-only/run/ral(0700), is bound onto/workand remountedRDONLY | NOSUID | NODEV; propagation is private. PID 1 makes mountpoints through the writable alias. A write to/workitself fails withEROFS.- 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.
- 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_holdgranted. Stop and recall withdraw the mailbox’s messages, then the held ones; folder changes stay queued. - 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 VZ | Windows OpenVMM | |
|---|---|---|
| Boot | MAX_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 |
| Expose | Take a free slot k; on the machine’s queue, setShare on device k to the folder | AddVpciDevice with a virtio-fs device: tag s{n}, root in Windows’ plain spelling, metadata or metadata;ro, instance id instance_id(n) |
| Evidence of exposure | The guest’s staged mount does not show the mark | The tag arrives and mounts |
| Withdraw | setShare on slot k back to the idle share | RemoveVpciDevice { instance_id(n) } |
| Evidence of withdrawal | A fresh guest mount of s{k} does show the mark (Vacated) | The answer, sent only after the device’s units are removed |
Withdrawn | Vacated | Removed |
end | Command::Force on the worker: Confirmed only on the Stopped state or a nil-error stop completion within STOP_GRACE; the worker then ends | A checked kill of the job (or an observed exit) is Confirmed |
- Devices and tags.
Exposure::Deviceis the backend’s own name for a device: au32index on OpenVMM, ausizeslot on VZ.Exposure::tagmaps it to the guest’s tag throughshares::numbered(s<n>), the one total tag constructor; no tag is parsed back into a device. - VZ slots are reused only after
Vacatedhas shown them idle. The host frees a slot when its withdrawal is applied, andSharesends the machine unless the followingVacatedconfirms 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 distinctn < 2²⁹never collide; the id space isDEVICES = 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
Statusanswer changed nothing (Outcome::Refused); I/O failure, timeout or a malformed answer isOutcome::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 isUnconfirmed. A compile-time check keeps it above twiceSTOP_GRACE.
- OpenVMM ignores deadlines on these calls. A
- One process and disk, two stops. On Windows,
Devicesowns the boot’s RPC client andlive: Option<(Vmm, SessionDisk)>.Devices::endtakes them when a sharing change ends the machine;Guest::stopreaches them throughShares::exposure(). Whichever stop comes first takes them, the process before its disk. Shutting down a machine a sharing change has already ended isOk(())on both backends.
The mounts wire
- Port:
guest_abi::ports::MOUNTS= 1733. PID 1 binds it before it dials control; theral-mountsthread accepts host peers only and serves one connection’s requests in order. The host dials it once, at the end of boot, soBootedimplies the wire. A failed dial isError::MountsUndialled, a fault in the machine’s socket transport, since the guest listens onMOUNTSbefore it dials control. An image built at an older contract refuses the boot line and never dials control; that isUndialledorEndedBeforeDial, whose wording (stale_image) names the rebuild. - Framing:
guest_abi::packet, at mostlink::MTUbytes per frame. The host allowsREQUEST_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 thatsetsockoptwithEINVALonce the peer has hung up, even with its reply still buffered; no I/O on such a socket can block, so on macOSTimedreads 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 orSurvivorsis one byte;Option<Mark>is a presence byte, then the mark; text is au16length and UTF-8. Text overMAX_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 }:
- The name must not be live. Wait up to 10 s for
tagin/sys/fs/virtiofs/*/tag. - Mount the tag at the root-only stage
/run/ral/stage,NOSUID | NODEV, plusRDONLYfor a read-only folder. - With
idle(VZ), the staged root must not hold the mark; if it does, unstage and answerFailed(“the hypervisor did not apply the share”). - Make
/run/ral/work/<name>and move the stage onto/work/<name>(MS_MOVE); the flags travel with it. statfsevery other live folder; thenDone.
Unmount { name, survivors }:
syncfsthe folder before any freeze; an error isFailed.- Under the fleet lock, and only while the fleet is open, write
1toral-engine/cgroup.freeze; wait up to 2 s forfrozen 1. - Under
Survivors::Stop, write1toral-exec/cgroup.killand wait up to 5 s forpopulated 0. syncfsagain. Only now isFROZEN_BUDGETchecked: if the engines have been frozen past it, thaw and answerFailed.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, givesFailed, naming every such holder and marking engines; engines are never stopped to free a folder. - Otherwise, with no detached command running,
Failedsays 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;
- A holder outside
- anything else:
InDoubt.
- ok: remove the mountpoint, then
- 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):
| Reply | Mount | Unmount | Vacated |
|---|---|---|---|
Done | live | withdraw on the host (VZ: then Vacated), then Ok(Withdrawn) | slot free |
Busy | Ended | UnmountError::Busy under Spare; Ended under Stop | Ended |
Failed | withdraw on the host (VZ: then Vacated), then Refused(MountRefused) | Refused(UnmountRefused) | Ended |
InDoubt, deadline, EOF, malformed | Ended | Ended | Ended |
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, orHELD.AgentMailbox::nexttakes a lease for every item it takes up (inputs, commands andGonealike) and keeps it in the cell until the owner next callsnext.Host::try_holdsucceeds only at zero and never blocks; dropping theHoldreleases it. While held, an admissible item waits: the agent neither takes it up, settles nor idles out. Parked owners see the release at their nextPARK_POLL(100 ms); waking them on drop would need the registry, which sits abovebus. Host::revoke(root) -> Result<Gate, Ended>withdraws a gated root’s unused release:Revokedif one was pending,Shutif none was. It answersBusy, changing nothing, only while an input that may open a job is in hand or a job is open; aCommandorGonetaken up does not make itBusy.Transient::ExchangeEndedis emitted by the owner after each exchange, however it ended.- Prefaces:
Port::submit(agent, text, preface)andInput::Human { text, preface }.Post,Transcript::UserPromptandTranscript::Steeringcarry an optionalpreface, 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::deliberatetakes anarrival::Prompt, which carries it.
Synod
- Start: every chosen folder is judged and named before boot; more than
MAX_FOLDERSis 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 asFolderChanged { 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 asShut,OpenorTaken; onlyControl::JobOpenedmarks itTaken. 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 butRevokedis retried at the next poll. Then the gate takes the hold and makes the change. - A change is prepared, then made.
Seat::readyneeds 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::changeruns 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.
toldstarts 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 }andFolderChanged { request, outcome }.JobDone { job, stopped }follows theFoldersthat carry the job’s accounts. EachTenureDtocarries its ownaccount,KeptorUnavailable. 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 asUnavailable) beforeFoldersis published again; a withdrawn folder’s closing account stands. - Survivors (Q2): a
Busywithdrawal names the commands that may hold the folder. Withdrawing again withStopstops every one of them, not only those named, and theBusyoutcome’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 beforesetShare. 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
Confirmedending completesVacated. Synod rewords vacated tenures as revoked once a sharing change, or the start’s admission of a folder, ends the machine withConfirmedevidence. 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 oneVZMultipleDirectoryShareon every change was dropped. - Q2:
Survivors::Stopstops 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/procscan is a snapshot that a fork, a passed descriptor, anmmapor achdircan 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
Removedif 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
Confirmedending, 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-smokewith two to eight folders: boot empty, mount A, hold a file in A from a detached command, mount B and read A, unmount A underSpare(Busy) and underStop, re-add A;/workand a read-only folder refuse writes withEROFS.- 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
Endedwith the rightStopEvidencewhen the VMM is killed mid-request. - VZ: eight slots validate and boot (V1);
setSharetakes effect live (V2); open files in other folders survive changes (V3); whether I/O through a held descriptor fails aftersetShare(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
Statusfor 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
CONTRACTis 5.ral.workspaceis gone andports::MOUNTSis 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, andFolderNameandSurvivorsre-exported fromguest-abi, which is now an unconditional dependency.ErrorgainsTooManyFolders,MountRefused,UnmountRefusedandMountsUndialled.- 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’sDropand the sweep recognise it; anidle/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_remindermoved, crate-private, torecord/context.rs.
Amended 2026-12-01 — the host runtime.
synodandexarch-guican 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 throughHost::rebind_engine, asked under theHold. A pending rebind wakes the held root, which serves it before taking up any item. The new engine boots under the newGrantStack, 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 underSurvivors::Spare) refuses withRebindOutcome::Busywhile a worker or helper runs;DismissAll(Survivors::Stop) ends them.Failedchanges nothing;LogRefusedends the root;Reboundwith any teardown failure ends the conversation withStopEvidence::Unconfirmed(Law 2). Host stacks withholdShellVerb::Detach(all but exarch’sdangerous), so a rebind reaches every command the session started. A host withdrawal never claims aWithdrawn: 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(theral-mountsthread);mount.rs(/run/ral, the alias,/work,cgroups);engine.rs(ENGINE_CGROUP, thepre_execjoin);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, itsliveprocess 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.