summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 19:55:02 -0300
committerGabriel Schneider <[email protected]>2026-11-19 19:55:02 -0300
commit2ab05b536bc3b063666b5aaab497157adc2a9120 (patch)
tree4b796e6abaf7658294d2b6cbb5d35e0210b88b40
parente4f99d2370c8b44e76b541826d91356d86090f53 (diff)
parent786cddd24e2be36d30847300075cec8c45d1b0ca (diff)
downloadpardes-2ab05b536bc3b063666b5aaab497157adc2a9120.tar.gz
pardes-2ab05b536bc3b063666b5aaab497157adc2a9120.zip
integration: the regular-expression fixes with the fixes the real loops asked for: pardes-regex-2 (mvzr's reads past a pattern cut short patched as it is fetched; the leak of a pattern that does not compile; the soak's corpus check comparing what is visible) and pardes-draw-2 (a step's notice bands and a markdown text's tables made from the step's own state, never from the last frame; a load under way in another live process no crash; an idle pair silent), merged without a conflict; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--core/Addon.zig62
-rw-r--r--core/Core.zig8
-rw-r--r--core/File.zig8
-rw-r--r--core/Tables.zig196
-rw-r--r--core/draw.zig149
-rw-r--r--core/mouse.zig44
-rw-r--r--core/replica.zig67
-rw-r--r--core/root.zig86
-rw-r--r--docs/next-tables.md15
-rw-r--r--test/replicas.zig15
10 files changed, 480 insertions, 170 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index d52462e0..54d1da00 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -445,11 +445,12 @@ fn markPath(buf: []u8, data: []const u8, comptime name: []const u8) ?[:0]const u
return std.fmt.bufPrintSentinel(buf, "{s}/" ++ name, .{data}, 0) catch null;
}
-/// The load of `path` under way, on disk until `unmark`.
+/// The load of `path` under way in this process, on disk until `unmark`:
+/// its name says whose (every pardes of the user shares the directory).
fn mark(data: []const u8, path: []const u8) void {
if (data.len == 0) return;
var buf: [4096]u8 = undefined;
- const at = markPath(&buf, data, "addon-loading") orelse return;
+ const at = std.fmt.bufPrintSentinel(&buf, "{s}/addon-loading.{d}", .{ data, std.c.getpid() }, 0) catch return;
const f = std.c.fopen(at, "w") orelse return;
_ = std.c.fwrite(path.ptr, 1, path.len, f);
_ = std.c.fclose(f);
@@ -468,16 +469,33 @@ fn unmark() void {
marked_len = 0;
}
-/// The library that crashed its session's load: a mark left by a start
-/// that never finished one becomes `addon-crashed`, which it stays.
+/// The library that crashed its session's load: a mark left by a process
+/// that is gone, its load never finished, becomes `addon-crashed`, which it
+/// stays. A live one's is a load under way (a client starting while its
+/// session loads the same library), no crash: taken for one, the client
+/// never ran the kind and every start after skipped it.
fn crashedPath(data: []const u8) Kind.Buf(4096) {
var out: Kind.Buf(4096) = .{};
if (data.len == 0) return out;
- var lbuf: [4096]u8 = undefined;
var cbuf: [4096]u8 = undefined;
- const loading = markPath(&lbuf, data, "addon-loading") orelse return out;
const crashed = markPath(&cbuf, data, "addon-crashed") orelse return out;
- if (std.c.access(loading, 0) == 0) _ = std.c.rename(loading, crashed);
+ var dbuf: [4096]u8 = undefined;
+ const dz = std.fmt.bufPrintSentinel(&dbuf, "{s}", .{data}, 0) catch return out;
+ if (std.c.opendir(dz)) |d| {
+ defer _ = std.c.closedir(d);
+ while (std.c.readdir(d)) |e| {
+ const name = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(&e.name)), 0);
+ if (!std.mem.startsWith(u8, name, "addon-loading")) continue;
+ // `addon-loading` alone is an older build's, whose is not known.
+ if (name.len > "addon-loading".len) {
+ const pid = std.fmt.parseInt(std.c.pid_t, name["addon-loading.".len..], 10) catch continue;
+ if (std.posix.errno(std.c.kill(pid, @fromBackingInt(@intCast(0)))) != .SRCH) continue;
+ }
+ var lbuf: [4096]u8 = undefined;
+ const loading = std.fmt.bufPrintSentinel(&lbuf, "{s}/{s}", .{ data, name }, 0) catch continue;
+ _ = std.c.rename(loading, crashed);
+ }
+ }
out.set(readSmall(crashed).slice());
return out;
}
@@ -916,6 +934,36 @@ test "addon reload gives migration the old record version and saves the new vers
try std.testing.expectEqual(@as(u32, 2), slot.version);
}
+test "a load under way in another live process is no crash: a start meanwhile lists the addon, and the mark stays the loader's" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [4096]u8 = undefined;
+ const data = buf[0..try tmp.dir.realPath(std.testing.io, &buf)];
+ try tmp.dir.createDirPath(std.testing.io, "addons");
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "addons/game.so", .data = "not a library" });
+ var lib_buf: [4096]u8 = undefined;
+ const lib = try std.fmt.bufPrint(&lib_buf, "{s}/addons/game.so", .{data});
+ var dir_buf: [4096]u8 = undefined;
+ const dir = try std.fmt.bufPrint(&dir_buf, "{s}/addons", .{data});
+ // In order, as two processes of the user went under load (daemon.py
+ // --games): one marks its load of the library (this process, alive),
+ // another starts its scan before it unmarks.
+ mark(data, lib);
+ defer unmark();
+ nfound = 0;
+ scanDir(data, dir, crashedPath(data).slice());
+ defer nfound = 0;
+ try std.testing.expectEqualStrings(lib, found[0].path);
+ try std.testing.expect(std.mem.indexOf(u8, found[0].why, "crashed") == null);
+ try std.testing.expectError(error.FileNotFound, tmp.dir.access(std.testing.io, "addon-crashed", .{}));
+ // The loader gone with its mark left: a crash, skipped.
+ var name_buf: [64]u8 = undefined;
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = try std.fmt.bufPrint(&name_buf, "addon-loading.{d}", .{std.math.maxInt(i32)}), .data = lib });
+ nfound = 0;
+ scanDir(data, dir, crashedPath(data).slice());
+ try std.testing.expect(std.mem.startsWith(u8, found[0].why, "skipped: it crashed its last load"));
+}
+
test "a load that never finished is skipped at the next start, and every start after, until a load asks for it" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
diff --git a/core/Core.zig b/core/Core.zig
index 769d16cd..d1cf1d94 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -1595,6 +1595,10 @@ fn serveFsInner(p: *Pardes, req: ctlfs.Req) ctlfs.Reply {
pub const update = pardes.tape.taped(updateInner);
fn updateInner(p: *Pardes, ev: Event) void {
const v = p.view();
+ // Its bands as its state stands: a step reads them (a press on a chip, a
+ // body's top under them), and what a frame drew, a view put back or a
+ // dump left in Pane.notices (derived) is not what every core has.
+ for (p.panes, 0..) |slot, id| if (slot) |pane| Messages.collectNotices(p, pane, v.rects[id], id);
defer pardes.panes.File.syncTwins(p);
defer p.reportFocus();
// A tick with no deadline due is the one event that cannot change
@@ -1629,7 +1633,6 @@ fn updateInner(p: *Pardes, ev: Event) void {
.tick => {
Stream.step(p);
Messages.advanceMessages(p);
- for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.tables.step(p.settings.tab, pane.gpa, f);
for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false);
},
else => {},
@@ -1813,6 +1816,7 @@ fn noteLateFailureInner(p: *Pardes, id: usize) void {
pub const presented = pardes.tape.taped(presentedInner);
fn presentedInner(p: *Pardes) void {
const v = p.view();
+ for (p.panes, 0..) |slot, id| if (slot) |pane| Messages.collectNotices(p, pane, v.rects[id], id);
if (v.pointer_inside and v.drag != .none) {
v.hover_col = v.pointer_raw_col;
v.hover_row = v.pointer_raw_row;
@@ -2040,8 +2044,6 @@ pub fn nextWake(p: *const Pardes) ?u64 {
for (p.panes) |slot| if (slot) |pane| if (pane.places.busy(pane)) return next;
const kinds = pardes.Kind.wake(p);
if (kinds) |due| if (due <= next) return next;
- // A markdown text's tables still being read from the top (Tables.zig).
- for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.tables.busy()) return next;
if (pardes.panes.Query.busy(p)) return next;
// A typed Grep waiting out its pause.
const streaming = p.stream.wake(next);
diff --git a/core/File.zig b/core/File.zig
index 820447ac..c9ee6b71 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -1722,8 +1722,8 @@ fn mapRows(tab: u16, pane: *Pane, f: *State) usize {
}
/// Everything the geometry is made of, hashed: the text (its revision and
-/// length), where it is scrolled, the pane's size, its tables as far as
-/// they have been read, its context declarations, the session's view.
+/// length), where it is scrolled, the pane's size, its tables, its context
+/// declarations, the session's view.
fn geometryKey(pane: *const Pane, f: *const State) u64 {
const t = &f.tables;
const facts = .{
@@ -1732,8 +1732,8 @@ fn geometryKey(pane: *const Pane, f: *const State) u64 {
pane.query != null, f.pager, f.mini != null, f.output != null,
if (f.output) |o| pardes.walk.digest(Output.Origin, &o.from) else 0, std.hash.Wyhash.hash(0, f.path), f.tree_context, f.context.revision orelse 0,
f.context.declarations.len, f.line_starts.len, t.revision orelse 0, t.list.items.len,
- if (t.pending) |r| r.at else std.math.maxInt(usize), pane.view.wrap, pane.view.layered, pane.view.body_h,
- pane.view.tagline_h, pane.view.rect_h,
+ pane.view.wrap, pane.view.layered, pane.view.body_h, pane.view.tagline_h,
+ pane.view.rect_h,
};
// One hash of them laid out as words: every reader of the map asks for
// this key, a hundred times a frame.
diff --git a/core/Tables.zig b/core/Tables.zig
index dc667b7c..a0256d8a 100644
--- a/core/Tables.zig
+++ b/core/Tables.zig
@@ -85,23 +85,10 @@ fences: std.ArrayList([2]u32) = .empty,
garbage: usize = 0,
/// How many times the whole text was read (for the numbers and the tests).
scans: u32 = 0,
-/// Where a reading of the whole text goes on from, until it reaches the
-/// end: it is read a frame's budget at a time from the top (`frame_ns`), as
-/// Places finds, so opening a big file never holds a frame; rows past it
-/// are shown as their source until it gets there.
-pending: ?Resume = null,
-/// A scan's place: the next line's byte and number, the fence it is in,
+/// Where a scan starts: the line's byte and number, the fence it is in,
/// and whether the line before ended a block.
-const Resume = struct { at: usize, n: u32, fence: ?Fence, prev_blank: bool };
-
-/// What one frame spends reading a big text from the top: on the session's
-/// tick, by the clock (core/tape.zig keeps a replica's reading in step).
-pub const frame_ns: u64 = 4 * std.time.ns_per_ms;
-/// What a new text's first look reads at once, wherever it is asked for
-/// (the render, or a step reading the view's geometry): a count, never the
-/// clock, so whoever asks first finds the same tables.
-pub const first_lines: u32 = 4096;
+const Start = struct { at: usize, n: u32, fence: ?Fence, prev_blank: bool };
pub fn deinit(t: *Tables, gpa: std.mem.Allocator) void {
t.list.deinit(gpa);
@@ -143,65 +130,18 @@ pub fn ensure(t: *Tables, tab: u16, gpa: std.mem.Allocator, f: *File.State) void
}
if (f.output != null or f.mini != null or !isMarkdown(f.path)) {
t.list.clearRetainingCapacity();
- t.pending = null;
return;
}
- const starts = File.lineIndex(gpa, f) catch {
- t.list.clearRetainingCapacity();
- t.pending = null;
- return;
- };
+ // Read whole, at once, whoever asks first (a frame, or a step reading
+ // the view's geometry): what is found is the text's alone, never how
+ // far a reading had got, which is no core's state (derived: a core
+ // that drew and one that did not, or one joined from a dump since,
+ // would find two answers). ReleaseFast: 40 ns a line of prose, 18 ms
+ // for 2.7 MB of 2000 tables (docs/next-tables.md's stress text).
const one_edit = t.revision != null and t.revision.? +% 1 == f.revision and
f.splice.revision == f.revision and f.splice.old_len == t.len;
- if (one_edit and t.garbage <= 4 * t.widths.items.len + 1024) {
- if (t.pending) |r| {
- // An edit past where the reading has got to changes nothing it
- // read: it goes on.
- if (lineHolding(starts, f.splice.head) >= r.n) {
- t.lines = starts.len;
- t.go(tab, gpa, f.content, 0, first_lines);
- return;
- }
- } else if (t.reflow(tab, gpa, f)) |_| return else |_| {}
- }
- t.begin(starts.len);
- t.go(tab, gpa, f.content, 0, first_lines);
-}
-
-/// A frame's more of a reading under way: on the session's tick, so a core
-/// that draws reads exactly as far as one that does not.
-pub fn step(t: *Tables, tab: u16, gpa: std.mem.Allocator, f: *File.State) void {
- t.ensure(tab, gpa, f);
- if (t.pending != null) t.go(tab, gpa, f.content, frame_ns, std.math.maxInt(u32));
-}
-
-/// Whether a reading of the text is still under way (Pardes.nextWake).
-pub fn busy(t: *const Tables) bool {
- return t.pending != null;
-}
-
-/// Start reading the whole text again, from the top.
-fn begin(t: *Tables, lines: usize) void {
- t.list.clearRetainingCapacity();
- t.widths.clearRetainingCapacity();
- t.aligns.clearRetainingCapacity();
- t.fences.clearRetainingCapacity();
- t.garbage = 0;
- t.scans +%= 1;
- t.lines = lines;
- t.pending = .{ .at = 0, .n = 0, .fence = null, .prev_blank = true };
-}
-
-/// Read on for about `budget_ns` (0: no clock) or `max_lines`, whichever
-/// ends first. On no memory there are no tables (the text is shown as it is).
-fn go(t: *Tables, tab: u16, gpa: std.mem.Allocator, content: []const u8, budget_ns: u64, max_lines: u32) void {
- var at = t.pending orelse return;
- const done = t.scanFrom(tab, gpa, content, &at, std.math.maxInt(u32), true, budget_ns, max_lines) catch {
- t.list.clearRetainingCapacity();
- t.pending = null;
- return;
- };
- t.pending = if (done) null else at;
+ if (one_edit and t.garbage <= 4 * t.widths.items.len + 1024) if (t.reflow(tab, gpa, f)) |_| return else |_| {};
+ t.scan(tab, gpa, f.content) catch t.list.clearRetainingCapacity();
}
/// Line `n` of a text whose line index is `starts`.
@@ -299,8 +239,8 @@ fn reflow(t: *Tables, tab: u16, gpa: std.mem.Allocator, f: *File.State) !void {
// Any fence line closes a block (a header may follow it).
const prev_blank = r0 == 0 or blank(prev) or fenceOf(prev) != null or std.mem.startsWith(u8, prev[@min(indentOf(prev), prev.len)..], "#");
const head = lineOf(content, starts, r0);
- var at: Resume = .{ .at = head.start, .n = head.n, .fence = null, .prev_blank = prev_blank };
- _ = try t.scanFrom(tab, gpa, content, &at, @intCast(r1), false, 0, std.math.maxInt(u32));
+ const at: Start = .{ .at = head.start, .n = head.n, .fence = null, .prev_blank = prev_blank };
+ try t.scanFrom(tab, gpa, content, at, @intCast(r1), false);
const fresh = try gpa.dupe(Table, t.list.items[before..]);
defer gpa.free(fresh);
t.list.shrinkRetainingCapacity(before);
@@ -502,28 +442,21 @@ pub fn scan(t: *Tables, tab: u16, gpa: std.mem.Allocator, content: []const u8) !
t.list.clearRetainingCapacity();
t.widths.clearRetainingCapacity();
t.aligns.clearRetainingCapacity();
- t.begin(std.mem.count(u8, content, "\n") + 1);
- var at = t.pending.?;
- _ = try t.scanFrom(tab, gpa, content, &at, std.math.maxInt(u32), true, 0, std.math.maxInt(u32));
- t.pending = null;
+ t.fences.clearRetainingCapacity();
+ t.garbage = 0;
+ t.scans +%= 1;
+ t.lines = std.mem.count(u8, content, "\n") + 1;
+ try t.scanFrom(tab, gpa, content, .{ .at = 0, .n = 0, .fence = null, .prev_blank = true }, std.math.maxInt(u32), true);
}
/// Find the tables whose header is on a line from `at` to `stop`,
-/// appending them; with `fences`, keep the fences. With a budget, stop
-/// when it is spent, `at` where to go on from. Whether it reached the end
-/// (or `stop`).
-fn scanFrom(t: *Tables, tab: u16, gpa: std.mem.Allocator, content: []const u8, at: *Resume, stop: u32, fences: bool, budget_ns: u64, max_lines: u32) !bool {
+/// appending them; with `fences`, keep the fences.
+fn scanFrom(t: *Tables, tab: u16, gpa: std.mem.Allocator, content: []const u8, at: Start, stop: u32, fences: bool) !void {
var fence = at.fence;
var prev_blank = at.prev_blank;
var line = lineAt(content, at.at, at.n);
- const t0 = if (budget_ns > 0) pardes.FrameStats.nowNs() else 0;
- var lines: usize = 0;
- while (line) |l| : (lines += 1) {
+ while (line) |l| {
if (l.n > stop) break;
- if (lines % 256 == 255 and (lines >= max_lines or (budget_ns > 0 and pardes.tape.over(t0, budget_ns)))) {
- at.* = .{ .at = l.start, .n = l.n, .fence = fence, .prev_blank = prev_blank };
- return false;
- }
const following = nextLine(content, l);
if (fence) |open| {
if (closes(l.text, open)) {
@@ -563,7 +496,6 @@ fn scanFrom(t: *Tables, tab: u16, gpa: std.mem.Allocator, content: []const u8, a
prev_blank = is_blank or std.mem.startsWith(u8, l.text[@min(indentOf(l.text), l.text.len)..], "#");
line = following;
}
- return true;
}
/// Take the table whose header is `header`: its rows, its columns' widths
@@ -1026,49 +958,6 @@ test "tables: an edit's tables, shifted and found again around it, are the whole
try testing.expect(reflowed > 1000);
}
-test "tables: a big text's tables are read a frame's budget at a time from the top, edits on the way kept" {
- var big: std.ArrayList(u8) = .empty;
- defer big.deinit(testing.allocator);
- for (0..1500) |i| try big.print(testing.allocator, "## {d}\n\n| a | b {d} |\n|---|--:|\n| one | two |\n| three | {d} |\n\n", .{ i, i, i * 7 });
- const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
- defer p.deinit();
- var frame = std.heap.ArenaAllocator.init(testing.allocator);
- defer frame.deinit();
- const pane = try testPane(p, big.items, frame.allocator());
- const f = &pane.file.?;
- // One frame did not read it all, and asks for the next.
- try testing.expect(f.tables.busy());
- try testing.expect(p.nextWake() != null);
- // The top's tables are found already: the view is right at once.
- try testing.expect(File.rowTable(pane, 2) != null);
- const reached = f.tables.pending.?.n;
- // An edit past where it got to: it goes on; one before it: from the top.
- var edits: usize = 0;
- var frames: usize = 0;
- while (f.tables.busy()) : (frames += 1) {
- if (edits < 2) {
- const at = if (edits == 0) f.content.len - 3 else 10;
- const new = try std.mem.concat(p.gpa, u8, &.{ f.content[0..at], "x", f.content[at..] });
- File.setContent(p, f, new);
- edits += 1;
- }
- p.update(.tick);
- _ = frame.reset(.retain_capacity);
- _ = try p.render(frame.allocator());
- try testing.expect(frames < 10_000);
- }
- try testing.expect(reached < File.nlines(p.gpa, f));
- var whole: Tables = .{};
- defer whole.deinit(testing.allocator);
- try whole.scan(config.tab_width, testing.allocator, f.content);
- try testing.expectEqual(whole.list.items.len, f.tables.list.items.len);
- for (whole.list.items, f.tables.list.items) |w, mine| {
- try testing.expectEqual(w.first, mine.first);
- try testing.expectEqual(w.end, mine.end);
- try testing.expectEqual(w.width, mine.width);
- }
-}
-
test "tables: a table wider than a wrapping pane is shown as its source, laid out again with Wrap off" {
const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 34, .rows = 24 });
defer p.deinit();
@@ -1087,3 +976,48 @@ test "tables: a table wider than a wrapping pane is shown as its source, laid ou
try testing.expect(!pane.body_wrapped);
try testing.expect(File.rowTable(pane, 2) != null);
}
+
+// How far a big text's tables have been read is derived (File.State.tables:
+// in no digest and no dump), and a frame reads them too: here the session
+// draws once before an edit and the replica joined from its dump draws
+// nothing, then the same edit and a click on a table's row go to both.
+test "tables: a click on a big text's table is the same state whichever frame this process drew last" {
+ const gpa = testing.allocator;
+ var big: std.ArrayList(u8) = .empty;
+ defer big.deinit(gpa);
+ for (0..5000) |_| try big.appendSlice(gpa, "x\n");
+ const table = big.items.len / 2;
+ try big.appendSlice(gpa, "\n| a | b |\n|---|---|\n| xyz | 1 |\n| q | 12345 |\n");
+ const a = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 16 });
+ defer a.deinit();
+ const pane_a = try a.setTestFile(big.items);
+ a.gpa.free(pane_a.file.?.path);
+ pane_a.file.?.path = try a.gpa.dupe(u8, "/notes.md");
+ const last: i32 = @intCast(table + 4);
+ pane_a.file.?.scroll = table - 4;
+ pane_a.body.cur_row = @intCast(table - 1);
+ pane_a.body.cur_col = 0;
+ a.sync();
+ const bytes = try pardes.dump.dumpBytes(a);
+ defer gpa.free(bytes);
+ const b = try pardes.dump.load(gpa, a.opts, bytes, null);
+ defer b.deinit();
+ var frame = std.heap.ArenaAllocator.init(gpa);
+ defer frame.deinit();
+ _ = try a.render(frame.allocator());
+ for ([_]*Pardes{ a, b }) |p| p.update(.{ .paste = "y" });
+ const r = a.view().rects[0];
+ for (0..14) |col| {
+ var at: [2]i32 = undefined;
+ for ([_]*Pardes{ a, b }, &at) |p, *got| {
+ const pane = p.panes[0].?;
+ const x: u16 = @intCast(r.x + config.GUTTER + File.gutterWidth(pane) + col);
+ const y: u16 = @intCast(p.bodyTop(pane, r) + @as(u16, @intCast(last - @as(i32, @intCast(pane.file.?.scroll)))));
+ p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } });
+ p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = x, .row = y } });
+ try testing.expectEqual(last, pane.body.cur_row);
+ got.* = pane.body.cur_col;
+ }
+ try testing.expectEqual(at[0], at[1]);
+ }
+}
diff --git a/core/draw.zig b/core/draw.zig
index dac6673e..88011373 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -1337,3 +1337,152 @@ test "a body with context rows is painted once, and the grid's rows are what a p
// The layer's own rows run past the grid's.
try std.testing.expect(layer.rows > body.rect.h);
}
+
+// The class kept closed: a frame changes nothing a step reads. What a frame
+// writes of a core is `.local` or `.derived` (in no digest and no dump: a
+// pane's notice bands, the geometry's wrap map and context rows, a markdown
+// text's tables), so a step that reads one must find what its own state
+// makes. Here one core draws after every input, each frame at its own time
+// after its step's, and one joined from its dump never draws: each input's
+// step leaves the two with one digest. A field a frame leaves that a step
+// then reads otherwise than a core that did not draw makes it, differs here.
+// Not seen: a core joined later (its authority's reads are the tape's, which
+// this has none of: the soak's late joins), and what no input here reaches.
+test "a frame changes nothing a step reads: a core drawing after every input and one never drawing agree" {
+ const gpa = std.testing.allocator;
+ const steps: usize = if (std.c.getenv("PARDES_FUZZ_STEPS")) |v| std.fmt.parseInt(usize, std.mem.span(v), 10) catch 600 else 600;
+ const seed: u64 = if (std.c.getenv("PARDES_FUZZ_SEED")) |v| std.fmt.parseInt(u64, std.mem.span(v), 10) catch 11 else 11;
+ var prng = std.Random.DefaultPrng.init(seed);
+ const random = prng.random();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(gpa);
+ for (0..4500) |i| try text.print(gpa, "line {d} {s}\n", .{ i, std.mem.asBytes(&@as([20][6]u8, @splat("words ".*)))[0 .. 6 * (i % 20)] });
+ try text.appendSlice(gpa, "\n| name | qty | note |\n|:--|--:|:-:|\n| fig | 1 | ripe |\n| apple || |\n| a longer name | 12345 | x |\n\n## end\n");
+ const metrics: pardes.RowMetrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 };
+ const a = try Pardes.init(gpa, .{ .tty_only = true, .cols = 90, .rows = 30 });
+ defer a.deinit();
+ a.update(.{ .resize = .{ .cols = 90, .rows = 30, .row_metrics = metrics } });
+ const pane = try a.setTestFile(text.items);
+ a.gpa.free(pane.file.?.path);
+ pane.file.?.path = try a.gpa.dupe(u8, "/notes.md");
+ a.newScratchBelow(0);
+ a.view().active = 0;
+ pane.file.?.scroll = 4490;
+ pane.body.cur_row = 4502;
+ a.sync();
+ const first = try pardes.dump.dumpBytes(a);
+ defer gpa.free(first);
+ const b = try pardes.dump.load(gpa, a.opts, first, null);
+ defer b.deinit();
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ const commands = [_][]const u8{ "Wrap", "Collapse", "Del", "Undo", "Redo" };
+ var now: u64 = std.time.ns_per_s;
+ for (0..steps) |i| {
+ const v = a.view();
+ // Most presses on the body around the table at the text's end.
+ const body = v.rects[0];
+ const ev: pardes.Event = switch (random.uintLessThan(u8, 13)) {
+ 0...4 => .{ .key = .{ .cp = switch (random.uintLessThan(u8, 16)) {
+ 0 => pardes.Key.escape,
+ 1 => 'i',
+ 2 => 'G',
+ 3 => 'g',
+ 4 => ' ',
+ 5 => 'd',
+ 6 => 'w',
+ 7 => 'b',
+ 8 => 'u',
+ 9, 10 => 'j',
+ 11, 12 => 'k',
+ 13 => 'h',
+ 14 => 'l',
+ else => 'x',
+ } } },
+ 5...7 => .{ .mouse = .{
+ .button = if (random.uintLessThan(u8, 4) == 0) .wheel_up else if (random.uintLessThan(u8, 4) == 0) .wheel_down else .left,
+ .kind = switch (random.uintLessThan(u8, 3)) {
+ 0 => .press,
+ 1 => .drag,
+ else => .release,
+ },
+ .col = if (random.boolean()) random.uintLessThan(u16, v.screen_w) else body.x + random.uintLessThan(u16, @max(1, @min(body.w, 40))),
+ .row = if (random.boolean()) random.uintLessThan(u16, v.screen_h) else body.y + random.uintLessThan(u16, @max(1, body.h)),
+ } },
+ 8 => .{ .command = commands[random.uintLessThan(usize, commands.len)] },
+ 9 => .{ .paste = "| new | row |\n" },
+ // The text changed on disk: a step changes it whole.
+ 10 => .{ .file_changed = .{ .pane = 0, .bytes = text.items[0 .. text.items.len - random.uintLessThan(usize, 40)] } },
+ else => blk: {
+ now += random.uintLessThan(u64, 2 * std.time.ns_per_s);
+ break :blk .tick;
+ },
+ };
+ for ([_]*Pardes{ a, b }) |p| {
+ p.clock.now_ns = now;
+ p.clock.stepped_ns = now;
+ p.update(ev);
+ }
+ // A frame is drawn at its own time, after its step's.
+ now += random.uintLessThan(u64, std.time.ns_per_s);
+ a.clock.now_ns = now;
+ b.clock.now_ns = now;
+ _ = arena.reset(.retain_capacity);
+ _ = try a.render(arena.allocator());
+ a.presented();
+ b.presented();
+ if (apart(a, b)) {
+ std.debug.print("seed {d}, step {d}: a {s} left them apart\n", .{ seed, i, @tagName(ev) });
+ return error.DigestsDiffer;
+ }
+ }
+}
+
+/// Whether two cores' digests differ, field by field (the panes' and their
+/// files' too), the fields that do named; but for the three that differ
+/// between two cores in one test process whatever they do: a message's
+/// stamp and a text's mtime, read off the wall clock with no tape, and a
+/// scratch pane's cwd, inherited by pointer on one and owned bytes on one
+/// loaded from a dump.
+fn apart(a: *const Pardes, b: *const Pardes) bool {
+ var any = false;
+ const names = comptime pardes.walk.fieldNames(Pardes);
+ var da: [names.len]u64 = undefined;
+ var db: [names.len]u64 = undefined;
+ _ = pardes.walk.fieldDigests(Pardes, a, &da);
+ _ = pardes.walk.fieldDigests(Pardes, b, &db);
+ for (names, da, db) |name, x, y| if (x != y and !std.mem.eql(u8, name, "panes")) {
+ std.debug.print(" {s}\n", .{name});
+ any = true;
+ };
+ const pane_names = comptime pardes.walk.fieldNames(Pane);
+ for (a.panes, b.panes, 0..) |pa, pb, id| {
+ if ((pa == null) != (pb == null)) {
+ std.debug.print(" pane {d} open on one\n", .{id});
+ any = true;
+ }
+ const x = pa orelse continue;
+ const y = pb orelse continue;
+ var pda: [pane_names.len]u64 = undefined;
+ var pdb: [pane_names.len]u64 = undefined;
+ _ = pardes.walk.fieldDigests(Pane, x, &pda);
+ _ = pardes.walk.fieldDigests(Pane, y, &pdb);
+ for (pane_names, pda, pdb) |name, u, v| if (u != v and !std.mem.eql(u8, name, "msg_said_ms") and !std.mem.eql(u8, name, "cwd")) {
+ if (std.mem.eql(u8, name, "file")) if (x.file) |*fx| if (y.file) |*fy| {
+ const file_names = comptime pardes.walk.fieldNames(panes.File.State);
+ var fda: [file_names.len]u64 = undefined;
+ var fdb: [file_names.len]u64 = undefined;
+ _ = pardes.walk.fieldDigests(panes.File.State, fx, &fda);
+ _ = pardes.walk.fieldDigests(panes.File.State, fy, &fdb);
+ for (file_names, fda, fdb) |file_name, q, r| if (q != r and !std.mem.eql(u8, file_name, "mtime")) {
+ std.debug.print(" pane {d}.file.{s}\n", .{ id, file_name });
+ any = true;
+ };
+ continue;
+ };
+ std.debug.print(" pane {d}.{s}\n", .{ id, name });
+ any = true;
+ };
+ }
+ return any;
+}
diff --git a/core/mouse.zig b/core/mouse.zig
index 6fb97787..5707cb57 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -1769,6 +1769,50 @@ test "a tag press is the same state whichever frame this process drew last" {
try expectSame(two.a, two.b, "after the press");
}
+// A notice band over a body's top rows is derived (Pane.notices): a frame
+// writes it at its own time, so a step makes it again as its state stands
+// before it reads it. Here the session draws a frame once Del's question is
+// due (its band shown) and the replica none: a press on the band's chip is
+// the same in both (the soak's divergence, through `kindMouse`, was this read).
+test "a press on a notice's chip is the same state whichever frame this process drew last" {
+ const gpa = std.testing.allocator;
+ const a = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 40 });
+ defer a.deinit();
+ a.update(.{ .resize = .{ .cols = 80, .rows = 40, .row_metrics = test_metrics } });
+ // Del asks which neighbour takes the rows of a pane with two.
+ a.newScratchBelow(a.view().active);
+ const mid = a.view().active;
+ a.newScratchBelow(mid);
+ a.view().active = mid;
+ a.sync();
+ const bytes = try pardes.dump.dumpBytes(a);
+ defer gpa.free(bytes);
+ const b = try pardes.dump.load(gpa, a.opts, bytes, null);
+ defer b.deinit();
+ for ([_]*Pardes{ a, b }) |p| {
+ p.clock.now_ns = 5 * std.time.ns_per_s;
+ p.clock.stepped_ns = p.clock.now_ns;
+ p.update(.{ .key = .{ .cp = ' ' } });
+ p.update(.{ .key = .{ .cp = 'd' } });
+ p.clock.now_ns = p.panes[mid].?.question_due_ns;
+ }
+ var frame: std.heap.ArenaAllocator = .init(gpa);
+ defer frame.deinit();
+ _ = try a.render(frame.allocator());
+ const pane = a.panes[mid].?;
+ try std.testing.expect(pane.notices.len > 0);
+ const last = pane.notices.len - 1;
+ try std.testing.expectEqual(Pane.Notices.Kind.prompt, pane.notices.kinds[last]);
+ const row = a.bodyTop(pane, a.view().rects[mid]) + pane.notices.row[last];
+ const press: pardes.Event = .{ .mouse = .{ .button = .left, .kind = .press, .col = pane.notices.left[last] + 1, .row = row } };
+ a.update(press);
+ b.update(press);
+ // What the press did (a pane's cwd and a message's wall-clock stamp
+ // differ between two cores in one test process: not compared).
+ try std.testing.expectEqual(a.view().drag, b.view().drag);
+ try std.testing.expectEqual(a.panes[mid].?.sel[0], b.panes[mid].?.sel[0]);
+}
+
// The same through a body hit (edit.pointerTextSelection, a sweep's drag),
// on a compact body layer (TreeContext), which a pixel shell inverts.
test "a body press, drag and release are the same state whichever frame this process drew last" {
diff --git a/core/replica.zig b/core/replica.zig
index fb3a81c4..e2775da8 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -3142,7 +3142,9 @@ pub const Link = struct {
}
if (c.r.moved) c.dirty = true;
c.r.moved = false;
- c.changed = true;
+ // One while a check is asked is the answer's: it comes
+ // after it in the stream and its digest covers it.
+ if (!c.asked) c.changed = true;
},
.screen => |bytes| {
defer std.heap.c_allocator.free(bytes);
@@ -3212,7 +3214,12 @@ pub const Link = struct {
/// another is a divergence (the replica joins again).
fn checked(c: *Link, theirs: u64) void {
c.asked = false;
- if (!c.r.quiet() or c.r.diverged != null) return;
+ // Not quiet now, the answer is let go: it covers nothing, and the
+ // next quiet asks again.
+ if (!c.r.quiet() or c.r.diverged != null) {
+ c.changed = true;
+ return;
+ }
const mine = c.r.digest();
c.r.stats.checks += 1;
c.r.since_check = 0;
@@ -5407,11 +5414,11 @@ const walk_prefixes = prefixes: {
/// The argument a word that means nothing without one is walked with.
const walk_samples = [_]struct { []const u8, []const u8 }{
- .{ "Look", "mise.toml" }, .{ "Exec", "echo" }, .{ "Mount", "x" }, .{ "Unmount", "x" },
- .{ "Msg", "hi" }, .{ "ThemeFile", "t.zon" }, .{ "Edit", "s/a/b/" }, .{ "Mini", "x" },
- .{ "Find", "x" }, .{ "Grep", "x" }, .{ "Rename", "x" }, .{ "WsSymbols", "x" },
- .{ "Theme", "acme" }, .{ "Font", "Mono 12" }, .{ "TaglineSize", "100" }, .{ "WindowOpacity", "100" },
- .{ "MessageLinger", "1000" }, .{ "InactiveDim", "0" }, .{ "GripWidth", "100" },
+ .{ "Look", "mise.toml" }, .{ "Exec", "echo" }, .{ "Mount", "x" }, .{ "Unmount", "x" },
+ .{ "Msg", "hi" }, .{ "ThemeFile", "t.zon" }, .{ "Edit", "s/a/b/" }, .{ "Mini", "x" },
+ .{ "Find", "x" }, .{ "Grep", "x" }, .{ "Rename", "x" }, .{ "WsSymbols", "x" },
+ .{ "Theme", "acme" }, .{ "Font", "Mono 12" }, .{ "TaglineSize", "100" }, .{ "WindowOpacity", "100" },
+ .{ "MessageLinger", "1000" }, .{ "InactiveDim", "0" }, .{ "GripWidth", "100" },
};
fn keyName(buf: []u8, k: pardes.Key) []const u8 {
@@ -5830,3 +5837,49 @@ test "a far client's replay of the session's Fonts and Font takes the session's
r.settle();
try agrees(a, r);
}
+
+// An idle client asked the session's digest once quiet after a change; the
+// session's pump that answers it sends a unit before the answer (its clock
+// read), which must not count as a change, or an idle pair asks, wakes and
+// answers every 300 ms for ever. A unit while asked is the answer's to
+// cover; an answer let go (not quiet then) covers nothing.
+test "an idle client's check answered covers the units that came while it was asked: it asks no other until something changes" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "build.zig" }, TestHost.host(), false);
+ defer a.deinit();
+ const r = try joinedNow(a, 1, 0);
+ defer r.deinit();
+ var fds: [2]c_int = undefined;
+ try std.testing.expectEqual(@as(c_int, 0), libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &fds));
+ defer for (fds) |fd| {
+ _ = libc.close(fd);
+ };
+ var c: Link = .{ .r = r, .fd = fds[0], .now = std.time.ns_per_s };
+ const unit = struct {
+ fn of(au: *Authority) !Said {
+ return .{ .unit = try std.heap.c_allocator.dupe(u8, try au.local(.tick)) };
+ }
+ }.of;
+ // Something changed, 300 ms quiet since its last input: asked.
+ c.take(try unit(a));
+ try std.testing.expectEqual(@as(?u32, null), c.quietCheck());
+ try std.testing.expect(c.asked);
+ // The session's pump for it (a unit), then the answer: agreed, and
+ // nothing to ask after it however long it stays quiet.
+ c.take(try unit(a));
+ c.take(.{ .checked = digestOf(a) });
+ try std.testing.expect(!c.asked and c.r.diverged == null);
+ c.now.? += 10 * std.time.ns_per_s;
+ try std.testing.expectEqual(@as(?u32, null), c.quietCheck());
+ try std.testing.expect(!c.asked);
+ // A unit after it is a change again.
+ c.take(try unit(a));
+ c.now.? += std.time.ns_per_s;
+ _ = c.quietCheck();
+ try std.testing.expect(c.asked);
+ // An answer let go (an input of its own pending then) covers nothing:
+ // asked again once quiet.
+ _ = try r.pend(.{ .key = .{ .cp = 'j' } });
+ c.take(.{ .checked = digestOf(a) });
+ try std.testing.expect(!c.asked and c.changed);
+}
diff --git a/core/root.zig b/core/root.zig
index 706c833d..2e8fe1dc 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -605,7 +605,7 @@ test "nothing of a core is a process global: every container-level var in core/
/// The count is a file's, so it cannot tell a step's read from its host
/// half's; the reason says which the file's are.
const machine_lines = [_]struct { []const u8, usize, []const u8 }{
- .{ "Addon.zig", 48, "the process's addon libraries: the start's scan of their directories, dlopen, the crash mark; the host's, never a step's" },
+ .{ "Addon.zig", 54, "the process's addon libraries: the start's scan of their directories, dlopen, the crash mark (whose: the pid alive); the host's, never a step's" },
.{ "Core.zig", 5, "the session's directory read once at its start (taped), a frame log (PARDES_FRAMES), a host_io type" },
.{ "Db.zig", 18, "the state file every session of the user shares: the authority's (`db`), off in every replica" },
.{ "Dir.zig", 1, "a directory's listing, the function under tape.site(.dir_listing), its io the tape's" },
@@ -721,3 +721,87 @@ test "what core/ asks of the machine is where the list says, with why: a new lin
};
try std.testing.expectEqual(@as(usize, 0), wrong);
}
+
+/// Every field kept out of the digest and the dump as a process's own
+/// (`.local`) or as made again from the rest (`.derived`): who writes it,
+/// and why what a step reads of it is what that step's own state makes, so
+/// a core that drew a frame and one that did not, or one joined since, step
+/// alike (a frame writes several; a step that read one a frame left as its
+/// state did not make it diverged a client: Pane.notices, then Tables'
+/// reading, 2026-11-19). A file, its names, the reason.
+const kept_out = [_]struct { []const u8, []const u8, []const u8 }{
+ .{ "Core.zig", "surface facts frames own_frames chrome frame_arena scratch echo undrawn", "the frame's own and the views drawn here: written by frames (and chrome by a theme's step), read by frames and the runner; no step reads them" },
+ .{ "Core.zig", "needs_frame", "whether to draw: steps set it, the loop reads it; no step's outcome reads it" },
+ .{ "Core.zig", "effects effects_head effects_len in_q in_head in_len opts dump_out dump_export tape", "this process's queues, options and tape, drained or set by its host" },
+ .{ "Core.zig", "shell_rows", "a terminal's rows as read here, swept at every update; a terminal is in no digest (Term.zig)" },
+ .{ "Core.zig", "diff_output locations_cache tty_filter_palette body_chrome", "caches of pure functions of their key (a text, a theme): a step finds what it would make; a query row's colours from them are out of its digest (locations.Row.digest)" },
+ .{ "Core.zig", "retired_panes", "panes torn down this step, freed at its end" },
+ .{ "Core.zig", "distrusted frames tape", "Options: the client's own list, its runner's statistics, its tape" },
+ .{ "Event.zig", "native_image_patches", "what this process's shell can take" },
+ .{ "panes.zig", "pv pv_known", "the views' shares as this process parks them (views.zig)" },
+ .{ "panes.zig", "wrap_line wrap_col wrap_pad wrap_n body_wrapped context_rows body_rows body_visible_rows context_row_limit geometry_key geometry_len", "File.geometry's, made by whoever asks first (a frame or a step) from everything its key hashes of the step's state; a tab change resets the key" },
+ .{ "panes.zig views.zig", "notices", "made again from the step's state at the top of update and presented, and at sync (Messages.collectNotices); a frame's are its own" },
+ .{ "panes.zig views.zig", "pan", "written by steps only (sync, a view unparked) from the pane and its terminal" },
+ .{ "File.zig", "cap line_starts line_cap", "the text's line index, of its bytes" },
+ .{ "File.zig", "highlights highlight_start syntax_dirty", "how a text looks, painted by frames: read by frames, and by a query's rows for colours only (out of their digest)" },
+ .{ "File.zig", "context", "the declarations of the text at a revision: found in sync (refreshContext), by a parse's answer (a step) or a dump's load" },
+ .{ "File.zig", "node_tree node_tree_revision node_tree_edits node_history", "the parse of the text at its revision, made by the first key that walks it" },
+ .{ "File.zig", "tables", "the whole text's, read at once by whoever asks first (Tables.ensure): no reading under way that a frame could move" },
+ .{ "Text.zig", "room", "a buffer's capacity" },
+ .{ "Kind.zig", "ops st gpa arena plain file opened reloads jobs record", "the kind's code and memory here: a plain kind's block is in the copy, and its state hash is checked at every call (Kind.Call.end)" },
+ .{ "Kind.zig", "thumb_at thumb_span pointer painted over used draws", "a frame's: written by a paint; `painted` is read by a tick of a kind that is not plain, whose calls are the authority's alone" },
+ .{ "Places.zig", "ticks ticks_gen re", "the rail's ticks, made again when the places move (`gen`), and the compiled pattern, of the pattern" },
+ .{ "Plumb.zig", "parsed parsed_arena", "the rules parsed, of their text" },
+ .{ "Stream.zig", "parse_ns paint paint_retired paint_count ahead ahead_for painted_ahead painted_on_loop ahead_seen ahead_ask", "the workers' paints and timings: how a text looks, and numbers" },
+ .{ "walk.zig", "cache", "a test's own type" },
+};
+
+test "every field kept out of the digest and the dump is one the list names, with who writes it and why a step's read of it is the step's" {
+ const gpa = std.testing.allocator;
+ const io = std.testing.io;
+ var dir = try std.Io.Dir.cwd().openDir(io, "core", .{ .iterate = true });
+ defer dir.close(io);
+ var walker = try dir.walk(gpa);
+ defer walker.deinit();
+ var unlisted: usize = 0;
+ var seen: usize = 0;
+ while (try walker.next(io)) |e| {
+ if (e.kind != .file or !std.mem.endsWith(u8, e.basename, ".zig")) continue;
+ const src = try e.dir.readFileAlloc(io, e.basename, gpa, .limited(16 << 20));
+ defer gpa.free(src);
+ for ([_][]const u8{ ".local = .{", ".derived = .{" }) |head| {
+ var at: usize = 0;
+ while (std.mem.indexOfPos(u8, src, at, head)) |start| {
+ const end = std.mem.indexOfScalarPos(u8, src, start, '}') orelse break;
+ at = end;
+ // Not in a comment or a string (walk.zig's example, this test).
+ const before = src[(std.mem.lastIndexOfScalar(u8, src[0..start], '\n') orelse 0)..start];
+ if (std.mem.indexOf(u8, before, "//") != null or std.mem.indexOfScalar(u8, before, '"') != null) continue;
+ var lines = std.mem.splitScalar(u8, src[start + head.len .. end], '\n');
+ while (lines.next()) |whole| {
+ const line = whole[0 .. std.mem.indexOf(u8, whole, "//") orelse whole.len];
+ var quoted = std.mem.splitScalar(u8, line, '"');
+ _ = quoted.next();
+ while (quoted.next()) |name| {
+ _ = quoted.next();
+ seen += 1;
+ const listed = listed: for (kept_out) |k| {
+ var files = std.mem.tokenizeScalar(u8, k[0], ' ');
+ const here = while (files.next()) |f| {
+ if (std.mem.eql(u8, f, e.path)) break true;
+ } else false;
+ if (!here) continue;
+ var names = std.mem.tokenizeScalar(u8, k[1], ' ');
+ while (names.next()) |n| if (std.mem.eql(u8, n, name)) break :listed true;
+ } else false;
+ if (listed) continue;
+ std.debug.print("core/{s}: `{s}` is kept out of the digest and the dump: on root.zig's kept_out, with who writes it and why a step reads only what its own state makes\n", .{ e.path, name });
+ unlisted += 1;
+ }
+ }
+ }
+ }
+ }
+ try std.testing.expect(seen > 60);
+ try std.testing.expectEqual(@as(usize, 0), unlisted);
+}
diff --git a/docs/next-tables.md b/docs/next-tables.md
index 121b345a..9aab2ba9 100644
--- a/docs/next-tables.md
+++ b/docs/next-tables.md
@@ -71,7 +71,6 @@ and 10-30 rows, fences every 50 tables. Debug build, 160x50, each step
|---|---|---|
| a whole read of the tables (once, blocking, for comparison) | 127 ms | - |
| the first frame | 27 ms | 18 ms |
-| frames until every table is read (4 ms a frame from the top) | 24 | - |
| `j` and its frame, in a table | 1.0 ms (worst 1.5) | 0.6 ms (0.9) |
| a letter typed in a cell and its frame | 3.2 ms (worst 8.5) | 2.0 ms (6.8) |
@@ -84,10 +83,12 @@ Two changes the numbers forced, both Places' patterns:
in what it replaced, reads everything (a fence changes every line after
it). A random 1500-edit test checks every result against a whole read;
more than 1000 took the short way.
-- **Opening reads from the top a frame's budget at a time** (`Tables.frame_ns`,
- `Pardes.nextWake` while `busy`): rows below the read point are drawn as
- source until it gets there (a quarter second on this file). An edit past
- the read point changes nothing read; one before it starts the read again.
+- **Opening reads the whole text at once** (18 ms in ReleaseFast on this
+ file). It was read a frame's budget at a time from the top, but how far a
+ reading had got is no core's state (the tables are derived: in no digest,
+ no dump), and a frame read them too: a core that drew before an edit, or
+ one joined from a dump since, found other pads than the session's, so a
+ click or a `j` over a table did otherwise in a client (2026-11-19).
## GUI and tty
@@ -169,8 +170,8 @@ byte's cell maps back to it, and every pad cell to the byte after it`; `...is
drawn aligned, its bytes in order, the caret and a click on each byte's cell`
(also the look); `...typing in a cell re-aligns the table live, and j/k keep
the column shown`; `...an edit's tables, shifted and found again around it,
-are the whole text's` (1500 random edits); `...a big text's tables are read
-a frame's budget at a time`; `...wider than a wrapping pane is shown as its
+are the whole text's` (1500 random edits); `...a click on a big text's
+table is the same state whichever frame this process drew last`; `...wider than a wrapping pane is shown as its
source`; `tables are the pipe_tables tree-sitter finds` (syntax.zig);
`a box-drawing rule reaches its cell's edges` (gui.zig); `zz tables timings`
(skipped without `TABLES_TIMES`). No layout change, so no rects invariant.
diff --git a/test/replicas.zig b/test/replicas.zig
index 6fd65bbe..f1c4ff60 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -792,19 +792,16 @@ const Soak = struct {
/// A Peer's queue, swapped out as its writer swaps it (the Peers'
/// allocator's).
sending: std.ArrayListUnmanaged(u8) = .empty,
- /// This wait ended at its frame's tick: its pump draws.
- at_frame: bool = false,
fn of(ctx: ?*anyopaque) *Soak {
return @ptrCast(@alignCast(ctx.?));
}
- /// Its own view drawn at its frame's tick (`.frame`), as the soak's
- /// session always drew it; not after every pump, as a terminal's is:
- /// drawn so, the soak finds a client's step replayed with a kind's call
- /// more than the session's (reports/pardes-runners-d.md).
- fn watchedHost(ctx: ?*anyopaque) bool {
- return of(ctx).at_frame;
+ /// Its own view drawn after every pump, as a terminal's session draws
+ /// its own (Core.render: drawn whenever a frame is owed and someone
+ /// sees it, and a terminal is always seen).
+ fn watchedHost(_: ?*anyopaque) bool {
+ return true;
}
fn ptyWrite(ctx: ?*anyopaque, pane: u8, bytes: []const u8) void {
@@ -1124,7 +1121,6 @@ const Soak = struct {
return false;
}
var took_output = false;
- s.at_frame = false;
// What its boundary took is old news.
_ = s.l.peers.urgent.swap(false, .acq_rel);
while (true) {
@@ -1219,7 +1215,6 @@ const Soak = struct {
s.frames_left = if (busy) 120 else s.frames_left -| 1;
if (s.frames_left > 0) try net.send(.{ .at = m.at + frame_us, .n = 0, .kind = .frame, .who = 0, .bytes = &.{} });
if (took_output or core.needs_frame or (core.nextWake() orelse std.math.maxInt(u64)) <= s.now_ns) {
- s.at_frame = true;
s.framed = true;
s.encode_ns = s.l.peers.screens.encode_ns;
return false;