summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 15:36:25 -0300
committerGabriel Schneider <[email protected]>2026-11-18 16:38:06 -0300
commit558051ca5525a4dade47ab6ef7794eefd848f7b2 (patch)
tree6428a7df78085027452b65f8fce681f12cc6ddb1 /src
parentceed9ad65c34a222f3b4e8c68ecaff595db17ffc (diff)
downloadpardes-558051ca5525a4dade47ab6ef7794eefd848f7b2.tar.gz
pardes-558051ca5525a4dade47ab6ef7794eefd848f7b2.zip
replicas: the soak loads addons (a picture, a PDF and a game of life as a user's libraries, in a data directory of its own; the picture open at the start, every client joining with it), its session has a clock (its loop's: a frame, its own input or a pty's read moves it, a client's mail does not; a frame pumps it, Authority.pump) and takes the Detach word (the client's link ended by the session, its view closed), pictures' draws land on their loop 3 ms after they are asked (Kind.drawer), and what it found: a client joined from a dump replayed a step that made a file's pane and said why it had no room for it by announcing to /log first (events.bootFirst read the session's log, p.fs, which a client's is not: a replica never announces there now; a test fails without it), and a Debug client's rollback put back a kind's Debug list of its allocations that a speculation had grown and freed on the page allocator (Slot.used now the slot's allocator's; the soak's seeds 0 and 2 at rtt 207 crashed without it); not fixed, reported: a client joined from a dump holding a PDF pane diverges at another client's key into it (pane N.addon, views[k].jumps); daemon.py --games, --window-clients (its PDF case run with the addons installed) pass on the base, process-test the base's two; replicas five clients diverged 0, unequal 0, checked/wrong 2143/0, 2000/0, 1846/0, quiet checks 554/0, 540/0, 706/0; three clients diverged 0; tui core-test 823/964, shell-test 999/1002, behaviour-test 274/274 and --replay 20 seeds 0 failures, pane-test 180/181, gui unit-test 1593/1597
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src')
-rw-r--r--src/Kind.zig10
-rw-r--r--src/ninep/events.zig5
-rw-r--r--src/replica.zig49
3 files changed, 59 insertions, 5 deletions
diff --git a/src/Kind.zig b/src/Kind.zig
index 233365c7..bf8f14d1 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -218,8 +218,10 @@ pub const Slot = struct {
/// A client's join: its plain kind's file, until the pane is opened
/// from it (dump.plainHere).
file: ?[]u8 = null,
- /// Debug: the kind's allocations, which paint must leave as they are
- /// (the list the page allocator's: a region's first is slow in Debug).
+ /// Debug: the kind's allocations, which paint must leave as they are.
+ /// The slot's allocator's, as the slot is: a client's rollback puts
+ /// the list back with the slot that holds it (on the page allocator,
+ /// the list put back was one a speculation had grown and freed).
used: if (checked) std.ArrayList([]u8) else void = if (checked) .empty else {},
pub const Job = struct { token: u32, in: []u8 };
@@ -239,7 +241,7 @@ pub const Slot = struct {
pub fn free(s: *Slot) void {
for (&s.jobs) |*j| if (j.*) |job| s.gpa.free(job.in);
s.gpa.free(s.selection);
- if (checked) s.used.deinit(std.heap.page_allocator);
+ if (checked) s.used.deinit(s.gpa);
if (s.shadow) |sh| sh.deinit(s.gpa);
if (s.plain) |b| if (b.len > 0) s.gpa.free(b);
s.arena.deinit();
@@ -1088,7 +1090,7 @@ pub const api: c.pa_api = .{
break :mem cl.slot.arena.allocator().alignedAlloc(u8, .@"16", @max(n, 1)) catch return null;
};
@memset(mem, 0);
- if (checked) cl.slot.used.append(std.heap.page_allocator, mem) catch {};
+ if (checked) cl.slot.used.append(cl.slot.gpa, mem) catch {};
return mem.ptr;
}
}.f,
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 9e6df93d..2af86108 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -154,8 +154,11 @@ pub fn announce(p: *Pardes) void {
/// The panes present at boot are the log's first records: something said
/// before the first update ends (an init file's notice) waits for them.
+/// The log is the session's (`p.fs`, the authority's): a replica client's,
+/// joined from a dump, is empty, and its step must not announce (taped
+/// reads, Recent's) where the session's, booted long ago, does not.
fn bootFirst(p: *Pardes) void {
- if (newest(p) == null) announce(p);
+ if (newest(p) == null and !pardes.tape.replaying()) announce(p);
}
/// Records `<kind> <serial> <name>`.
diff --git a/src/replica.zig b/src/replica.zig
index 3af1caac..2cbf0c0c 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -239,6 +239,18 @@ pub const Authority = struct {
a.batched += 1;
}
+ /// A pass of its host's loop with no input (a frame's wake): its pump
+ /// alone, its clock advanced and what is due ticked, into the open
+ /// batch.
+ pub fn pump(a: *Authority) void {
+ a.t.no_digest = true;
+ defer a.t.no_digest = false;
+ const was = Stepping.begin(&a.t, null);
+ a.core.pump(a.host) catch {};
+ was.end();
+ a.batched += 1;
+ }
+
/// The open batch as a unit, or null: what the host sends before it
/// steps any other input, and once a frame.
pub fn pending(a: *Authority) !?[]const u8 {
@@ -4173,6 +4185,43 @@ test "a replica joined from the session's dump replays the units after it" {
try std.testing.expectEqual(digestOf(a), r.digest());
}
+test "a replica joined from a dump replays a step that opens a file's pane and says it has no room for it: its /log, empty, is not the session's" {
+ const gpa = std.testing.allocator;
+ // No rows for a second pane: the Look's pane of a kind is made, the
+ // placement says it has no room (a message in the step that made the
+ // pane, which was not in /log yet), and the pane goes.
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 5, .file = "mise.toml" }, TestHost.host(), false);
+ defer a.deinit();
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const zon = pardes.Kind.loadedOf(&Zon.ops, "/x/zon.so", @splat(9), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &zon } });
+ const r = try joinedNow(a, 1, 0);
+ defer r.deinit();
+ try std.testing.expectEqual(digestOf(a), r.digest());
+ var whole: [libc.PATH_MAX]u8 = undefined;
+ var look: [libc.PATH_MAX + 8]u8 = undefined;
+ const path = std.mem.span(libc.realpath("build.zig.zon", &whole) orelse return error.SkipZigTest);
+ r.confirm(try a.local(.{ .command = try std.fmt.bufPrint(&look, "Look {s}", .{path}) }));
+ if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why});
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+}
+
+/// A kind of `.zon` files, for a replica's Look of one (a picture's,
+/// as a kind's pane is made).
+const Zon = struct {
+ const pa = pardes.Kind.c;
+ fn open(_: [*c]const u8, _: [*c]const u8, _: u64) callconv(.c) ?*anyopaque {
+ return pardes.Kind.api.alloc.?(4);
+ }
+ fn paint(_: ?*anyopaque, _: [*c]const pa.pa_window, _: [*c]pa.pa_paint) callconv(.c) void {}
+ const ops = std.mem.zeroInit(pardes.Kind.Ops, .{
+ .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "zon".* ++ @as([13]u8, @splat(0)), .version = 1, .exts = ".zon" }),
+ .open = open,
+ .paint = paint,
+ });
+};
+
test "a replica joined from a themed dump paints its taglines in the restored theme" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "build.zig" }, TestHost.host(), false);