diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 16:41:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 18:42:47 -0300 |
| commit | 78d94c4a62ec3f4039a475b637ff6a60649fde52 (patch) | |
| tree | 92b7d29d43bd1f563291db3aa1ab4b90ba55824a /runtime | |
| parent | d0e36bb453526af64349a4eb2335b86c94bea56d (diff) | |
| download | pardes-78d94c4a62ec3f4039a475b637ff6a60649fde52.tar.gz pardes-78d94c4a62ec3f4039a475b637ff6a60649fde52.zip | |
core: the entries that take or answer a slot take and answer its type (P21, pardes-ids change 2): a pane's slot is `Pane.Id` in the twelve entries that took it, six as `usize` (setCwd, acknowledgeShell, setMessage, setStatus, reportError, noteLateFailure) and six as `u8` (readerFailed, shellFailed, restartFailed, saveFailed, reloadWatchedFile, File.deleted), and in what adoptShell answers (`?Pane.Id`); a view's slot is `View.Id` in closeView, leaveView, awayView, rejoinView and the hand-written toView (its `to_view` variant is `Pardes.View.Id` now, and its replay arm unchanged) and in what openView answers (`?View.Id`); the tape's other variants follow their inners' types with no edit (`Args`); each inner converts where its body indexes (`id.index()`), passes the id itself to another entry, and the core's own code stays integers; every caller converts at its own line, `p.reportError(.at(id), ..)` (the decl literal of the parameter's type), 514 calls in 56 files written by a script that refuses any path outside the workspace (`.scratch/sketch/reorg/pardes-ids/wrap.py`), 46 `.index()`; nothing the compiler caught was a pane's slot passed as a view's or the reverse: what it caught were a script's wrong guesses (Editor.reportError(err) and macos.zig's own reloadWatchedFile, same names, undone) and the integers a view's id met (views.zig's tests, replica.zig's Authority and Peers.join, host_io's Adoption); in files another agent is in, each conversion on the line that was there: core/Kind.zig 5 lines, core/Addon.zig 4, core/replica.zig 23 (Authority.openView and join, closeView/toView/awayView/rejoinView/leaveView calls, Peers.join's `openView`, tests), test/replicas.zig 1; the tape's records are smaller (a `usize` is a byte in six inputs) and its shape moves, so the semantics word moves, 313a99190b93a8c5 -> c47ecf638b3f4b9f; test/perf.zig untouched (its harness id does not move); the Mac: runtime/macos.zig 16 call lines, abi/pardes.h unchanged; 581 lines changed in 56 files, no line added. Gate (load 4 to 28: a drat build and other agents' gates beside): 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), gui unit-test 1618/1622 (BaselineHarnessMismatch, the base's); replicas --clients 5 (TMPDIR /tmp/claude-1000/ids, alternated with the base twice, both pass both times): diverged 0, unequal 0 at rtt 30, 80, 207, deltas checked/wrong 1811/0, 1838/0, 1715/0, quiet checks 567/0, 650/0, 544/0, stops not on may_wait 0 (its corpus-through-a-client scene fails at step 21 as on the base with that TMPDIR); two earlier runs of this tree under a load of 10 to 28 ended in a leak of Places' compiled regex (Places.derive from Query.produce) and one rtt-207 run in an assertion in mouse.kindMouse's clamp during a client's speculation, the leak not seen in the eight runs of this tree after them (the full soak, each rtt alone, single seeds), the assertion not in the two full runs after it, and neither in three full runs of the base (by reading neither touches a slot: in the report); daemon.py plain, --far, --games, --window-clients, --upgrade both ways against pardes-tree's base prefix pass; 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-2 against tree1) 77/77 byte-identical in Debug, unit-test 1618/1622 there too, perfab corpus2x -0.059% (session noise 0.134%, threshold 0.4%), pictures identical in all 10 runs, perfops 97 counts within 0.1% (largest image-frame on longline +0.0274%), key-down on medium 10,040,104 -> 10,039,959 an operation (-0.0014%), render on medium 11,455,764 -> 11,455,707 (-0.0005%)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/9p_io.zig | 12 | ||||
| -rw-r--r-- | runtime/addon_test.zig | 2 | ||||
| -rw-r--r-- | runtime/macos.zig | 32 | ||||
| -rw-r--r-- | runtime/upgrade.zig | 6 |
4 files changed, 26 insertions, 26 deletions
diff --git a/runtime/9p_io.zig b/runtime/9p_io.zig index ef4ecfdd..bcb0f81b 100644 --- a/runtime/9p_io.zig +++ b/runtime/9p_io.zig @@ -1109,7 +1109,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene // unreachable: a u32 is at most 10 digits const fallback = std.fmt.bufPrint(&name, "{d}", .{@as(u32, @intCast(libc.getpid()))}) catch unreachable; return listen(io, gpa, core, core.opts.ninep_name, fallback, core.opts.ninep_tcp) catch { - if (refusal.len > 0) core.setMessage(0, refusal) else core.reportError(0, "9p listener", error.ListenFailed); + if (refusal.len > 0) core.setMessage(.at(0), refusal) else core.reportError(.at(0), "9p listener", error.ListenFailed); return null; }; } @@ -2647,7 +2647,7 @@ test "a held read is answered when the log has news, and a flushed one spends no try s.flush(); try heldNow.count(p, 2); pardes.turn.wake(); - p.setMessage(0, "after the flush"); + p.setMessage(.at(0), "after the flush"); pardes.turn.rest(); try heldNow.count(p, 1); pardes.turn.wake(); @@ -2670,7 +2670,7 @@ test "a held read is answered when the log has news, and a flushed one spends no try testing.expectEqual(second, refused.tag); try testing.expectEqualStrings(pardes.ctlfs.e_in_use, refused.result.fail); pardes.turn.wake(); - p.setMessage(0, "while held"); + p.setMessage(.at(0), "while held"); const retry_all = pardes.turn.parked; pardes.turn.rest(); try testing.expect(!retry_all); @@ -2698,9 +2698,9 @@ test "a held read is answered when the log has news, and a flushed one spends no try s.flush(); try heldNow.count(p, 1); pardes.turn.wake(); - p.setMessage(0, "queued one"); - p.setMessage(0, "queued two"); - p.setMessage(0, "queued three"); + p.setMessage(.at(0), "queued one"); + p.setMessage(.at(0), "queued two"); + p.setMessage(.at(0), "queued three"); l.reset(p); pardes.turn.rest(); const cut = try s.settle(); diff --git a/runtime/addon_test.zig b/runtime/addon_test.zig index a08237fc..a37a2262 100644 --- a/runtime/addon_test.zig +++ b/runtime/addon_test.zig @@ -121,7 +121,7 @@ fn run(io: std.Io, gpa: std.mem.Allocator, lib: []const u8, script_path: ?[]cons if (is(verb, "view")) { const n = std.fmt.parseInt(u8, arg[0..@min(1, arg.len)], 10) catch 1; while (n > 1 and !pardes.views.isOpen(p, n - 1)) _ = p.openView() orelse break; - if (pardes.views.isOpen(p, n -| 1)) p.toView(n -| 1); + if (pardes.views.isOpen(p, n -| 1)) p.toView(.at(n -| 1)); } p.update(.{ .frontend = .{ .windowed = false, .native_images = std.mem.endsWith(u8, arg, "on") } }); } else if (is(verb, "dump")) { diff --git a/runtime/macos.zig b/runtime/macos.zig index 4f8bd709..3a00210d 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -385,7 +385,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { while (core.nextEffect()) |effect| core.perform(effect); st.started = true; - if (st.ninep) |listener| listener.watch(st, wakeNinep) catch |err| core.reportError(0, "9p wake", err); + if (st.ninep) |listener| listener.watch(st, wakeNinep) catch |err| core.reportError(.at(0), "9p wake", err); for (&st.ptys, 0..) |*slot, id| if (slot.*) |*pt| startReader(st, pt, @intCast(id)); pardes.lsp.setStatusSink(&st.inbox, Inbox.lspStatus); @@ -593,7 +593,7 @@ fn refreshCwds(ctx: ?*anyopaque) void { stale.* = false; const pt = st.ptys[id] orelse continue; var buf: [1024]u8 = undefined; - if (host_io.ttyCwd(pt.pid, pt.file.handle, st.core.settings.shell.effective.get(), &buf)) |wd| st.core.setCwd(id, wd); + if (host_io.ttyCwd(pt.pid, pt.file.handle, st.core.settings.shell.effective.get(), &buf)) |wd| st.core.setCwd(.at(id), wd); } } @@ -682,7 +682,7 @@ fn reloadWatchedTheme(st: *State, announce: bool) bool { live.retries_left = 0; if (announce) { var mbuf: [256]u8 = undefined; - st.core.setMessage(request.pane, message.stamp(&mbuf, "reloaded theme", request.path)); + st.core.setMessage(.at(request.pane), message.stamp(&mbuf, "reloaded theme", request.path)); } return true; } @@ -711,7 +711,7 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool { defer st.core.gpa.free(bytes); const hash = std.hash.Wyhash.hash(0, bytes); if (hash == old_hash) break :text .no_change; - if (!st.core.reloadWatchedFile(pane, bytes)) { + if (!st.core.reloadWatchedFile(.at(pane), bytes)) { retryWatchedFile(st, pane, generation); break :text .no_change; } @@ -732,7 +732,7 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool { break :pdf .no_change; }; if (old_identity) |old| if (old.eql(before)) break :pdf .no_change; - if (!st.core.reloadWatchedFile(pane, &.{})) { + if (!st.core.reloadWatchedFile(.at(pane), &.{})) { retryWatchedFile(st, pane, generation); break :pdf .no_change; } @@ -759,7 +759,7 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool { }; if (result == .committed and announce) { var mbuf: [256]u8 = undefined; - st.core.setMessage(pane, message.stamp(&mbuf, "reloaded", watched.path)); + st.core.setMessage(.at(pane), message.stamp(&mbuf, "reloaded", watched.path)); } return result != .no_change; } @@ -817,7 +817,7 @@ fn drainInbox(st: *State) bool { }, .lsp_status => |text| { var mbuf: [256]u8 = undefined; - st.core.setStatus(st.core.view().active, message.stamp(&mbuf, "lsp", text)); + st.core.setStatus(.at(st.core.view().active), message.stamp(&mbuf, "lsp", text)); }, .pipe => |value| { st.core.update(.{ .pipe_resp = .{ @@ -874,12 +874,12 @@ fn restoreCore(st: *State) bool { if (st.core.quit) return false; const path = st.core.takeRestore() orelse return false; const bytes = dump.restoreBytes(st.core, st.gpa, path) catch |err| { - st.core.reportError(st.core.view().active, "Restore", err); + st.core.reportError(.at(st.core.view().active), "Restore", err); return false; }; defer st.gpa.free(bytes); const replacement = dump.restore(st.core, bytes, path) catch |err| { - st.core.reportError(st.core.view().active, "Restore", err); + st.core.reportError(.at(st.core.view().active), "Restore", err); return false; }; if (st.inbox.lsp_task) |*task| { @@ -1655,8 +1655,8 @@ fn spawnShell(ctx: ?*anyopaque, pane: u8, cwd: []const u8) void { // start leaves the running one be (pty/ctl's exec). const running = st.ptys[pane] != null; const child = host_io.forkShell(core, pane, &st.prompt_rcs, core.shellBin(), cwd, core.view().screen_h, core.view().screen_w) catch |err| { - if (running) return core.restartFailed(pane, err); - return core.shellFailed(pane, err); + if (running) return core.restartFailed(.at(pane), err); + return core.shellFailed(.at(pane), err); }; reap(st, pane); st.gens[pane] +%= 1; @@ -1673,7 +1673,7 @@ fn spawnShell(ctx: ?*anyopaque, pane: u8, cwd: []const u8) void { // Only a shell given no directory is asked where it is: one given a // directory is named by it already (newShell), and asked now, before // its chdir, it would answer this process's, a rename to undo. - if (cwd.len == 0) if (host_io.shellCwd(child.pid, &lbuf)) |wd| core.setCwd(pane, wd); + if (cwd.len == 0) if (host_io.shellCwd(child.pid, &lbuf)) |wd| core.setCwd(.at(pane), wd); if (st.started) if (st.ptys[pane]) |*pt| startReader(st, pt, pane); } @@ -1710,10 +1710,10 @@ fn killJob(ctx: ?*anyopaque, pane: u8) bool { fn writeFile(ctx: ?*anyopaque, pane: u8, path: []const u8, bytes: []const u8) void { const st = hostState(ctx); filesystem.write(st.core, path, bytes) catch |err| - return st.core.saveFailed(pane, path, err); + return st.core.saveFailed(.at(pane), path, err); st.file_watches.restampText(pane, path, std.hash.Wyhash.hash(0, bytes)); var mbuf: [256]u8 = undefined; - st.core.setMessage(pane, message.stamp(&mbuf, "saved", path)); + st.core.setMessage(.at(pane), message.stamp(&mbuf, "saved", path)); } fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void { @@ -1739,12 +1739,12 @@ fn dumpThemes(ctx: ?*anyopaque, pane: u8) void { const st = hostState(ctx); const config_dir = st.core.opts.config_dir orelse return; const out_dir = pardes.config.User.dumpThemes(st.io, st.gpa, config_dir, pardes.themes) catch |err| { - st.core.reportError(pane, "dump themes", err); + st.core.reportError(.at(pane), "dump themes", err); return; }; defer st.gpa.free(out_dir); var mbuf: [256]u8 = undefined; - st.core.setMessage(pane, message.stamp(&mbuf, "dumped themes", out_dir)); + st.core.setMessage(.at(pane), message.stamp(&mbuf, "dumped themes", out_dir)); } fn setClipboard(ctx: ?*anyopaque, text: []const u8) void { diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index 6ee5d29c..77928dd0 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -77,7 +77,7 @@ fn inodeOf(path: [:0]const u8) ?u64 { /// rebuilding (a stat). ponytail: explicit only, no watch and no automatic /// upgrade. pub fn noticeNewer(core: *pardes.Pardes) void { - if (newer()) core.setMessage(core.view().active, pardes.newer_build_words); + if (newer()) core.setMessage(.at(core.view().active), pardes.newer_build_words); } /// Whether to say a newer build is installed now (`noticeNewer`): the @@ -413,7 +413,7 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op // keep its blocks for as long as this session runs. if (rec.old >= 0) _ = libc.close(rec.old); rec.old = -1; - p.setMessage(p.view().active, if (rec.refused.len > 0) + p.setMessage(.at(p.view().active), if (rec.refused.len > 0) std.fmt.bufPrint(&buf, "Upgrade: the new build could not load this session ({s}); it goes on as {s}", .{ rec.refused[0..@min(rec.refused.len, 200)], version_line }) catch "Upgrade: the new build could not load this session; it goes on as before" else "Upgrade: now " ++ version_line); @@ -435,7 +435,7 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op var o = opts; o.load_path = null; const p = try pardes.Pardes.init(core_gpa, o); - p.setMessage(p.view().active, std.fmt.bufPrint(&buf, "Upgrade: no build could load the session ({s}); its shells are here, and Restore {s} brings the rest back", .{ why, again_name[0..@min(again_name.len, 400)] }) catch "Upgrade: no build could load the session; its dump is kept for a Restore"); + p.setMessage(.at(p.view().active), std.fmt.bufPrint(&buf, "Upgrade: no build could load the session ({s}); its shells are here, and Restore {s} brings the rest back", .{ why, again_name[0..@min(again_name.len, 400)] }) catch "Upgrade: no build could load the session; its dump is kept for a Restore"); return p; } } |
