From 78d94c4a62ec3f4039a475b637ff6a60649fde52 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 16:41:27 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Query.zig | 62 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'core/Query.zig') diff --git a/core/Query.zig b/core/Query.zig index ce83a6ac..784e6af4 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -248,7 +248,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo if (focus) toLineOne(p, from); return; } - const line = std.mem.concat(p.scratch.allocator(), u8, &.{ wordOf(source), if (source == .text) "" else " ", arg }) catch |err| return p.reportError(from, "search", err); + const line = std.mem.concat(p.scratch.allocator(), u8, &.{ wordOf(source), if (source == .text) "" else " ", arg }) catch |err| return p.reportError(.at(from), "search", err); var id: usize = undefined; const existing = ofOwner(p, owner.serial); if (existing) |reused| { @@ -259,7 +259,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, arg: []const u8, focus: boo if (q.frozen and q.saved == null) q.saved = save(p, rp, q) catch null; q.frozen = false; const f = &rp.file.?; - const new = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch |err| return p.reportError(from, "search", err); + const new = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch |err| return p.reportError(.at(from), "search", err); File.setContent(p, f, new); q.reset(p); if (rp.collapsed) layout.toggleCollapse(p, id); @@ -286,18 +286,18 @@ pub const born_rows: u16 = 8; fn create(p: *Pardes, owner_id: usize, line: []const u8, source: Source) ?usize { const owner = p.panes[owner_id] orelse return null; const free = p.freeSlot() orelse { - p.reportError(owner_id, "search", error.NoPaneSlots); + p.reportError(.at(owner_id), "search", error.NoPaneSlots); return null; }; const dir = if (p.exec_header) p.sessionDir() else Pardes.paneDir(owner); const content = std.mem.concat(p.gpa, u8, &.{ line, "\n" }) catch return null; const np = Output.open(p, free, dir, .search, "", content) catch |err| { p.gpa.free(content); - p.reportError(owner_id, "search", err); + p.reportError(.at(owner_id), "search", err); return null; }; const q = p.gpa.create(Query) catch { - p.reportError(owner_id, "search", error.OutOfMemory); + p.reportError(.at(owner_id), "search", error.OutOfMemory); return null; }; q.* = .{ .owner = owner.serial }; @@ -343,7 +343,7 @@ pub fn toLineOne(p: *Pardes, id: usize) void { t.nsel = 0; t.cur_pinned = true; rp.query.?.seen_row = 0; - edit.enterInsert(p.editor(), t, .line_end, 1) catch |err| return p.reportError(id, "query", err); + edit.enterInsert(p.editor(), t, .line_end, 1) catch |err| return p.reportError(.at(id), "query", err); showCurrent(rp); } @@ -562,7 +562,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { const asked = parse(line); if (changed) { const was = q.source; - const new_asked = p.gpa.dupe(u8, line) catch |err| return p.reportError(id, "search", err); + const new_asked = p.gpa.dupe(u8, line) catch |err| return p.reportError(.at(id), "search", err); p.gpa.free(q.asked); q.asked = new_asked; q.made_gen = std.math.maxInt(u64); @@ -615,7 +615,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { q.waited = 0; q.made_gen = gen; q.made_rev = of_.revision; - makeTextRows(p, id, oid, false) catch |err| p.reportError(id, "search", err); + makeTextRows(p, id, oid, false) catch |err| p.reportError(.at(id), "search", err); }, .all => { if (changed) for (p.panes) |slot| { @@ -634,13 +634,13 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { if (gen == q.made_gen and !changed) return; if (!changed and !tick) return; q.made_gen = gen; - makeAllRows(p, id) catch |err| p.reportError(id, "search", err); + makeAllRows(p, id) catch |err| p.reportError(.at(id), "search", err); }, .find, .recent, .panes, .symbols => { if (changed) q.names.typed(p.gpa, a.pat) else if (q.names.busy()) q.names.rescore(p.gpa); if (q.names.gen == q.made_gen and !changed) return; q.made_gen = q.names.gen; - makeNameRows(p, id) catch |err| p.reportError(id, "search", err); + makeNameRows(p, id) catch |err| p.reportError(.at(id), "search", err); }, .grep => { const dir = std.Io.Dir.path.dirname(f.path) orelse "/"; @@ -653,7 +653,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { // On the disk engine's worker, once the typing pauses. // A script's (a 9P write): run to its end before it answers. if (a.pat.len > 0) { - Stream.query(p, rp.serial, .grep, a.pat, dir, if (p.fs.serving) .now else .typed) catch |err| return p.reportError(id, "search", err); + Stream.query(p, rp.serial, .grep, a.pat, dir, if (p.fs.serving) .now else .typed) catch |err| return p.reportError(.at(id), "search", err); if (p.fs.serving) Stream.step(p); } else if (p.stream.target == rp.serial) { _ = p.stream.stop(); @@ -664,7 +664,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { const gen: u64 = (@as(u64, q.grep_gen) << 32) | (q.found.items.len << 1) | @intFromBool(searching); if (gen == q.made_gen and !changed) return; q.made_gen = gen; - makeGrepRows(p, id, false) catch |err| p.reportError(id, "search", err); + makeGrepRows(p, id, false) catch |err| p.reportError(.at(id), "search", err); }, .refs, .defs, .impls, .diagnostics => { if (changed and q.lsp_rows.len == 0) { @@ -681,7 +681,7 @@ fn produce(p: *Pardes, id: usize, tick: bool, keyed: bool) void { return noteRows(p, id, " asked of the language server...\n"); } if (!changed) return; - makeListRows(p, id, a.pat) catch |err| p.reportError(id, "search", err); + makeListRows(p, id, a.pat) catch |err| p.reportError(.at(id), "search", err); }, } } @@ -713,7 +713,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz // The files under the directory, listed once on the disk engine's // worker (rg --files, else the walk); each keystroke scores them. .find => { - Stream.query(p, rp.serial, .files, "", dir, .now) catch |err| return p.reportError(id, "search", err); + Stream.query(p, rp.serial, .files, "", dir, .now) catch |err| return p.reportError(.at(id), "search", err); if (p.fs.serving) Stream.step(p); }, .recent => { @@ -812,7 +812,7 @@ fn noteRows(p: *Pardes, id: usize, note: []const u8) void { const rp = p.panes[id].?; const q = rp.query.?; q.items.clearRetainingCapacity(); - q.items.append(p.gpa, .{ .kind = .note }) catch |err| return p.reportError(id, "search", err); + q.items.append(p.gpa, .{ .kind = .note }) catch |err| return p.reportError(.at(id), "search", err); q.current = null; q.total = 0; q.k = 0; @@ -820,7 +820,7 @@ fn noteRows(p: *Pardes, id: usize, note: []const u8) void { var out: std.ArrayList(u8) = .empty; defer out.deinit(p.gpa); var rows: std.ArrayList(locations.Row) = .empty; - writeRow(p, &out, &rows, note[0 .. note.len - 1], .{ .kind = .context, .path = &.{}, .at = .{}, .location_end = 0, .code_start = 0 }) catch |err| return p.reportError(id, "search", err); + writeRow(p, &out, &rows, note[0 .. note.len - 1], .{ .kind = .context, .path = &.{}, .at = .{}, .location_end = 0, .code_start = 0 }) catch |err| return p.reportError(.at(id), "search", err); setRows(p, rp, &out, &rows); } @@ -865,7 +865,7 @@ fn setRows(p: *Pardes, rp: *Pane, out: *std.ArrayList(u8), rows: *std.ArrayList( } File.setRows(p, f, meta) catch |err| { locations.freeRows(p.gpa, meta); - if (p.paneBySerial(rp.serial)) |id| p.reportError(id, "rows", err); + if (p.paneBySerial(rp.serial)) |id| p.reportError(.at(id), "rows", err); }; if (f.pager_spans.len > 0) p.gpa.free(f.pager_spans); f.pager_spans = &.{}; @@ -1299,12 +1299,12 @@ pub fn fillList(p: *Pardes, owner_id: usize, source: Source, rows: []const u8) v const qid = id orelse return; const rp = p.panes[qid].?; const q = rp.query.?; - const copy = p.gpa.dupe(u8, rows) catch |err| return p.reportError(qid, "search", err); + const copy = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(qid), "search", err); p.gpa.free(q.lsp_rows); q.lsp_rows = copy; const line = lineOne(rp.file.?.content); const a = parse(line) orelse return; - makeListRows(p, qid, a.pat) catch |err| p.reportError(qid, "search", err); + makeListRows(p, qid, a.pat) catch |err| p.reportError(.at(qid), "search", err); // Diagnostics are a jump (]d): the keyboard stays on the place in the // text. The others are a list answered, not a query typed: the keyboard // on the current row in normal mode (j, k, n, N step, Enter lands, Esc @@ -1533,7 +1533,7 @@ pub fn step(p: *Pardes, id: usize, delta: i32) void { const in_window = for (q.items.items) |it| { if (it.kind == .hit and it.hit == q.grep_at) break true; } else false; - if (!in_window) makeGrepRows(p, id, q.frozen) catch |err| p.reportError(id, "search", err); + if (!in_window) makeGrepRows(p, id, q.frozen) catch |err| p.reportError(.at(id), "search", err); for (q.items.items, 0..) |it, i| if (it.kind == .hit and it.hit == q.grep_at) return setCurrent(p, id, i, true); return; } @@ -1652,7 +1652,7 @@ fn makePreview(p: *Pardes, qid: usize, rows: u16, giver: usize) ?usize { }; layout.compute(p); if (!layout.attachFrom(p, qid, free, rows, giver)) { - p.removePane(free, qid) catch |err| p.reportError(qid, "query", err); + p.removePane(free, qid) catch |err| p.reportError(.at(qid), "query", err); return null; } rp.query.?.preview = np.serial; @@ -1782,14 +1782,14 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { // The whole list now, once, every place found: a result from here. if (set.started and set.from == rp.serial) { set.fill(p, owner, std.math.maxInt(usize), @import("regexp.zig").Regex.budget); - makeTextRows(p, id, oid, true) catch |err| p.reportError(id, "search", err); + makeTextRows(p, id, oid, true) catch |err| p.reportError(.at(id), "search", err); } if (set.started and set.from == rp.serial) { if (set.literal) { var escaped: std.ArrayList(u8) = .empty; - normal.appendSearchLiteral(&escaped, p.scratch.allocator(), set.pattern) catch |err| return p.reportError(id, "search", err); - p.registers.put(p.gpa, '/', escaped.items, 0, 1, true) catch |err| return p.reportError(id, "search", err); - } else p.registers.put(p.gpa, '/', set.pattern, 0, 1, true) catch |err| return p.reportError(id, "search", err); + normal.appendSearchLiteral(&escaped, p.scratch.allocator(), set.pattern) catch |err| return p.reportError(.at(id), "search", err); + p.registers.put(p.gpa, '/', escaped.items, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err); + } else p.registers.put(p.gpa, '/', set.pattern, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err); p.registers.last_search = '/'; set.provenance = .search; } @@ -1846,7 +1846,7 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void { return; }; // A Grep's whole list, now it is a result. - if (q.source == .grep) makeGrepRows(p, id, true) catch |err| p.reportError(id, "search", err); + if (q.source == .grep) makeGrepRows(p, id, true) catch |err| p.reportError(.at(id), "search", err); var buf: [4096 + 64]u8 = undefined; const address = if (meta.at.line > 0) std.fmt.bufPrint(&buf, "{s}:{d}:{d}", .{ meta.path, meta.at.line, meta.at.col }) catch meta.path @@ -1888,14 +1888,14 @@ pub fn cancel(p: *Pardes, id: usize) void { // go to the text whose rows they were. if (previewOf(p, id)) |pid| { p.panes[pid].?.attached_to = null; - p.removePane(pid, owner_id) catch |err| p.reportError(id, "query", err); + p.removePane(pid, owner_id) catch |err| p.reportError(.at(id), "query", err); q.preview = 0; } const f = &rp.file.?; File.setContent(p, f, s.content); File.setRows(p, f, s.rows) catch |err| { locations.freeRows(p.gpa, s.rows); - p.reportError(id, "query", err); + p.reportError(.at(id), "query", err); }; p.gpa.free(q.asked); q.asked = s.asked; @@ -1921,10 +1921,10 @@ pub fn cancel(p: *Pardes, id: usize) void { // Attached, its rows go back to its owner; else to its own column's. const attached = layout.ownerOf(p, id) != null; if (owner_id) |oid| { - p.removePane(id, if (attached) oid else null) catch |err| p.reportError(id, "query", err); + p.removePane(id, if (attached) oid else null) catch |err| p.reportError(.at(id), "query", err); p.view().active = oid; if (layout.findPane(p, oid)) |at| p.setActiveColumn(at.col); - } else p.removePane(id, null) catch |err| p.reportError(id, "query", err); + } else p.removePane(id, null) catch |err| p.reportError(.at(id), "query", err); } /// A parse of pane `serial`'s text came back (Stream.receiveParse): its @@ -2026,7 +2026,7 @@ pub fn clampEdit(p: *Pardes, t: *panes.Text, old: []const u8, new: []u8) ?[]u8 { if (span.head > end or (span.head == end and old_to > end and put.len == 0 and end < old.len)) { t.refused = true; if (t.pane()) |pane| if (panes.paneIdOf(p, pane)) |id| - p.setMessage(id, "the rows are line 1's: edit the query (Enter keeps them as text)"); + p.setMessage(.at(id), "the rows are line 1's: edit the query (Enter keeps them as text)"); return null; } // From inside line 1 into the rows: what it put in, flat, and what is -- cgit v1.3