summaryrefslogtreecommitdiff
path: root/src/Query.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 15:15:01 -0300
committerGabriel Schneider <[email protected]>2026-10-30 16:49:16 -0300
commit5af775e9817395af39792cc609b832394d4a4fb8 (patch)
treed1aad3579b8b16ebd74c80567ae386fa7d3825d8 /src/Query.zig
parent3f62f4e2a0f40e9d92f79665c2e87804c2d55357 (diff)
downloadpardes-5af775e9817395af39792cc609b832394d4a4fb8.tar.gz
pardes-5af775e9817395af39792cc609b832394d4a4fb8.zip
replica: what only the authority holds, a step reads off the tape (tape.authority): the store's closed panes and Recent, a script's hold on a pane's events, the 9P socket, the session's config directory and startup file; a replica's own are never read, and never put back by a rollback
The Panes picker's closed rows, Recent's rows, a closed pane brought back (a Look at @pN, a Panes row), a jump to a closed file and the +Jumps rows read `p.store` and `p.recent`, `.authority` state a replica keeps on its own: its store has no file, its Recent only what it replayed since it joined. The rows made of them went into digested state, so every client of a session diverged together after a Del (H4), every client that joined after one diverged at its first unit forever (H11: trackJump dropped a closed file's jumps at every step when Recent did not know the file), a client's Del of a file the session's Recent knew made the stat the session skipped (H12: noteClosed looked in Recent first), and a client on another machine read its own store (H13). - tape.authority: poison, then a value read: the authority's answer is taped, a replay takes it, a speculation waits for it. One site, `.authority`. - Readers through it: Query's Recent and closed-pane rows, Store.reopen's record, Pardes.recentByHash (jumps, +Jumps), mouse.reportRange's readers check (a script reading a pane's events takes a look or exec: `pane.fs.readers`, the 9P server's), Tty9p's socket check, Pardes.configDir and startupPath (ThemeFile, DumpThemes, Config, DumpConfig, an init file saved), DumpConfig's dump directory. - trackJump no longer reads Recent at every step: a closed file's jump stays; the jump to it drops that file's entries when Recent has forgotten it, as when the file is gone. - noteClosed asks the host (recentKeeps, a taped stat) before it looks in Recent: the same syscall on every side. - The tty toggle, read on every key, is session state: Pardes.tty_toggle, from the options when the core is made, dumped. - The rollback copy no longer saves `store` and `recent` (rollback.zig `unsaved`): their bytes put back pointed at lists the host's heap (recentGpa) had freed, which the epoch never holds. A speculated Del then a Panes listing read a freed name (H8, the segfault). Tests, each failing before: a rollback leaves the store and Recent as a speculation left them; a replica joined after a pane closed has the session's jump to it, its Panes and Recent rows, asked by either (and the variant hunt's Recent written by another window); a replica's Del of a file its session's Recent knows asks the host what the session asked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Query.zig')
-rw-r--r--src/Query.zig21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Query.zig b/src/Query.zig
index 49f58a0e..2f417a68 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -48,6 +48,7 @@ const memory = @import("memory.zig");
const Names = @import("Names.zig");
const Places = @import("Places.zig");
const Stream = @import("Stream.zig");
+const Store = @import("Store.zig");
const Surface = @import("surface.zig").Surface;
const Pardes = pardes.Pardes;
const Pane = panes.Pane;
@@ -591,12 +592,9 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
if (p.fs.serving) Stream.step(p);
},
.recent => {
- // Every window's files: what the others wrote since, read.
- p.store.refresh(p);
var out: std.Io.Writer.Allocating = .init(gpa);
defer out.deinit();
- Output.recentText(p, &out.writer, true) catch {};
- var lines = std.mem.splitScalar(u8, out.written(), '\n');
+ var lines = std.mem.splitScalar(u8, pardes.tape.authority(recentRows, .{ p, &out }), '\n');
while (lines.next()) |ln| {
if (ln.len == 0) continue;
const rel = Names.relative(ln, dir);
@@ -617,10 +615,9 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
}
// Then the panes this session closed, the latest first, each
// `(closed)` and dimmer (makeNameRows): Enter brings one back
- // where it was. Its name alone is matched, not the word.
- var i = p.store.closed.items.len;
- while (i > 0) : (i -= 1) {
- const c = p.store.closed.items[i - 1];
+ // where it was. Its name alone is matched, not the word. The
+ // store's, which a replica has from the authority.
+ for (pardes.tape.authority(Store.closedNames, .{p})) |c| {
var buf: [4096 + 48]u8 = undefined;
const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}" ++ closed_word, .{ c.serial, Names.relative(c.name, dir) }) catch continue;
const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1;
@@ -652,6 +649,14 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
/// What a Panes row of a closed pane ends with.
const closed_word = " (closed)";
+/// Every window's files, as a Recent query lists them: what the others
+/// wrote since, read first. The store's (`tape.authority`): in `out`.
+fn recentRows(p: *Pardes, out: *std.Io.Writer.Allocating) []const u8 {
+ p.store.refresh(p);
+ Output.recentText(p, &out.writer, true) catch {};
+ return out.written();
+}
+
/// The owner's declarations, from a parse that already exists: its sticky
/// headers' (TreeContext) at this revision, or the locations cache's. None
/// is made here, on the loop, unless `small` and the text is small: a