Map: synod

Synod shares the folders a person chooses with an office assistant, in a hardware VM or offline on the host, adds and withdraws them while it runs, and accounts for each folder’s changes after each job. It is a desktop product: synod::PRODUCT supplies its persona, grants and prompts. An account reads metadata, never file contents, and offers no restoration operation. Sharing and withdrawal are decided in hot-shared-folders.

The crates

One runtime agreement connects the host, guest, engine and image tools (the-vm-crates-are-layered).

  • guest-abi — dependency-free, std-only runtime constants, boot grammar, packet framing and the mounts wire.
  • ral-core — the engine, wire transport, path judgments and pure egress policy data; it depends on guest-abi.
  • exarch — provider machinery, agents, the threaded fleet host, policy loading and guest-engine construction over core and guest-abi; its default vm feature adds exarch::vm over vm-manager and netgate.
  • netgate — host CONNECT gate, TCP/IP stack and audit ledger; it depends on core and guest-abi.
  • vm-manager — machine construction, lifecycle and media; its runtime workspace dependency is guest-abi, and it has no privileged half.
  • ral-guest — binary-only Linux PID 1 over guest-abi.
  • ral-vm-image-build-tools (vm-image/build-tools/) — manifest production and checking over core and guest-abi.
  • desktop — the shared GUI shell over core, exarch, vm-manager, netgate and guest-abi.
  • synod — thin binary and library over desktop, exarch, core, vm-manager and guest-abi; exarch-gui is its sibling over desktop, exarch, core and vm-manager (exarch).

guest-abi/ and ral-guest/ — the guest

One PID 1 assembles and supervises the guest without an exec between stages.

  • guest-abi/src/{boot,ports,link,layout,packet,mounts}.rs owns the runtime agreement. boot::Net validates routing once and preserves it through private fields. Changes to boot, layout, framing, mounts, the factory port or the mounts port bump boot::CONTRACT beside its writer and reader.
  • The boot line names no folder (CONTRACT 5). mounts carries the host’s folder requests to PID 1 on ports::MOUNTS: Request::{Mount, Unmount, Vacated} and Reply::{Done, Busy, Failed, InDoubt}, over the checked Tag, FolderName and Mark. The engine path defaults because it belongs to the image.
  • ral.port and ral.net name separate host-side control and network ports: confusing them connects different protocols. Without a network, the engine receives no proxy environment for a missing peer.
  • packet is shared by host and guest without a Linux gate to prevent codec drift. Frames have no prologue and reject invalid lengths before allocation. Raw read_exact prevents read-ahead bytes being lost on descriptor handoff; framing or I/O failure ends the link because a frame boundary cannot be guessed.
  • ral-guest/src/main.rs refuses a non-init process before any side effect, ignores argv, then calls assemble::assemble and init::serve.
  • assemble/{plan,run}.rs loads modules to a fixpoint, adopts the console, probes rootfs/session disk pairs, formats the session disk, assembles the overlay, installs the engine, reclaims the initramfs and switches root. Mount primitives are shared through mount.rs.
  • Module metadata supplies a load-order hint; missing symbols can resolve after another pass, so loading repeats while it makes progress. An absent manifest permits kernels with built-in drivers; EEXIST already satisfies a requirement.
  • The host supplies the boot clock because the guest has no reliable RTC. It is set once; long sessions can drift, and further correction belongs on the protocol rather than under a second clock authority in PID 1.
  • init/serve.rs orders clock, mounts, cgroups, the read-only /work, sysctls, the mounts listener, control dial, networking, root engine, factory and the ral-mounts thread. reap::mask blocks signals before threads; children unmask before exec. engine.rs constructs one closed command/environment and hands each engine its stream unread on fd 3. Each engine joins ENGINE_CGROUP (/sys/fs/cgroup/ral-engine, beside ral-exec) first thing in pre_exec, through a cgroup.procs descriptor opened before the fork; a failed join fails the spawn.
  • mount.rs::work makes propagation private, the root-only /run/ral and its stage, and a tmpfs alias at /run/ral/work bound onto /work and remounted RDONLY | NOSUID | NODEV. /work holds only the folders’ mountpoints.
  • init/mounts.rs binds MOUNTS before the control dial and runs the ral-mounts thread, which serves the host’s requests in order and powers the guest off after an InDoubt reply. folders.rs stages a share at /run/ral/stage, checks VZ’s idle mark there, moves it onto /work/<name>, statfses the other live folders, and certifies a withdrawal with a non-lazy unmount, scanning /proc for holders on EBUSY: Busy only when every holder found is a detached command (in ral-exec), its text only the list of those commands; a holder outside it, such as an engine, gives Failed, naming it. maintenance.rs freezes ral-engine and stops ral-exec’s survivors, each wait bounded. FROZEN_BUDGET (10 s) is checked once, after the frozen syncfs and before umount2; that flush, the unmount and the holder scan may overrun it. Only the host’s REQUEST_PATIENCE (60 s) ends the window, by ending the machine.
  • Each guest engine installs core’s per-command jail: the one unprivileged GUEST_ID, cgroup budgets, NO_NEW_PRIVS, descriptor marking and seccomp, plus a private network namespace for net: `offline. sysctl.rs sets kernel.yama.ptrace_scope to 3 and user.max_user_namespaces to 0 before any engine runs, a failure ending the boot; one command may still signal another and read its read-mode /proc entries. Every command’s HOME is layout::HOME (/tmp/home), which mount.rs gives to GUEST_ID. The admitted utility and descendants have no per-grant fs/exec projection; VM mounts/topology and Unix modes remain the file perimeter, and host NetPolicy remains the destination gate (guest jail boundary).
  • init/fleet.rs owns admission and the host-CID-only engine factory; binding precedes the root spawn. exarch::vm’s machine factory dials this listener to create one engine per helper. init/halt.rs owns reaping, deepest-first engine cgroup cleanup and TERM/grace/KILL shutdown with cgroup.kill. Engine cleanup spares the shared ral-exec/detached survivor leaf. Halt closes the fleet, thaws ral-engine (a freeze is written only while the fleet is open, under its lock), then kills the whole ral-exec tree, including that leaf, and ral-engine.
  • pump::start owns tun/net descriptors in two threads, one writer per direction, with raw read_exact. Any I/O end or caught panic records the first fatal notification through reap::fail and signals PID 1 with TERM. Root exit ends the session; the root is never restarted.

netgate/ — the host network boundary

The guest’s tun has one peer: a host TCP/IP stack that admits only vetted CONNECT destinations, with no network adapter on the VM (egress).

  • ral_core::egress owns Host, NetPolicy, admits and refusal text; exarch loads policy and passes only its search bit to the agent.
  • netgate/src/lib.rs exports run, Config, Session, Dialer, System, AuditLog and LEDGER. stack.rs owns Config, pipe.rs owns Wake, and private refusal.rs serves decoding and vetting.
  • connect.rs decodes bounded CONNECT headers; vet.rs resolves once, rejects non-public addresses and dials only vetted destinations. ledger.rs owns strict-poison audit writes and rotation: admission is recorded before sending 200, refusal before returning it, and close includes byte counts.
  • device.rs uses core’s WireStream; pipe.rs owns bounded rings and backpressure. Directional EOF is independent of whole-worker retirement: upload EOF shuts the origin’s write half; download EOF closes only output. A full frame inbox drops packets so guest TCP backs off; transmit blocks on the wire. Full byte rings leave bytes in smoltcp’s receive buffer. Rings ignore poison because joining reports worker panics and surviving peers must remain able to wake; ledger poison stays strict.
  • stack.rs tracks live workers without joining them on the poll thread. Drained output can send FIN; whole-worker completion starts FIN_GRACE. Session::{stop, join} wakes and joins the workers. There is no active tunnel timeout; TUNNEL_CAP bounds the population.

The stack speaks bare IP (medium-ip) because its peer is a tun, with no UDP sockets. Vetting and dials raise no separate card: their accounting is the ledger, and the invoking exec already surfaces the operation. The fuzz workspace isolates nightly/libfuzzer dependencies; ordinary parser tests replay its corpus. Loopback tests retain real address vetting but dial local fixtures, and run serially because thread-count assertions are process-wide. Timeout margins allow scheduling jitter; finite join waits make a hung session fail its case instead of hanging the suite.

vm-manager/ — machines and media

The crate root is the public facade; backend children import their owning modules directly. Only real machines are constructed.

  • spec.rs owns Share { folder, read_only } and its resolve, SIZE (4 vCPUs, 6144 MiB) and boot_line, the caller of the sole ABI command-line writer. machine.rs owns Booted, Wires, Socket, MAX_FOLDERS (8), StopEvidence, Withdrawn, MountError { Refused, Ended }, UnmountError { Refused, Busy, Ended } and the Hypervisor/Machine traits; Hypervisor::boot(&self) boots with no folder, and every machine method is required.
  • shares.rs::Shares is the backend-independent order of every sharing change over the mounts wire: expose then mount; certify the unmount, then withdraw; roll back a refused mount; and end the machine, with StopEvidence, on any change it cannot confirm. Every later call returns that ending. mount resolves the folder before refusing a duplicate name. A backend supplies only an Exposure: its Device (a u32 index on OpenVMM, a usize slot on VZ) and tag, built by numbered, the one total tag constructor, with no tag parsed back; expose, withdraw, its idle mark if any, and end. PLUG_PATIENCE (15 s) bounds each backend’s half, client-side. The guest’s text gives the cause; the host adds the consequence.
  • direct(artifact) and detect(media) check availability before construction and resolve artifacts before another process opens them; available(exe, flavor) checks the backend, its entitlement and the media’s presence, never inflating or hashing them. detect checks availability before invoking its lazy BootMedia, so a refused host inflates nothing. Missing hardware support, entitlement, WHP, openvmm.exe or media gives a refusal. MSI cabinets cannot hold a two-gigabyte rootfs file, so installed media is compressed.
  • media::locate(exe, flavor) reads nothing: it tries bundle ../Resources/boot, then installed boot beside the executable, where an installation ships one rootfs (rootfs.img.zst with its checksum, else rootfs.img), then a target ancestor’s checkout, whose rootfs is per flavor (vm-image/out/rootfs-<RootfsFlavor::name>/). Failing all, it is Error::NoGuestImage { flavor, looked_in }, naming the just vm::rootfs recipe.
  • Layout::ready verifies and publishes rootfs-<sha256>.img, the raw disk both backends attach. publish locks <leaf>.lock, prepares a unique temporary file, syncs it and publishes without replacement. inflate bounds the zstd window.
  • lifecycle.rs::await_dials receives control and net against one 60-second deadline; its refusals (Undialled, with a per-wire cause, or EndedBeforeDial for a guest power event) quote the console and name the hypervisor’s own log when it has one. stop_within polls every PULSE for five seconds before forcing, and a force that fails is returned in place of ForcedStop. SessionDisk holds a std exclusive lease in a unique ral-vm-session-<epoch>-<pid>-<suffix> directory under temp_dir(), the one session directory on both backends. It is private from creation: mode 0700 on Unix, and on Windows a protected owner DACL given to CreateDirectoryW; there it also holds the backend’s AF_UNIX sockets. session.img is sparse and SESSION_BYTES (8 GiB) on both. Removal retries for two seconds; sweep reclaims aged, unleased directories without following links or other reparse points, and one predicate admits our own socket entries (r.sock, v.sock, v.sock_<digits>, each an AF_UNIX reparse point) to both Drop and sweep. On macOS it also holds idle/, VZ’s idle share, which Drop and sweep recognise by shape.
  • error.rs owns data-only Error; worded(spell) renders at the caller’s boundary. GuestConsole::{Kept, Unkept} distinguishes a retained empty console from no retained copy. GuestConsole::report supplies engine-loss diagnostics. Windows refusals include HypervisorPlatformOff, NoVmm { looked_in }, SocketPathTooLong { path } (set both TMP and TEMP, since Windows reads TMP first), NoPlainSpelling (a path Win32 would read as another) and VmmFailed (OpenVMM’s own failure, with its log’s tail), each naming its remedy. Sharing adds TooManyFolders, MountRefused, UnmountRefused and MountsUndialled, which reads as a socket-transport fault, since the guest listens on MOUNTS before it dials; an outdated image is named by stale_image under Undialled and EndedBeforeDial on the control wire.
  • vz/{mod,config,queue}.rs owns the macOS arm64 machine, configuration and serial-queue operations. It requires the virtualization entitlement, boots MAX_FOLDERS virtio-fs slot devices (s0…s7) on a per-boot idle share, attaches RO rootfs and RW sparse session disks, and multiplexes both accepted wires on one vsock device, dialling the mounts port after them. Slots points a slot at a folder with setShare on the machine’s queue; the guest’s mount confirms it against the idle mark, and Vacated confirms each withdrawal. force_stop observes its completion. Every wait on the machine thread is bounded: PLUG_PATIENCE for share, unshare, force and the stop on shutdown or drop (kept above twice STOP_GRACE at compile time); BOOT_PATIENCE for the boot report; CONNECT_PATIENCE for a guest dial. Its console goes to stdout without a retained copy. The generated objc2 binding avoids a Swift shim and its second toolchain; configuration construction needs no entitlement, but validation already does.
  • openvmm/{mod,hypervisor,proto,relay,ttrpc,process,afunix,console,win}.rs owns the Windows x86_64 machine: one unprivileged openvmm.exe on WHP, spawned by absolute path into a kill-on-close Job Object it joins at creation, and ready once r.sock accepts (windows-runs-openvmm). proto.rs and ttrpc.rs hand-encode CreateVM, ResumeVM, AddVpciDevice and RemoveVpciDevice over r.sock; with relay.rs’s CONNECT/OK parser they compile under cfg(any(windows, test)), so their golden tests run on Linux. The machine has direct kernel boot, raw rootfs and session disks on VMBus SCSI, a VPCI virtio-fs device hot-added per folder by Devices (tag s<n> and instance_id(n), never reused; metadata or metadata;ro), which owns the boot’s RPC client and live: Option<(Vmm, SessionDisk)>, taken by the first stop (Devices::end, or Guest::stop through Shares::exposure()); the hybrid vsock relay at v.sock, a COM1 console that OpenVMM opens on the host’s pipe, and no network adapter. Guest power events exit the process (0 shutdown, 64/65/66 reset/crash/watchdog), and the exit code is the stop. The console tees stdout, a bounded log and a line ring; OpenVMM’s stderr is a sibling log. Guest RAM is committed at boot and faulted in lazily.
  • Machine::dial_engine(&self) -> Result<Socket, DialError> asks for guest_abi::ports::FACTORY; connect_guest(&self, port: u32) has the same result type. Both backends implement it: macOS on the vsock device, Windows by CONNECT <port> on v.sock, where a port with no listener is DialError::Unanswered.
  • dial.rs owns DialError and DialBackend, independent of ral-core. Failures retain machine/device/completion state, timeout versus disconnected wait, backend and native platform domain/code/detail, or the original io::Error. Presentation does not replace this evidence.

synod/src/ — the product

synod supplies product identity, grants and prompts to desktop::run; window plumbing, folder accounting and narration are desktop’s, and the machine is exarch::vm’s.

  • src/lib.rs defines PRODUCT (synod::product()): exarch::app::SYNOD (providers.ral), StrictOffice, RootfsFlavor::Office, live pages on, diff review and mid-session model switching off, RuntimeMode::Vm by default, no profiles, and ChatGPT sign-in. Its network policy is net_policy::load() in a machine and NetPolicy::offline() on the host.
  • src/grant.rs owns the office TOOLBOX (bare names, so image additions never widen the grant), vm_ceiling (guest /work and scratch, the toolbox, no editor, no GPU; shell left open, since the machine bounds every survivor; pinned at src/golden/ceiling-grant.md) and host_stack (the shared folders and scratch, the toolbox and bundled tools, ShellVerb::Chdir without Detach, GPU withheld, offline, sealed by exarch::policy::secure_host_stack). Python and find -exec make the toolbox a job policy, not containment.
  • src/prompt.rs assembles both prompts over data/*.md and exarch::prompt::{RAL_REFERENCE, EDIT_REPLACE}. assemble_vm speaks of /work folders, the installed toolbox and the guest network (data/network.md); assemble_host says only what holds on the host: the grant’s programs run only where installed, nothing installs, and the network is off (data/host-network.md). Optional house rules come from trusted config; surface then live-page guidance (data/live.md) come last.
  • data/network.md describes destination admission on port 443 to vetted public addresses, not an information-flow boundary (egress).
  • src/main.rs calls exarch::exit_if_re_exec_child() first, then desktop::run(synod::product(), context) on GUI builds, or desktop::run_unavailable. build.rs guards tauri_build::build(); tauri-build stays an unconditional build dependency for cross-target checks.

vm-image/ — build and packaging

Boot compatibility is checked by the image tools before bundling.

  • common.sh is the skeleton both builders source: host-derived architecture (no override, no cross-building), mirror, podman and emulation check, staging, and lock-then-swap publication.
  • build-rootfs.sh [office|dev] builds a flavor’s image from packages-<flavor>.txt in a native arm64 or amd64 container into vm-image/out/rootfs-<flavor>/, with checksum and package manifest, the ext4 label ral-<flavor> and a per-flavor FS_UUID. It adds the work user (GUEST_ID, home HOME); office pre-builds the font cache and spot-checks its document tools, and dev fails unless gcc, git and cargo run. vm-image/README.md records the pipeline and remaining image questions.
  • build-boot.sh builds static musl ral-guest and exarch separately (exarch with --no-default-features --features coreutils), packages PID 1 as /init, and writes kernel, initramfs and boot-manifest.txt. It refuses kernels without CONFIG_SECCOMP_FILTER, CONFIG_NET_NS or CONFIG_SECURITY_YAMA, or whose CONFIG_LSM omits yama, keeps a persistent cargo cache, and under WSL builds from an ext4 copy of a drvfs checkout.
  • build-tools/src/manifest.rs owns read, check and lines. media-manifest compiles boot_contract and proto_version from their defining constants; check-media compares them. Present media without a readable manifest is refused; absent media is left to bundling.
  • Each product’s tauri.bundle.conf.json alone carries its flavor’s guest media, and runs check-media first; tauri.bundle.notices.conf.json alone carries its third-party notices, and tauri.bundle.windows.conf.json alone stages openvmm.exe, its licence and THIRDPARTY-OPENVMM, so a checkout without them still compiles. Linux has no VM backend, so its bundle takes the notices but no guest media. Generated gen/ permissions stay ignored.

The source describes behavior; a successful build alone does not witness a machine boot.

  • The macOS path has prior end-to-end exercise of a boot-time folder. The Windows OpenVMM backend awaits native acceptance on a standard account: a boot, virtio-fs metadata on NTFS, host-to-guest dials, the named-pipe console and job containment. Live folder sharing awaits native acceptance on both platforms, VZ’s setShare on a running machine above all (hot-shared-folders). vm-manager/examples/boot-smoke.rs boots empty and exercises sharing with two to eight folders.
  • The image README holds build instructions.
  • desktop, agent, frontend and engine-protocol locate the shared shell, reusable guest engine, conversation bus and wire semantics.
  • boot-contract-is-versioned, session-disk-outlives-its-machine and guest-console-outlives-stdout record the media, disk and diagnostic laws.