summaryrefslogtreecommitdiff
path: root/src/daemon.zig
Commit message (Collapse)AuthorAge
* daemon: --attach=<name> to a session of the other kind (pardes in a terminal ↵Gabriel Schneider2026-10-31
| | | | | | for a window's session, pardes-gui for a terminal's) joins it as a replica client through this machine's pardes-replica.sock, where it was refused in words; the daemon answers `other <name>` (a named one, or with none of the client's kind the one session there is) and the client goes on as --attach=<sock>:<name>; --help says attach takes an attached session too; test/daemon.py's window test attaches a terminal to the window session by name (the old build refused it, 'is a window') Co-Authored-By: Claude Opus 5.5 <[email protected]>
* views: a client that joins again has its own view back, layout, focus and ↵Gabriel Schneider2026-10-30
| | | | | | the panes opened in it: an Upgrade's clients and one whose bye says it joins again (a divergence's, wire 19's `bye.again`) leave their view kept for them (`views_away`, digested and dumped, so an Upgrade's new build has it; taped `awayView`), the client names it in its next hello (`Hello.view`, handed on by the daemon with the connection) and its join takes it back (taped `rejoinView`) rather than a copy of the session's; the live view is never a kept one, `views.count` counts the others, and a join with every view taken lets one go (every Upgrade made each client's own panes leave its view: the hunt's 80 ms cell lost `+Search` and `+New`) Co-Authored-By: Claude Opus 5.5 <[email protected]>
* remote clients: a pointer's hit carries the place it was made on ↵Gabriel Schneider2026-10-30
| | | | | | (Layer.Place, on the wire, version 17) and a step resolves it from that, never from this process's frame (`surface`, `.local`), which a session never draws for a client: a window's pointer over a tag diverged it at once (the user's `tape byte 119`, 15 rejoins in 25 s) and a click there aborted it; a replay that meets a site its tape lacks, or makes a syscall that is none, is a divergence that goes on harmless (poisonOf), not a panic, and a speculation that makes one waits (Tty's shell lookup, untaped, is a value site now, as Shell's was); a copy over a queue is refused, not asserted; a session's last client, while no one else watches it, leaves it its layout (leaveView, settled as closeView is), which its rejoin copies; a redial waits only after an Upgrade's `refused` (a divergence's redialled a gone session 20 s); a dying session shuts its clients' links before its trace, and an --attach client ends its ssh and socket whatever way it exits; a far join's hashing stops at a blob once its client is let go (its leave waits for it in the step); a confirmed speculation's state is checked against its unit's digest, and the trace gives a key's and a pointer's words; test/daemon.py: 200 far joins level, a window's pointer swept over tags and body, ssh stand-in clients refused and detached, a client of a killed session ending in 2 s; in-process tests for each Co-Authored-By: Claude Opus 5.5 <[email protected]>
* daemon: pardes --ps, --kill=<name>, --kill-all: the daemon's registry as a ↵Gabriel Schneider2026-10-30
| | | | | | tree (the daemon, each session with its pid, kind, state and name and the shells it holds, then the shells no session holds, which Adopt takes) and sessions ended with their shells: a TERM, a KILL 2 s later, gone once the daemon no longer lists them (a zombie still answers kill 0), a killed session's held masters closed rather than kept for an Adopt and --kill-all's every kept one; in --help, the guide and the reference; --help's ssh default no longer -C; test/daemon.py --manage Co-Authored-By: Claude Opus 5.5 <[email protected]>
* replica clients over a socket: the session streams each its dump and every ↵Gabriel Schneider2026-10-30
| | | | | | | | | | | | unit after it (replica.zig `Peers`, a writer and a reader thread a client, units at each step boundary, a client's input stepped there in its own view), and `pardes --attach=<socket>:<name>` and `--attach=<host>:<name>` (through `ssh -tt -L`) are a client in the tty host, its keys applied at once by its own replica and drawn by its own process wire.zig version 15: welcome (the client's id and view, the dump's length, the session's UTC offset and digest), dump pieces, units (with the authority's clocks), terminal messages both ways, a check. A unit carries one digest, at its end (`unit_digests`). The client: tty.zig `Shell.remote`, `feed` (a terminal's input to the replica and the session); the session's clock guessed from the last unit's (tape.zig `Guess`); a pump woken only by a client's post reads no new time (`mail_only`), and a unit of another's ending where the last ended leaves the speculation as it is (`neutral`); the rollback copy taken while idle (`Replica.ready`); views a frontend here does not draw left undrawn. A lagging client never holds the session: its queue is cut off past 64 MiB (PARDES_REPLICA_LAG_KB). Detach in a client ends that client; a Restore lets every client go. daemon.zig: a replica the daemon hands over is the session's loop's (a note), not a stub thread's. A window session refuses one in words. test/daemon.py `--clients`: two clients (one through the delay relay) type into a detached session and agree with it, one killed outright, one detached, a third typing into a shell. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* upgrade: a newer build at the path a session started from is said at a ↵Gabriel Schneider2026-10-29
| | | | | | focus-in, once a build, the path read just after the first frame (off a startup's way); an upgraded process lets the binary it replaced go (held, its deleted file kept its blocks) and sweeps its old image's prompt files (kept for an exec that failed); test/daemon.py --upgrade asks through /ctl, checks the fds and prompt files level, and runs on FreeBSD (procstat, the daemon's registry, no kept old binary there) Co-Authored-By: Claude Opus 5.5 <[email protected]>
* upgrade: the Upgrade word (SPC s U, a tag, 9P) moves a running session onto ↵Gabriel Schneider2026-10-29
| | | | | | the pardes installed where it started, in place, by exec at a step boundary: its dump in the DumpDir, its pty masters, terminals, stubs and daemon link kept open and named on the new command line, every view and running shell its own again; the daemon re-execs too, its registry on its command line; a build that cannot load the dump falls back to the old binary, or starts afresh with the shells adopted and the dump kept (test/daemon.py --upgrade, --upgrade --gui) Co-Authored-By: Claude Opus 5.5 <[email protected]>
* the replica socket: the daemon listens on pardes-replica.sock, a stream `ssh ↵Gabriel Schneider2026-10-29
| | | | | | | | | | | | -L` can forward, refuses another build's hello in words and hands the connection to its session, which welcomes it and answers pings The daemon binds `pardes-replica.sock` beside its own (SOCK_STREAM, so ssh can forward it; the SEQPACKET socket that carries fds stays local) once it holds its lock. A replica's first message is a hello (detached/wire.zig, now version 14): the protocol version at offset 0, the client's semantics hash and the session's name. The daemon reads exactly that much and no further, so whatever the client sends next is the session's, keeps up to 16 hellos still on their way (ponytail: one that never comes holds its slot until it hangs up), and refuses in words another protocol, a session nobody has, or another build: every session now says its own hash in its registration (daemon protocol 2), so a mismatch never reaches it. An accepted connection goes to the session over its link (SCM_RIGHTS) and the daemon keeps no copy; the session welcomes it with its pid and name on a thread of its own and answers each ping with a pong, until bye or a hangup. ponytail: that stub is all a session does with a replica until phase 5 proper; it is what times a round trip through the handoff and `ssh -L`. The semantics hash (wire.semantics) is phase 1's undone item: the protocol, the release and commit, the platform, the build options, every dependency the manifest pins by its content hash (grammars, ghostty, the Unicode tables: build.zig's new `deps` option) and the walker codec's assumptions (pointer width, byte order). Not the OS: a Linux client of a FreeBSD session is the main case. ponytail: an unstamped build has no commit, so two dev trees of one release with the same options are not told apart. `pardes --version` prints it on a second line. The hello lost its grid (a replica's view takes a resize like any other input). test/daemon.py: a hello of this build welcomed by the session itself (its pid, one fd more in the session and none in the daemon, and back once it hangs up), 50 pings, another build's hello and an unknown session's refused, and `--ping <socket> <session> <pardes> [n]`, which times a hello and n pings on any replica socket (a forwarded one, say). Co-Authored-By: Claude Opus 5.5 <[email protected]>
* views: several clients on one session, each its own layout, focus, cursors ↵Gabriel Schneider2026-10-29
| | | | | | | | | | | | | | | | and scroll over the panes they share; a second `pardes --attach` draws on its own terminal beside the first, and `pardes-gui --attach` opens another window The core still sees one view, the live one, in the fields it always had (src/views.zig): a view's share of the session (`views.fields`: its screen, columns, rects, focus, pointer and gestures, jumps, key prefixes, column tags, presentation and animations, windowed and native_images) and of each pane (`PaneView`: its place in the layout, which text has the keyboard, the body's cursor, selections and mode, its scroll, a document's size, what the step measured of it) is copied out when another view goes live and back when it is live again. One view never parks: the single client pays a test of one byte a step. `toView`, `openView` and `closeView` are taped inputs; the pump draws each other view by going into it and back, which leaves every digested field as it was, so the replica that draws nothing skips it. A parked view is in no digest (its slot is written whenever it goes out); what drawing it made of its own (animations, presentation) is kept, whatever its unpark brought inside a changed text is done again when it is next live. Shared: the panes' text, terminals, tags, prompts, messages, registers (yanked in one view, put in another), the workspace tag and settings. A terminal shown at two sizes takes the size of the view that typed into it last (`Pane.sized_by`), and any view's once that one is gone; the others show it at that size. A text edited in one view moves the other views' cursors and scroll with the splice, as a Zerox twin's (File.ParkedPlaces). A pane closed in one view leaves the others' layouts (by its slot's serial); a pane focused in a view that does not show it is placed in its active column (views.show). tty: each terminal is a Screen of its own (its vaxis, input reader, frame answer, kitty images and shm probe, glide, trail and flash); its input reaches the loop as its view's (a `from` ahead of it when another terminal posted last, so one terminal posts none). A SIGWINCH asks every terminal its size; a SIGHUP asks each whether it hung up or lost its stub. Detach, or a terminal's end, with other views left closes only that view, its stub told `d`; the session's end tells every stub. daemon.zig: an attach names an attached session too (or the only one there is when none is detached). gui: the Gui holds the live window's share of itself (window_fields: the SDL window and its presenting, scroll, glide, scene and post chain, pointer, blink, captures); the others wait in Shell.windows, swapped in (`follow`) as the core's live view changes, and each SDL event first takes its window's view live (`route`). Closing a window while others stay closes its view. Harnesses: `start <rows> <cols> views=N` in a snapshot script gives the app N-1 more terminals (PARDES_TEST_VIEWS, opened as attached ones), `view <k>` types into and captures terminal k, every wait reads them all; `pardes-monkey --views=N` switches among N; `zig build replay` runs its seeds at three views too. views.snap pins two terminals: an edit seen in both, a scroll in one, a line yanked in one and put in the other, Newcol in one, Detach in one. Unit tests: own cursor, scroll, mode, layout and focus; edits shared; registers shared; terminal size by last typist; closing views; drawing the others leaves the digest; a view keeps its place in a text another edits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* daemon.zig: a forked session takes its stub's death, a SIGKILL too, as the ↵Gabriel Schneider2026-10-29
| | | | | | | | | | | | | | | | | | terminal's HUP and detaches PR_SET_PDEATHSIG (FreeBSD: PROC_PDEATHSIG_CTL) in the session child, cleared again at Detach so the stub's own exit then is no hangup; a stub dead before it was set hangs up at once. It is the HUP the signal thread already takes (blocked in every thread, sigwaited), and setsid does not touch it. An --attach stub is no parent of its session: one killed so still leaves the session drawing until the terminal closes or Detach. test/daemon.py kills a session's stub outright under a shell that keeps the terminal (on FreeBSD the session leader's exit revokes it), waits for the session to put the terminal back and detach, and attaches it again; without the death signal it times out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* daemon.zig: one pardes daemon per user, holding pty masters and handing ↵Gabriel Schneider2026-10-29
terminals to detached sessions `pardes --daemon` listens on pardes-daemon.sock in the runtime directory (ninep_io.socketDir), its .lock flocked for its life so two never run. The first session that finds none takes the lock, binds and listens itself and queues its own connection; the daemon is then double-forked and exec'd onto that listener and lock (fds 3 and 4), by a terminal's stub after the session's fork, so no startup waits for it: the hello sits queued, and the `ok` is the reader thread's. Another starter waits on the lock; a stale socket is the lock holder's to replace. Idle a second (no connection, no master held), it unlinks the socket and exits. It spawns nothing and is nobody's parent: a session registers on one connection (hello: kind, pid, name, attached or detached), sends a dup of every pty master it forks (`pty`), says which it closed (`close`) and when it ends (`quit`, its shells hang up), and asks for the masters of sessions that died holding them (`adopt`). A master whose shell is gone (POLLHUP, polled with no events, its output never read here) is dropped. `attach` hands a terminal and a stub's pipe (pardes --attach), or a window request (pardes-gui --attach), to the detached session of that name or the only one, and refuses in words: no such session, attached already, the other kind. SOCK_SEQPACKET datagrams, a line of words and the fds they carry. The client half: connect (starting one), register, the session's link and its reader thread, and the stub a terminal's session leaves behind (forkSession, stubWait), which passes WINCH, TERM, INT, QUIT and HUP on and ends with the session's status. Co-Authored-By: Claude Opus 5.5 <[email protected]>