From 0635ceab26f92836de300fef4066d7e9dc2494c5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 06:52:28 -0300 Subject: replica.may_wait: a directory's pane walked and listed: the screen-state soak's 'client 5's input key stopped at dir_listing, which may_wait does not list' (s5-1, seed 1 at 207 ms) was a far client's own step listing a directory (Dir.zig's tape.site(.dir_listing), from a Look of a directory or Get on one), which no row listed because the walk never stood in a directory's pane; FIRST the walk: On.dir, a directory's pane made by Look / on the authority and walked as the others (every word, key, prefix and gesture): 18 inputs stopped unlisted (Enter and Tab, alone and after each prefix); then the rows, right by P14 (the session's disk): Get -> dir_listing, Enter and * Enter -> resolve, Tab and * Tab -> kind; the walk test passes (11/11 under its filter); a user's far client typing those in a directory's pane waited, as it should, but the soak called it a fault Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index 56fc4a59..ced4329d 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6537,7 +6537,7 @@ test "a client's n in a kind's pane is a motion: it steps to the next place a re /// `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 }; +const On = enum { any, file, kind, shell, shell_normal, addon, dir }; /// 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 @@ -6558,6 +6558,12 @@ const may_wait = [_]Wait{ .{ .what = "LookPrev", .on = .any, .stop = "resolve", .why = "a Look's walk: each word asked of the disk" }, .{ .what = "Mini *", .on = .any, .stop = "resolve", .why = "a file opened by name, from the session's disk" }, .{ .what = "Get", .on = .any, .stop = "read_file", .why = "the file read again from the session's disk" }, + .{ .what = "Get", .on = .dir, .stop = "dir_listing", .why = "a directory listed again from the session's disk" }, + // A directory's pane (Dir.zig): its entries are names on the session's disk. + .{ .what = "Enter", .on = .dir, .stop = "resolve", .why = "the entry under the cursor opened, from the session's disk" }, + .{ .what = "* Enter", .on = .dir, .stop = "resolve", .why = "the entry opened (Enter after a prefix still opens it)" }, + .{ .what = "Tab", .on = .dir, .stop = "kind", .why = "what the entry under the cursor is, asked of the session's disk" }, + .{ .what = "* Tab", .on = .dir, .stop = "kind", .why = "what the entry is (Tab after a prefix still asks)" }, .{ .what = "Save", .on = .any, .stop = "write_file", .why = "a save" }, // A program run, a shell opened or closed: the session's processes. .{ .what = "Exec *", .on = .any, .stop = "kind", .why = "a program run: its name asked of the disk first" }, @@ -6833,12 +6839,16 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell' _ = try a.local(.{ .command = "Still" }); const kind = a.core.view().active; try std.testing.expect(file != kind and a.core.panes[file].?.file != null and a.core.panes[kind].?.addon != null); + // A directory's pane (Dir.zig), listed from the disk. + _ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/", .{dir}) }); + const listing = a.core.view().active; + try std.testing.expect(a.core.panes[listing].?.file.?.listing != null); var seen: [may_wait.len]bool = @splat(false); var hit: [may_wait.len]bool = @splat(false); var unlisted: u32 = 0; var tried: u32 = 0; - const stands = [_]struct { On, ?usize }{ .{ .file, file }, .{ .kind, kind }, .{ .shell, shell }, .{ .shell_normal, shell } }; + const stands = [_]struct { On, ?usize }{ .{ .file, file }, .{ .kind, kind }, .{ .shell, shell }, .{ .shell_normal, shell }, .{ .dir, listing } }; for (stands) |stand| { const on, const at = stand; const id = at orelse continue; -- cgit v1.3 From b6644ee7091ed1ba19b8e696a83f562c2686c805 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 15:36:47 -0300 Subject: replica: daemon.py plain from 2 of 3 failing on Debug ("the first terminal drawn", the first of two attach clients never shown the shell's last line) to 10 of 10: a client's acknowledgement of a terminal's delta is followed by a flush to it (core/replica.zig `Peers.boundary`, the `.screen` arm: the boundary flushed at its unit and then took the clients' notes, so room an acknowledgement freed in a client's flight, 32 versions at most, sent nothing, and a client at that bound when the last output came kept an old screen until something else stepped; a user could hit it: the last lines of a fast output left unshown on a slow client); and the joiner takes the session's view only for a pair's first join (`Joining.own`) or the first back after a Restore (`Peers.restored`, set by `restoring`; the restored core has the one view), a detached session's attach opening a view of its own again as before `slxkptto` (the coordinator's lean: the wider rule was NOT (A)'s cause, which failed with the narrow rule alone 2 of 3); test/daemon.py `far` waits for the refusal's words through ssh instead of reading the Term the moment the client is gone; core-test 895/1055 (160 skipped), shell-test 1097/1100 (3 skipped) (+1 each: "a detached session's first attach opens a view of its own beside the session's; the first back after a Restore takes the session's"); process-test as a pair 0 of 145 (load 13), own path 0 of 145; plain on Debug 10 of 10 (loads 3-6), on ReleaseSafe 4 of 6, both failures answer_late's adopted `echo $$`, which pardes-rows' `adopted_pid` (ymvuluxr, not in this base) fixes Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 57 +++++++++++++++++++++++++++++++++++++++++++++++++------- test/daemon.py | 5 ++++- 2 files changed, 54 insertions(+), 8 deletions(-) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index ef073ad5..3e6be763 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -2117,6 +2117,9 @@ pub const Peers = struct { /// No frontend of its own (the host says): with no client either, the /// session is unattended. detached: bool = false, + /// A Restore let every client go (`restoring`): the restored core's one + /// view (views.only) is the first to join again's. + restored: bool = false, /// Its last client left with a close (its window closed, its terminal /// hung up) and the session is a pair's not kept (daemon.sessionState): it /// ends there (runtime/session.zig). @@ -2246,7 +2249,14 @@ pub const Peers = struct { }, .screen => |in| { defer ps.gpa.free(in.msg); - const reply = (ps.screens.take(core, in.peer.sid, in.msg) catch null) orelse continue; + // An acknowledgement (or a reset): room again in its flight + // for what its terminals came to since. Its flush at this + // boundary came before it, and at the bound sent nothing: + // with no step after it, that client kept an old screen. + const reply = (ps.screens.take(core, in.peer.sid, in.msg) catch null) orelse { + ps.screensTo(core, in.peer, .flush); + continue; + }; defer ps.gpa.free(reply); const head = wire.header(@backingInt(wire.ServerTag.screen), reply.len); in.peer.send(&.{ &head, reply }); @@ -2346,10 +2356,11 @@ pub const Peers = struct { ps.recording = true; ps.samples = std.c.getenv("PARDES_REPLICA_STATS") != null; } - // A session with no frontend and no client, no view kept for one - // (a pair's after a Restore: views.only; one detached since): the - // view it has is the joiner's. - const own = joining.own or (ps.detached and ps.count() == 0 and core.views_away == 0); + // A pair's first client, or the first back after a Restore with no + // client and no view kept for one: the view the session has is the + // joiner's. Any other attach (a detached session's too) opens one. + const own = joining.own or (ps.restored and ps.count() == 0 and core.views_away == 0); + ps.restored = false; const k = viewFor(core, joining.view, own) orelse { core.unattended = ps.count() == 0 and ps.detached; if (ps.count() == 0) ps.stop(core); @@ -2425,8 +2436,8 @@ pub const Peers = struct { /// its client is sent, not by the view's settle, as a client that made /// its core itself performs none of them. /// `own`: the live view is the joiner's, in a session nobody looks at - /// (a pair's first client, Options.pair; any with no frontend and no - /// client): not one beside it nobody looks at, which would size its + /// (a pair's first client, Options.pair; the first back after a + /// Restore): not one beside it nobody looks at, which would size its /// terminals (Pardes.sizes). /// ponytail: a divergence's redial that came before its old link's end /// (posted by that link's reader, microseconds after the bye; the @@ -2570,6 +2581,7 @@ pub const Peers = struct { } ps.lock.unlock(ps.io); ps.drop(core, false); + ps.restored = true; for (again.items) |j| ps.post(.{ .join = j }); } @@ -4867,6 +4879,37 @@ test "a Restore tells its clients so before it lets them go (each joins again, s try std.testing.expectEqual(1, ps.inbox.items.len); } +test "a detached session's first attach opens a view of its own beside the session's; the first back after a Restore takes the session's" { + const gpa = std.testing.allocator; + const core = try Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); + defer core.deinit(); + core.host = TestHost.host(); + var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .name = "attach", .detached = true }; + defer ps.deinit(); + defer live_peers = null; + defer ps.dropAll(core); + const session_view = core.live; + var fds: [2]c_int = undefined; + if (libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &fds) != 0) return error.NoSocket; + defer _ = libc.close(fds[1]); + ps.join(core, .{ .fd = fds[0] }); + const first = for (ps.list) |slot| { + if (slot) |peer| break peer; + } else return error.NotJoined; + try std.testing.expect(first.view.index() != session_view); + try std.testing.expect(pardes.views.isOpen(core, session_view)); + ps.restoring(core); + var again: [2]c_int = undefined; + if (libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &again) != 0) return error.NoSocket; + defer _ = libc.close(again[1]); + ps.join(core, .{ .fd = again[0] }); + const back = for (ps.list) |slot| { + if (slot) |peer| break peer; + } else return error.NotJoined; + try std.testing.expectEqual(core.live, back.view.index()); + try std.testing.expectEqual(1, pardes.views.count(core)); +} + /// A session's first client on its pair making its core itself /// (`ownBoot`), the file it opens `edited` after the session read it. fn ownBootAgainst(edited: bool) !void { diff --git a/test/daemon.py b/test/daemon.py index 5c075520..23189578 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -2035,7 +2035,10 @@ def far(binary): time.sleep(.3) os.write(ts.master, b' sD') wait_for(f'the client through ssh ends ({name})', lambda: sc.poll() is not None, timeout=30) - assert name == 'files' or b"no session called 'nobody'" in ts.text(), ts.text()[-300:] + # Its words are read off its terminal by a thread of the Term's: + # the process can be gone before they are in `text()`. + if name == 'nobody': + wait_for('the refusal said through ssh', lambda: b"no session called 'nobody'" in ts.text(), timeout=5) wait_for(f'its ssh and socket gone ({name})', lambda: not forwarded(), timeout=10) body = texts() for words in (b'from-A', b'from-B', b'again-A', b'from-C', b'from-D', b'from-E', b'from-F'): -- cgit v1.3