summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 19:50:04 -0300
committerGabriel Schneider <[email protected]>2026-11-20 21:53:39 -0300
commit1ae6addf4590d3b9c1070f6546c29e807d272491 (patch)
tree0c9a618753dcb214c2c614a13f62d2ea28b3c895 /core/replica.zig
parent391c1383011f4fb84743f824c6cc29e68cc4beb7 (diff)
downloadpardes-1ae6addf4590d3b9c1070f6546c29e807d272491.tar.gz
pardes-1ae6addf4590d3b9c1070f6546c29e807d272491.zip
rollback: the copy walks a type by its fields when it says what they are (`replica`), whatever digest of its own it has: it skipped every type with one as if it were a terminal, so since faults-4 the 9P state (fs.Namespace, a pane's ninep State) was saved only as the bytes of its records, never the buffers they own, and a unit kept over a copy that wrote one in place came back other than it was (a script's exec held "Ta", the next write ran `Tab 8` and moved "Un" to the front of the same buffer, and the rollback's replay ran `Unb 8`: the client's digest other than the session's); now only a type with a digest and no `replica` (Term.State, the authority's emulator; locations.Row, made again and never written) is left out (`unwalked`); the test, that exec write over a copy taken ahead and a rollback by another's key, differed on the base (digest 12509739004356058903 against 4039275215734315918) and passes; the tree gated whole (load 1-8): tui core-test 875/1033 (158 skipped), shell-test 1075/1078, term-test 17/17, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test 0 of 145 failed; both soaks diverged 0, unequal 0, unlisted 0, quiet checks 597/0 673/0 779/0 and 693/0 586/0 829/0, the corpus 22 of 22, no leak; daemon.py --clients 39 of 40 alone and 20 of 20 pinned, plain 5 of 5, --far, --far-find, --relink, --launch, --pair, --restore, --games (addon-test 5/5), --window-clients (its PDF case skipped: no pdf.so in a tui prefix), --gui pass; the cross-builds (macos, macos arm, freebsd) build; the frame and perf gate against tree2: 77/77 frames, perfab +0.043%, 121 per-operation counts within 0.1% (largest client-key-down on medium +0.0749%), gui unit-test 1671/1675 with no failure the base has not
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 4ba08849..c895618d 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -7124,6 +7124,37 @@ test "a 9P open the session made over a copy taken ahead, replayed after a rollb
try agrees(a, r);
}
+test "a script's half line held over a copy taken ahead, its next write run and its rest moved to the front in place, put back by a rollback: the line replayed is the session's" {
+ var n = try NinepJoin.init("one\n", TestHost.host());
+ defer n.deinit();
+ try n.join();
+ const r = n.late.?;
+ const exec = n.node(.exec);
+ const h = (try n.serve(.{ .tag = 1, .op = .open, .node = exec, .omode = 1 }, true)).handle;
+ _ = try n.serve(.{ .tag = 2, .op = .write, .node = exec, .handle = h, .data = "Ta" }, true);
+ r.ready();
+ // Replayed over the copy and kept: `Tab 8` runs, `Un` is held where
+ // `Ta` was, in the buffer the copy holds.
+ _ = try n.serve(.{ .tag = 3, .op = .write, .node = exec, .handle = h, .data = "b 8\nUn" }, true);
+ try std.testing.expect(r.copy.held and r.since.items.len > 0);
+ var sent: std.ArrayListUnmanaged([]u8) = .empty;
+ defer {
+ for (sent.items) |m| std.testing.allocator.free(m);
+ sent.deinit(std.testing.allocator);
+ }
+ try key(r, 'l', &sent);
+ try std.testing.expectEqual(@as(usize, 1), r.applied);
+ // The session's key first: a rollback, the write replayed again.
+ try n.send(try n.a.local(.{ .key = .{ .cp = 'j', .text = "j" } }));
+ try std.testing.expect(r.stats.foreign > 0);
+ try n.send(try n.a.take(sent.items[0]));
+ _ = try n.serve(.{ .tag = 4, .op = .write, .node = exec, .handle = h, .data = "do\n" }, true);
+ _ = try n.serve(.{ .tag = 5, .op = .release, .node = exec, .handle = h, .opened = true }, true);
+ if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why});
+ try std.testing.expect(r.diverged == null and r.quiet());
+ try n.agree();
+}
+
// Del with a pane above and below asks which way the space goes, its
// question shown once a delay is up (builtins.zig): its time was the
// host's clock read in the step, an answering entry a speculation stops at.