summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ghostty-macos-notes.md4
-rw-r--r--docs/macos.md4
-rw-r--r--docs/next-daemon.md111
-rw-r--r--docs/next-drag.md6
-rw-r--r--docs/next-run.md62
-rw-r--r--docs/next-terminal.md2
-rw-r--r--docs/next-tests.md2
-rw-r--r--docs/next-winmode.md4
-rw-r--r--docs/render-pipeline.md23
-rw-r--r--docs/search-proto-converge.md6
-rw-r--r--docs/typ/building.typ229
-rw-r--r--docs/typ/builtins-gui.json2
-rw-r--r--docs/typ/builtins-tui.json2
-rw-r--r--docs/typ/reference.typ14
-rw-r--r--docs/typ/running.typ146
15 files changed, 469 insertions, 148 deletions
diff --git a/docs/ghostty-macos-notes.md b/docs/ghostty-macos-notes.md
index 830d4b1f..3dc03265 100644
--- a/docs/ghostty-macos-notes.md
+++ b/docs/ghostty-macos-notes.md
@@ -56,10 +56,10 @@ comptime {
The payoff is that adding a feature adds an enum case, not a struct field: hosts
that do not implement it return `false` and the ABI never changed. Worth copying
the day a fixed callback list starts growing. pardes has three callbacks today
-— `wakeup`, `set_clipboard`, `read_clipboard` (`Runtime` in `runtime/macos.zig:153`)
+— `wakeup`, `set_clipboard`, `read_clipboard` (`Callbacks` in `runtime/macos.zig:153`)
— and does not need it yet.
-Two userdata scopes, worth noting: the runtime struct's `userdata` is
+Two userdata scopes, worth noting: the callbacks struct's `userdata` is
app-scoped, and each surface carries its own. Swift round-trips both with
`Unmanaged.passUnretained(self).toOpaque()` — libghostty never retains, so
lifetime stays entirely on the Swift side.
diff --git a/docs/macos.md b/docs/macos.md
index 44b77d67..98cd5312 100644
--- a/docs/macos.md
+++ b/docs/macos.md
@@ -85,7 +85,7 @@ copies had in common is the argument for the shared file existing: none set
the pty master, so a program in one pane could read and write another pane's
terminal and closing a master did not reliably hang its shell up.
-That is why the runtime struct is three callbacks rather than a second vtable —
+That is why the callbacks struct is three callbacks rather than a second vtable —
and why two of the three are the clipboard: the pasteboard is AppKit's, in both
directions, and is the one piece of IO the Zig side cannot reach for itself.
@@ -128,7 +128,7 @@ is made of and what opens a path from argv or the Dock (`Look <path>`).
it. `pardes_resize` also carries one cell in *physical* pixels, which only the
native PDF placement path reads — pass the backing-store size, not points.
-**Runtime callbacks.** `pardes_runtime_s` is a `userdata` and three functions,
+**Callbacks.** `pardes_callbacks_s` is a `userdata` and three functions,
copied by value during init so the struct need not outlive the call. `wakeup`
means "your state moved, please pump me". `set_clipboard` hands over text to put
on the pasteboard, borrowed for the duration of the call; it fires inside a tick
diff --git a/docs/next-daemon.md b/docs/next-daemon.md
index d93cbbea..37ba0241 100644
--- a/docs/next-daemon.md
+++ b/docs/next-daemon.md
@@ -9,8 +9,9 @@
Designed 2026-10-29 in discussion (the user, the coordinator, a survey
agent), and built since, phase by phase (phases 1 to 6, then the
-architecture steps): each phase's notes below say what was built, and where
-it went otherwise than the design that follows. Where the build differs, the
+architecture steps, then the reorganisation of 2026-11-17 to 19): each
+phase's notes below say what was built, and where it went otherwise than
+the design that follows; the reorganisation's notes are the last but two. Where the build differs, the
design's line is kept and marked *Built otherwise*. What runs today, in the
words ruled on 2026-11-17 (session, client, far, frontend, detached,
attach), is the manual's "How pardes runs" (`docs/typ/running.typ`); where
@@ -338,7 +339,7 @@ the ponytail lens:
one on a plain terminal differ. The 223 comptime platform branches stay
comptime: a session is one build, which the semantics hash says.
- Each pane's, each view's own (`PaneView`): `vweight`, `collapsed` and
- `attached_to` (a layout's); `focus`; the body's mode, cursor,
+ `docked_to` (a layout's); `focus`; the body's mode, cursor,
selections, sticky column, pending normal command and find; a document's
scroll, `hscroll` and size; and what the step measured for that view
(`tag_rows`, `tag_top`, `tag_scroll`, `view`, `notices`), so a view drawn
@@ -3358,7 +3359,10 @@ either kind. Decisions at the forks, with the ponytail lens:
- **The wheel in a client moves a row a turn.** The window's glide and a
touchpad's fraction run on the core's clock, which in a client is the
session's and moves only with its units. ponytail: whole rows, no glide;
- the local window's is unchanged.
+ the local window's is unchanged. *Built since:* the notch glides in a
+ client as in the session's own window (measured 2026-11-17, 5 frames, 0
+ to -22 px): whole rows go to the session, and the picture moves between
+ them on the client's own clock (`dev/gui/gui.zig` `glideFrame`).
- **A client says its frontend first** (`Event.frontend`: windowed, native
images and patches; wire 16, client tag 0x20): the view the session opens
for a joiner copies the live view's, and a window's view of a terminal's
@@ -3610,7 +3614,7 @@ Not done, and why:
touchpad's fractions are the client window's own picture, and only its
whole rows go to the session (`gui.zig`, the test "detached trackpad
scrolling keeps fractions local and queues whole rows for replication");
- a wheel's notch is still whole rows with no glide.
+ a wheel's notch glides too (above).
- **The notice a client gets is in its title and its log, not its frame**
(the session's words: joined again, let go, refused). The tty's draws
them on its notice band, which the window's frame has no slot for
@@ -4615,6 +4619,103 @@ After it, the query pane's two:
min and six clients (late windows and a late terminal among them): no
rejoin, no differing check, no panic. All pass.
+## The reorganisation notes (2026-11-17 to 2026-11-19)
+
+The reorganisation (`.scratch/sketch/PARDES.md`, its rulings P12 to P30)
+kept the design above: speculation and rollback, the session the only
+orderer. The user's rulings it built on: a far client keeps instant local
+echo and the replicated core stays (P12, P13); on a far client typing,
+motions, edits and layout are instant and what has a side effect on the
+system may take the round trip (P14); a client's yank fills the client's
+clipboard, and a layout change beside a shell is instant (P16). And the
+rule every later choice is measured by (P30): "keep the wire protocol
+simple and raw, and the local state process it" (`docs/typ/building.typ`,
+"The principle"). What was built, as it stands:
+
+- **The tree.** `src/` became four directories, each a module that names
+ the others: `core/` (`core/root.zig`, the core's struct
+ `core/Core.zig`), `dev/` (the frontends `dev/tui`, `dev/gui`, `dev/macos`,
+ and `dev/host_io.zig` cut into `Host`, `Shell`, `Inbox`, `KindJob`,
+ `Lsp`), `runtime/` (main, the daemon, the upgrade, 9P's transport, the
+ loops) and `abi/` (the wire, `plain`, `term`, the headers). A test
+ program runs its root module's tests, so a suite runs one a module.
+- **The frontends draw from the frame.** A frontend reads the `Surface`
+ and one record beside it, `Facts` (`core/surface.zig`, filled by
+ `draw.place`), to draw and to turn input into events, never the core;
+ so a client no longer makes its view live to read it (`OwnView`,
+ `Replica.within` deleted). Its frame statistics are its runner's
+ (`FrameStats`), and `present` says whether it showed the frame
+ (`present_skipped` gone). Left reading the core: the window's hit
+ test, its close, a session window's font.
+- **One client loop** (`runtime/client.zig`, `Loop(Frontend)`), which the
+ terminal's client (`Tty`) and the window's (`Client`) run: the joins and
+ the reader thread, and a pass of the frontend's calls (`own`, `again`,
+ `deadline`, `wait`, `present`, `copy`, `paste`, `open`, ...), written
+ once where `runClient` and `clientSession` each had their own. A client's
+ input is sent before it is applied (`Replica.pend`), and its yank, paste
+ and link are done on the client's machine.
+- **One session loop** (`runtime/session.zig`, `Loop(Frontend)`), which
+ the terminal's and the window's own frontend (`Own`) run: the
+ allocators, the workers, the core, the prompt files, the 9P listener,
+ `Peers`, the pump and the unit, an Upgrade or a Restore, and one order
+ for the parts' end. The devices are still each frontend's.
+- **The soak runs both** (`test/replicas.zig`): each client is
+ `client.Loop`, the session `session.Loop` over a frontend whose host is
+ the soak's delayed network (`Peers.threads` off: the soak does the
+ reader's and the writer's work in memory). It judges every stop against
+ `may_wait`, runs a frame corpus through a client (22 scenes, its frame
+ and `Facts` against a session's own), and ends each run with the
+ session's allocators' leak check. `replica.Authority` remains the
+ session's stand-in in the core's unit tests and the soak's side cases.
+- **What a far client does at once.** A Host entry that returns nothing no
+ longer stops a speculation, but for those on `keeps_stopping`
+ (`core/tape.zig`); closing a pane learns from its open whether Recent
+ keeps the file (`File.State.on_disk`), with no stat; `n`/`N` in a kind's
+ pane step the rows' own places, asking the disk nothing; a pane switch
+ beside a shell that asked for focus events tells the program a round
+ trip later. What may wait is one list, `may_wait` (`core/replica.zig`),
+ each row with why, pinned by a test that walks every word, key and
+ gesture on four kinds of pane.
+- **The session's facts** (its home, default shell and directory) are the
+ core's state, read once through the tape; `DumpDir`'s check and
+ `Font`/`Fonts` read the session's machine through it too. A count of
+ what `core/` asks of the machine is a test (`core/root.zig`,
+ `machine_lines`).
+- **Nothing of a core is a process global**: `config.tab_now`,
+ `Addon.distrusted` and `Kind.draw_tokens` went (the tab is the core's
+ `settings.tab`, handed down; the distrusted list is the client's,
+ `Options.distrusted`; a draw's token is its slot's); a test walks
+ `core/` for container-level `var`s (`allowed_vars`). With it, two
+ faults a rollback met: a terminal's image cache on the epoch's allocator,
+ a non-plain kind's slot freed by a speculation.
+- **Nothing a frame writes is read by a step.** A step read a pane's
+ notice bands and a big markdown text's tables as the last frame left
+ them; both are made from the step's state now (the tables read whole at
+ once, the budgeted reading deleted). `kept_out` (`core/root.zig`) names
+ every field out of the digest with who writes it, and `core/draw.zig`'s
+ test steps a core that draws and one that never does, digests equal.
+- **An entry written once.** Each of the core's taped entries is a private
+ body with its public name beside it,
+ `pub const update = pardes.tape.taped(updateInner);`; the tape's `Input`
+ variant and the replay come from the body's parameters. Six stay by
+ hand, each with why.
+- **The tape as a handle.** A core holds its tape as it holds its
+ allocator (`p.tape`, never null; `tape: *Tape` where no core is handed),
+ and the kinds, the addons, a directory's listing, the file system, the
+ core's own files and the smaller ones ask it so. The effects, the
+ budgets, the terminals and the process's `tape.on` are not moved yet.
+- **A slot is a type** where it crosses the core's edge: `Pane.Id` and
+ `View.Id`, each an `enum(u8)`, in the entries, events, effects, the Host
+ table, the wire's welcome and the device messages.
+- **Found by the real loops**: an idle client's quiet check woke its
+ session every 0.3 s for ever (now a check answered covers the units that
+ came while it was asked); an addon load under way in another live process
+ was taken for a crash (the mark is the loader's, `addon-loading.<pid>`);
+ a kind's draw landing after its pane closed was kept; the command line's
+ serve thread freed its core under a request; mvzr read past a pattern cut
+ short (`a{`), patched as it is fetched (`build/patches.zig`,
+ `docs/mvzr-bounds.md`).
+
## Architecture step 6 notes: the rollback and the digest through the journal
The clean-room plan's step 6 (`.scratch/clean-room/architecture.md` 9.4)
diff --git a/docs/next-drag.md b/docs/next-drag.md
index cfaa6c69..47ccdb0b 100644
--- a/docs/next-drag.md
+++ b/docs/next-drag.md
@@ -56,15 +56,15 @@ window it goes to is found by asking every registry session.
at the pointer where SDL can place windows), in its own session, so it
outlives the source and leaves no zombie. It waits (up to 15 s) for the
child's registry entry to answer `status`; the child reads the dump before
- it listens (gui.localSession), so then the file is removed and `handed`
- is posted into `host_io.Inbox`.
+ it listens (runtime/session.zig's `Loop.run`), so then the file is removed and `handed`
+ is posted into `host_io.Inbox` (dev/Inbox.zig).
- `Handover.finish`: taken, each carried pane is closed with
`Pardes.removePane` (Del's rows rule: its rows go to its neighbour; a
carried column's empty column is dropped); a pane whose revision changed
since the dump is kept, unattached ("copied to …; edited on the way, kept
here too"). Refused or failed: everything stays, the reason on the
message row. One handover flies at a time.
-- New option `--geometry=WxH[+X+Y]` (main.zig, `Options.geometry`).
+- New option `--geometry=WxH[+X+Y]` (runtime/main.zig, `Options.geometry`).
### 3. A grip let go over another pardes window: it goes there
diff --git a/docs/next-run.md b/docs/next-run.md
index dc189bc6..06941026 100644
--- a/docs/next-run.md
+++ b/docs/next-run.md
@@ -11,7 +11,7 @@ stays as built; the vocabulary and the manual's page first, no code moved
yet. Nothing in this note is built. What runs today, with a figure for each
way of starting pardes, is the manual's "How pardes runs"
(`docs/typ/running.typ`); the daemon's history is `docs/next-daemon.md`.
-Line numbers are this tree's, 2026-11-17.
+Line numbers are this tree's, 2026-11-19.
## The ruling
@@ -38,7 +38,7 @@ docs/next-run.svg`).
Today `pardes attach` is four mechanisms, picked by the daemon's `find`
(`runtime/daemon.zig:901-972`) and by `main.zig`'s `attachTo`
-(`runtime/main.zig:1774-1810`): a terminal handed to a detached terminal's
+(`runtime/main.zig:1806-1842`): a terminal handed to a detached terminal's
session, which draws on it in its own process while the attach process
waits as its stub; a window's detached session asked to open its own
window again, while the attach process exits; a client here, when the
@@ -51,19 +51,19 @@ The reorganisation plan's option b, checked against this tree:
| What goes | Where today | Lines, about |
|---|---|---|
-| A terminal handed to a session: the daemon's `attach` request and answer, the session's `attachTerminal`, the `attach` note and message | `daemon.zig:400-403`, `:431-437`, `:504-533`, `:883-897`; `tui.zig:105-107`, `:1065-1068`, `:1162-1167`, `:1373-1406`, `:1723`; `main.zig:1789-1810` | 110 |
-| A window opened again in place | `gui.zig:540-544` (what it reopens with), `:982-1000` (`reopenWindow`), `:2534-2547` (`openTheWindow`), `:2753`, `:3275-3281` | 50 |
-| The daemon choosing which session takes a frontend: `find`, its `other` answer, the use of `daemon.Kind` to match | `daemon.zig:901-972`, `:506-509` | 75 |
-| The stub's second use: an attach process waiting on a session that is not its child (`stubWait`'s `child = false`, its `r` refusals) | `daemon.zig:561-616` in part (`:593-597`, `:613-615`) | 10 |
+| A terminal handed to a session: the daemon's `attach` request and answer, the session's `attachTerminal`, the `attach` note and message | `runtime/daemon.zig:400-403`, `:431-437`, `:504-533`, `:883-897`; `dev/tui/tui.zig:107-109`, `:1037-1040`, `:1135-1140`, `:1354-1387`, `:1711`; `runtime/main.zig:1821-1842` | 110 |
+| A window opened again in place | `dev/gui/gui.zig:550-557` (what it reopens with), `:1004-1022` (`reopenWindow`), `:2588-2601` (`openTheWindow`), `:2823`, `:3388-3394` | 50 |
+| The daemon choosing which session takes a frontend: `find`, its `other` answer, the use of `daemon.Kind` to match | `runtime/daemon.zig:901-972`, `:506-509` | 75 |
+| The stub's second use: an attach process waiting on a session that is not its child (`stubWait`'s `child = false`, its `r` refusals) | `runtime/daemon.zig:561-616` in part (`:593-597`, `:613-615`) | 10 |
What does not go, against the plan's list: the upgrade record's terminal
and window fields. A session born with a terminal still takes it across an
-Upgrade (`tui.zig:1455-1463`, `upgrade.zig:101-117`), and a window's still
-says whether it had its window (`gui.zig:2600`). Only the record's other
-terminals (`tui.zig:1504-1523`, a build's from before 2026-11-06, when a
+Upgrade (`dev/tui/tui.zig:1438-1446`, `runtime/upgrade.zig:101-117`), and a window's still
+says whether it had its window (`dev/gui/gui.zig:2656`). Only the record's other
+terminals (`dev/tui/tui.zig:1487-1506`, a build's from before 2026-11-06, when a
second local terminal stopped being the session's) are already dead weight.
-Detach of the session's own frontend stays too (`tui.zig:1346-1371`,
-`gui.zig:2476-2485`, `:2521-2532`): it is how a session becomes detached.
+Detach of the session's own frontend stays too (`dev/tui/tui.zig:1327-1352`,
+`dev/gui/gui.zig:2530-2539`, `:2575-2586`): it is how a session becomes detached.
`daemon.Kind` stays in the hello and in `pardes ps` (`tty` or `gui`).
The plan counted 87 + about 60 + 67 lines for the first three rows; the
@@ -102,15 +102,16 @@ what is true, and whether it was measured.
for the wheel, measured (`.scratch/sketch/reports/pardes-measure.md`
sections C and E): a notch in a client glides as it does in the
session's own window (5 frames, 0 to -22 px, in both). Only whole rows
- go to the session (`gui.zig:2147-2161`; its comment and
- `docs/next-daemon.md`'s GUI replica notes still say "no glide"); the
+ go to the session (`dev/gui/gui.zig:2200-2214`; its comment still says
+ "no glide", which `docs/next-daemon.md`'s GUI replica notes said too
+ until 2026-11-19); the
picture moves between them on the client's own clock (`glideFrame`,
- `gui.zig:3544`). A touchpad's fractions are the client window's own
+ `dev/gui/gui.zig:3673`). A touchpad's fractions are the client window's own
picture too (the test "detached trackpad scrolling keeps fractions local
- and queues whole rows for replication", `gui.zig:8042`). Fonts: a client follows the session's font request by
+ and queues whole rows for replication", `dev/gui/gui.zig:8190`). Fonts: a client follows the session's font request by
the face's name when that face is installed on its machine
- (`gui.zig:580-608`, `syncReplicaFont`); its opacity is its own (not in
- the client's per-frame chores, `gui.zig:1311-1323`). The note said "keeps
+ (`dev/gui/gui.zig:595-623`, `syncReplicaFont`); its opacity is its own (not in
+ the client's per-frame chores, `dev/gui/gui.zig:1296-1322`). The note said "keeps
its own font"; it is corrected there. Measured: a face the client lacks
leaves it at its old face and its old size, and it diverged and joined
again (2 runs of 2, cause not found).
@@ -122,29 +123,32 @@ what is true, and whether it was measured.
## A session registering again
-Today a session says hello once, at its start (`main.zig:1535-1563`), or
-on its link after an Upgrade (`daemon.zig:392-398`). When the daemon dies
-the session's reader sees the link end (`daemon.zig:419-425`) and nothing
+Today a session says hello once, at its start (`runtime/main.zig:1567-1595`), or
+on its link after an Upgrade (`runtime/daemon.zig:392-398`). When the daemon dies
+the session's reader sees the link end (`runtime/daemon.zig:419-425`) and nothing
dials again, so the session runs on unlisted: `pardes ps` and attach do not
find it, Detach and Adopt refuse, and its frontend closing ends it
-(`tui.zig:1711-1721`, `gui.zig:1784`). The next daemon knows only the
+(`dev/tui/tui.zig:1699-1709`, `dev/gui/gui.zig:1839`). The next daemon knows only the
sessions that start after it.
The work: when `gone` is set, the session's loop (which calls
-`daemon.watch` each iteration already, `tui.zig:1115`, `gui.zig:1154`)
+`daemon.watch` each iteration already, `runtime/session.zig:115`, `:133-135`)
dials again, starting a daemon if none answers (`daemon.connect(true)`),
says its hello with its state, sends a dup of every pty master it holds
-(at most 64 fds a message, `daemon.zig:37`), and its clients' pids. What
+(at most 64 fds a message, `runtime/daemon.zig:37`), and its clients' pids. What
cannot come back: the shells of sessions killed earlier, which only the
dead daemon held.
## `--detach` forking
-Today `--detach` is the launch process itself (`main.zig:1502-1537`): it
-blocks the shell unless backgrounded by hand, it stays the job of the
-terminal it was typed in, and a window's detached session ends on that
-terminal's hangup (no handler of its own: `9p_io.zig:704-729`). The work:
-fork as `daemon.forkSession` does (`daemon.zig:663-698`), `setsid` in the
+Today `--detach` is the launch process itself (`runtime/main.zig:1517-1569`): it
+blocks the shell unless backgrounded by hand, and it stays the job of the
+terminal it was typed in. `pardes-gui --detach` runs the `pardes` beside
+it in its place (`runtime/main.zig:1518-1534`), so a window's binary is a
+detached session only where no `pardes` is beside it, and that one ends
+on its terminal's hangup (no handler of its own:
+`runtime/9p_io.zig:704-729`). The work:
+fork as `daemon.forkSession` does (`runtime/daemon.zig:663-698`), `setsid` in the
child, its stdin, stdout and stderr on `/dev/null`, and the parent
printing the session's name and exiting 0, with no stub (nothing waits on
it). For the window's build the fork comes before SDL starts. Then
@@ -181,7 +185,7 @@ session takes back.
- Re-registration: dial again at once and back off, or only when
something needs the daemon (a Detach, an Adopt, the frontend closing)?
- `--detach` with no daemon starts a session nothing can attach to
- (`main.zig:1535-1537` ignores the failed registration). Refuse, or keep
+ (`runtime/main.zig:1567-1569` ignores the failed registration). Refuse, or keep
it as a 9P-only session?
- `pardes ps` says "has a frontend" for a session with a frontend of its
own (the daemon's list, and so /sessions, still says `attached`, a wire
diff --git a/docs/next-terminal.md b/docs/next-terminal.md
index 26996897..2d033380 100644
--- a/docs/next-terminal.md
+++ b/docs/next-terminal.md
@@ -230,7 +230,7 @@ What differs from the plan above, and why:
of them fail for want of a terminal (they open a shell or a command
pane, read the emulator, or index the classic boot's three shells) and
say so on their first line (`if (pardes.Term.ops == null) return
- error.SkipZigTest; // a shell`), and ninep/testing.zig's `withTerm`
+ error.SkipZigTest; // a shell`), and ninep/harness.zig's `withTerm`
once for its 29. The rest run. core-test: 810 of 949 run, 139 skip;
`shell-test` runs all of them with the terminal. The 28 tests that read
terminal.zig's own state through a core are in test/terminal.zig
diff --git a/docs/next-tests.md b/docs/next-tests.md
index 2266b06a..7da60470 100644
--- a/docs/next-tests.md
+++ b/docs/next-tests.md
@@ -13,7 +13,7 @@ agent's survey. The `e2e` line (kbdin, mousein) is its first step.
`mousein`), the process (flags, daemon, attach, signals, terminal bytes),
and files on disk and effects. A rewrite that keeps those keeps its tests.
- **T1, in-process 9P, is the main tier.** The core is driven only through
- `serveFs` (core/ninep/testing.zig's `call`, `rd`, `wr`): as behavioural
+ `serveFs` (core/ninep/harness.zig's `call`, `rd`, `wr`): as behavioural
as a client on a socket, and milliseconds a case.
- **One process runner, not Python (the user, 2026-11-04):** test/process.zig's
`Process` starts `pardes` detached (over its socket), in a pty, or as the
diff --git a/docs/next-winmode.md b/docs/next-winmode.md
index c2a01da8..1f7c87c2 100644
--- a/docs/next-winmode.md
+++ b/docs/next-winmode.md
@@ -36,13 +36,13 @@ Typed in one go, the `j` after `SPC d` lands 100-250 ms after the `d`
waiting to see something happen. 400 ms clears a relaxed typist with margin
and is still quick enough to read as "it is asking", not "it is broken".
Key-hint popups elsewhere (which-key) wait a few hundred ms for the same reason. It is a compile-time
-constant beside `del_question` (keys are compiled in); a Runtime setting
+constant beside `del_question` (keys are compiled in); a `Settings` field
would be one line in config if the author wants to tune it live.
## Tests
- `window mode d deletes the outlined pane and asks k or j, c collapses
- it, and the mode stays` (pardes.zig): c twice restores the height; d asks,
+ it, and the mode stays` (core/layout.zig): c twice restores the height; d asks,
Esc keeps it, d j gives the rows below and the outline follows; d with one
neighbour closes at once onto it; labels hold none of h j k l d c.
- `the Del question shows only once its delay is up: a quick SPC d j never
diff --git a/docs/render-pipeline.md b/docs/render-pipeline.md
index 05bc8cfa..4f3cc7a5 100644
--- a/docs/render-pipeline.md
+++ b/docs/render-pipeline.md
@@ -15,7 +15,8 @@ frontend keeps the little it draws on its own.
deadline (`nextWake`: a message's linger, the look-hover preview, a
question's hint, a paused Grep, work that resumes a frame at a time);
`now`; `poll_frame`; `render` and `present` only when a frame is owed
- (`needs_frame`); and `post_present`, whose `Pardes.presented` lets a
+ (`needs_frame`; `present` says whether it showed the frame, and one it
+ held is owed again); and `post_present`, whose `Pardes.presented` lets a
drag's moving end and a look-hover follow what is under the pointer now.
- `advance(now)` steps `.tick`s a `frame_ns` (16 ms) at a time, for the
work that resumes a frame at a time; a wait is jumped in one step.
@@ -24,7 +25,12 @@ frontend keeps the little it draws on its own.
owner and focus; a body's first line and the text it shows,
`Region.line` and `Region.doc`), the layers a pixel shell draws at the
tagline's pitch and with compact context rows, the placements, the
- cursor and the palette (`Chrome`). Nothing on it moves.
+ cursor and the palette (`Chrome`). Nothing on it moves. Beside it,
+ `draw.place` fills one record, `Facts` (surface.zig): the view's size,
+ each open pane's rectangle, tag rows and kind, and the settings a
+ frontend draws by. A frontend draws, and turns its input into events,
+ from the Surface and its Facts, not from the core, so a client draws
+ its own view as a session's own frontend does.
- A placement (surface.zig's `Placement`) is a picture over the cells, a
pane's at a time and lowest first: its pixels (`raster`: RGBA, straight
alpha), the part shown (`src`), the cells it lies over and is clipped to
@@ -41,9 +47,10 @@ frontend keeps the little it draws on its own.
## The frontends' own
-Each draws these on its own clock, from the Surface alone, and draws their
-frames itself while they move (the last frame again: the tty's
-`poll_frame`, the window's loop), pacing its own waits:
+Each draws these on its own clock, from the Surface and its Facts alone, and draws their
+frames itself while they move (the last frame again: a session's own
+frontend through its host's `poll_frame`, a client's through the client
+loop's `again`, runtime/client.zig), pacing its own waits:
| what | tty | window | from |
|---|---|---|---|
@@ -55,9 +62,9 @@ frames itself while they move (the last frame again: the tty's
| `Pet` | (unsupported) | a sprite in the workspace tag's blank end (gui/pet.zig) | the grid's first row; SDL's ticks |
| a placement | a kitty image placed over its cells, or glyph art in them (Art.zig) without kitty graphics or when its pane asks | a texture by key, scissored to its cells, or glyph art when its pane asks | the frame's placements |
-The settings these read are plain bytes in the core's settings, dumped
-and replicated as any other; nothing a frontend keeps goes back to the
-core.
+The settings these read are the core's settings, plain bytes dumped and
+replicated as any other, copied into the frame's Facts; nothing a frontend
+keeps goes back to the core.
## The window's composition
diff --git a/docs/search-proto-converge.md b/docs/search-proto-converge.md
index ddc41196..da336f7c 100644
--- a/docs/search-proto-converge.md
+++ b/docs/search-proto-converge.md
@@ -15,7 +15,7 @@ only the prompts that are not search.
| piece | file | lifted from |
|---|---|---|
-| attached panes: a group under its owner, rows from the owner alone, moving/folding/closing with it, seam drag, Dump/Restore, `Unattach` | `core/layout.zig` "Attached panes", `Pane.attached_to` | attached |
+| attached panes: a group under its owner, rows from the owner alone, moving/folding/closing with it, seam drag, Dump/Restore, `Undock` | `core/layout.zig` "Attached panes", `Pane.docked_to` | attached |
| places: every match tinted, rail ticks (B1 on a tick goes there), current selected and in view, smart-case regex, view-first sliced scan, silent wrap | `core/Places.zig`, `Pane.places` | incsearch (MatchSet) |
| the query pane: line 1, its first word the source, live rows, preview, Enter/Esc/Del, reuse, settings | `core/Query.zig`, `Pane.query` | queryline, pick, live, preview, everywhere |
| fuzzy names (files, recent, panes, declarations) | `core/Names.zig` | pick (its scorer, whole) |
@@ -115,7 +115,7 @@ erases it and B2 / B3 on it take the word clicked, as on any row.
**Enter** puts the keyboard on the current hit in its pane (the +Preview
promoted in place: same slot, serial, rect, an unattached file pane from
then on), fills `/`, and freezes the rows into ordinary text (tag ` Save
-Unattach Del`). A `/` freezes its whole list (every place found first, 2000
+Undock Del`). A `/` freezes its whole list (every place found first, 2000
rows at most), a Grep every line it has. **Esc** while typing puts every
view back, clears the places it fed and closes the pane, its rows back to
the owner; a reused pane's frozen rows and their places come back instead.
@@ -145,7 +145,7 @@ cursor on line 15000.
| keystroke 1, `p` | Every `p` in the view tinted at once, the rest found a 4 ms slice a frame (the tag `1/38479+` until done); rail ticks fill in; the first `p` at or after the cursor selected in layout.zig (scrolled only if off screen). Rows: the lines holding `p`, each ` 15003 code`, from two before the current one, the current marked as the visited row, a note row above saying how many places come before them. |
| keystroke 2, `a` | `pa`: tints, ticks and rows narrow (`1/10189`); the current is again the first at or after where `/` was pressed, not after the last preview. The pane is the same size, line 1 where it was. |
| Ctrl-n / Ctrl-p | The next / previous `pa` current, selected in layout.zig; `2/10189`. |
-| Enter | The keyboard on that `pa`, `pa` in `/`, the rows frozen (the whole list, 2000 rows), tag `+Search 2/10189 Save Unattach Del`; tints and ticks stay while the pane lives. Ctrl-o goes back to where `/` was pressed. |
+| Enter | The keyboard on that `pa`, `pa` in `/`, the rows frozen (the whole list, 2000 rows), tag `+Search 2/10189 Save Undock Del`; tints and ticks stay while the pane lives. Ctrl-o goes back to where `/` was pressed. |
| `n` | The next `pa` in layout.zig, `3/10189`, its row marked in the +Search. |
| `N` | Back to `2/10189`; from the first, round to the last with no message. |
| Esc (typing) | layout.zig's selection and scroll exactly as at `/`, tints and ticks gone, the +Search closed, its rows back to layout.zig. |
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"],
)