diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 03:03:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 03:03:55 -0300 |
| commit | 70c9e3fbf9cdc7139b4da0142f3a44741a7e1491 (patch) | |
| tree | 966bee71386ad820cb8b23a96ac0c09e5a0f0c1d | |
| parent | d56973aa92d0de6d84446dff73eba9d5654fe6f4 (diff) | |
| download | pardes-70c9e3fbf9cdc7139b4da0142f3a44741a7e1491.tar.gz pardes-70c9e3fbf9cdc7139b4da0142f3a44741a7e1491.zip | |
replica: no road to choose, and the wire at 30 (the old road's deletion, piece 4 of 8; the coordinator's decision: the welcome's road byte goes, no dead field stays on the wire): `Peers.bytes` (set by runtime/session.zig unless PARDES_TERM_SCREEN), the welcome's `bytes` byte (abi/wire.zig: its encode, its decode, the round-trip test's byte), `Joined.bytes` and `joinOn`'s copy of it, `road` (fromDump's, ownBoot's, confirmBoot's, a test's: a replica's `made` arms its echo already, and no replica starts on screen state since piece 3), and ownBoot's read of PARDES_TERM_SCREEN; so PARDES_TERM_SCREEN and PARDES_TERM_BYTES name nothing in the tree; abi/wire.zig's version is 30, its history line saying both of this line's wire changes (the screen messages retired as gaps in piece 3, the welcome's byte here); test/daemon.py's `WIRE` 30; firstOnPair's argument is now what it chose, `by_dump` (a client joined by the session's dump, or one that makes its own core); core/root.zig `machine_lines` for replica.zig 74 -> 73; core-test 911/1068 (157 skipped), shell-test 1110/1113
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | abi/wire.zig | 14 | ||||
| -rw-r--r-- | core/replica.zig | 53 | ||||
| -rw-r--r-- | core/root.zig | 2 | ||||
| -rw-r--r-- | runtime/session.zig | 6 | ||||
| -rw-r--r-- | test/daemon.py | 2 | ||||
| -rw-r--r-- | test/replicas.zig | 1 |
6 files changed, 24 insertions, 54 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index ab974e35..48b3ae51 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,9 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 30: the terminals' one road: the screen-state messages are retired (a +/// replica's `screen_ack`, 0x04, and the session's `screen`, 0x06: gaps) +/// and a welcome says no road (its `bytes` byte gone); /// 29: a session's terminals reach its clients as the pty's bytes in its /// units, each client's emulator its own; a welcome says the road (`bytes`; /// screen state under PARDES_TERM_SCREEN), which the client loads its dump @@ -54,7 +57,7 @@ const build_info = @import("build_info"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 29; +pub const version: u16 = 30; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { @@ -221,7 +224,7 @@ pub const ServerMsg = union(ServerTag) { /// dump that follows is, and the session's offset from UTC (a replica /// guesses the session's time of day). A far client is told how many /// blobs the dump holds (`blobs`). - welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, bytes: bool = false, blobs: u32 = 0 }, + welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, blobs: u32 = 0 }, refused: []const u8, pong: u64, dump: []const u8, @@ -256,7 +259,6 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg { .gmtoff = try r.takeInt(i32, .little), .digest = try r.takeInt(u64, .little), .semantics = try r.takeInt(u64, .little), - .bytes = try r.takeByte() != 0, .blobs = try r.takeInt(u32, .little), } }, .refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) }, @@ -287,7 +289,6 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { try w.writeInt(i32, h.gmtoff, .little); try w.writeInt(u64, h.digest, .little); try w.writeInt(u64, h.semantics, .little); - try w.writeByte(@intFromBool(h.bytes)); try w.writeInt(u32, h.blobs, .little); }, .refused => |words| try putSlice16(&w, words), @@ -729,14 +730,13 @@ test "detached wire: every Event variant round-trips" { try testing.expectEqual(@as(u64, 0xfeed_beef_0000_0001), (try roundClient(&buf, .{ .ping = 0xfeed_beef_0000_0001 })).ping); { // The other way: framed the same, its tag the ServerTag's number. - const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work", .bytes = true } }); + const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work" } }); const f = (try framed(bytes)).?; try testing.expectEqual(@as(u8, 0x01), f.tag); - try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, f.payload); + try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f.payload); const back = (try decodeServer(f.tag, f.payload)).welcome; try testing.expectEqualStrings("work", back.session); try testing.expectEqual(@as(u32, 42), back.pid); - try testing.expect(back.bytes); try testing.expectEqual(@as(u8, 0x03), (try framed(try encodeServer(&buf, .{ .pong = 7 }))).?.tag); } diff --git a/core/replica.zig b/core/replica.zig index 3f897044..55e7a1f7 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -1789,11 +1789,6 @@ pub const Peers = struct { /// writer would write (its join, then `out`) and its reader read /// (`Peer.take`, then `.gone` posted) are its driver's to do. threads: bool = true, - /// Its clients' terminals cross as the pty's bytes in its units, each - /// client's emulator its own (P29, P32), not as screen state: every - /// session's (runtime/session.zig) but under PARDES_TERM_SCREEN, the - /// soak's `--bytes`; its welcome says so to each client. - bytes: bool = false, pub const Note = union(enum) { join: Joining, input: Msg, gone: *Peer, check: *Peer, joined: *Peer }; /// A connection to join, and the view it joins again for, if it does. @@ -1992,7 +1987,7 @@ pub const Peers = struct { // (a pair's client, its own boot: `writeJoin`). const digest = tape.digestOf(core); peer.digest = digest; - peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len), .bytes = ps.bytes } }) catch unreachable).len; + peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; if (ps.threads) peer.writer = std.Thread.spawn(.{}, Peer.writeLoop, .{peer}) catch null; if (ps.threads) peer.reader = std.Thread.spawn(.{}, Peer.readLoop, .{peer}) catch null; if (ps.threads and (peer.writer == null or peer.reader == null)) { @@ -2316,9 +2311,6 @@ pub const Joined = struct { /// Its replica is its own boot, the welcome not read yet (`ownBoot`, /// `confirmBoot`). booted: bool = false, - /// Its session's terminals come as the pty's bytes, not screen state - /// (the welcome's word, Peers.bytes). - bytes: bool = false, }; /// A blob a far join was sent: where it is in the dump, and its hash. @@ -2399,7 +2391,6 @@ fn joinOn(gpa: Allocator, fd: c_int, session: ?[]const u8, why: []u8, have: ?*Ha r.j.gmtoff = w.gmtoff; r.j.digest = w.digest; r.j.semantics = w.semantics; - r.j.bytes = w.bytes; if (r.boot == w.digest) { r.done = true; return false; @@ -2803,16 +2794,14 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o return fromDump(gpa, j, o, have, why, t0); } -/// The replica of the dump `j` brought, on the road its welcome says, its -/// load checked by the session's digest, and what it takes of `j`; null, -/// and why in `why`, when it does not load as the session. +/// The replica of the dump `j` brought, its load checked by the session's +/// digest (its emulators' among it), and what it takes of `j`; null, and +/// why in `why`, when it does not load as the session. fn fromDump(gpa: Allocator, j: *Joined, o: pardes.Options, have: ?*Have, why: []u8, t0: u64) ?*Replica { const r = Replica.initDump(gpa, j.client, j.view, j.dump, o) catch |err| { _ = std.fmt.bufPrint(why, "the session's dump would not load: {t}\x00", .{err}) catch {}; return null; }; - // Before the check: on the bytes road the digest covers its emulators. - road(r, j.bytes); if (!r.loaded(j.digest)) { r.deinit(); _ = std.fmt.bufPrint(why, "the session's dump loaded as another session (a build's dump is not complete)\x00", .{}) catch {}; @@ -2822,14 +2811,6 @@ fn fromDump(gpa: Allocator, j: *Joined, o: pardes.Options, have: ?*Have, why: [] return r; } -/// Its terminals its own emulators, fed the pty's bytes its units carry -/// (`bytes`, its session's Peers.bytes), or the session's screen state; -/// its echo predicted on either (core/echo.zig). -fn road(r: *Replica, bytes: bool) void { - r.t.screen_state = !bytes; - r.core().echo = &r.echo; -} - /// What a replica joined by `j` takes of it, and of the environment. fn takeJoined(r: *Replica, j: *Joined, have: ?*Have, t0: u64) void { // PARDES_NO_ECHO: no predicted echo (the gates' baseline). @@ -2867,10 +2848,7 @@ fn ownBoot(gpa: Allocator, j: *Joined, fd: c_int, o: pardes.Options, why: *[600] _ = std.fmt.bufPrint(why, "the session hung up\x00", .{}) catch {}; return null; } - // Its session is this process's child, on the road this environment - // says (runtime/session.zig): the welcome says it again. - j.* = .{ .fd = fd, .pid = 0, .client = r.id, .view = r.view, .gmtoff = gmtoff(), .dump = &.{}, .digest = digest, .semantics = wire.semantics, .booted = true, .bytes = std.c.getenv("PARDES_TERM_SCREEN") == null }; - road(r, j.bytes); + j.* = .{ .fd = fd, .pid = 0, .client = r.id, .view = r.view, .gmtoff = gmtoff(), .dump = &.{}, .digest = digest, .semantics = wire.semantics, .booted = true }; takeJoined(r, j, null, t0); return r; } @@ -2889,7 +2867,6 @@ pub fn confirmBoot(gpa: Allocator, j: *Joined, r: *Replica, o: pardes.Options, w if (j.dump.len == 0) { r.id = j.client; r.view = j.view; - road(r, j.bytes); return r; } defer { @@ -4230,9 +4207,10 @@ fn ownBootAgainst(edited: bool) !void { /// A session's first client on a socket pair (runtime/session.zig's, then /// the client's first join on its end), the session's first effects after: /// its boot shell spawned, its first bytes output; the client quiet and -/// checked. Bytes: the client loaded as the soak's bytes clients are -/// (`replica.join` loads the screen-state kind until the switch). -fn firstOnPair(bytes: bool) !void { +/// checked. `by_dump`: the client joined by the session's dump, as any +/// client loads one (`fromDump`); else it makes its own core (Options.pair, +/// `confirmBoot`). +fn firstOnPair(by_dump: bool) !void { if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const gpa = std.testing.allocator; const Spawns = struct { @@ -4249,7 +4227,7 @@ fn firstOnPair(bytes: bool) !void { const core = try Pardes.init(gpa, opts); defer core.deinit(); core.host = .{ .ctx = &spawns, .vtable = &Spawns.vtable }; - var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .name = "pair", .bytes = true, .detached = true }; + var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .name = "pair", .detached = true }; defer ps.deinit(); defer live_peers = null; defer ps.dropAll(core); @@ -4257,12 +4235,10 @@ fn firstOnPair(bytes: bool) !void { ps.join(core, .{ .fd = fds[0], .own = true }); var j: Joined = undefined; var why: [600]u8 = @splat(0); - const r = if (bytes) r: { - // Joined by its dump as any client loads one (`fromDump`): the - // welcome says the road, and its load is checked on it. + const r = if (by_dump) r: { + // Joined by its dump as any client loads one (`fromDump`). j = joinOn(gpa, fds[1], null, &why, null, null, null) orelse return error.JoinFailed; defer gpa.free(j.dump); - try std.testing.expect(j.bytes); break :r fromDump(gpa, &j, opts, null, &why, nowNs()) orelse { std.debug.print("the join: {s}\n", .{std.mem.sliceTo(&why, 0)}); return error.JoinFailed; @@ -4333,7 +4309,7 @@ fn firstOnPair(bytes: bool) !void { defer arena.deinit(); const rows = try pardes.Term.viewport(r.core().panes[shell].?.terminal.?, arena.allocator(), false); try std.testing.expect(std.mem.indexOf(u8, rows[0], "first$") != null); - if (!bytes) return; + if (!by_dump) return; // One that comes after the shell's bytes: every side reloads. var late: [2]c_int = undefined; if (libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &late) != 0) return error.NoSocket; @@ -5767,7 +5743,7 @@ test "a step of the session's own that reads a terminal right after its output, core.view().active = shell; // The session as runtime/session.zig runs it; the client's link in // memory. - var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .threads = false, .bytes = true }; + var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .threads = false }; defer ps.deinit(); defer ps.dropAll(core); var fds: [2]c_int = undefined; @@ -5795,7 +5771,6 @@ test "a step of the session's own that reads a terminal right after its output, try whole.appendSlice(gpa, peer.dump[pos..]); const r = try Replica.initDump(gpa, w.client, w.view.index(), whole.items, .{ .cols = 80, .rows = 24, .boot = .tty }); defer r.deinit(); - road(r, w.bytes); try std.testing.expect(r.loaded(w.digest)); var link: Link = .{ .r = r, .fd = fds[1] }; defer link.deinit(gpa); diff --git a/core/root.zig b/core/root.zig index 66630b2d..171bdfef 100644 --- a/core/root.zig +++ b/core/root.zig @@ -632,7 +632,7 @@ const machine_lines = [_]struct { []const u8, usize, []const u8 }{ .{ "jj.zig", 11, "jj run under tape.site(.jj) on an io of its own (the tape's spawns nothing) with this process's environment, the signal mask cleared as Stream's children's: the session's, a replica replays its answer; or on a worker for `Changes`, its answer an input, with the wall clock it was made at (tape.value(.clock) on the loop) for its descriptions' ages; a test's shell inbox (dev)" }, .{ "look.zig", 6, "openLink's fork (the host's: a view's frontend opens a link) and a remote's error name" }, .{ "memory.zig", 7, "the memory regions themselves (mmap, madvise, their locks)" }, - .{ "replica.zig", 74, "the client and session engines: sockets, threads, clocks, the blob cache, traces" }, + .{ "replica.zig", 73, "the client and session engines: sockets, threads, clocks, the blob cache, traces" }, .{ "rollback.zig", 1, "a test helper's directory" }, .{ "root.zig", 4, "dev's modules re-exported (host_io, file_watch, glide, fonts)" }, .{ "selection_pipe.zig", 14, "a pipe's child processes and their files: the host's `pipe` entry" }, diff --git a/runtime/session.zig b/runtime/session.zig index 9499da9c..75e8efcc 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -86,11 +86,7 @@ pub fn Loop(comptime Frontend: type) type { defer l.prompt_rcs.deinit(); l.fs = ninep_io.start(l.io, l.gpa, l.core); defer if (l.fs) |f| f.deinit(l.gpa); - // Its clients' terminals by the pty's bytes (Peers.bytes), each - // client's emulator its own; PARDES_TERM_SCREEN (a working name, - // the way back until the screen state's road is deleted): as - // screen state. Its welcome tells each client which. - l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name(), .bytes = std.c.getenv("PARDES_TERM_SCREEN") == null }; + l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name() }; l.inbox = .{ .io = l.io, .gpa = l.gpa, .lsp_allocator = l.allocs.lsp }; defer l.inbox.deinit(); // A search's worker may be waiting on the queue for room. diff --git a/test/daemon.py b/test/daemon.py index 3a481c00..c5c39be3 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -257,7 +257,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 29 + WIRE = 30 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout diff --git a/test/replicas.zig b/test/replicas.zig index 46eff641..aa10d4a9 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -1296,7 +1296,6 @@ const Soak = struct { pub fn open(s: *Soak, l: *SessionLoop) !pardes.Host { s.l = l; l.peers.threads = false; - l.peers.bytes = true; const host: pardes.Host = .{ .ctx = s, .vtable = &vtable }; l.core.host = host; return host; |
