From d667965902512147f976fbbf89cb1ee77d0a37d0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 15:57:57 -0300 Subject: test/cross_replay.py: a session that meets the host's failures (a Look of a fifo and of a directory, a Save into a file, a Restore of no dump, a stat and a read under /os) recorded by one build of pardes and replayed by others, its errors by name in the tape; --record and --replay alone, for the box; pardes-snap --replay-with (zig build replay -Dreplay-with=) replays every script's tape with another build too, whose replica that draws nothing must agree (a replica client draws none of its session's frames) Co-Authored-By: Claude Opus 5.5 --- test/cross_replay.py | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 test/cross_replay.py (limited to 'test/cross_replay.py') diff --git a/test/cross_replay.py b/test/cross_replay.py new file mode 100644 index 00000000..2a4a7ae7 --- /dev/null +++ b/test/cross_replay.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +"""A session's tape recorded by one build of pardes and replayed by another +(docs/next-daemon.md, the remote bugs): a window's build replaying a +terminal's session, a terminal's build a window's, a Linux build a FreeBSD +one's. A replica of another build reads its session's units as this replay +reads the tape, so what the tape carries must mean the same to both. + + python3 -B test/cross_replay.py ... + a session of recorded here, replayed by it and by each + replayer (a pardes-gui records in a hidden window) + python3 -B test/cross_replay.py --record + the session alone, its tapes left in (on the box, say) + python3 -B test/cross_replay.py --replay ... + each tape replayed alone + +The session meets the host's failures, whose errors cross by name: a Look +of a fifo (a read the host refuses) and of a directory, a stat and a read +under /os over 9P, a Save into a file as if it were a directory and a +Restore of a dump that is not there (errors the host reports, anyerrors). +""" +import os +import shutil +import signal +import subprocess +import sys +import tempfile +import time +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).parent)) +from daemon import Window, alive, processes, wait_for # noqa: E402 +from ninep import Client # noqa: E402 + + +def record(binary, out): + """One session of `binary`, recording into `out`: its tapes' paths.""" + out = Path(out).resolve() + out.mkdir(parents=True, exist_ok=True) + # A short runtime directory: a socket's path holds 108 bytes at most. + root = Path(tempfile.mkdtemp(prefix='xr-', dir=os.environ.get('TMPDIR', '/tmp'))) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + XDG_STATE_HOME=str(root / 'state'), XDG_CACHE_HOME=str(root / 'cache'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/sh') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'a.txt').write_text('hello\n') + (root / 'dir').mkdir() + (root / 'dir' / 'b.txt').write_text('in a directory\n') + os.mkfifo(root / 'fifo') + # No `MessageLinger 0` (test/daemon.py's sessions have it): with it, now + # and then, a tape does not replay even by its own build, on main too + # (pane 0's message differs a step after a failure is said). + (root / 'config' / 'pardes' / 'init').write_text('') + stem = Path(binary).name + env['PARDES_RECORD'] = str(out / f'{stem}-') + window = 'gui' in stem + started = [] + win = None + try: + if window: + win = Window(root, 'rec', [binary, '--9p=xr', str(root / 'a.txt')], env) + started.append(win.pid) + else: + started.append(subprocess.Popen([binary, '--detach=xr', str(root / 'a.txt')], env=env, cwd=root, + stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, start_new_session=True).pid) + sock = root / 'pardes-9p-xr.sock' + wait_for('the session\'s 9P socket', sock.exists, timeout=30) + with Client(sock) as c: + status = dict(line.split(maxsplit=1) for line in c.read('/status').decode().splitlines()) + started.append(int(status['pid'])) + pane = next(int(row.split()[0]) for row in c.read('/index').splitlines() if row.split()[1] == b'text') + for line in (f'Look {root / "fifo"}', f'Look {root / "dir"}', f'Save {root / "a.txt" / "x"}', + f'Restore {root / "nothing.dump"}'): + try: + c.write(f'/pane/{pane}/exec', line.encode() + b'\n') + except Exception: + pass # said as the write's error: a failure is what is wanted + time.sleep(.3) + c.stat(f'/os{root / "a.txt"}') + assert c.read(f'/os{root / "a.txt"}') == b'hello\n' + for _ in range(2): # the failed Save left the text edited: Exit asks again + try: + c.write(f'/pane/{pane}/exec', b'Exit\n') + except Exception: + pass + if win: + win.close() + wait_for('the session\'s end', lambda: not any(alive(p) for p in started), timeout=20) + finally: + for pid in started + processes(root): + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + shutil.rmtree(root, ignore_errors=True) + tapes = sorted(out.glob(f'{stem}-*.tape')) + assert tapes, f'{binary} wrote no tape into {out}' + taped = b''.join(t.read_bytes() for t in tapes) + for name in (b'NotAFile', b'NotDir', b'FileNotFound'): # the fifo's, the Save's, the Restore's + assert name in taped, f'no {name} in the tapes' + return tapes + + +def replay(binary, tape): + """`binary`'s replay of `tape`: its replicas' digests agree. A replica + client never draws its session's frames, and only the replica that + draws none (`headless`) must agree with another frontend's tape: the + two that draw meet the other build's drawing (a window's, a terminal's).""" + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')} + env['PARDES_REPLAY'] = str(tape) + got = subprocess.run([binary], env=env, capture_output=True, timeout=600) + said = got.stderr.decode(errors='replace') + alike = ('gui' in Path(tape).name) == ('gui' in Path(binary).name) + agreed = [line for line in said.splitlines() if line.endswith('digests agree')] + assert ('headless replica' in ''.join(agreed)) and (not alike or (got.returncode == 0 and len(agreed) == 3)), \ + f'{binary} replaying {tape}:\n{said[-3000:]}' + print(f'cross_replay: {Path(binary).name} replayed {Path(tape).name}: ' + + '; '.join(line.split(': ', 1)[1] for line in said.splitlines() if 'replica' in line)) + + +if __name__ == '__main__': + if sys.argv[1:2] == ['--record']: + for t in record(sys.argv[2], sys.argv[3]): + print(t) + elif sys.argv[1:2] == ['--replay']: + for t in sys.argv[3:]: + replay(sys.argv[2], t) + else: + out = Path(tempfile.mkdtemp(prefix='xr-tapes-', dir=os.environ.get('TMPDIR', '/tmp'))) + try: + for t in record(sys.argv[1], out): + for b in sys.argv[1:]: + replay(b, t) + finally: + shutil.rmtree(out, ignore_errors=True) -- cgit v1.3 From d92ea9dfdd9198b69bff420c3b594f0ffed1e1bb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 16:50:58 -0300 Subject: Messages: a detached session's messages go on the clock in the pump, after its wait, not in the host's wait: the host's call (tty waitInput, gui waitDetached) was no input, its clock read untaped, so a replay (and every replica of a session nobody attached) kept a message its session had let go; with MessageLinger 0 (test/daemon.py's sessions) a tape whose session said a failure never replayed, on main too (pane 0's msg, digest 6, 7 of 7 runs; 0 of 6 after); test/cross_replay.py's session says MessageLinger 0 again Co-Authored-By: Claude Opus 5.5 --- src/Messages.zig | 12 +++++++----- src/gui/gui.zig | 3 +-- src/pardes.zig | 5 +++++ src/tty/tty.zig | 4 ++-- test/cross_replay.py | 7 +++---- 5 files changed, 18 insertions(+), 13 deletions(-) (limited to 'test/cross_replay.py') diff --git a/src/Messages.zig b/src/Messages.zig index e1d18849..371ed168 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -216,9 +216,10 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { /// With no frontend attached no input dismisses a message, and a detached /// session's /screen and messages kept what was said an hour ago: each /// pane's lines go once its newest has been up `message_linger_ms`, on the -/// clock, checked as the core is stepped and by the detached session's loop -/// between steps -- not as a 9P request is served, since a read is answered -/// while a step is out and must change nothing. +/// clock, checked as the core is stepped (each event, and each pump after +/// its wait, which a message wakes) -- not as a 9P request is served, since +/// a read is answered while a step is out and must change nothing, nor by +/// the host, whose call is no input a replay makes. /// ponytail: a pane's older lines go with its newest, not each on its own /// clock; the render pipeline's clock will give every line its own. fn nowMs() i64 { @@ -742,10 +743,11 @@ test "with no frontend attached a message goes once it has lingered, on the cloc // Detached with nobody attached: past its linger it is gone, and the // line above it with it. p.unattended = true; - // A read served meanwhile changes nothing; the session's loop expires. + // A read served meanwhile changes nothing; the session's step after its + // wait expires, not the host (whose call no replay makes). _ = p.serveFs(.{ .tag = 1, .op = .read, .node = @backingInt(ctlfs.TopFile.index), .size = 64 }); try std.testing.expect(pane.msg_len > 0); - expireUnattended(p); + try p.pump(.{}); try std.testing.expectEqual(@as(u16, 0), pane.msg_len); try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len); // A fresh one stays until its linger is up. diff --git a/src/gui/gui.zig b/src/gui/gui.zig index c3fdd63a..ead89a8a 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -4941,9 +4941,8 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { /// Detached: no window, asleep until the queue's wake (an SDL user event: /// a pty's output, the daemon's window request), the core's next wake, or a /// quit (SDL makes SIGTERM and SIGINT one). With nobody to dismiss them, -/// messages go on the clock. +/// messages go on the clock (the pump's, after this wait), which wakes it. fn waitDetached(core: *pardes.Pardes, timeout_ms: u32) void { - pardes.Messages.expireUnattended(core); var ms: c_int = if (timeout_ms != 0) @intCast(@min(timeout_ms, std.math.maxInt(c_int))) else -1; for (core.panes) |slot| if (slot) |pane| if (pane.msg_len > 0) { ms = if (ms < 0) 100 else @min(ms, 100); diff --git a/src/pardes.zig b/src/pardes.zig index 189a5b02..a4fcb2d3 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6175,6 +6175,11 @@ pub const Pardes = struct { } else 0; f(h.ctx, timeout); } + // Detached, nobody's key dismisses a message: they go on the clock, + // here in the step, where the clock read is taped (the host's wait + // did it, untaped, and a replay kept a message its session had let + // go). + Messages.expireUnattended(p); p.frames.mark_start = FrameStats.nowNs(); if (v.now) |clock| p.advance(clock(h.ctx)); p.settle(); diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 39c287f7..03b7a7e2 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -2432,9 +2432,9 @@ const Shell = struct { // ends the wait at once and its frame is drawn then; the ticks after // it run from it. var wait = timeout_ms; - // Detached, nobody's key dismisses a message: they go on the clock. + // Detached, nobody's key dismisses a message: they go on the clock + // (the pump's, after this wait), which wakes it. if (!s.attached()) { - pardes.Messages.expireUnattended(s.core); for (s.core.panes) |slot| if (slot) |pane| if (pane.msg_len > 0) { wait = if (wait == 0) 100 else @min(wait, 100); break; diff --git a/test/cross_replay.py b/test/cross_replay.py index 2a4a7ae7..26304d9a 100644 --- a/test/cross_replay.py +++ b/test/cross_replay.py @@ -47,10 +47,9 @@ def record(binary, out): (root / 'dir').mkdir() (root / 'dir' / 'b.txt').write_text('in a directory\n') os.mkfifo(root / 'fifo') - # No `MessageLinger 0` (test/daemon.py's sessions have it): with it, now - # and then, a tape does not replay even by its own build, on main too - # (pane 0's message differs a step after a failure is said). - (root / 'config' / 'pardes' / 'init').write_text('') + # As test/daemon.py's sessions are: a detached session's message goes at + # once, on the clock (Messages.expireUnattended). + (root / 'config' / 'pardes' / 'init').write_text('MessageLinger 0\n') stem = Path(binary).name env['PARDES_RECORD'] = str(out / f'{stem}-') window = 'gui' in stem -- cgit v1.3 From 0d147b0a46bf5a0a92c75f7018cb64546120f453 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 17:12:05 -0300 Subject: walk: an enum is digested by its name (its word, a fixed-width hash), not its number: registry.Builtin, made at compile time, has Tty9p in a Linux build and not a FreeBSD one, so a +LocationsConfig (its output's origin a Builtin) digested otherwise in each, and a Linux client of a FreeBSD session holding one could not join (the hunt's H19: `the session's dump loaded as another session`, main's window client of main's session on the box; after, a terminal and a window client here join one with a +Search, a directory, a renamed file and a +LocationsConfig, and agree); walk's test, and test/cross_replay.py's session holds a +LocationsConfig and a renamed file (a FreeBSD tape replayed here diverged at pane 2.file.output before) Co-Authored-By: Claude Opus 5.5 --- src/walk.zig | 46 +++++++++++++++++++++++++++++++++++++++++++--- test/cross_replay.py | 11 ++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) (limited to 'test/cross_replay.py') diff --git a/src/walk.zig b/src/walk.zig index c5a6e7a2..14e1929e 100644 --- a/src/walk.zig +++ b/src/walk.zig @@ -302,12 +302,12 @@ pub fn hash(comptime T: type, v: *const T, h: *Hasher) void { .bool => h.update(&.{@intFromBool(v.*)}), .int => hashInt(T, v.*, h), .float => h.update(std.mem.asBytes(v)), - .@"enum" => |e| hashInt(e.tag_type, @backingInt(v.*), h), + .@"enum" => hashEnum(T, v.*, h), .optional => |o| if (v.*) |*payload| { h.update(&.{1}); hash(o.child, payload, h); } else h.update(&.{0}), - .array => |a| if (comptime flat(a.child)) h.update(std.mem.sliceAsBytes(v)) else for (v) |*e| hash(a.child, e, h), + .array => |a| if (comptime flatHash(a.child)) h.update(std.mem.sliceAsBytes(v)) else for (v) |*e| hash(a.child, e, h), .pointer => |p| switch (p.size) { .one => hash(p.child, v.*, h), .slice => hashSlice(p.child, v.*, h), @@ -361,6 +361,35 @@ pub fn hash(comptime T: type, v: *const T, h: *Hasher) void { } } +/// Bytes a digest takes whole: an enum's are its build's number, not it. +fn flatHash(comptime T: type) bool { + return flat(T) and @typeInfo(T) != .@"enum"; +} + +/// An enum by its name, as a dump reads it, not by its number: an enum +/// made at compile time numbers its words as its build has them +/// (`registry.Builtin` has fewer in a FreeBSD build than a Linux one, which +/// has Tty9p), so a window client here of a session on the box loaded a +/// +LocationsConfig to another digest. A name's word (its hash, fixed +/// width, so that two names in a row are not one), looked up by number +/// where the words are numbered 0 up; one numbered by hand, or a value no +/// word has, by its number. +fn hashEnum(comptime T: type, v: T, h: *Hasher) void { + const e = @typeInfo(T).@"enum"; + const words: ?[e.field_names.len]u64 = comptime words: { + @setEvalBranchQuota(100_000); + var out: [e.field_names.len]u64 = undefined; + for (e.field_names, e.field_values, 0..) |name, n, i| { + if (n != i) break :words null; + out[i] = std.hash.Wyhash.hash(0, name); + } + break :words out; + }; + const n = @backingInt(v); + if (words) |table| if (n >= 0 and n < table.len) return h.update(std.mem.asBytes(&table[@intCast(n)])); + hashInt(e.tag_type, n, h); +} + /// An integer by its value: one narrower than its bytes (a u21, an i2) has /// bits in memory that are no part of it. fn hashInt(comptime I: type, n: I, h: *Hasher) void { @@ -372,7 +401,7 @@ fn hashInt(comptime I: type, n: I, h: *Hasher) void { fn hashSlice(comptime E: type, items: []const E, h: *Hasher) void { if (in_blob and items.len * @sizeOf(E) >= blob_min) return hashBlob(E, items, h); h.update(std.mem.asBytes(&items.len)); - if (comptime flat(E)) return h.update(std.mem.sliceAsBytes(items)); + if (comptime flatHash(E)) return h.update(std.mem.sliceAsBytes(items)); for (items) |*e| hash(E, e, h); } @@ -652,6 +681,17 @@ test "an error is taped by its name, which another build reads back as its own" try std.testing.expectEqual(error.FileNotFound, (try decode(Report, &r, arena.allocator())).err); } +test "an enum is digested by its name, which another build may number otherwise" { + // registry.Builtin as a Linux build makes it (Tty9p in it) and as a + // FreeBSD one does: LocationsConfig is another number in each. + const Linux = enum { Look, Tty9p, LocationsConfig }; + const FreeBSD = enum { Look, LocationsConfig }; + const S = struct { from: Linux, also: [2]Linux }; + const T = struct { from: FreeBSD, also: [2]FreeBSD }; + try std.testing.expectEqual(digest(S, &.{ .from = .LocationsConfig, .also = .{ .Look, .LocationsConfig } }), digest(T, &.{ .from = .LocationsConfig, .also = .{ .Look, .LocationsConfig } })); + try std.testing.expect(digest(S, &.{ .from = .Look, .also = .{ .Look, .Look } }) != digest(S, &.{ .from = .Tty9p, .also = .{ .Look, .Look } })); +} + test "a digest is of values: the same text at two addresses is one digest" { const S = struct { name: []const u8, n: u32, next: ?*const u32 }; const a = "same text"; diff --git a/test/cross_replay.py b/test/cross_replay.py index 26304d9a..6c5a1e4d 100644 --- a/test/cross_replay.py +++ b/test/cross_replay.py @@ -17,6 +17,11 @@ The session meets the host's failures, whose errors cross by name: a Look of a fifo (a read the host refuses) and of a directory, a stat and a read under /os over 9P, a Save into a file as if it were a directory and a Restore of a dump that is not there (errors the host reports, anyerrors). +And it holds what a digest must name the same in every build: a ++LocationsConfig, whose origin is a Builtin, and a file pane renamed (H19: +no Linux client could join a FreeBSD session so). ponytail: no Grep or +Find, which a 9P write runs on the loop, its reads no tape site (a replay +of it panics, by any build). """ import os import shutil @@ -70,12 +75,16 @@ def record(binary, out): started.append(int(status['pid'])) pane = next(int(row.split()[0]) for row in c.read('/index').splitlines() if row.split()[1] == b'text') for line in (f'Look {root / "fifo"}', f'Look {root / "dir"}', f'Save {root / "a.txt" / "x"}', - f'Restore {root / "nothing.dump"}'): + f'Restore {root / "nothing.dump"}', 'LocationsConfig'): try: c.write(f'/pane/{pane}/exec', line.encode() + b'\n') except Exception: pass # said as the write's error: a failure is what is wanted time.sleep(.3) + # A pane a word made (+LocationsConfig: its origin a Builtin, + # which a FreeBSD build numbers otherwise), and a file renamed. + c.write(f'/pane/{pane}/ctl', f'name {root / "renamed.txt"}\n'.encode()) + time.sleep(.3) c.stat(f'/os{root / "a.txt"}') assert c.read(f'/os{root / "a.txt"}') == b'hello\n' for _ in range(2): # the failed Save left the text edited: Exit asks again -- cgit v1.3 From b7dec1c3da59f23298eaccb2a5185ccf7a50a87a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 18:27:14 -0300 Subject: Stream: a search run on the loop (a 9P write's Grep or Find, which answers whether it found anything) is a tape site, `search`, its batches what the replay takes, as it takes a worker's (Event.search): its file reads were no site, so a replica of a session a script greps in read no file and joined again (`a syscall that is no tape site, made replaying`, a terminal client live, 2 of 2 before, none after); test/cross_replay.py's session greps and finds again Co-Authored-By: Claude Opus 5.5 --- src/Stream.zig | 25 +++++++++++++++++-------- src/tape.zig | 3 +++ test/cross_replay.py | 12 ++++++------ 3 files changed, 26 insertions(+), 14 deletions(-) (limited to 'test/cross_replay.py') diff --git a/src/Stream.zig b/src/Stream.zig index 665241df..263a6628 100644 --- a/src/Stream.zig +++ b/src/Stream.zig @@ -708,19 +708,28 @@ pub fn runHere(p: *Pardes, gen: u32) void { }; defer job.deinit(); job.waits = false; - var got: Collect = .{ .gpa = p.gpa }; - defer got.batches.deinit(p.gpa); - { - pardes.turn.yield(); - defer pardes.turn.back(); - work(std.Io.Threaded.global_single_threaded.io(), job, &got, Collect.take); - } - for (got.batches.items) |*b| { + // Its reads a site of the tape's (a 9P write's Grep or Find runs here): + // a replica takes the batches the session got, as it takes a worker's + // (Event.search), and reads no file. + const batches = pardes.tape.site(.search, p.gpa, searchHere, .{ p.gpa, job }); + defer p.gpa.free(batches); + for (batches) |*b| { receive(p, b); b.deinit(p.gpa); } } +/// The whole search, its batches gpa's. +fn searchHere(gpa: std.mem.Allocator, job: *Job) []Batch { + var got: Collect = .{ .gpa = gpa }; + work(std.Io.Threaded.global_single_threaded.io(), job, &got, Collect.take); + return got.batches.toOwnedSlice(gpa) catch { + for (got.batches.items) |b| b.deinit(gpa); + got.batches.deinit(gpa); + return &.{}; + }; +} + const Collect = struct { gpa: std.mem.Allocator, batches: std.ArrayList(Batch) = .empty, diff --git a/src/tape.zig b/src/tape.zig index e446c06a..9152bcb0 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -94,6 +94,8 @@ pub const Site = enum(u16) { kind, probe, preview, + /// A search run on the loop (Stream.runHere: a 9P write's Grep or Find). + search, // Read in place (`value`). clock, budget, @@ -132,6 +134,7 @@ pub const results = .{ anyerror![]u8, anyerror!void, terminal.Told, ?pardes.ctlfs.pty.Printed, @typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?, + []pardes.Stream.Batch, // What only the authority holds (`authority`): a closed pane's record, // Recent's entry for a closed jump, the closed panes' names. ?@import("Store.zig").Record, ?@import("recent.zig").Entry, diff --git a/test/cross_replay.py b/test/cross_replay.py index 6c5a1e4d..9ce7d152 100644 --- a/test/cross_replay.py +++ b/test/cross_replay.py @@ -17,11 +17,11 @@ The session meets the host's failures, whose errors cross by name: a Look of a fifo (a read the host refuses) and of a directory, a stat and a read under /os over 9P, a Save into a file as if it were a directory and a Restore of a dump that is not there (errors the host reports, anyerrors). -And it holds what a digest must name the same in every build: a -+LocationsConfig, whose origin is a Builtin, and a file pane renamed (H19: -no Linux client could join a FreeBSD session so). ponytail: no Grep or -Find, which a 9P write runs on the loop, its reads no tape site (a replay -of it panics, by any build). +It greps and finds, as a script does, which a 9P write runs on the loop: +its reads are a tape site (a replica of a session a script greps in read +no file and diverged). And it holds what a digest must name the same in +every build: a +LocationsConfig, whose origin is a Builtin, and a file +pane renamed (H19: no Linux client could join a FreeBSD session so). """ import os import shutil @@ -75,7 +75,7 @@ def record(binary, out): started.append(int(status['pid'])) pane = next(int(row.split()[0]) for row in c.read('/index').splitlines() if row.split()[1] == b'text') for line in (f'Look {root / "fifo"}', f'Look {root / "dir"}', f'Save {root / "a.txt" / "x"}', - f'Restore {root / "nothing.dump"}', 'LocationsConfig'): + f'Restore {root / "nothing.dump"}', 'Grep hello', 'Find txt', 'LocationsConfig'): try: c.write(f'/pane/{pane}/exec', line.encode() + b'\n') except Exception: -- cgit v1.3 From c07baa7bf83039600a54b261eaae7fdd4d673768 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 21:06:51 -0300 Subject: builtins: Tty9p is a word of every hosted build, not a Linux build's alone, so a build's words, the rows of its Help, are the same on FreeBSD: a Linux client of a box session made SPC ?'s +Help with one row more than its session's and joined again (`pane 4.file.content`, and `.splice` over a +Help made again: two of the box soak's three divergences); whether its host is Linux is the authority's answer (tape.authority), so a replica of a FreeBSD session refuses Tty9p as its session does; test/cross_replay.py's session runs Help (a FreeBSD tape replayed here diverged at its pane's content) Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 5 ++++- src/builtins_json.zig | 2 +- src/config.zig | 2 +- src/exec.zig | 10 ++++++++-- test/cross_replay.py | 7 ++++--- 5 files changed, 18 insertions(+), 8 deletions(-) (limited to 'test/cross_replay.py') diff --git a/src/builtins.zig b/src/builtins.zig index b101e34d..38a4d835 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1487,8 +1487,11 @@ pub const Tty = struct { }; /// A Linux terminal with the current session mounted through kernel v9fs. +/// A word of every hosted build, Linux's or not: a build's words are its +/// Help's rows, which a replica of another build's session makes as its +/// session did (a Linux client of a FreeBSD one diverged at SPC ?). pub const Tty9p = struct { - pub const enabled = pardes.hosted and @import("builtin").os.tag == .linux; + pub const enabled = pardes.hosted; pub fn run(c: Ctx) void { exec.spawnV9fsTty(c.p, c.id); } diff --git a/src/builtins_json.zig b/src/builtins_json.zig index 489f1e22..3402b2ee 100644 --- a/src/builtins_json.zig +++ b/src/builtins_json.zig @@ -74,7 +74,7 @@ pub fn write(w: *std.Io.Writer) !void { test "docs/typ/builtins-.json is what the registry says now" { // a terminal build checks its file, a window build its own; both are - // Linux builds' lists (Tty9p is Linux's) + // Linux builds' lists if (comptime @import("builtin").os.tag != .linux) return error.SkipZigTest; const file = switch (pardes.platform) { .tty => "builtins-tty.json", diff --git a/src/config.zig b/src/config.zig index ebca14ea..c1f1981c 100644 --- a/src/config.zig +++ b/src/config.zig @@ -2283,7 +2283,7 @@ const doc_typ = struct { for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p| if (std.mem.eql(u8, p, path[0..n])) return true; for (leader_args) |la| if (std.mem.eql(u8, la.path, path[0..n])) return true; - // A word this build leaves out (Tty9p off Linux) keeps its leader in the other's. + // A word this build leaves out keeps its leader in the other's. var buf: [96]u8 = undefined; const needle = std.fmt.bufPrint(&buf, "\"leader\": \"{s}\"", .{k}) catch return false; return std.mem.indexOf(u8, other_build, needle) != null; diff --git a/src/exec.zig b/src/exec.zig index c5218279..af312c45 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -409,14 +409,20 @@ pub fn spawnTty(p: *Pardes, from: usize) ?*Pane { } pub fn spawnV9fsTty(p: *Pardes, from: usize) void { - if (comptime !hosted or @import("builtin").os.tag != .linux) + if (comptime !hosted) return p.reportError(from, "Tty9p", error.LinuxRequired); + // The session's host's and its 9P server's: a replica, of another + // build too (a Linux client of a FreeBSD session), has their answers. + if (!pardes.tape.authority(onLinux, .{})) return p.reportError(from, "Tty9p", error.LinuxRequired); - // The 9P server's: a replica has the authority's answer. if (!pardes.tape.authority(servesSocket, .{p})) return p.reportError(from, "Tty9p", error.SessionSocketRequired); _ = spawnTtyWithMount(p, from, true); } +fn onLinux() bool { + return @import("builtin").os.tag == .linux; +} + fn servesSocket(p: *Pardes) bool { return p.fs.socket_path.len != 0; } diff --git a/test/cross_replay.py b/test/cross_replay.py index 9ce7d152..21367ca1 100644 --- a/test/cross_replay.py +++ b/test/cross_replay.py @@ -20,8 +20,9 @@ Restore of a dump that is not there (errors the host reports, anyerrors). It greps and finds, as a script does, which a 9P write runs on the loop: its reads are a tape site (a replica of a session a script greps in read no file and diverged). And it holds what a digest must name the same in -every build: a +LocationsConfig, whose origin is a Builtin, and a file -pane renamed (H19: no Linux client could join a FreeBSD session so). +every build: a +LocationsConfig, whose origin is a Builtin, a file +pane renamed (H19: no Linux client could join a FreeBSD session so), and +a +Help, which lists the build's words (Tty9p was a Linux build's alone). """ import os import shutil @@ -75,7 +76,7 @@ def record(binary, out): started.append(int(status['pid'])) pane = next(int(row.split()[0]) for row in c.read('/index').splitlines() if row.split()[1] == b'text') for line in (f'Look {root / "fifo"}', f'Look {root / "dir"}', f'Save {root / "a.txt" / "x"}', - f'Restore {root / "nothing.dump"}', 'Grep hello', 'Find txt', 'LocationsConfig'): + f'Restore {root / "nothing.dump"}', 'Grep hello', 'Find txt', 'LocationsConfig', 'Help'): try: c.write(f'/pane/{pane}/exec', line.encode() + b'\n') except Exception: -- cgit v1.3