summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 08:10:53 -0300
committerGabriel Schneider <[email protected]>2026-11-19 11:40:11 -0300
commit3f0261245d69e015d4caea0432aefa97747d02ad (patch)
tree602c3c21858cef0c2a9c97530c7782931cc9f612 /core
parentd2f854de898cb84776e9f56ece0ec9e9c548e27d (diff)
downloadpardes-3f0261245d69e015d4caea0432aefa97747d02ad.tar.gz
pardes-3f0261245d69e015d4caea0432aefa97747d02ad.zip
replicas: the soak runs THE client loop, the one the terminal and the window run (the reorganisation's runners, step 10b, its second part; the user's rule: replica bugs caught by a soak that does what real use does, twice hidden by a hand-written imitation): each client of test/replicas.zig is runtime/client.zig's Loop over a frontend of the soak's own (a terminal's or a window's by turns: it draws no pixels but counts its frames and keeps the facts a window reads; a window's size posted from its own pass; a terminal holds a key already one pass in four, so no copy then; its wait is the delayed link's next message, a wake it asks for one timer at a time on the soak's clock), driven as a loop woken from outside (Loop.pass up to its wait, Loop.woken after what woke it), so its mirrors of the two loops are deleted (Client.draw, own, within, pass, and the quiet check imitated on the soak's clock: the link's own quietCheck now runs, its clock the soak's through Link.now as Echo.now is); its host has every entry (replica.everyEntry, which 12b's FullHost is now too: pty_resize, watch_file, watch_theme, open_link, pipe, search and the rest do nothing unless the soak's), and an input whose stop's name replica.may_wait does not list fails the run, said with its input (replica.mayWait; the soak's random inputs cannot be named as the walk names them, so by the name alone): the soak found seven names the list did not have, all a far client's by design, now rows with why (Search's rows, a session worker's: `search`; a +Preview's file, the session's disk: `preview`; a kind whose state is its own on the session, a PDF's, its search, a place in it, its word, its open and its close: five rows on a new pane kind `addon`, which the walk does not stand in and never judges stale); the stops by name, the wakes asked and the frames drawn are a line per rtt; the leftovers go (Stats.unspeculated and its column, Proc with enter and current: the distrusted list is the client's, the stale comment about config.tab_now); and a new check, the frame corpus through a client (corpusCase): the corpus's scenes (a wheel, a click, a jump, TaglineSize, a markdown file, three columns, a dirty pane, InactiveDim, WindowOpacity, ligatures, Zerox, a resize) typed into a session's own view drawn by its own pump and, the same, through the client loop into a client's view of a second session of the same files, the session's unit back at once; after each, the two frames a frontend draws from (cells, cursor, chrome, regions, the facts beside them, the placements) are the same: 22 scenes, 25 frames own and 24 through the client, every one the same. Gate: the soak on the shared loop (--clients 5, 4 seeds) diverged 0, unequal 0, deltas wrong 0, quiet checks 489/0, 556/0, 700/0, mispredicted 32/36/43, stopped 87/43/81 of 1784/1806/1977 at rtt 30/80/207 (pty_write 54/9/47, the kinds' 20/19/20, resolve 6/8/4, search 2/4/4, the authority's own state 3/2/3, close a terminal 0/0/3, kind 1/0/0, detach 1/1/0), unlisted 0, 216 s (the base's 230 s); tui core-test 836/979 (143 skipped), shell-test 1014/1017, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's); gui unit-test 1612/1616 with the base's BaselineHarnessMismatch; daemon.py plain, --far, --games, --window-clients, --upgrade from pardes-tree's pfx-base to this and back; the macOS library for Linux and aarch64-macos and the FreeBSD tui configure; rollback-bench runs; gate-w run3-2 against tree1: frames 77/77 byte-identical in Debug, the alternated windows' pictures identical in all 10 runs, corpus2x -0.055% (PASS), perfops 97 counts within 0.1% (largest image-frame on large +0.031%); its unit-test 1608/1616: the gate was started in the background (`&`), so SIGINT was ignored down to its test shells and the four host_io tests whose Ctrl-C must end a foreground job failed; the same unit-test run detached but not so (setsid, no terminal) 1612/1616 with the base's BaselineHarnessMismatch only
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/replica.zig134
1 files changed, 83 insertions, 51 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 31a06214..92e49df5 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -562,8 +562,6 @@ pub const Stats = struct {
speculated: u32 = 0,
/// Stopped at a host call, a syscall or an emulator: waits one RTT.
stopped: u32 = 0,
- /// Not tried: an event of the view's (a resize, the pointer), phase 4's.
- unspeculated: u32 = 0,
/// The authority's unit was the pending head, recorded the same.
fast: u32 = 0,
/// The copy put back: the head recorded otherwise (a guess of the clock
@@ -3008,6 +3006,9 @@ pub const Link = struct {
/// waits a while after each).
input_ns: u64 = 0,
asked_ns: u64 = 0,
+ /// The clock those read, when not the machine's: a simulation's (the
+ /// soak's, test/replicas.zig), as `Echo.now` is.
+ now: ?u64 = null,
/// How many of its own inputs the session recorded otherwise when it
/// last drew: a frame after one that draws something is a rollback that
/// may have been seen (counted so: an upper bound, the frame shows the
@@ -3035,6 +3036,10 @@ pub const Link = struct {
draws: u32 = 0,
again: u32 = 0,
+ fn time(c: *const Link) u64 {
+ return c.now orelse nowNs();
+ }
+
/// The test knobs the environment sets (PARDES_REPLICA_CHECK,
/// PARDES_TEST_DIVERGE).
pub fn fromEnv(c: *Link, gpa: Allocator, env: *const std.process.Environ.Map) !void {
@@ -3079,7 +3084,7 @@ pub const Link = struct {
pub fn input(c: *Link, ev: pardes.Event) void {
// Its notice read: a key of its own puts it away.
if (c.notice_len > 0 and (ev == .key or ev == .paste)) c.notice_len = 0;
- c.input_ns = nowNs();
+ c.input_ns = c.time();
const msg = c.r.input(ev) catch return;
if (!sendInput(c.fd, msg)) c.cut();
c.dirty = true;
@@ -3155,12 +3160,12 @@ pub const Link = struct {
pub fn quietCheck(c: *Link) ?u32 {
if (!c.changed or c.asked or !c.r.quiet()) return null;
const quiet_ns = 300 * std.time.ns_per_ms;
- const since = nowNs() -| @max(c.input_ns, c.asked_ns);
+ const since = c.time() -| @max(c.input_ns, c.asked_ns);
if (since < quiet_ns) return @intCast((quiet_ns - since) / std.time.ns_per_ms + 1);
c.changed = false;
c.asked = askCheck(c.fd);
if (!c.asked) c.cut();
- c.asked_ns = nowNs();
+ c.asked_ns = c.time();
return null;
}
@@ -5247,7 +5252,10 @@ test "a client's n in a kind's pane is a motion: it steps to the next place a re
/// The kinds of pane the walk below stands in: a file's, a plain kind's,
/// a shell's raw (its program has the keys) and a shell's in normal mode
/// (pardes's own keys over its history). `any` is a row's for all four.
-const On = enum { any, file, kind, shell, shell_normal };
+/// `addon`: a kind whose state is its own on the session (a PDF's), which
+/// the walk does not stand in (its Still has no search, place or word):
+/// the soak's (test/replicas.zig) PDF and pictures are, judged by name.
+const On = enum { any, file, kind, shell, shell_normal, addon };
/// What a far client may wait a round trip for (the user's line, P14: a
/// side effect on the system may be slow; motions, edits and layout are
@@ -5299,12 +5307,31 @@ const may_wait = [_]Wait{
.{ .what = "DumpConfig", .on = .any, .stop = "the authority's own state", .why = "the config file written" },
.{ .what = "ThemeFile *", .on = .any, .stop = "the authority's own state", .why = "a theme file, the session's" },
.{ .what = "DumpThemes", .on = .any, .stop = "the authority's own state", .why = "the theme files written" },
+ // A search's rows: the session's worker or its loop writes them, and
+ // whether it has a worker is not the client's to know (12a); a
+ // +Preview's text is read from the session's disk.
+ .{ .what = "Search *", .on = .any, .stop = "search", .why = "a search's rows, the session's worker's" },
+ .{ .what = "Search *", .on = .any, .stop = "preview", .why = "a +Preview's file, from the session's disk" },
+ // A kind's own state on the session (a PDF's document): asking it.
+ .{ .what = "*", .on = .addon, .stop = "a kind's search", .why = "a search in a kind's pane: its own state, the session's" },
+ .{ .what = "*", .on = .addon, .stop = "a kind's address", .why = "a place in a kind's pane (`Look doc.pdf:3`): its own state" },
+ .{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" },
+ .{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" },
+ .{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" },
} ++ (if (pardes.platform == .gui) [_]Wait{
// A window's view (the font words are a window's).
.{ .what = "Font *", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
.{ .what = "Fonts", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
} else [_]Wait{});
+/// Whether a stop of that name (`Tape.poisoned_by`) is one `may_wait`
+/// lists for something: the soak's (test/replicas.zig) judge of its
+/// clients' inputs, which it cannot name as the walk does.
+pub fn mayWait(stop: []const u8) bool {
+ for (may_wait) |row| if (std.mem.eql(u8, row.stop, stop)) return true;
+ return false;
+}
+
/// The keys the walk types: every printable one, and the specials a
/// frontend reads; each plain, with Ctrl and with Alt.
const walk_keys = keys: {
@@ -5374,53 +5401,58 @@ fn keyName(buf: []u8, k: pardes.Key) []const u8 {
return std.fmt.bufPrint(buf, "{s}{u}", .{ mod, k.cp }) catch unreachable;
}
-/// A session's host with every entry a step may ask, each doing nothing:
-/// a client's step stops, or goes on, as against a real session's (a
-/// client's tape offers only the entries its session's host has). The
-/// loop's own (`now`, `wait_input`, the frame's) no step asks.
-const FullHost = struct {
- fn Noop(comptime F: type) type {
- const info = @typeInfo(@typeInfo(@typeInfo(F).optional.child).pointer.child).@"fn";
- const R = info.return_type.?;
- const P = info.param_types;
- return switch (P.len) {
- 1 => struct {
- fn f(_: ?*anyopaque) R {
- return std.mem.zeroes(R);
- }
- },
- 2 => struct {
- fn f(_: ?*anyopaque, _: P[1].?) R {
- return std.mem.zeroes(R);
- }
- },
- 3 => struct {
- fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?) R {
- return std.mem.zeroes(R);
- }
- },
- 4 => struct {
- fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?, _: P[3].?) R {
- return std.mem.zeroes(R);
- }
- },
- 5 => struct {
- fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?, _: P[3].?, _: P[4].?) R {
- return std.mem.zeroes(R);
- }
- },
- else => @compileError("a host entry of more arguments"),
- };
- }
- const vtable = table: {
- var v: pardes.Host.VTable = .{};
- for (@typeInfo(pardes.Host.VTable).@"struct".field_names) |name| {
- if (std.mem.eql(u8, name, "now") or std.mem.eql(u8, name, "wait_input") or std.mem.eql(u8, name, "present") or
- std.mem.eql(u8, name, "post_present") or std.mem.eql(u8, name, "poll_frame")) continue;
- @field(v, name) = &Noop(@FieldType(pardes.Host.VTable, name)).f;
+/// `v` with every entry a step may ask that it leaves out doing nothing
+/// (answering zero): a client's step stops, or goes on, as against a real
+/// session's (a client's tape offers only the entries its session's host
+/// has). The loop's own (`now`, `wait_input`, the frame's) no step asks.
+pub fn everyEntry(comptime v: pardes.Host.VTable) pardes.Host.VTable {
+ const Noop = struct {
+ fn Of(comptime F: type) type {
+ const info = @typeInfo(@typeInfo(@typeInfo(F).optional.child).pointer.child).@"fn";
+ const R = info.return_type.?;
+ const P = info.param_types;
+ return switch (P.len) {
+ 1 => struct {
+ fn f(_: ?*anyopaque) R {
+ return std.mem.zeroes(R);
+ }
+ },
+ 2 => struct {
+ fn f(_: ?*anyopaque, _: P[1].?) R {
+ return std.mem.zeroes(R);
+ }
+ },
+ 3 => struct {
+ fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?) R {
+ return std.mem.zeroes(R);
+ }
+ },
+ 4 => struct {
+ fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?, _: P[3].?) R {
+ return std.mem.zeroes(R);
+ }
+ },
+ 5 => struct {
+ fn f(_: ?*anyopaque, _: P[1].?, _: P[2].?, _: P[3].?, _: P[4].?) R {
+ return std.mem.zeroes(R);
+ }
+ },
+ else => @compileError("a host entry of more arguments"),
+ };
}
- break :table v;
};
+ var all = v;
+ for (@typeInfo(pardes.Host.VTable).@"struct".field_names) |name| {
+ if (std.mem.eql(u8, name, "now") or std.mem.eql(u8, name, "wait_input") or std.mem.eql(u8, name, "present") or
+ std.mem.eql(u8, name, "post_present") or std.mem.eql(u8, name, "poll_frame")) continue;
+ if (@field(all, name) == null) @field(all, name) = &Noop.Of(@FieldType(pardes.Host.VTable, name)).f;
+ }
+ return all;
+}
+
+/// A session's host with every entry a step may ask, each doing nothing.
+const FullHost = struct {
+ const vtable = everyEntry(.{});
fn host() pardes.Host {
return .{ .vtable = &vtable };
}