Map: desktop

desktop is the GUI shell both synod and exarch-gui run: a product is a &'static Product of plain data and functions, and the shell runs one assistant, in a machine or on the host, over the folders a person shares. Folders are worked in place; an account reads metadata, and file text only under diff review. Sharing and withdrawal are decided in hot-shared-folders; the products are mapped on synod and exarch.

Layers and the product seam

The order is folder < wire < assistant < seam < window; site.rs is a leaf holding the layers’ typed I/O sites, and test_fixture.rs the OFFICE and WORKSPACE products tests run.

LayerFilesResponsibility
Productproduct.rsProduct, TerritoryPolicy, RuntimeMode, StartOptions, Shared
L0 folderfolder/{grant,manifest,changes,diff}.rsAdmission, walks, stat-only change reports, diff review
L1 wirewire.rsEvery TS type, pure DTO constructors, WindowReport::of, open_as
L2 assistantassistant/{runtime,conversation,gate,baseline,prompt,accounts,menu,signin}.rsThe runtime, the conversation and its gated loop
L3 seamseam/{narration,ipc}.rsEvent folding and the four desktop:* event names
L4 windowwindow/{app,state,conversation,files,accounts,highlight,live,seal}.rsTauri state, commands, publication, the live-frame scheme
  • The crate exports exactly Product, RuntimeMode, Shared, StartOptions and TerritoryPolicy, with run or run_unavailable. Product’s switches are plain fields (live_pages, diff_review, mid_session_model_switch, default_runtime, rootfs, territory); its profiles are exarch Bases, the first the default, empty for a product that sets its own grants; its logins are Logins; its policy is five function pointers (vm_ceiling, net_policy, vm_prompt, host_workspace, host_prompt).
  • Product::normalize_options gives every function options whose profile is Some exactly when profiles is non-empty, refusing one not offered. StartOptions::read_only is Base::confines_writes of that profile.
  • window/ and run compile on macOS, Windows and glibc Linux under --features linux-gui; elsewhere run_unavailable names the remedy for the build at hand; there the lower layers compile without their callers.
  • bootstrap is an async command: exarch::vm::available checks backend, entitlement and media presence without inflating or hashing an image, and an unavailable machine defaults the window to RuntimeMode::Host with the reason, ProductBootstrap::vm_unavailable (None when the machine can run). ProductBootstrap carries the product’s copy, its ProductCapabilities (the three window switches, a DTO only), its Profiles, the first the default (Profile::from(Base) is the one table of label, summary and read-only-ness), and each login’s Login::title.

Folder and report

The account distinguishes unseen changes from known absence.

  • folder/grant.rs::admit is exarch::vm::Folder::admit (resolved, a listable directory, not a disk’s root), and under StrictOffice also refuses home, what holds it, settings trees (AppData, Library, .config, .local) and anything in a hidden folder of home, with strict temp descendants exempt. Settings can execute at sign-in. Office wording (“the documents for this job”) appears only there. Folder::{clear_of, meets, mint} judge overlap under every spelling and name a folder by its leaf.
  • folder/manifest.rs::Manifest::of_folder_via walks through typed sites: Walk::all under StrictOffice, Walk::work_tree under Workspace (ignore rules honoured, dotfiles kept, every .git skipped). It records paths, kinds, sizes, nanosecond mtimes and modes, empty folders, and link targets without following them. Stop and a progress callback make it interruptible and observable.
  • A listed entry that vanishes becomes Manifest::unread. A missing or unentered root and a stopped walk are errors, never empty or partial accounts.
  • folder/changes.rs::job_report compares manifests without I/O. Kind, size or mode changes are Modified; a timestamp alone is Touched. Equal (size, mtime_ns) pairs a deletion with a creation as Renamed, unless both sides have several candidates. Unread prefixes suppress claims beneath them.
  • Diff review is the real diff (folder/diff.rs). Only under product.diff_review does baseline::take keep each file’s text as sharing began: UTF-8 only, at most FILE_CAP (512 KiB) a file and FOLDER_CAP (32 MiB) a folder. After each walk diffs gives every changed file, before or after, Diff::between its kept text and the file now, read name by name without following a link and paid for, in path order, out of REPORT_CAP (8 MiB) a report; otherwise it says why (Undiffed::{Binary, TooLarge, Unkept, Overflow, Unreadable}). Synod reads no file’s bytes.
  • A diff is taken once per file state. Each diff is stamped with its change’s path before the job and the (size, mtime_ns) fingerprint of the file now; the next walk reuses a diff whose stamp still holds, neither reading nor diffing it again, yet charges it to the report as if read, so the report does not depend on what was reused. A file modified within GRAIN_NS (2 s, FAT’s timestamp grain) of the walk, an Overflow and an Unreadable are never stamped.
  • JobReport { changes, unreadable, diffs } has no serde form. WindowReport::of makes each ChangeFile, with FileDiff::{Text, Withheld}; Change::leaves_file says where Open/Reveal applies, and open_as classifies by the OPENABLE extension list.

Assistant

The conversation owns the runtime and the baselines its work is judged against; shared machinery stays with exarch and vm-manager.

  • assistant/accounts.rs builds Wallet::of(product.app, config_file, config_label) and prepares it once, before threads: environment credentials are resolved and scrubbed above saved keys. An account is chosen by id; with none, the refusal names each Login::title. menu.rs serves cached listings and refreshes off every lock; signin.rs words LoginPhase as SignInStep.
  • Conversation::begin normalizes the options and admits the opening folders through exarch::vm::opening_folders with grant::admit (more than MAX_FOLDERS refused before any is admitted, each cleared and named, read-only when chosen so or when the profile confines writes); the count is refused, at opening or mid-session, by exarch::vm::room_for. Then, for Vm, it detects the machine before anything else is set up. It opens the run directory under RunLock (anchored to the first folder), spawns each writable folder’s Baseline, and launches the root Admission::Gated, returns: false, without scheduling or reset-resume, with SPAWN_FUEL and HELPER_IDLE; provider requests share one Pool per conversation.
    • Vm: boot, settle the walks, then vm_prompt, vm_ceiling and the netgate audit ledger under the product’s state directory; exarch::vm::Guest::start shares every opening folder, and a failure before it shuts the machine down.
    • Host: settle the walks, make the Scratch, read the host’s system baseline, and boot RootEngine::Identity once under host_workspace’s (GrantStack, CwdPath) and host_prompt.
  • assistant/baseline.rs::Baseline owns one opening walk’s thread; settle joins it before its folder is shared, and Drop stops and joins only an abandoned walk.
  • One tenure per sharing. Conversation holds an append-only Vec<Tenure>; the index is the TenureId. Ledger::ReadOnly keeps no account; Ledger::Kept { baseline, texts, latest } holds what sharing began from and the latest walk; Ledger::Void { why } is an account the conversation’s end left unknown.
  • A change is prepared, then made. Seat::ready needs no hold: it judges the count, admission and overlap with live tenures, refuses a root that meets a VM tenure left Withdrawn::Vacated until the machine is confirmed stopped (Q3), names it, and walks a writable folder’s baseline. Seat::change runs under the hold and only shares or withdraws; a withdrawal records its Proof and takes the closing walk, and an ending records its StopEvidence.
  • Seat::invalidate voids every shared account and calls Port::end(root), ending that root’s subtree, not the fleet; a withdrawn folder’s closing account stands. Seat::settled walks every shared writable tenure after a certified settlement; a failed walk is that tenure’s unavailable account, and a later success restores it.
  • assistant/runtime.rs is the one runtime, Runtime::{Vm(Guest), Host}.
    • Vm: share and withdraw are Guest::{mount, unmount}; a withdrawal’s proof is Proof::Vm(Withdrawn).
    • Host: both rebind the root (Host::rebind_engine) under the product’s new stack, cwd and prompt for what stays shared: RebindMode::SpareBusy for an addition or Survivors::Spare, DismissAll for Survivors::Stop. Busy names the workers and helpers and changes nothing; Failed changes nothing; LogRefused, an ended root, or Rebound with teardown failures end the runtime with StopEvidence::Unconfirmed. A clean Rebound owes the agent a shell-restarted note.
    • A host withdrawal proves only what the new stack proves: Proof::Host { readable } is whether it still admits reading the folder’s root. It never constructs a Withdrawn.
    • Runtime::end ends the guest, or the host and its scratch. A machine’s lost engine is captured into engine.log by its factory (Factory::lost); Runtime::engine_lost only words it.
  • assistant/prompt.rs::preface(told, shared, path_for, restarted) is the harness note ahead of a human message whenever the shared map differs from what the agent was told, or the shell restarted: each folder (/work/<name> in a machine, its host path on the host), its access, what changed, what is gone. The system prompt names no folder.

The gate

assistant/gate.rs::run(seat, stage, sink) is the job loop and the ordered ingress (L7). Seat is what the loop needs of the conversation and Stage what it publishes, so the loop is tested off-window.

  • It releases the first job. Root JobOpened marks the release Taken and publishes JobBegan; root JobSettled is held with its commit number until the root’s inclusive Signal::Synced watermark covers it. Then it drains a pending snapshot, walks, drains another, publishes Folders then JobDone, and only then releases again. A root that dies before its watermark covers the job never certifies it.
  • TeardownFailed, a nonempty Died { failures } and a root EngineSevered are terminal. Every ending it explains goes through gate::void: invalidate, then republish Folders.
  • A folder change heading the queue waits its turn. The release is Release::{Shut, Open, Taken}, and only JobOpened makes it Taken. The change waits for a taken release’s certified settlement, lets messages already in the mailbox go first, and revokes an open release, retrying at the next poll on any answer but Gate::Revoked. It is prepared once (kept while Host::try_hold is refused), made under the hold, and published with Folders and FolderChanged; the held messages up to the next change follow with a fresh preface. An ending outcome ends the loop.
  • What the agent was told (told) starts empty and advances to the shared map only once a prefaced human prompt was recorded, the root’s Transient::ExchangeEnded followed, and that job’s settlement was certified. A shell restart is owed in every preface until then; a later change or refusal never drops it.

Narration and window

Publication and ownership agree at one generation boundary.

  • seam/narration.rs folds events by Role::{Trunk, Helper}. Router latches the first signalling agent as the trunk; helper prose is suppressed, helper cards become process cards, usage still counts, and plumbing faults stay visible. A trunk UserPrompt or Steering in the human’s voice projects as DesktopEvent::Human, never its preface. Router::busy is a BTreeSet<AgentId>: a helper’s birth or a pending state inserts, ready or death removes, and Helpers { busy } is emitted only on a change. Narrator<F> is a Sink over a callback, independent of Tauri.
  • wire.rs owns every #[derive(TS)], exported to desktop/ui/js/bindings/ with snake_case tags; exarch has no ts-rs dependency. Mark payloads stay open records (Record<string, any>, and unknown for Measure, whose tag any would erase); raw marks become lossy text once, here.
  • Withdrawal::of(proof, name, stopped) never overstates: Removed, a host stack that no longer reads the folder, or a confirmed stop is Revoked; Vacated says no program in the machine holds the folder and it cannot reach it afresh, without macOS’s confirmation; a host stack that still reads it is Reachable, and says so. FolderOutcome::{Added, Withdrawn, Refused, Busy, Ended} echoes the window’s RequestId (at most 2⁵³ − 1), or null for an opening folder; JobId stays numeric.
  • window/state.rs: Owner::{Open, Closing} admits one close owner, whose five-second grace bounds the wait for teardown. Handle holds the generation, the window’s attempt, the baseline Stop and an Inlet { root, held, preface }, the one ordered ingress: root is None while the runtime starts; held keeps every message and change from the oldest pending change on (while starting, everything); a message with nothing held goes straight to Port::submit. Preface is Quiet, Due or Sent: a due note rides the next message, a recalled one is owed again, uptake quiets it. Recall and Stop withdraw the mailbox’s messages, then the held ones; changes stay queued. Review maps each TenureId to its Held report, kept after the worker ends so its cards stay openable.
  • window/conversation.rs::Emitter publishes only while its generation owns the slot. A new start takes the slot atomically, and the new worker stops and joins its predecessor outside the owner lock. registered checks the attempt for send_message, recall_queued, switch_model and change_folder; stop_job is synchronous under the slot lock. Queue snapshots are read and published under the same lock, so an older one never follows a newer. drive runs the conversation under catch_unwind, keeping a begun Conversation outside the unwind: after a panic it voids its accounts and ends its runtime before publishing the failure. A failure also clears the generation’s Review.
  • window/app.rs registers the plugins and commands, creates the main window in setup ("create": false, so macOS can hand it the sealed configuration) and owns the single close. The opener’s click handling is off: only the checked open_url opens links. The navigation guard is a plugin, so it covers every webview: it admits the app origin, the live frame in WebKit’s spelling (is_live_frame, only with live pages) and, in debug builds, the configured dev origin; foreign navigation would expose the command bridge to model output. CSP and capabilities are each product’s tauri.conf.json and capabilities/.
  • window/live.rs serves ral-live, registered only when product.live_pages (live-pages-run-sealed). route admits /, four prelude files and vendor/ by plain segments; serve answers non-GET with 405, the shell with 503 until Sealed exists on macOS, and anything else unrouted or resolved as text/html with 404. Every response carries the frame’s CSP, nosniff, a wildcard CORS origin and X-DNS-Prefetch-Control: off.
  • window/seal.rs (macOS) seals the webview at creation and manages the zero-sized Sealed once its settings read back; Windows and Linux are unsealed (live-page-egress).
  • window/files.rs::open_file takes (tenure, index, shown name) against the held report and walks without following links or reparse points; only plain files open, allowlisted documents in the default application, others revealed. Under StrictOffice, Windows stamps Mark of the Web, best-effort. open_url admits web and mail schemes only.
  • window/accounts.rs owns key and endpoint writes, single-flight cancellable sign-in (refused for a login the product lacks, naming those it has) and menu refresh; sign-in releases its slot before refreshing the menu and announcing completion. window/highlight.rs gives core’s spans in UTF-16 offsets.

desktop/ui/ — the static frontend

ES modules without a bundler or npm, served as each product’s frontendDist; just ui type-checks and tests them with Deno.

  • js/ipc.js alone holds the Tauri bridge, one typed function per command or event. dom.js owns lookup and screens, status.js facts and status, core.js confirmation and transcript pinning. Without the dialog plugin confirmDialog resolves false, so nothing is confirmed.
  • attempt.js filters updates by attempt before projection: terminal attempts never revive, and only addressed job_began and job_done move job activity.
  • folders.js is pure, tested by tests/folders_test.ts: chips lists the shared tenures, then the pending additions in request order; kept is what Start again shares; accounted drops read-only tenures; notice words a change made, never strengthening its Withdrawal.
  • Each folder change goes out at once through changeFolder with a fresh request number and shows pending until the folder_changed carrying it; busy opens the survivor dialog, which resends with stop on confirmation.
  • Live frames mount only under the bootstrap’s live_pages; the change report draws each ChangeFile’s diff.

See also

synod, exarch, synod-is-a-second-product, hot-shared-folders, a-frontend-holds-a-port, live-page-egress.