diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/typ/reference.typ | 14 | ||||
| -rw-r--r-- | docs/typ/running.typ | 146 |
2 files changed, 96 insertions, 64 deletions
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"], ) |
