diff options
Diffstat (limited to 'docs/typ')
| -rw-r--r-- | docs/typ/building.typ | 229 | ||||
| -rw-r--r-- | docs/typ/builtins-gui.json | 2 | ||||
| -rw-r--r-- | docs/typ/builtins-tui.json | 2 | ||||
| -rw-r--r-- | docs/typ/reference.typ | 14 | ||||
| -rw-r--r-- | docs/typ/running.typ | 146 |
5 files changed, 301 insertions, 92 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 5273298e..9350b484 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -1,7 +1,8 @@ -// Building pardes, for contributors: platforms, options, the library, tests, -// the release gates and sending patches, then how the pieces fit: the core -// and its shells, the threads, the daemon and its sessions, the 9P engine, the -// listeners and mounts. +// Building pardes, for contributors: platforms, options, the patches to +// dependencies, the library, tests, the release gates and sending patches, +// then how the pieces fit: the principle, the tree, the core and its +// frontends, the loops, the tape, the checks, the threads, the daemon and its +// sessions, the 9P engine, the listeners and mounts. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs For contributors: how pardes is built, tested and released, and how its @@ -9,7 +10,7 @@ pieces fit. To install it, see #doc("setup", section: "install"). = Platforms -Zig *0.17.0* (`build.zig.zon` pins `minimum_zig_version`). Dependencies are +Zig *0.17.1* (`build.zig.zon` pins `minimum_zig_version`). Dependencies are fetched and pinned by the manifest; the terminal build needs no system package. The SDL shell builds SDL3 and FreeType from source. Pictures and PDFs are addons, each its own step: `zig build image`, `zig build pdf` @@ -73,6 +74,22 @@ must share with its session; `pardes --help` lists every flag. [`-Dhelix-harness`], [reference executable for live differential tests; `HX_HARNESS`, else `hx-harness` on `PATH`], ) +== Patches to dependencies <dep-patches> + +A fault in a dependency is fixed in the dependency, never guarded in the +core. pardes builds a few with edits of its own, made as each is fetched: +`build/patches.zig` holds, for each patched file, a table of exact edits +(and a file to append, in `build/patches/`), which `tools/patch.zig` +applies at make time, so a fresh fetch is patched the same and a bump that +moves an anchor fails that file's step. Each table says why, edit by edit. + +#pairs( + [vaxis], [its input parser (no reply, split read or malformed sequence reaches the editor as typed text), its event queue (every blocked writer woken) and its render (a blank whose ink alone changed is not sent)], + [zstbi], [stb_image and its writer cut out: its resize alone is left, for a terminal PNG's downscale], + [ghostty], [kitty graphics: a path opened only once it is a regular file, shared memory non-blocking, an image no larger than a screen's storage], + [mvzr], [a step budget, a group's backtracking, `$` before `|`, the `**` Zig 0.17 removed, a class's range to `\xff`, and its reads past a pattern cut short; `docs/mvzr-group-backtrack.md` and `docs/mvzr-bounds.md` are the reports for upstream], +) + == As a library <library> A Zig package that depends on pardes is given one module and nothing of @@ -174,6 +191,9 @@ zig build lib-test the library, from a package that depends on pardes (t zig build hxlib helix's cases on the library's editor (-- --parity: against the file pane) zig build behaviour-test behaviour through the 9P tree, in process (test/behaviour/), and the T1 runner's short run of random 9P requests +zig build replicas the soak: a session and clients in process, on the real + session and client loops, each client typing over a + delayed link (-- [--seeds N] [--clients C] [--rtt 30,80,207]) zig build process-test real sessions over their sockets: mounts, flags, shells (test/process/), and the tty's own cases, each a pardes in a pty against its golden (test/process/tty_*.zig, test/snapshots/); -Dplatform=gui runs the @@ -251,12 +271,60 @@ Mail patches to the list `~gbrls/[email protected]`; it is the preferred way to #link("https://git-send-email.io")[git-send-email.io] sets `git send-email` up. The mirrors (#doc("setup", section: "install")) are for cloning, as a GitHub one will be; pull requests are not the preferred route. -= The core and its shells += The principle <principle> + +The owner's rule, in their words: "keep the wire protocol simple and raw, +and the local state process it" (2026-11-19). Every design choice is +measured against it. + +What crosses between processes is raw and ordered: a client's keys and +gestures, and the session's steps, each with what the session's machine +answered inside it (a file's bytes, the clock, a directory's listing) as +the machine said it. Each process's own core turns them into state. Nothing +computed is shipped where the input that computes it can be, and bandwidth +is spent before correctness is. What follows from it in the tree today: + +- A client is a whole core, loaded once from the session's dump. It applies + its own input at once and replays the session's units over it, rolling + back where the session ordered otherwise; nothing it draws is sent to it. + A picture or a game is drawn by the process that shows it, from its own + addon's code. +- A step that asks the machine asks through the tape (#link(<tape>)[below]): + the session records the answer, a client's replay reads that answer and + not its own machine's. The session's home, shell and directory are state + of the core for the same reason. +- What may wait is what touches the session's machine; the lists that say + so are checked by a test (#link(<may-wait>)[below]). +- Nothing a frame writes is read by a step, and nothing of a core is a + process global, so a core that drew and one that did not, in this process + or another, step alike (#link(<core-checks>)[the checks]). +- The exceptions, each small and named: the dump a client joins from (it + cannot replay from the start); the digests and quiet checks (a check, not + state); and a terminal, which crosses as the session's screen state + (rows and their changes), not as the pty's bytes. + += The tree <tree> + +#pairs( + [`core/`], [the editor as a state machine: panes, layout, the frame, the 9P tree, the tape and the replica engine. Module `core`, rooted at `core/root.zig`; the core's struct is `core/Core.zig`, `pardes.Pardes`], + [`dev/`], [the devices: the frontends (`dev/tui`, `dev/gui`, the Mac app's Swift in `dev/macos`), the host's services (`dev/host_io.zig` and the files beside it: `Host`, `Shell`, `Inbox`, `KindJob`, `Lsp`), the file watcher, the fonts, the language servers' client. Module `dev`], + [`runtime/`], [what runs a session: a session's loop (`session.zig`) and a client's (`client.zig`), the daemon and the stub, the upgrade, the crash file, the 9P listener and client (`9p_io.zig`). Module `runtime`; beside it each product's root, a module of its own: `runtime/main.zig` (`pardes`, `pardes-gui`) and `runtime/macos.zig` (the Mac's library)], + [`abi/`], [what crosses a process or a language: the replica stream (`abi/wire.zig`, module `wire`), the records the core and the terminal share (`plain.zig`), the terminal's table (`term.zig`), the addon's header and module, `pardes.h`], +) + +The modules name each other. A Zig test program runs the tests of the +module it is rooted at, so `core-test` and `shell-test` run one program a +module (core, dev, runtime, wire, and for `shell-test` `runtime/main.zig`'s); +each module's `root.zig` lists the files whose tests it runs. Beside the +four: `addons/`, `build/` (the build script's parts, the patches), `test/`, +`tools/`, `shaders/`, `vendor/`, `assets/` and `docs/`. + += The core and its frontends -One core, three shells (tui, gui, macos). The core owns -editing, layout, rendering and the virtual filesystem it serves over 9P; a shell turns native -input into `pardes.Event`, presents `pardes.Surface`, and performs host -effects such as spawning processes. +One core, three frontends (tui, gui, macos). The core owns +editing, layout, rendering and the virtual filesystem it serves over 9P; a +frontend turns native input into `pardes.Event`, presents `pardes.Surface`, +and its host performs effects such as spawning processes. - The core is a state machine: input arrives as an `Event` through `update`; output leaves as a `Surface` from `render(arena)` and as a ring @@ -271,13 +339,21 @@ effects such as spawning processes. - `pump` runs: wait for input (the host owns the sleep), flush paused 9P write batches, drain queued events, drain effects, settle the turn, then render and present only when a frame is needed and someone is looking. -- `host_io.Host` is a context pointer and a vtable of optional callbacks; a - null method is not an error, and `Host{}` is a complete in-process pardes - that the tests use. Comptime decides what a build has (`pardes.platform`, - `can_attach`); the vtable - decides who serves it. -- The root module is chosen by platform: `main.zig` (tui, gui), - `macos.zig`. The macOS shell is a library whose host owns `main()`. +- `Host` (`dev/Host.zig`) is a context pointer and a table of optional + callbacks; a null method is not an error, and `Host{}` is a complete + in-process pardes that the tests use. Comptime decides what a build has + (`pardes.platform`, `can_attach`); the table decides who serves it. +- The terminal and the window draw from the frame alone: the `Surface` + (cells, regions, layers, placements, cursor, `Chrome`) and one record + beside it, `Facts` (`core/surface.zig`: the view's size, each open + pane's rectangle, tag rows and kind, the settings a frontend draws by), + which `draw.place` fills with the frame. Each reads these, not the core, + to draw and to turn its input into events, so a client draws its own + view with no view of the core made live. A few reads of the core remain, in the window: its + hit test, its close and a session window's font. +- The macOS build is a library whose Swift app owns `main()` and the run + loop (`runtime/macos.zig`); it reads the core beyond the frame (its + theme, a pane's document state) and runs neither loop below. - The terminal is a module of its own, `term` (`core/term/`): the emulator (ghostty-vt), kitty images (wuffs, zstbi), the pager's parse and the replicas' screen state. It never imports the core; the core @@ -292,14 +368,115 @@ effects such as spawning processes. safe, its checks in Debug builds only. Code map: `core/panes.zig` and the pane kinds it names (`core/File.zig`, -`src/Terminal.zig`, ...), `core/layout.zig`, `core/fs.zig` (host access, -mounts and resolution) and `core/root.zig` (input), with one file per -thing beside them (`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, -`mouse.zig`, ...). `core/ninep/` is the control tree, `runtime/daemon.zig` the -per-user daemon and a terminal's stub, `abi/wire.zig` the input -wire a remote client will speak, `core/lsp/` the -language-server client; `test/` holds harnesses, goldens and helix cases, -`build/` the process tests' build steps. +`core/Term.zig`, `core/Kind.zig`, ...), `core/layout.zig`, `core/fs.zig` +(host access, mounts and resolution), `core/Core.zig` (the core's state +and its entries) and `core/draw.zig` (the frame), with one file per thing +beside them (`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, +`mouse.zig`, ...). `core/ninep/` is the control tree, `core/tape.zig` the +tape, `core/replica.zig` the replica engine (a client's `Replica` and +`Link`, a session's `Peers`), `runtime/daemon.zig` the per-user daemon and +a terminal's stub, `abi/wire.zig` the replica stream's frames, `core/lsp/` +the language-server client; `test/` holds harnesses, goldens and helix +cases, `build/` the build script's parts. + +== The loops <loops> + +A session runs `runtime/session.zig`'s `Loop`, a client +`runtime/client.zig`'s, each over the frontend it is given (comptime: no +vtable). The terminal's and the window's own frontend (`Own` in each) and +their client frontends (`Tty`, the window's `Client`) give the calls; +what a loop holds and its order are written once. + +- The session's loop holds its allocators and workers, its core (new, + from a dump, or an Upgrade's), the prompt files its shells start with, + the 9P listener and its clients (`Peers`). A turn is a `pump`, the step's + unit to the clients (`Peers.boundary`), the frontend's `sent`, an + Upgrade or a Restore between steps, and the daemon's notes. Its parts end + in one order: the listener, the clients, the frontend's devices, the + prompt files, the core, the workers, the allocators. The devices (ptys, + their readers, watched files, the jobs, the queue they post to) are + still each frontend's (`open`, `start`, `close`). +- A client's loop holds what it keeps across joins (`client.Start`: its + allocators, the addons it distrusts, its frame timings, the blobs it + keeps when far) and runs its joins: the reader thread, a pass at a time, + and a join again after a divergence or an Upgrade. A pass: the + frontend's own work (`own`), the predicted echo's frame, a draw or the + frontend's own motion (`again`), the wait (`deadline`, `wait`), then the + session's units settled, and a yank, paste or link its view asked for + done on this machine (`copy`, `paste`, `open`). An input is sent to the + session before it is applied here. +- The soak, `zig build replicas` (`test/replicas.zig`), runs both: its + session is `session.Loop` over a frontend whose host is the soak's + delayed network, every client a `client.Loop`, so what it tests is what + a session and a client run. The core's own unit tests stand a session in + with `replica.Authority`. + +== The tape <tape> + +The tape (`core/tape.zig`) records what a step takes in: the entry a host +called and its arguments, and every answer of the machine inside the step. +A session records its steps; a client replays the session's and records +its own speculations, to compare. + +- An entry is written once: a private body and, directly under it, its + public name made by `tape.taped` + (`pub const update = pardes.tape.taped(updateInner);`); the tape's + `Input` variant and the replay come from the body's parameters. The few + written by hand (`init`, `deinit`, `pump`, `render`, ...) each say why. +- The tape is the handle a step is given, as an allocator is: a core + holds it (`p.tape`, never null), and a function handed no core takes + `tape: *Tape`. A step's question of the machine goes through it + (`p.tape.value`, `p.tape.site`, `p.tape.authorityOnly`): the session + records the answer, a replay reads it. So far the kinds and addons, a + directory's listing, the file system, the core's own files and the + smaller ones ask it so; beside the field, the process's `tape.on` still + says which core is being stepped. +- A pane's and a view's slot are types where they cross the core's edge + (an entry's argument or answer, an event, an effect, a host call, the + wire's welcome): `Pane.Id` and `View.Id`, each an `enum(u8)` of its own. + The core's own loops keep their integers. +- The session's facts, its home, default shell and directory, are the + core's state (`session_home`, `session_shell`, `session_dir`), read once + at its start through the tape and carried in its dump: a far client's + `~`, #word("Shell") and a word run in the session's directory are the + session's. + +== What may wait <may-wait> + +A client applies its own input at once; a step that needs the session's +machine stops its speculation, and the input waits a round trip for the +session's unit (`tape.hostCall`). The user's line: motions, edits and +layout are instant; what has a side effect on the system may wait. Two +lists say which, each row with why: + +- `keeps_stopping` (`core/tape.zig`): the Host entries that return nothing + and still stop a speculation (`pty_write`, `spawn`, `write_file`, ...). + A client records any other such call as made and goes on; an entry that + answers stops by nature, the answer being the session's. +- `may_wait` (`core/replica.zig`): each word, key or gesture that may wait, + on a kind of pane, and where it stops. A test walks every word of the + registry, every key (and every key after each prefix) and the gestures + between panes, on a file's, a kind's and a shell's pane: a stop not + listed fails it, and a row nothing stopped at is stale. The soak judges + its stops by name against the same list. + +== The checks <core-checks> + +At the end of `core/root.zig`, run by `core-test`, `shell-test` and +`unit-test`: + +- *No process globals:* every container-level `var` in `core/` is on + `allowed_vars`, with why it is not a core's. +- *What the core asks of the machine:* every line of `core/` naming libc, + `std.posix`, `getenv`, a `std.Io` file, directory or socket, `dev` or + `runtime` is counted, a file at a time, against `machine_lines`, with why. +- *What is kept out of the digest:* every field kept out of the digest and + the dump (`.local`, `.derived`) is on `kept_out`, with who writes it and + why a step's read of it is the step's. + +Beside them, `core/draw.zig`'s test "a frame changes nothing a step reads" +steps a core that draws after every input and one that never draws, and +their digests agree after every step. == Threads @@ -311,7 +488,7 @@ would change a pane parks (`Status.again`) and is retried when the editor rests. 9P requests are not events: they enter through `Pardes.serveFs`, and only one that changes a pane costs a frame. Language-server and selection-pipe workers post completions through a bounded mailbox; a -`host_io.Lsp.Job` owns copies of the source, path and arguments, never +`Lsp.Job` (`dev/Lsp.zig`) owns copies of the source, path and arguments, never reading the live core, and a request id, the pane's serial and (for an edit) the file's revision reject a stale reply. A process that never calls `turn.start` (the tests) has no second thread. diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 8ed70b10..732e66a7 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -101,8 +101,8 @@ {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."}, - {"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."}, + {"name": "Undock", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Undock a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Unfollow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Take this pane out of its Follow chain: it stays, a Zerox twin with the scroll it has, and the chain closes up behind it."}, {"name": "Unmount", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Unmount the 9P tree mounted under /n/<name>."}, {"name": "Up", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane above, and from a column's top pane to its tag."}, diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json index aa95d9a6..0a074c44 100644 --- a/docs/typ/builtins-tui.json +++ b/docs/typ/builtins-tui.json @@ -95,8 +95,8 @@ {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."}, - {"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."}, + {"name": "Undock", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Undock a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Unfollow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Take this pane out of its Follow chain: it stays, a Zerox twin with the scroll it has, and the chain closes up behind it."}, {"name": "Unmount", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Unmount the 9P tree mounted under /n/<name>."}, {"name": "Up", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane above, and from a column's top pane to its tag."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 2562c91b..4c193e0f 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -1179,8 +1179,12 @@ of it is laid out by `view` and drawn by `paint`. handed (the last allocation the answer); one asked before an #word("Addon") `reload` answers into nothing, and the old library stays until its last such job has answered. -- A client of the session runs no addon's code: a pane of a kind it lacks - shows the session's frames of it, and its keys go to the session. +- A client of the session runs a kind whose state is plain (`PA_PLAIN`: + the games, the picture, the PDF) from its own addons, as the session + does, and draws its pictures itself. A pane of a plain kind it lacks, or + one that broke its promise there, shows a line saying so; a kind whose + state is not plain runs in the session alone, and its pane in a client + shows a line saying that. The session sends no pictures to a client. - #word("Addon") `load <path>` (relative to the pane's directory) loads one; `unload <name>` lets one go, refused while a pane of its kind is @@ -1230,8 +1234,10 @@ of it is laid out by `view` and drawn by `paint`. pane whose file changes on disk opens again from it, its record kept for its `load` (a PDF stays on its page). - An addon runs in pardes's process. A load is marked on disk while it - runs; a start that finds the mark of one that never finished skips that - library, listed so, until #word("Addon") `load` asks for it again. A + runs, with the loading process's pid; a start that finds the mark of a + load whose process is gone (it never finished) skips that library, + listed so, until #word("Addon") `load` asks for it again. Another + pardes's load still under way is no crash. A crash inside one says `in addon <file>, <call>` in the crash record. - `pardes --addon-test <lib> <script>` runs a script of keys, clicks, words and ticks (its clock starts at 1 s), `focus` and `blur`, `size C diff --git a/docs/typ/running.typ b/docs/typ/running.typ index 7e0d16d4..1500845e 100644 --- a/docs/typ/running.typ +++ b/docs/typ/running.typ @@ -9,10 +9,11 @@ A running pardes is up to four kinds of process. Which of them there are, and what each holds, depends only on how it was started. -// daemon.zig:8-16 (nobody's parent; dups; hands terminals, windows, -// replicas); replica.zig:1-19, :730-769 (a client's core from the dump); -// host_io.zig:2176-2179 (the shells are the session's children); -// 9p_io.zig:57 (the socket); daemon.zig:546-698 (the stub). +// runtime/daemon.zig:8-16 (nobody's parent; dups; hands terminals, +// windows, replicas); core/replica.zig:1-19, :747-794 (a client's core +// from the dump); dev/host_io.zig:548-551 (the shells are the session's +// children); runtime/9p_io.zig:57 (the socket); runtime/daemon.zig:546-698 +// (the stub). #pairs( [*session*], [the process with the truth: the one core every other copy follows, the shells' pty masters (the shells are its children) and the 9P socket. There is one a session, always.], [*client*], [any further terminal or window on a session: a process of its own, with a copy of the session's core (a replica) loaded from the session's dump and kept in step with the session's tape. It has its own view (columns, focus, cursors, scroll) and draws it. It holds no shells and no 9P socket. A client on another machine is *far*.], @@ -20,9 +21,9 @@ and what each holds, depends only on how it was started. [*stub*], [the process your shell waits on when the session is not it. It holds nothing: it passes signals on, and ends when the session leaves its terminal.], ) -// tui.zig:588 (a session's terminal: one or none); gui.zig:2381-2384 (the -// window, or none while detached); daemon.zig:901-905 ("a session shows one -// frontend of its own"). +// dev/tui/tui.zig:590 (a session's terminal: one or none); +// dev/gui/gui.zig:2433-2436 (the window, or none while detached); +// runtime/daemon.zig:901-905 ("a session shows one frontend of its own"). A *frontend* is what draws: the terminal (`pardes`), the window (`pardes-gui`), or the Mac's own build. A session draws at most one frontend of its own: the one it was started with, or one attached to it @@ -40,10 +41,11 @@ travels on it. #run-terminal() -// main.zig:1538-1563, daemon.zig:663-698 (the fork, setsid, the stub); -// daemon.zig:550-559, :567-616 (what the stub forwards and how it ends); -// tui.zig:1697-1721 (the terminal's end: detached while kept, else the -// end); daemon.zig:305-314 (kept: the daemon answered and is still there). +// runtime/main.zig:1570-1595, runtime/daemon.zig:663-698 (the fork, +// setsid, the stub); runtime/daemon.zig:550-559, :567-616 (what the stub +// forwards and how it ends); dev/tui/tui.zig:1685-1709 (the terminal's +// end: detached while kept, else the end); runtime/daemon.zig:305-314 +// (kept: the daemon answered and is still there). `pardes` forks the session off and stays as its stub. The session runs in a POSIX session of its own, so it can outlive the job your shell waits on. It reads the keys from the terminal and draws on it itself; the stub only @@ -58,9 +60,9 @@ daemon, or after the daemon has died, it ends the session and its shells. #run-window() -// main.zig:1536-1537 (registered, no fork); gui.zig:1775-1788 (the -// window's close); next-daemon.md "Phase 3 notes", known gaps (a terminal's -// job). +// runtime/main.zig:1568-1569 (registered, no fork); +// dev/gui/gui.zig:1830-1843 (the window's close); next-daemon.md "Phase 3 +// notes", known gaps (a terminal's job). The process you started is the session; there is no stub. Closing the window ends the session and its shells, unless the session has clients and a daemon: then only the window closes, and the session runs on, detached. @@ -71,17 +73,18 @@ terminal hangs up. #run-detach() -// main.zig:1502-1520 (no fork; 160x50); main.zig:1535-1537 (registered -// detached, or with no daemon not at all); tui.zig:596-603 and :1700 -// (a hangup taken, nothing to leave); 9p_io.zig:704-729 (the hangup's -// default handler in a window's process). +// runtime/main.zig:1517-1552 (no fork; 160x50); runtime/main.zig:1567-1569 +// (registered detached, or with no daemon not at all); +// dev/tui/tui.zig:598-605 and :1688 (a hangup taken, nothing to leave); +// runtime/9p_io.zig:704-729 (the hangup's default handler in a window's +// process). The process you started is the session: nothing is forked, so the `&` that puts it in the background is yours to type (`pardes new --detach=work` is the same). It draws nothing and is 160×50 until an attach or the root #file("ctl")'s `size` sizes it. Until something attaches, 9P is the only way in (#doc("scripting")). -// main.zig, the --detach branch (the exec of the pardes beside it). +// runtime/main.zig, the --detach branch (the exec of the pardes beside it). `pardes-gui --detach` runs the `pardes` installed beside it in its place: a detached session draws nothing, and a window's binary would start a GPU device and its fonts for it. So every detached session is a terminal's @@ -96,9 +99,10 @@ reaches it. #run-attach-detached() -// main.zig:1780-1810 (attachTo); daemon.zig:883-897 (handed on); -// tui.zig:1373-1401 (the terminal entered as the first was); -// gui.zig:3271-3289, :2534-2547 (the window opened again). +// runtime/main.zig:1812-1842 (attachTo); runtime/daemon.zig:883-897 +// (handed on); dev/tui/tui.zig:1354-1382 (the terminal entered as the +// first was); dev/gui/gui.zig:3384-3402, :2588-2601 (the window opened +// again). For a terminal's session, `pardes attach work` hands its terminal and a pipe to the session through the daemon, and stays as the stub. For a window's, `pardes-gui attach work` asks, then exits, and the session opens @@ -106,7 +110,7 @@ its own window again. Either way the frontend is the session's own again, in the process that has been the session all along: what happens when it closes is what the first two sections say. -// daemon.zig:901-972 (find: the bare attach, and `other`). +// runtime/daemon.zig:901-972 (find: the bare attach, and `other`). The kind has to match. A terminal's session attached from `pardes-gui`, or a window's from `pardes`, is joined as a client (the next section). Bare, `pardes attach` takes the one detached session of its kind; with @@ -118,14 +122,15 @@ spelling of `attach work`. #run-attach-client() -// main.zig:1812-1818 (crossAttach); daemon.zig:974-1008 (the hello, the -// same build, handed on); replica.zig:1-19 (speculation and rollback); -// replica.zig:2013-2023, views.zig:31, Core.zig:1110-1153 (four views, the -// session's own among them); replica.zig:2111-2133 (a client leaving); -// replica.zig initDump, Addon.zig plainOps (a plain kind's code runs in -// the client that has it; another's in the session alone); gui.zig:2147-2161 -// (a client's notch: whole rows sent), :3544 (glideFrame: the picture on -// the client's clock); gui.zig:580-608 (a client's font: the session's +// runtime/main.zig:1844-1850 (crossAttach); runtime/daemon.zig:974-1008 +// (the hello, the same build, handed on); core/replica.zig:1-19 +// (speculation and rollback); core/replica.zig:2204-2214, core/views.zig:31, +// core/Core.zig:1163-1203 (four views, the session's own among them); +// core/replica.zig:2303-2325 (a client leaving); core/replica.zig initDump, +// core/Addon.zig plainOps (a plain kind's code runs in the client that has +// it; another's in the session alone); dev/gui/gui.zig:2200-2214 (a +// client's notch: whole rows sent), :3673 (glideFrame: the picture on the +// client's clock); dev/gui/gui.zig:595-623 (a client's font: the session's // request, by the face's name on this machine). Measured 2026-11-17 // (.scratch/sketch/reports/pardes-measure.md sections A, C and E): a // client's notch glides as the session's window does (5 frames, 0 to @@ -140,12 +145,28 @@ loads the session's dump into its own core, applies its own keys at once, and takes the session's tape (each step as the session took it) as the truth, rolling back when the session ordered things differently. +// core/replica.zig:5316-5395 (may_wait: what a client waits for, each +// row's why); core/tape.zig:1163-1193 (keeps_stopping); core/Core.zig:1763-1778 +// (readSessionFacts: the session's home, shell, directory); +// runtime/client.zig:245-261 (asks: a client's yank, paste and link, here). +What a client applies at once is what changes the editor alone: typing, +motions, edits, the layout (a pane dragged, collapsed or closed, a column +made), a yank. What touches the session's machine waits a round trip for +the session's step: a save, a shell's keys or its closing, a file read +from its disk, a program run, a kind whose state is the session's +(#doc("building", section: "may-wait") lists each, with why). The +session's machine is the one a client's words read: `~`, the default +shell and the directory a word runs in are the session's. The client's +machine is the one its view acts on: a yank to the system clipboard fills +the clipboard here, #word("ClipPaste") pastes it, and a link looked at +opens here. + A session takes three clients: four views at once, its own among them. A client's #word("Detach"), or its terminal or window closing, ends that client only; the last client of a detached session leaves its layout as the session's, for the next one to find. In a client, an addon whose state -is plain (`PA_PLAIN`: the games) runs in the client that shows it, from -that client's own addons, its keys applied at once; one the client lacks +is plain (`PA_PLAIN`: the games, the picture, the PDF) runs in the client +that shows it, from that client's own addons; one the client lacks shows a line saying so, and any other addon's panes show a line saying it runs in the session alone. A window client's wheel glides as the session's own window does: whole rows @@ -160,11 +181,11 @@ part. #run-far() -// main.zig:1498-1500, :1687-1772 (HOST:NAME, ssh -L, PARDES_SSH, -// PARDES_REMOTE_RUNTIME, a path with '/'); tui.zig:678-685 (far: blobs by -// hash, zstd); replica.zig:2516-2640 (Have: the disk cache); -// tui.zig:819-828, replica.zig:3012-3024 (no reconnect; a rejoin only -// after a divergence or an Upgrade). +// runtime/main.zig:1513-1515, :1719-1804 (HOST:NAME, ssh -L, PARDES_SSH, +// PARDES_REMOTE_RUNTIME, a path with '/'); runtime/client.zig:74-87 (far: +// blobs by hash, zstd); core/replica.zig:2709-2845 (Have: the disk cache); +// runtime/client.zig:168-177, core/replica.zig:3262-3274 (no reconnect; a +// rejoin only after a divergence or an Upgrade). `pardes attach box:work` runs `ssh -L` from a socket here to box's replica socket and is a client through it. `PARDES_SSH` replaces `ssh`; `PARDES_REMOTE_RUNTIME` names box's runtime directory when it is not the @@ -181,12 +202,12 @@ of the session or a divergence of its own. `pardes attach /run/x.sock:work` #run-no-daemon() -// daemon.zig:52-61 (PARDES_DAEMON, PARDES_TEST), :34 (Linux and FreeBSD -// only); main.zig:1544-1560 (no daemon reached: no fork); tui.zig:1352-1353, -// gui.zig:2483, host_io.zig:227 (Detach and Adopt refused); -// replica.zig:1900-1905 (a client only through the daemon); -// core/root.zig:117 (can_attach); runtime/main.zig:1498-1500 (a far attach needs no -// daemon here). +// runtime/daemon.zig:52-61 (PARDES_DAEMON, PARDES_TEST), :34 (Linux and +// FreeBSD only); runtime/main.zig:1576-1592 (no daemon reached: no fork); +// dev/tui/tui.zig:1333-1334, dev/gui/gui.zig:2537, dev/host_io.zig:85 +// (Detach and Adopt refused); core/replica.zig:2087-2092 (a client only +// through the daemon); core/root.zig:118 (can_attach); +// runtime/main.zig:1513-1515 (a far attach needs no daemon here). With `PARDES_DAEMON=off`, in a window under test (`PARDES_TEST`), where none could start, and in the Mac's own build, the session is the process you started, with no stub. #word("Detach") and #word("Adopt") refuse, no @@ -198,9 +219,10 @@ client. = At a glance <run-glance> -// The rows' sources are the sections above; `ps`: daemon.zig:241-245 -// (the daemon is whichever binary started it), main.zig:1727 (ssh's -// arguments), upgrade.zig:5-8 (an upgraded session's command line). +// The rows' sources are the sections above; `ps`: +// runtime/daemon.zig:241-245 (the daemon is whichever binary started it), +// runtime/main.zig:1759 (ssh's arguments), runtime/upgrade.zig:5-8 (an +// upgraded session's command line). #{ set text(size: 0.85em) set par(justify: false) @@ -225,13 +247,14 @@ started it. After an #word("Upgrade"), a session's command line starts with = What survives what <run-survives> -// replica.zig:2111-2133 (a client leaving); daemon.zig:485-502, -// 9p_io.zig:704-729, tui.zig:949-961 (TERM, HUP, INT: the shells go); -// daemon.zig:755-765, :770-789 (killed outright: kept for Adopt; `kill`: -// not); tui.zig:596-598 (a HUP kept by a daemon is a terminal's end, not -// the session's); daemon.zig:397, main.zig:1534-1561 (registered at the start and at -// an Upgrade only); upgrade.zig:1-15, replica.zig:2178-2201, :2787-2807 -// (Upgrade); Db.zig:1-17, :385-410 (the state file: Recent, the dumps). +// core/replica.zig:2303-2325 (a client leaving); runtime/daemon.zig:485-502, +// runtime/9p_io.zig:704-729, dev/tui/tui.zig:928-940 (TERM, HUP, INT: the +// shells go); runtime/daemon.zig:755-765, :770-789 (killed outright: kept +// for Adopt; `kill`: not); dev/tui/tui.zig:598-600 (a HUP kept by a daemon +// is a terminal's end, not the session's); runtime/daemon.zig:397, +// runtime/main.zig:1566-1593 (registered at the start and at an Upgrade +// only); runtime/upgrade.zig:1-15, core/replica.zig:2370-2393, :2988-3008 +// (Upgrade); core/Db.zig:1-17, :385-410 (the state file: Recent, the dumps). #{ set text(size: 0.85em) set par(justify: false) @@ -269,15 +292,18 @@ The code says these words too, each for one thing of its own (the older notes, `docs/next-daemon.md` among them, still say `remote` for a client and `headless` for detached): -// replica.zig:1-19 (authority); replica.zig:1832-1876, :2812 (Peers, Link, -// Joining); tui.zig:1189, gui.zig:2379 (Shell); Core.zig:269-271, -// replica.zig:1850-1852 (unattended against detached); daemon.zig:283, -// :363, :799 (the daemon's attached and detached), main.zig:1616 (`ps` -// says "has a frontend"). +// core/replica.zig:1-19 (authority); core/replica.zig:2006-2062, :3013 +// (Peers, Link, Joining); dev/tui/tui.zig:1162, dev/gui/gui.zig:2431 +// (Shell); core/Core.zig:313-315, core/replica.zig:2028-2030 (unattended +// against detached); runtime/daemon.zig:283, :363, :799 (the daemon's +// attached and detached), runtime/main.zig:1647 (`ps` says "has a +// frontend"); runtime/session.zig:1-30, runtime/client.zig:1-35 (the +// loops and what a frontend gives each). #pairs( [`authority`], [the session's core, inside the replica engine; `replica`, a client's core], [`Peers`, `Peer`; `Link`, `Joining`, `Joined`], [a session's clients, seen from the session; a client's connection, seen from the client], - [`Shell`], [a frontend's host object (`tui.zig`, `gui.zig`); elsewhere the user's shell], + [`Shell`], [a frontend's host object (`dev/tui/tui.zig`, `dev/gui/gui.zig`); elsewhere the user's shell], + [`session.Loop`, `client.Loop`], [the one loop a terminal's or a window's session runs and the one a client runs (`runtime/session.zig`, `runtime/client.zig`), each over the frontend that draws it: `Own` for a session's own terminal or window, `Tty` and `Client` for a client's; the Mac's own build keeps its own], [`unattended`], [a detached session with no client either: nobody looks, so a message goes on the clock], [`attached` in #file("/sessions")], [the daemon's word for a session with a frontend of its own; `pardes ps` says "has a frontend"], ) |
