From 5671a8275203334594b6f3b548e6a6012ef9fae6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 07:33:55 -0300 Subject: ninep: a client that joins a session with 9P work under way has the 9P state the session has: what a step reads that the requests made is the core's state like any other (P30, P35), so the walk sees it: fs leaves Pardes's and Pane's authority lists and the 9P server's own part says so in its types (fs.Namespace: the sockets, mounts, log, the request being served's flags and the rest; pane.State: the event and pty readers' queues and counts, winsize, unannounced; Open: the listener's held read and a stream's last answer; LogOpen whole), so the open records, the writes held to go in as one edit (fs.batch) and each pane's addr, limit, dot truncation, wrsel, joined, nomark, noscroll, lock, run, unmarked, tag truncation and chord are in every dump and in the digest; the digest is cheap by type: a pane's 9P state adds nothing for a pane no script has touched and its fields as one run of bytes for the rest (pane.State.digest), the namespace the opens in use and held writes by their length (Namespace.digest: a 9P body append hashed its whole batch, +0.14% on body-appends), so the frame and perf gate's 121 per-operation counts are within 0.1% of tree2 (largest client-key-down +0.054%; the plain walk of the same state cost client-key-down +0.73%); an open's union is named (Open.What) and digests what a step reads of it (its kind, a run, an event reader's flag, a pager's serial, a port's index), never the text its reader is answered with, which each process makes of its own state (walk.hash takes a tagged union's own digest as it takes a struct's); the opens are taken as far as fs.opens_len (an idle session's none; the scans that read records bound by it, openOf too, and an open lets go of what a rollback left in its record past the length); a session revived from a dump (Restore, an Upgrade, a start from one: dump.loadAndRevive; a closed pane brought back: loadPane) drops the opens and each pane's 9P state, as today, its connections gone (fs.Namespace.forget): a client's join loads alone and keeps them; not the join's dump alone: the tape's dump round trip at a replay's end wants the image to carry what the digest covers; pty.Run's answer cut at its length; the wire version 24, so the semantics word moves 64e89d6b25a84796 -> 18636a639ac075de (it did not move with the walk alone: a base client would have digested other fields than its session; test/daemon.py's WIRE with it, and its upgrade case takes a client of the other side's protocol saying `run the same pardes at both ends`, as its third terminal already did); the eleven tests of the change before pass; a join's dump (the probe, Debug): idle 63258 -> 64612 bytes, 50 opens held 63270 -> 66744; the image idle 233426 -> 237001, 50 opens 233738 -> 295089; tui core-test 867/1022 (155 skipped), shell-test 1062/1065, behaviour-test 275/275 and --replay 275/275, replicas --clients 5 diverged 0/0/0, unequal 0, unlisted stops 0, corpus 22 of 22, no leak (load 30-40, before the digests were made cheap; the whole gate on the change after) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/wire.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'abi/wire.zig') diff --git a/abi/wire.zig b/abi/wire.zig index a36e746b..4055e42d 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,8 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 24: the 9P state a session's requests made (its open records, each +/// pane's) is in its join's dump and its digest (core/fs.zig Namespace); /// 23: a pane of a kind's frame names its rasters by key, their pixels /// crossing before it as strips of 4 MiB at most over the rows it shows /// (screen kind 5), and a replica lacking one asks for its pane again @@ -36,7 +38,7 @@ const build_info = @import("build_info"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 23; +pub const version: u16 = 24; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { -- cgit v1.3 From 27837e6345b51ceb2ceaaee58fd593024feb07c8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 08:13:35 -0300 Subject: ninep: the audit's two more finds ride with the rest: the panes the last look or exec touched (fs.results and each open's) and a column's or the workspace's tag truncation (fs.header_rewrite, header_trunc_pending, header_held) are digested and dumped, dropped at a revive as the opens are; found by reading the namespace field by field (reports/pardes-faults-4.md section 3): exec.leased reads an open's results to keep a done command pane a script reads from being taken again, and a new open's results are the session's last (no test: it needs a finished command pane read by a script); a header's truncation is the pane tag's twin: test "a client joined after a script truncated the workspace's tag writes the tag its session writes" (unequal on the base); the rest of the namespace is no fault (set and read in one request's step, or replies, the log, the listener) but edit_hold (listed: the session's listener sets it between steps); gate on this tip (load 5-18): tui core-test 868/1023 (155 skipped), shell-test 1063/1066, pane-test 183/184, behaviour-test 275/275 and --replay 275/275, term-test 17/17, kitty-test 45/45, addon-test 5/5, process-test 1 of 144 (pty/run's "busy while a job holds the tty", at load 18; 3 of 3 alone), replicas --clients 5, --bytes --clients 5 and both with --seeds 8: diverged 0, unequal 0, unlisted stops 0, corpus 22 of 22, no leak; attach probe 0 of 6; cross_replay 29 digests agree on each replica; daemon.py plain, --far, --games, --window-clients, --upgrade base -> this and this -> base pass; the macOS (Linux host), macOS arm and FreeBSD builds; the frame and perf gate against tree2 PASS: 77/77 frames, gui unit-test 1660/1664, perfab corpus2x +0.009%, perfops 121 within 0.1% (largest client-key-down on medium +0.054%) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/wire.zig | 3 ++- core/fs.zig | 23 ++++++++++++++++++----- core/ninep/tree.zig | 5 +++-- core/replica.zig | 12 ++++++++++++ 4 files changed, 35 insertions(+), 8 deletions(-) (limited to 'abi/wire.zig') diff --git a/abi/wire.zig b/abi/wire.zig index 4055e42d..e68e8462 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -11,7 +11,8 @@ const config = @import("pardes_options"); const build_info = @import("build_info"); /// 24: the 9P state a session's requests made (its open records, each -/// pane's) is in its join's dump and its digest (core/fs.zig Namespace); +/// pane's, the panes the last look or exec touched, a header's +/// truncation) is in its join's dump and its digest (core/fs.zig Namespace); /// 23: a pane of a kind's frame names its rasters by key, their pixels /// crossing before it as strips of 4 MiB at most over the rows it shows /// (screen kind 5), and a replica lacking one asks for its pane again diff --git a/core/fs.zig b/core/fs.zig index dcc33cd6..eadb7c19 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -843,7 +843,10 @@ pub const EditHold = struct { pub const Namespace = struct { /// What a step reads that 9P requests made (every request an input /// each replica replays) is the core's like any state: the open - /// records and the writes held to go in as one edit, digested and dumped (a client's join takes them from + /// records (a command pane a script reads is not taken again: + /// exec.leased), the panes the last look or exec touched (a new open's + /// own), the writes held to go in as one edit and a header tag's + /// truncation, digested and dumped (a client's join takes them from /// the dump; a session revived from one drops the opens with the /// connections that held them: dump.zig `loadAndRevive`). The rest is /// the server's (core/walk.zig): its sockets and the mounts (dumped @@ -861,9 +864,9 @@ pub const Namespace = struct { "lsp_answer_at", "edit_started", "edit_hold", "edit_said", "lsp_result", "write_room", "write_waits", "log_full_hash", "pages", "closed_lines", "ran_at", "refilled", "failures", "ename", "news", "hanging_up", "log", "plumb_held", - "results", "results_len", "started", "header_rewrite", "header_trunc_pending", "header_held", + "started", }, - .len = .{.{ "opens", "opens_len" }}, + .len = .{ .{ "opens", "opens_len" }, .{ "results", "results_len" } }, }; socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, @@ -1025,11 +1028,17 @@ pub const Namespace = struct { /// Its digest (core/walk.zig): the opens in use, and writes held by /// their length (their bytes are the same writes on every side; a /// stream of 8 KB appends hashed whole cost each its length again; - /// none held, the rest of `batch` is nothing a step reads). Nothing at + /// none held, the rest of `batch` is nothing a step reads), the panes + /// the last look or exec touched, a header's truncation. Nothing at /// all for a session no script holds anything of. pub fn digest(st: *const Namespace, h: *pardes.walk.Hasher) void { - comptime if (pardes.walk.fieldNames(Namespace).len != 3) @compileError("Namespace.digest: hash every field the walk does not leave out"); + comptime if (pardes.walk.fieldNames(Namespace).len != 8) @compileError("Namespace.digest: hash every field the walk does not leave out"); for (st.opens[0..st.opens_len]) |*o| pardes.walk.hash(tree.Open, o, h); + h.update(std.mem.sliceAsBytes(st.results[0..st.results_len])); + if (st.header_rewrite != null or st.header_trunc_pending != null or st.header_held) { + const words = [_]u64{ st.header_rewrite orelse std.math.maxInt(u64), st.header_trunc_pending orelse std.math.maxInt(u64), @intFromBool(st.header_held) }; + h.update(std.mem.asBytes(&words)); + } const b = &st.batch; if (b.bytes.items.len == 0) return; const words = [_]u64{ b.serial, b.node, b.handle, b.at, b.bytes.items.len, b.last_ns }; @@ -1041,8 +1050,12 @@ pub const Namespace = struct { pub fn forget(st: *Namespace, gpa: std.mem.Allocator) void { for (&st.opens) |*o| o.deinit(gpa); st.opens_len = 0; + st.results_len = 0; st.batch.bytes.deinit(gpa); st.batch = .{}; + st.header_rewrite = null; + st.header_trunc_pending = null; + st.header_held = false; } pub fn mount(st: *Namespace, gpa: std.mem.Allocator, name: []const u8, dial: []const u8) !void { diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig index 107479f6..3eeb5d3f 100644 --- a/core/ninep/tree.zig +++ b/core/ninep/tree.zig @@ -126,8 +126,8 @@ pub const out_reserve = 4 * 1024; pub const Open = struct { /// A client's join carries it and the digest covers it (fs.Namespace), /// but what only its reader is answered with: the listener's held - /// read, the stream's last answer, the panes a look or exec touched. - pub const replica = .{ .authority = .{ "results", "held", "replay" } }; + /// read and the stream's last answer. + pub const replica = .{ .authority = .{ "held", "replay" } }; /// The node it was opened on, which every use checks; 0 is a free record. node: u64 = 0, what: What = .{ .snapshot = null }, @@ -216,6 +216,7 @@ pub const Open = struct { pub const Replay = struct { off: u64, bytes: []u8 }; pub const Results = struct { + pub const replica = .{ .len = .{.{ "list", "len" }} }; list: [pardes.MAX_PANES]u32 = undefined, len: u8 = 0, /// Written on: reads are a stream from the write on, whatever diff --git a/core/replica.zig b/core/replica.zig index 50615fc0..4d1a635c 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7133,6 +7133,18 @@ test "a client joined after a script truncated a pane's tag writes the tag its s try n.agree(); } +test "a client joined after a script truncated the workspace's tag writes the tag its session writes" { + var n = try NinepJoin.init("one\n", TestHost.host()); + defer n.deinit(); + const tag: u64 = @backingInt(pardes.ctlfs.TopFile.tag); + const h = (try n.serve(.{ .tag = 1, .op = .open, .node = tag, .omode = 1 }, true)).handle; + _ = try n.serve(.{ .tag = 2, .op = .setattr, .node = tag, .handle = h, .truncate = true }, true); + try n.join(); + _ = try n.serve(.{ .tag = 3, .op = .write, .node = tag, .handle = h, .data = "Exit\n" }, true); + _ = try n.serve(.{ .tag = 4, .op = .release, .node = tag, .handle = h, .opened = true }, true); + try n.agree(); +} + test "a client joined while a chorded exec waits for its event reader's write-back runs it with its argument, as its session does" { var n = try NinepJoin.init("Msg said\narg-text\n", TestHost.host()); defer n.deinit(); -- cgit v1.3