diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 00:05:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 00:40:36 -0300 |
| commit | a3d98f0e465ed9634d0534e0a6c71767b2a709b9 (patch) | |
| tree | d8f777c00b13490c245ee7c93aa2a932c406173a /abi | |
| parent | e6dd9c5c3a60e3609e99ab2076b5a2509a014a66 (diff) | |
| download | pardes-a3d98f0e465ed9634d0534e0a6c71767b2a709b9.tar.gz pardes-a3d98f0e465ed9634d0534e0a6c71767b2a709b9.zip | |
link: a client whose link is up and must take the session's state again (it diverged, fell 2 s behind, or the session cut it off 64 MB behind) comes back OVER THAT LINK, the daemon not asked: its goodbye that says `again` and today's hello for its view in one write (`replica.comeBack`, runtime/client.zig `Loop.run` when `Link.backHere`), its reader letting the stream it leaves go (units, blobs and checks not even copied) and stopping at the session's welcome there, put back at its framer's front for the join's reader (`readLink`'s back mode, `Framer.putBack`), the join read on that framer (`joinOn` takes it; `replica.join`'s `here`); on the session the reader reads on after a `bye` that says `again`, a hello after it is the same client back (`Peer.take`, inputs numbered afresh), and `Peers.joinAgain` dumps for it there with what the old road put on the tape (`awayView`, then the join's `viewFor`: every side's terminals reloaded in that step), what was queued for it let go, the cut over; one writer loop writes a join whenever one is due (`Peer.gen`, `Peer.written`; the `.joined` note carries its gen so a stale one releases nothing), what it was sent a MiB at most a write at a message's end (`writeOut`) so a join due waits for no more of the old stream, a far client's old zstd frame ended before the welcome; a cut keeps the link (its words, then nothing until the hello); a link that ends before the welcome (an Upgrade's or a Restore's words: the session closes it), or one gone, is dialled again as before: the one case left for a redial; and a client refused its own load (`fromDump`) asks ONCE more over the same link with the session's digest a word a field after that dump (wire 31, nothing at 31 installed: a bye's byte 3 = `again` + `parts`, a new ServerTag `parts` 0x0d) and only then gives up, naming the fields that differ in its words and its log; the failing run first: test/daemon.py's new `pair_back` (a no-daemon pair whose client diverges, and one stopped 3 s while the session is edited) on the installed build 79b73e14711e: "the client and the session went (client exit 1)", "'diverged' let this client go", on this tree both join again over their own link, the session alive, the unsaved text there, agreed; `clients`: client D's socket the same across its rejoin, the session counting 6 joins, 1 over a client's own link and 5 handed by the daemon; `far_flood` (20 KB/s, 200 ms): the same link after 3 joins again of 0.56 s each against a dial each time on the installed build (0.99 s each), but agreement 68.6 s after `yes` ended against 22.7 s: the client reads through what the relay holds for it (the relay buffers without bound; ssh bounds it by its window), said in reports/pardes-link-lifecycle.md; `Peer.rejoin` and `hungUp` stay for the one road that still dials after a goodbye saying `again` (a client of another build exec'ing: `sameBuild`), their test rewritten for it; core tests at the replica's surface with real link threads (near and far: back over its own link; a refused load asked once more and loaded; refused twice and named, against a session played by hand; a cut client back over its link, the same peer, connection and view); the soak models the road (`ended`, `Soak.joinDown`, the `here` column); core-test 924/1084 (160 skipped), shell-test 1126/1129 (3 skipped), root.zig's machine_lines for replica.zig 76 -> 90 (the tests' sockets and sleeps; the session's one shutdown of a link it will not dump for again, and a close)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'abi')
| -rw-r--r-- | abi/wire.zig | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index 55a08909..31b3310d 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -12,7 +12,11 @@ const build_info = @import("build_info"); /// 31: where a view stands in a terminal's history is the view's: a pane's /// `scrolled_to` (and its share's in each view) in the dump and the digest, -/// the emulator's own view out of both (its `Parts.view` gone); +/// the emulator's own view out of both (its `Parts.view` gone); a client +/// whose link is up joins again over it (its bye's `again`, then its hello +/// there: core/replica.zig `Peers.joinAgain`), and one whose load was +/// refused asks once more so, the session's digest a word a field after +/// that dump (a bye's 3, `parts`); /// 30: the terminals' one road: the screen-state messages are retired (a /// replica's `screen_ack`, 0x04, and the session's `screen`, 0x06: gaps), /// a welcome says no road (its `bytes` byte gone), and a pane's @@ -224,6 +228,10 @@ pub const ServerTag = enum(u8) { ended = 0x0b, /// ...or this client left it running (a Detach typed in it): its name. left = 0x0c, + /// The session's digest a word a field at a join's dump (tape.zig + /// `digestParts`), u64le each, after that dump, to a client whose bye + /// asked (`parts`): its load refused once, it names what differs. + parts = 0x0d, }; pub const ServerMsg = union(ServerTag) { @@ -242,6 +250,7 @@ pub const ServerMsg = union(ServerTag) { blob: []const u8, ended: u8, left: []const u8, + parts: []const u8, }; /// A message's header, for a payload sent on its own (a unit, a dump's @@ -271,6 +280,7 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg { .refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) }, .pong => .{ .pong = try r.takeInt(u64, .little) }, .dump => return .{ .dump = payload }, + .parts => return .{ .parts = payload }, .unit => return .{ .unit = payload }, .check => .{ .check = try r.takeInt(u64, .little) }, .blobs => return .{ .blobs = payload }, @@ -300,7 +310,7 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { }, .refused => |words| try putSlice16(&w, words), .pong => |v| try w.writeInt(u64, v, .little), - .dump, .unit, .blobs, .zstd, .blob => |bytes| try w.writeAll(bytes), + .dump, .unit, .blobs, .zstd, .blob, .parts => |bytes| try w.writeAll(bytes), .check => |v| try w.writeInt(u64, v, .little), .ended => |code| try w.writeByte(code), .left => |name| try putSlice16(&w, name), @@ -322,9 +332,12 @@ pub fn helloVersion(payload: []const u8) Error!u16 { /// one call and no longer. pub const ClientMsg = union(enum) { hello: Hello, - /// The client's end: `again`, it joins again for its view at once; - /// `close`, its window was closed (a pair's session ends at its last). - bye: struct { again: bool = false, close: bool = false }, + /// The client's end: `again`, it joins again for its view at once (its + /// hello next, on this link while it is up); `close`, its window was + /// closed (a pair's session ends at its last); `parts`, with `again`: + /// its last load was refused, the session's digest a word a field after + /// the next dump (`ServerTag.parts`). + bye: struct { again: bool = false, close: bool = false, parts: bool = false }, /// A round trip's probe, answered `pong` with the same value. ping: u64, check, @@ -541,8 +554,9 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { try putSlice16(&w, h.session); try w.writeByte(h.view orelse 0xff); }, - // 0 it leaves, 1 it joins again, 2 its window was closed. - .bye => |b| try w.writeByte(if (b.close) 2 else @intFromBool(b.again)), + // 0 it leaves, 1 it joins again, 2 its window was closed, 3 it + // joins again and asks the session's digest a word a field. + .bye => |b| try w.writeByte(if (b.close) 2 else if (b.parts) 3 else @intFromBool(b.again)), .ping, .boot => |v| try w.writeInt(u64, v, .little), .want => |bytes| try w.writeAll(bytes), .check => {}, @@ -616,6 +630,7 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg { 0 => .{}, 1 => .{ .again = true }, 2 => .{ .close = true }, + 3 => .{ .again = true, .parts = true }, else => return error.BadValue, } }, .ping => .{ .ping = try r.takeInt(u64, .little) }, |
