From bf351b62e8843a3d173cedeefa2dd0b8ef4b4392 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 18:35:16 -0300 Subject: core, dev: what carries a slot across the core's edge carries its type (P21, pardes-ids change 3): `Pane.Id` in Event's six variants that carry a pane (output, eof, exited, file_changed, addon, job), in the fourteen effects that do (spawn, write, resize_pty, signal_pty, close_pty, start, save_file, save_text, lsp, watch, dump_themes, detach, addon, job), in the fourteen Host functions that take one (dev/Host.zig: adopt, upgrade, spawn, pty_write, pty_resize, pty_signal, close_pty, tty_taken, fg_name, kill_job, write_file, watch_file, dump_themes, job; tape.zig's Wrap follows with no edit), in the device messages that carry one into the core (the inbox's output and eof and the five reader functions that make them, dev/Lsp.zig's Request, host_io's Adoption and Adoptions.take, which hold what adoptShell answered); `View.Id` in abi/wire.zig's welcome.view (its bytes on the wire unchanged: one byte, hand-encoded, `.at(takeByte())`/`writeByte(view.index())`); every producer converts at its own line (`.pane = .at(id)`, a script that refuses any path outside the workspace, `fields.py`), every consumer where it indexes or compares (`o.pane.index()`), every Host implementer at its own first line (`fn spawn(ctx, id: pardes.Pane.Id, ..) { const pane = id.index(); ..}`: the terminal's 14, the window's 14, the Mac's 10, and the tests' hosts), and an id that went integer and back is passed through whole (`s.core.readerFailed(e.pane, err)`); the compiler caught no pane's slot passed as a view's or the reverse, only integers meeting the type; kept integers on purpose: KindJob.pane (core/Kind.zig, another agent's, reads it four times; converted at KindJob's and Effect's lines), the Watch table (file_watch: its last slot is the theme's, no pane), the hello's view and the replica's Peer/Joined/Replica views (core/replica.zig, another agent's), the C ABI's `pardes_watch_changed(uint8_t pane)` (abi/pardes.h unchanged; runtime/macos.zig converts at its Host functions); in files another agent is in, each conversion on the line that was there: core/Kind.zig 2 lines, core/Addon.zig 4, core/replica.zig 31 (the welcome's view, 3 test hosts, test literals), test/replicas.zig 12 (4 host functions with their first lines, 1 signature, the welcome's view, 5 literals); the tape's shape moves (Event is update's input), so the semantics word moves, c47ecf638b3f4b9f -> 38b5ae573b965550; test/perf.zig follows on 6 lines its Event and effect literals forced, so its harness id moves, be7cc504010471bc -> 1ed95030eb768eae (unit-test's perf check was BaselineHarnessMismatch already); 607 lines added, 562 deleted in 48 files. Gate (load 4 to 8): tui core-test 841/984 (143 skipped), shell-test 1020/1023, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds of 70 steps, 0 failures, process-test lspcomplete and lspcompletemoved (the base's; hscroll failed once and passed on the runner's retry), gui unit-test 1618/1622 (BaselineHarnessMismatch, the base's); replicas --clients 5 (TMPDIR /tmp/claude-1000/ids): diverged 0, unequal 0 at rtt 30, 80, 207, deltas checked/wrong 1811/0, 1838/0, 1660/0, quiet checks 567/0, 650/0, 655/0, stops not on may_wait 0 (corpus through a client fails at step 21 as on the base with that TMPDIR); daemon.py plain, --far, --games, --window-clients, --upgrade both ways against pardes-tree's base prefix pass (the semantics words differ: the upgrade carries the session by its dump); test/cross_replay.py (tui records, gui replays): 27 digests agree in each of three replicas; rollback-bench runs; the macOS library for Linux and aarch64-macos and the FreeBSD cross-build build; frames (gpu/ids-3 against tree1) 77/77 byte-identical in Debug, unit-test 1618/1622 there, perfab corpus2x -0.021% (session noise 0.036%, threshold 0.4%), pictures identical in all 10 runs, perfops 97 counts within 0.1% (largest image-frame on longline +0.0231%), key-down on medium 10,040,108 -> 10,039,990 an operation (-0.0012%), render on medium 11,455,765 -> 11,455,683 (-0.0007%), terminal on all +0.0030% Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/ninep/pty.zig | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'core/ninep/pty.zig') diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig index 96f2a6bf..6f3a8af0 100644 --- a/core/ninep/pty.zig +++ b/core/ninep/pty.zig @@ -96,14 +96,14 @@ fn verb(p: *Pardes, id: usize, line: []const u8, apply: bool) ?[]const u8 { // is refused, never quietly raised. if (rows < pty_rows_min) return e_winsize_rows; if (!apply) return null; - p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = cols, .rows = rows } }); + p.emit(.{ .resize_pty = .{ .pane = .at(id), .cols = cols, .rows = rows } }); pane.fs.winsize = .{ cols, rows }; }, .sig => { const which = signalNamed(words.next() orelse return e_bad_pty_ctl) orelse return e_bad_pty_ctl; if (words.next() != null) return e_bad_pty_ctl; if (!apply) return null; - p.emit(.{ .signal_pty = .{ .pane = @intCast(id), .serial = pane.serial, .sig = which } }); + p.emit(.{ .signal_pty = .{ .pane = .at(id), .serial = pane.serial, .sig = which } }); }, .exec => { if (words.next() != null) return e_bad_pty_ctl; @@ -709,7 +709,7 @@ test "pty/data writes at the shell and reads the raw stream" { try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - p.update(.{ .output = .{ .pane = 0, .bytes = "unwatched" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "unwatched" } }); while (p.nextEffect()) |_| {} try testing.expectEqual(@as(usize, 0), p.panes[0].?.fs.pty_out.buf.items.len); try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); @@ -724,20 +724,20 @@ test "pty/data writes at the shell and reads the raw stream" { try testing.expectEqual(@as(u16, 0), p.fs.listeners); try testing.expect(p.panes[0].?.fs.readers == 0); - p.update(.{ .output = .{ .pane = 0, .bytes = "hello" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "hello" } }); while (p.nextEffect()) |_| {} try testing.expectEqualStrings("hello", rd(p, data, 0, 64).bytes); try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - p.update(.{ .output = .{ .pane = 0, .bytes = "abcdef" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "abcdef" } }); while (p.nextEffect()) |_| {} try testing.expectEqualStrings("ab", rd(p, data, 0, 2).bytes); try testing.expectEqualStrings("cd", rd(p, data, 0, 2).bytes); - p.update(.{ .output = .{ .pane = 0, .bytes = "ghi" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "ghi" } }); while (p.nextEffect()) |_| {} try testing.expectEqualStrings("efghi", rd(p, data, 0, 64).bytes); - p.update(.{ .output = .{ .pane = 0, .bytes = "orphan" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "orphan" } }); while (p.nextEffect()) |_| {} _ = call(p, .{ .tag = 6, .op = .release, .node = data, .handle = reader.reply.handle }); try testing.expect(!p.panes[0].?.fs.pty_reader); @@ -750,7 +750,7 @@ test "pty/data writes at the shell and reads the raw stream" { try testing.expectEqual(Status.err, second.reply.status); try testing.expectEqualStrings(tree.e_in_use, second.reply.ename); try testing.expect(p.panes[0].?.fs.pty_reader); - p.update(.{ .output = .{ .pane = 0, .bytes = "still" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "still" } }); while (p.nextEffect()) |_| {} try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes); } @@ -765,7 +765,7 @@ test "a run waiting for a new terminal's first prompt is the only line typed the const node = Node.of(serialOf(p), .pty_run); const h = call(p, .{ .tag = 1, .op = .open, .node = node }).reply.handle; _ = call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .data = "true\n" }); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } }); var sent: [32]u8 = undefined; var len: usize = 0; while (p.nextEffect()) |e| if (e == .write) { @@ -783,7 +783,7 @@ test "run answers how its command ended once the shell is back at a prompt" { const node = Node.of(serialOf(p), .pty_run); const out = struct { fn put(pp: *Pardes, bytes: []const u8) void { - pp.update(.{ .output = .{ .pane = 0, .bytes = bytes } }); + pp.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } }); while (pp.nextEffect()) |_| {} } }; @@ -801,7 +801,7 @@ test "run answers how its command ended once the shell is back at a prompt" { // A respawn before that prompt keeps it waiting for the new shell's. p.acknowledgeShell(.at(0), "/bin/sh", true); try testing.expectEqual(Status.again, call(p, .{ .tag = 3, .op = .read, .node = node, .handle = early.reply.handle, .size = 64 }).reply.status); - p.update(.{ .output = .{ .pane = 0, .bytes = prompt } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = prompt } }); var sent_late: [16]u8 = undefined; var sent_len: usize = 0; while (p.nextEffect()) |e| if (e == .write) { @@ -909,7 +909,7 @@ test "a shell that exits under a run answers its status, and the log says exit b const serial = serialOf(p); const node = Node.of(serial, .pty_run); const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07"; - p.update(.{ .output = .{ .pane = 0, .bytes = prompt } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = prompt } }); while (p.nextEffect()) |_| {} const log = @backingInt(tree.TopFile.log); const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; @@ -918,9 +918,9 @@ test "a shell that exits under a run answers its status, and the log says exit b const r = call(p, .{ .tag = 4, .op = .open, .node = node }); _ = call(p, .{ .tag = 5, .op = .write, .node = node, .handle = r.reply.handle, .data = "echo bye; exit 3\n" }); - p.update(.{ .output = .{ .pane = 0, .bytes = "echo bye; exit 3\r\n\x1b]133;C;aid=pardes\x07bye\r\n" } }); - p.update(.{ .exited = .{ .pane = 0, .status = 3 } }); - p.update(.{ .eof = .{ .pane = 0 } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "echo bye; exit 3\r\n\x1b]133;C;aid=pardes\x07bye\r\n" } }); + p.update(.{ .exited = .{ .pane = .at(0), .status = 3 } }); + p.update(.{ .eof = .{ .pane = .at(0) } }); while (p.nextEffect()) |_| {} try testing.expect(p.paneBySerial(serial) == null); try testing.expectEqualStrings("exit 3\nbye\n", call(p, .{ .tag = 6, .op = .read, .node = node, .handle = r.reply.handle, .size = 64 }).bytes); @@ -969,7 +969,7 @@ test "a run's answer says cut when its output's start is gone, and reads a bound const pane = p.panes[0].?; const sh = struct { fn put(pp: *Pardes, bytes: []const u8) void { - pp.update(.{ .output = .{ .pane = 0, .bytes = bytes } }); + pp.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } }); while (pp.nextEffect()) |_| {} } fn send(pp: *Pardes, n: u64) u32 { @@ -1099,7 +1099,7 @@ test "a terminal's ctl counts its body, and a new directory is a rename in the l const p = try withTerm(gpa); defer p.deinit(); const serial = serialOf(p); - p.update(.{ .output = .{ .pane = 0, .bytes = "some history\r\nmore" } }); + p.update(.{ .output = .{ .pane = .at(0), .bytes = "some history\r\nmore" } }); while (p.nextEffect()) |_| {} const opened = call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .body) }); const body_len = call(p, .{ .tag = 2, .op = .read, .node = Node.of(serial, .body), .handle = opened.reply.handle, .size = 1 << 16 }).bytes.len; -- cgit v1.3