diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 18:43:09 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 18:43:23 -0300 |
| commit | b7b6a682cd8abe63f763eb671a068b53be9600d8 (patch) | |
| tree | c8b229fdae29f2519f37d0d45963bef5d0d00429 /docs/typ | |
| parent | 65a8bce7a44932534b8eec088ab45d6875c138b2 (diff) | |
| download | pardes-b7b6a682cd8abe63f763eb671a068b53be9600d8.tar.gz pardes-b7b6a682cd8abe63f763eb671a068b53be9600d8.zip | |
docs: figures in the manual: docs/typ/figures.typ, the one file of the corpus that imports a package (cetz 0.4.2, which compiles with typst 0.15.1 here), draws in style.typ's palette; on paper a figure is its canvas, in HTML the same canvas as an inline SVG (html.frame) on the paper colour, in a <figure class="diagram"> that site.css frames; the grammar of "how pardes runs" (a process a box, its kind by colour, the core with the truth a starred chip, a replica's an outlined one, a screen, a line labelled with what travels) and its seven figures, and the design note's before and after
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'docs/typ')
| -rw-r--r-- | docs/typ/figures.typ | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/docs/typ/figures.typ b/docs/typ/figures.typ new file mode 100644 index 00000000..4ca51c1a --- /dev/null +++ b/docs/typ/figures.typ @@ -0,0 +1,313 @@ +// The figures of the corpus, drawn with cetz: the one file that imports it +// (a content file imports what it draws from here, never cetz itself). +// Colours are style.typ's palette. Each figure is a cetz canvas: on paper +// the canvas itself, in HTML the same canvas laid out as an inline SVG +// (html.frame), on the paper colour so it reads the same on a dark page. +#import "@preview/cetz:0.4.2" +#import "style.typ": palette, mono, html-out + +// ---- the grammar of "how pardes runs" (running.typ) ---- +// +// A box with a heavy edge is a process: its kind (session, client, daemon, +// stub) in the kind's colour, the command `ps` shows, then what it holds. +// The core with the truth is a filled chip with a star, a replica's core an +// outlined one; a terminal or a window is a screen (a bar along its top); +// a line is a connection, labelled with what travels on it, solid for +// what a person types and sees, dashed for the processes' own errands. + +#let kinds = ( + session: palette.grip, + client: palette.tag-name, + daemon: palette.col-grip, + stub: palette.rule.darken(25%), + other: palette.ink.lighten(45%), +) +#let truth = palette.mouse +#let small = 7.4pt +#let tint(c) = c.lighten(87%) + +/// What a process holds, one line each: `("truth", body)` the core with the +/// truth, `("replica", body)` a replica's core, `("plain", body)` anything +/// else. +#let held(kind, body) = { + let (fill, stroke, mark) = if kind == "truth" { + (truth.lighten(80%), 1pt + truth, text(fill: truth)[★ ]) + } else if kind == "replica" { + (palette.paper, (paint: truth, thickness: 0.9pt, dash: "dashed"), text(fill: truth)[☆ ]) + } else { + (palette.paper, 0.5pt + palette.rule, []) + } + box(width: 100%, fill: fill, stroke: stroke, radius: 1.5pt, inset: (x: 3pt, y: 2.2pt), + text(size: small, fill: palette.ink, [#mark#body])) +} + +/// A process at (x, y), w by h (cm): its kind, its command, what it holds. +/// `dash` for a process that does not stay (an attach that asks and exits). +#let proc(x, y, w, ht, kind, cmd, ..holds, name: none, dash: none) = { + import cetz.draw: * + let c = kinds.at(kind) + rect((x, y), (x + w, y + ht), fill: tint(c), stroke: (paint: c, thickness: 1.3pt, dash: dash), radius: 3pt, name: name) + content((x + 0.14, y + ht - 0.1), anchor: "north-west", box(width: (w - 0.28) * 1cm, stack(spacing: 2.4pt, + if kind != "other" { text(size: small, weight: "bold", fill: c, upper(kind)) }, + text(font: mono, size: 0.95 * small, fill: palette.ink, cmd), + v(1pt), + ..holds.pos().map(((k, b)) => held(k, b)), + ))) +} + +/// A terminal or a window at (x, y), w by h: a screen with a bar along its +/// top. `none-there: true` for the screen a session does not have. +#let screen(x, y, w, ht, label, none-there: false) = { + import cetz.draw: * + let ink = if none-there { palette.rule } else { palette.ink } + let dash = if none-there { "dashed" } else { none } + rect((x, y), (x + w, y + ht), fill: palette.paper, stroke: (paint: ink, thickness: 0.9pt, dash: dash), radius: 2pt) + if not none-there { + rect((x, y + ht - 0.22), (x + w, y + ht), fill: ink.lighten(70%), stroke: (paint: ink, thickness: 0.9pt), radius: (north: 2pt)) + } + content((x + w / 2, y + (ht - if none-there { 0 } else { 0.22 }) / 2), box(width: (w - 0.3) * 1cm, + align(center, text(size: small, fill: if none-there { palette.tag-fg } else { palette.ink }, label)))) +} + +/// A shell, a child of its session: a small plain box. +#let shellbox(x, y, label) = { + import cetz.draw: * + rect((x, y), (x + 1.3, y + 0.62), fill: palette.paper, stroke: 0.7pt + palette.rule, radius: 2pt) + content((x + 0.65, y + 0.31), text(font: mono, size: small, fill: palette.tag-fg, label)) +} + +/// A connection through `pts`, labelled where `at` says (on the paper, so +/// no text sits on a line). `ends`: "end", "both" or none. +#let wire(..pts, label: none, at: none, ends: "end", dash: none, side: "center", width: none) = { + import cetz.draw: * + let p = pts.pos() + let m = (fill: palette.ink, scale: 0.6) + let mark = if ends == "both" { (start: "stealth", end: "stealth", ..m) } else if ends == "end" { (end: "stealth", ..m) } else { none } + line(..p, stroke: (paint: palette.ink, thickness: 0.8pt, dash: dash), mark: mark) + if label != none and at != none { + let body = text(size: small, fill: palette.ink, label) + content(at, anchor: side, box(fill: palette.paper, inset: (x: 2pt, y: 1.2pt), + if width != none { box(width: width * 1cm, align(center, body)) } else { body })) + } +} + +/// A machine's edge, dashed, its name at its top left. +#let machine(x, y, w, ht, label) = { + import cetz.draw: * + rect((x, y), (x + w, y + ht), stroke: (paint: palette.rule, thickness: 0.9pt, dash: "dashed"), radius: 5pt) + content((x + 0.2, y + ht - 0.12), anchor: "north-west", text(size: small, style: "italic", fill: palette.tag-fg, label)) +} + +/// A canvas as a figure of either output: on paper unbreakable, in HTML an +/// inline SVG on the paper colour (class `diagram`, for site.css). +#let drawn(body, alt: "") = { + let canvas = { + // A figure's words are short labels: never justified, never hyphenated. + set par(justify: false) + set text(hyphenate: false) + cetz.canvas(length: 1cm, body) + } + context if html-out() { + html.elem("figure", attrs: (class: "diagram", role: "img", "aria-label": alt), + html.frame(block(fill: palette.paper, inset: 8pt, canvas))) + } else { + block(breakable: false, above: 1em, below: 1.2em, width: 100%, align(center, canvas)) + } +} + +// The truth and the screens, the same in every figure below. +#let core-truth = ("truth", [the core: *the truth*]) +#let ptys = ("plain", [the shells' pty masters]) +#let ninep(n) = ("plain", [the 9P socket #raw("pardes-9p-" + n + ".sock")]) +#let daemon-box(x, y, ..extra) = proc(x, y, 3.4, 2.0, "daemon", "pardes --daemon", + ("plain", [a dup of each pty master]), ("plain", [the list of sessions]), ..extra) + +/// The legend: one of each mark the figures use. +#let run-legend() = drawn(alt: "legend: the four kinds of process, the core with the truth, a replica's core, a screen, a connection", { + import cetz.draw: * + let chip(x, kind, label) = { + let c = kinds.at(kind) + rect((x, 0.75), (x + 0.42, 1.17), fill: tint(c), stroke: 1.3pt + c, radius: 2pt) + content((x + 0.55, 0.96), anchor: "west", text(size: small, fill: c, weight: "bold", upper(label))) + } + chip(0, "session", "session") + chip(2.45, "client", "client") + chip(4.65, "daemon", "daemon") + chip(6.95, "stub", "stub") + content((9.0, 0.96), anchor: "west", box(width: 3.2cm, held("truth", [the truth]))) + content((12.5, 0.96), anchor: "west", box(width: 3.3cm, held("replica", [a replica's core]))) + screen(0, -0.55, 3.0, 0.85, [a terminal, a window]) + wire((3.4, -0.12), (5.0, -0.12), ends: "both") + content((5.2, -0.12), anchor: "west", text(size: small)[what you type and see]) + wire((8.1, -0.12), (9.9, -0.12), dash: "dashed") + content((10.1, -0.12), anchor: "west", text(size: small)[the processes' own errands]) +}) + +/// `pardes` in a terminal. +#let run-terminal() = drawn(alt: "pardes in a terminal: a stub, the session it forked, the daemon, the shells", { + import cetz.draw: * + screen(0, 3.1, 3.2, 1.9, [your terminal]) + proc(0, 0, 3.2, 2.0, "stub", "pardes", + ("plain", [the job your shell waits on]), ("plain", [holds nothing else])) + proc(5.4, 1.0, 5.0, 4.0, "session", "pardes", + core-truth, ptys, ninep("<pid>"), + ("plain", [draws on your terminal]), + ("plain", [the stub's child, in a POSIX session of its own])) + daemon-box(12.6, 3.0) + shellbox(12.6, 1.05, "bash") + shellbox(14.3, 1.05, "make") + wire((3.2, 4.25), (5.4, 4.25), ends: "both", label: [keys in, \ frames out], at: (4.3, 4.72), width: 1.9) + wire((3.2, 1.4), (5.4, 1.4), ends: "both", dash: "dashed", label: [signals →\ ← it left, or ended], at: (4.3, 0.82), width: 2.0) + wire((1.6, 3.1), (1.6, 2.0), ends: none, dash: "dotted", label: [opened it], at: (2.4, 2.55)) + wire((10.4, 4.25), (12.6, 4.25), ends: "both", dash: "dashed", label: [registered; \ a dup of each pty], at: (11.5, 4.82), width: 2.0) + wire((10.4, 1.36), (12.6, 1.36), ends: "both", label: [a pty's bytes], at: (11.5, 1.72)) + wire((14.1, 3.0), (14.1, 1.67), ends: none, dash: "dotted", label: [keeps each \ one open], at: (15.15, 2.33), width: 1.6) +}) + +/// `pardes-gui`. +#let run-window() = drawn(alt: "pardes-gui: one session process that draws the window, the daemon, the shells", { + import cetz.draw: * + screen(0, 2.6, 3.2, 2.4, [a window]) + content((1.6, 1.7), box(width: 3.1cm, align(center, text(size: small, fill: palette.tag-fg)[started from a terminal, it is that terminal's job]))) + proc(5.4, 1.0, 5.0, 4.0, "session", "pardes-gui", + core-truth, ptys, ninep("<pid>"), + ("plain", [draws the window (SDL, the GPU)]), + ("plain", [no stub: it is the process you started])) + daemon-box(12.6, 3.0) + shellbox(12.6, 1.05, "bash") + shellbox(14.3, 1.05, "make") + wire((3.2, 4.0), (5.4, 4.0), ends: "both", label: [keys in, \ frames out], at: (4.3, 4.47), width: 1.9) + wire((10.4, 4.25), (12.6, 4.25), ends: "both", dash: "dashed", label: [registered; \ a dup of each pty], at: (11.5, 4.82), width: 2.0) + wire((10.4, 1.36), (12.6, 1.36), ends: "both", label: [a pty's bytes], at: (11.5, 1.72)) + wire((14.1, 3.0), (14.1, 1.67), ends: none, dash: "dotted", label: [keeps each \ one open], at: (15.15, 2.33), width: 1.6) +}) + +/// `pardes --detach=work &`. +#let run-detach() = drawn(alt: "pardes --detach: the session with nothing drawn, reached by 9P, registered with the daemon", { + import cetz.draw: * + screen(0, 3.1, 3.2, 1.9, [no terminal, no window: nothing drawn, 160×50 until something sizes it], none-there: true) + proc(0, 0, 3.2, 2.0, "other", "pardes fs read index -s work", + ("plain", [a script, or a pane's `pardes FILE`: a 9P client])) + proc(5.4, 1.0, 5.0, 4.0, "session", "pardes --detach=work", + core-truth, ptys, ninep("work"), + ("plain", [draws nothing]), + ("plain", [the process you started: your shell's background job])) + daemon-box(12.6, 3.0) + shellbox(12.6, 1.05, "bash") + shellbox(14.3, 1.05, "make") + wire((3.2, 1.4), (5.4, 1.4), ends: "both", label: [9P], at: (4.3, 1.75)) + wire((10.4, 4.25), (12.6, 4.25), ends: "both", dash: "dashed", label: [registered, \ detached], at: (11.5, 4.82), width: 2.0) + wire((10.4, 1.36), (12.6, 1.36), ends: "both", label: [a pty's bytes], at: (11.5, 1.72)) + wire((14.1, 3.0), (14.1, 1.67), ends: none, dash: "dotted", label: [keeps each \ one open], at: (15.15, 2.33), width: 1.6) +}) + +/// `pardes attach work` to a session with no frontend: a terminal's and a +/// window's. +#let run-attach-detached() = drawn(alt: "pardes attach to a detached session: the terminal handed to the session through the daemon; for a window, the session opens its own again", { + import cetz.draw: * + // A terminal's session. + content((0, 8.75), anchor: "west", text(size: 8pt, weight: "bold")[a terminal's session: `pardes attach work`]) + screen(0, 6.4, 3.4, 1.7, [this terminal]) + proc(0, 3.9, 3.4, 2.0, "stub", "pardes attach work", + ("plain", [now the job your shell waits on]), ("plain", [holds nothing])) + daemon-box(5.5, 3.9) + proc(11.0, 3.9, 5.0, 4.2, "session", "pardes --detach=work", + core-truth, ptys, ninep("work"), + ("plain", [draws on this terminal now]), + ("plain", [the same process as before])) + wire((3.4, 4.8), (5.5, 4.8), label: [① this terminal \ and a pipe], at: (4.45, 5.32), width: 1.8) + wire((8.9, 4.8), (11.0, 4.8), dash: "dashed", label: [② handed on], at: (9.95, 5.15)) + wire((3.4, 7.25), (11.0, 7.25), ends: "both", label: [③ keys in, frames out], at: (7.2, 7.6)) + line((-0.1, 3.3), (16.1, 3.3), stroke: (paint: palette.rule, thickness: 0.6pt)) + // A window's session. + content((0, 2.85), anchor: "west", text(size: 8pt, weight: "bold")[a window's session: `pardes-gui attach work`]) + proc(0, 0, 3.4, 2.0, "other", "pardes-gui attach work", ("plain", [asks, then exits: no stub]), dash: "dashed") + daemon-box(5.5, 0) + proc(11.0, 0, 5.0, 2.3, "session", "pardes-gui --detach=work", + core-truth, ("plain", [opens its own window again])) + wire((3.4, 0.9), (5.5, 0.9), label: [① asks], at: (4.45, 1.25)) + wire((8.9, 0.9), (11.0, 0.9), dash: "dashed", label: [② "attach"], at: (9.95, 1.25)) +}) + +/// `pardes attach work` to a session that has a frontend (or is of the +/// other kind): a client. +#let run-attach-client() = drawn(alt: "pardes attach to a session with a frontend: a client process with its own replica core, joined through the daemon", { + import cetz.draw: * + screen(0, 3.4, 3.0, 1.7, [its own terminal]) + proc(0, 0, 4.8, 2.9, "session", "pardes", + core-truth, ptys, ninep("<pid>"), ("plain", [draws its own terminal])) + daemon-box(6.3, 3.4) + proc(11.2, 0, 4.8, 2.9, "client", "pardes attach work", + ("replica", [the core: a replica]), ("plain", [its own view: columns, focus, cursors]), + ("plain", [no shells, no 9P socket]), ("plain", [draws this terminal])) + screen(13.0, 3.4, 3.0, 1.7, [another terminal]) + wire((1.5, 3.4), (1.5, 2.9), ends: "both", label: [keys in, frames out], at: (1.7, 3.15), side: "west") + wire((14.5, 3.4), (14.5, 2.9), ends: "both", label: [keys in, frames out], at: (14.3, 3.15), side: "east") + wire((12.0, 2.9), (12.0, 4.4), (9.7, 4.4), label: [① hello: the session's \ name, this build], at: (10.85, 4.88), width: 2.2) + wire((6.3, 4.4), (3.9, 4.4), (3.9, 2.9), dash: "dashed", label: [② its socket, \ handed on], at: (5.05, 4.9), width: 1.8) + wire((11.2, 1.75), (4.8, 1.75), label: [③ its keys and clicks], at: (8.0, 2.1)) + wire((4.8, 0.85), (11.2, 0.85), label: [③ the tape: each step the session took; the terminals' screens], at: (8.0, 0.45), width: 6.2) +}) + +/// A far session: `pardes attach box:work`. +#let run-far() = drawn(alt: "a far session: a client here, ssh -L, and on the far machine the daemon and the session", { + import cetz.draw: * + machine(0, 0, 7.7, 5.6, [this machine]) + machine(8.3, 0, 7.7, 5.6, [box, the far machine]) + screen(0.3, 3.4, 2.8, 1.6, [your terminal]) + proc(0.3, 0.3, 4.2, 2.7, "client", "pardes attach box:work", + ("replica", [the core: a replica]), ("plain", [its own view]), + ("plain", [the texts it was sent, kept on disk])) + proc(5.0, 0.7, 2.4, 1.6, "other", "ssh -L", ("plain", [a socket here, \ the far one there])) + daemon-box(8.6, 2.9) + proc(12.4, 0.3, 3.3, 2.7, "session", "pardes", + core-truth, ptys, ("plain", [its own frontend there, or none])) + wire((1.7, 3.4), (1.7, 3.0), ends: "both") + wire((4.5, 1.55), (5.0, 1.55), ends: "both") + wire((7.4, 2.0), (10.3, 2.0), (10.3, 2.9), label: [① hello], at: (9.0, 2.35)) + wire((12.0, 4.1), (14.05, 4.1), (14.05, 3.0), dash: "dashed", label: [② handed on], at: (13.3, 4.45)) + wire((7.4, 1.1), (12.4, 1.1), ends: "both", label: [③ the tape in zstd, \ texts by hash], at: (9.9, 0.6), width: 2.6) +}) + +/// No daemon: `PARDES_DAEMON=off`, or none could start. +#let run-no-daemon() = drawn(alt: "no daemon: one process, the session, with nothing to detach to", { + import cetz.draw: * + screen(0, 1.5, 3.0, 1.9, [your terminal, \ or its window]) + proc(5.4, 0.3, 5.2, 3.1, "session", "pardes", + core-truth, ptys, ninep("<pid>"), ("plain", [draws on the terminal: the process you started])) + shellbox(12.2, 0.4, "bash") + shellbox(13.9, 0.4, "make") + rect((12.2, 1.7), (15.6, 3.4), stroke: (paint: truth, thickness: 0.9pt, dash: "dashed"), radius: 3pt) + content((13.9, 2.55), box(width: 3.2cm, align(center, text(size: small, fill: truth)[no daemon: Detach, Adopt and clients are refused]))) + wire((3.0, 2.45), (5.4, 2.45), ends: "both", label: [keys in, \ frames out], at: (4.2, 2.95), width: 1.6) + wire((10.6, 0.7), (12.2, 0.7), ends: "both", label: [a pty's bytes], at: (11.4, 1.05)) +}) + +// ---- docs/next-run.md: the ruled direction, not built ---- + +/// What `pardes attach` does today (four things) beside what it does once +/// "an attach is always a client" is built (one). Drawn by +/// docs/next-run.typ for the design note; no chapter shows it. +#let run-attach-before-after() = drawn(alt: "pardes attach today: four mechanisms; after: always a client", { + import cetz.draw: * + let row(x, y, when, typed, kind, said) = { + content((x, y + 1.2), anchor: "west", text(size: small, style: "italic", fill: palette.tag-fg, when)) + rect((x, y), (x + 3.4, y + 0.95), fill: palette.paper, stroke: 0.8pt + palette.ink, radius: 2pt) + content((x + 1.7, y + 0.475), text(font: mono, size: 0.95 * small, typed)) + line((x + 3.4, y + 0.475), (x + 3.9, y + 0.475), stroke: 0.8pt + palette.ink, mark: (end: "stealth", fill: palette.ink, scale: 0.6)) + let c = kinds.at(kind) + rect((x + 3.9, y), (x + 7.5, y + 0.95), fill: tint(c), stroke: 1.3pt + c, radius: 3pt) + content((x + 5.7, y + 0.475), box(width: 3.4cm, align(center, text(size: small, said)))) + } + content((0, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[Today: four mechanisms]) + row(0, 6.0, [a terminal's session, detached], [pardes attach work], "session", [the session draws here; this process becomes its stub]) + row(0, 4.3, [a window's session, detached], [pardes-gui attach work], "session", [the session opens its own window; this process exits]) + row(0, 2.6, [it has a frontend, or is the other kind], [pardes attach work], "client", [a client: this process, with a replica]) + row(0, 0.9, [on another machine], [pardes attach box:work], "client", [a client, through `ssh -L`]) + line((7.95, -0.1), (7.95, 8.4), stroke: (paint: palette.rule, thickness: 0.8pt)) + content((8.45, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[After: always a client]) + row(8.45, 6.0, [any session on this machine], [pardes attach work], "client", [a client: this process, with a replica]) + row(8.45, 4.3, [on another machine], [pardes attach box:work], "client", [a client, through `ssh -L`]) + content((8.45, 2.85), anchor: "west", box(width: 7.5cm, text(size: small)[A session's own frontend is only the one it was born with: a Detach, or its terminal or window closing, leaves it detached for good, and each attach after is a client.])) + content((8.45, 1.1), anchor: "west", box(width: 7.5cm, text(size: small, fill: truth)[Gone: a terminal handed to a session, a window opened again in place, the daemon choosing which session takes a frontend, the stub of an attach.])) +}) |
