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.
| Layer | Files | Responsibility |
|---|---|---|
| Product | product.rs | Product, TerritoryPolicy, RuntimeMode, StartOptions, Shared |
| L0 folder | folder/{grant,manifest,changes,diff}.rs | Admission, walks, stat-only change reports, diff review |
| L1 wire | wire.rs | Every TS type, pure DTO constructors, WindowReport::of, open_as |
| L2 assistant | assistant/{runtime,conversation,gate,baseline,prompt,accounts,menu,signin}.rs | The runtime, the conversation and its gated loop |
| L3 seam | seam/{narration,ipc}.rs | Event folding and the four desktop:* event names |
| L4 window | window/{app,state,conversation,files,accounts,highlight,live,seal}.rs | Tauri state, commands, publication, the live-frame scheme |
- The crate exports exactly
Product,RuntimeMode,Shared,StartOptionsandTerritoryPolicy, withrunorrun_unavailable.Product’s switches are plain fields (live_pages,diff_review,mid_session_model_switch,default_runtime,rootfs,territory); itsprofilesare exarchBases, the first the default, empty for a product that sets its own grants; itsloginsareLogins; its policy is five function pointers (vm_ceiling,net_policy,vm_prompt,host_workspace,host_prompt). Product::normalize_optionsgives every function options whoseprofileisSomeexactly whenprofilesis non-empty, refusing one not offered.StartOptions::read_onlyisBase::confines_writesof that profile.window/andruncompile on macOS, Windows and glibc Linux under--features linux-gui; elsewhererun_unavailablenames the remedy for the build at hand; there the lower layers compile without their callers.bootstrapis an async command:exarch::vm::availablechecks backend, entitlement and media presence without inflating or hashing an image, and an unavailable machine defaults the window toRuntimeMode::Hostwith the reason,ProductBootstrap::vm_unavailable(Nonewhen the machine can run).ProductBootstrapcarries the product’s copy, itsProductCapabilities(the three window switches, a DTO only), itsProfiles, the first the default (Profile::from(Base)is the one table of label, summary and read-only-ness), and each login’sLogin::title.
Folder and report
The account distinguishes unseen changes from known absence.
folder/grant.rs::admitisexarch::vm::Folder::admit(resolved, a listable directory, not a disk’s root), and underStrictOfficealso 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_viawalks through typed sites:Walk::allunderStrictOffice,Walk::work_treeunderWorkspace(ignore rules honoured, dotfiles kept, every.gitskipped). It records paths, kinds, sizes, nanosecond mtimes and modes, empty folders, and link targets without following them.Stopand 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_reportcompares manifests without I/O. Kind, size or mode changes areModified; a timestamp alone isTouched. Equal(size, mtime_ns)pairs a deletion with a creation asRenamed, unless both sides have several candidates. Unread prefixes suppress claims beneath them.- Diff review is the real diff (
folder/diff.rs). Only underproduct.diff_reviewdoesbaseline::takekeep each file’s text as sharing began: UTF-8 only, at mostFILE_CAP(512 KiB) a file andFOLDER_CAP(32 MiB) a folder. After each walkdiffsgives every changed file, before or after,Diff::betweenits kept text and the file now, read name by name without following a link and paid for, in path order, out ofREPORT_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 withinGRAIN_NS(2 s, FAT’s timestamp grain) of the walk, anOverflowand anUnreadableare never stamped. JobReport { changes, unreadable, diffs }has no serde form.WindowReport::ofmakes eachChangeFile, withFileDiff::{Text, Withheld};Change::leaves_filesays where Open/Reveal applies, andopen_asclassifies by theOPENABLEextension 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.rsbuildsWallet::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 eachLogin::title.menu.rsserves cached listings and refreshes off every lock;signin.rswordsLoginPhaseasSignInStep.Conversation::beginnormalizes the options and admits the opening folders throughexarch::vm::opening_folderswithgrant::admit(more thanMAX_FOLDERSrefused 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, byexarch::vm::room_for. Then, forVm, it detects the machine before anything else is set up. It opens the run directory underRunLock(anchored to the first folder), spawns each writable folder’sBaseline, and launches the rootAdmission::Gated,returns: false, without scheduling or reset-resume, withSPAWN_FUELandHELPER_IDLE; provider requests share onePoolper conversation.Vm: boot, settle the walks, thenvm_prompt,vm_ceilingand thenetgateaudit ledger under the product’s state directory;exarch::vm::Guest::startshares every opening folder, and a failure before it shuts the machine down.Host: settle the walks, make theScratch, read the host’s system baseline, and bootRootEngine::Identityonce underhost_workspace’s(GrantStack, CwdPath)andhost_prompt.
assistant/baseline.rs::Baselineowns one opening walk’s thread;settlejoins it before its folder is shared, andDropstops and joins only an abandoned walk.- One tenure per sharing.
Conversationholds an append-onlyVec<Tenure>; the index is theTenureId.Ledger::ReadOnlykeeps 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::readyneeds no hold: it judges the count, admission and overlap with live tenures, refuses a root that meets a VM tenure leftWithdrawn::Vacateduntil the machine is confirmed stopped (Q3), names it, and walks a writable folder’s baseline.Seat::changeruns under the hold and only shares or withdraws; a withdrawal records itsProofand takes the closing walk, and an ending records itsStopEvidence. Seat::invalidatevoids every shared account and callsPort::end(root), ending that root’s subtree, not the fleet; a withdrawn folder’s closing account stands.Seat::settledwalks 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.rsis the one runtime,Runtime::{Vm(Guest), Host}.Vm:shareandwithdrawareGuest::{mount, unmount}; a withdrawal’s proof isProof::Vm(Withdrawn).Host: both rebind the root (Host::rebind_engine) under the product’s new stack, cwd and prompt for what stays shared:RebindMode::SpareBusyfor an addition orSurvivors::Spare,DismissAllforSurvivors::Stop.Busynames the workers and helpers and changes nothing;Failedchanges nothing;LogRefused, an ended root, orReboundwith teardown failures end the runtime withStopEvidence::Unconfirmed. A cleanReboundowes 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 aWithdrawn. Runtime::endends the guest, or the host and its scratch. A machine’s lost engine is captured intoengine.logby its factory (Factory::lost);Runtime::engine_lostonly 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
JobOpenedmarks the releaseTakenand publishesJobBegan; rootJobSettledis held with its commit number until the root’s inclusiveSignal::Syncedwatermark covers it. Then it drains a pending snapshot, walks, drains another, publishesFoldersthenJobDone, and only then releases again. A root that dies before its watermark covers the job never certifies it. TeardownFailed, a nonemptyDied { failures }and a rootEngineSeveredare terminal. Every ending it explains goes throughgate::void: invalidate, then republishFolders.- A folder change heading the queue waits its turn. The release is
Release::{Shut, Open, Taken}, and onlyJobOpenedmakes itTaken. 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 butGate::Revoked. It is prepared once (kept whileHost::try_holdis refused), made under the hold, and published withFoldersandFolderChanged; 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’sTransient::ExchangeEndedfollowed, 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.rsfolds events byRole::{Trunk, Helper}.Routerlatches 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 trunkUserPromptorSteeringin the human’s voice projects asDesktopEvent::Human, never its preface.Router::busyis aBTreeSet<AgentId>: a helper’s birth or a pending state inserts, ready or death removes, andHelpers { busy }is emitted only on a change.Narrator<F>is aSinkover a callback, independent of Tauri.wire.rsowns every#[derive(TS)], exported todesktop/ui/js/bindings/withsnake_casetags; exarch has no ts-rs dependency. Mark payloads stay open records (Record<string, any>, andunknownforMeasure, whose taganywould 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 isRevoked;Vacatedsays 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 isReachable, and says so.FolderOutcome::{Added, Withdrawn, Refused, Busy, Ended}echoes the window’sRequestId(at most 2⁵³ − 1), ornullfor an opening folder;JobIdstays numeric.window/state.rs:Owner::{Open, Closing}admits one close owner, whose five-second grace bounds the wait for teardown.Handleholds the generation, the window’s attempt, the baselineStopand anInlet { root, held, preface }, the one ordered ingress:rootisNonewhile the runtime starts;heldkeeps every message and change from the oldest pending change on (while starting, everything); a message with nothing held goes straight toPort::submit.PrefaceisQuiet,DueorSent: 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.Reviewmaps eachTenureIdto itsHeldreport, kept after the worker ends so its cards stay openable.window/conversation.rs::Emitterpublishes 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.registeredchecks the attempt forsend_message,recall_queued,switch_modelandchange_folder;stop_jobis synchronous under the slot lock. Queue snapshots are read and published under the same lock, so an older one never follows a newer.driveruns the conversation undercatch_unwind, keeping a begunConversationoutside the unwind: after a panic it voids its accounts and ends its runtime before publishing the failure. A failure also clears the generation’sReview.window/app.rsregisters the plugins and commands, creates the main window insetup("create": false, so macOS can hand it the sealed configuration) and owns the single close. The opener’s click handling is off: only the checkedopen_urlopens 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’stauri.conf.jsonandcapabilities/.window/live.rsservesral-live, registered only whenproduct.live_pages(live-pages-run-sealed).routeadmits/, four prelude files andvendor/by plain segments;serveanswers non-GET with 405, the shell with 503 untilSealedexists on macOS, and anything else unrouted or resolved astext/htmlwith 404. Every response carries the frame’s CSP,nosniff, a wildcard CORS origin andX-DNS-Prefetch-Control: off.window/seal.rs(macOS) seals the webview at creation and manages the zero-sizedSealedonce its settings read back; Windows and Linux are unsealed (live-page-egress).window/files.rs::open_filetakes(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. UnderStrictOffice, Windows stamps Mark of the Web, best-effort.open_urladmits web and mail schemes only.window/accounts.rsowns 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.rsgives 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.jsalone holds the Tauri bridge, one typed function per command or event.dom.jsowns lookup and screens,status.jsfacts and status,core.jsconfirmation and transcript pinning. Without the dialog pluginconfirmDialogresolvesfalse, so nothing is confirmed.attempt.jsfilters updates by attempt before projection: terminal attempts never revive, and only addressedjob_beganandjob_donemove job activity.folders.jsis pure, tested bytests/folders_test.ts:chipslists the shared tenures, then the pending additions in request order;keptis what Start again shares;accounteddrops read-only tenures;noticewords a change made, never strengthening itsWithdrawal.- Each folder change goes out at once through
changeFolderwith a fresh request number and shows pending until thefolder_changedcarrying it;busyopens the survivor dialog, which resends withstopon confirmation. - Live frames mount only under the bootstrap’s
live_pages; the change report draws eachChangeFile’sdiff.
See also
synod, exarch, synod-is-a-second-product, hot-shared-folders, a-frontend-holds-a-port, live-page-egress.