summaryrefslogtreecommitdiff
path: root/src/detached/wire.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 02:01:30 -0300
committerGabriel Schneider <[email protected]>2026-10-30 03:13:15 -0300
commitf8a56c962d5103b84453d4305cd27973a71d4aa3 (patch)
tree95da95264b53fab6637808bd62410f7740b2880c /src/detached/wire.zig
parent6118ad214bb74744e7b38004b34e4487a6635be1 (diff)
downloadpardes-f8a56c962d5103b84453d4305cd27973a71d4aa3.tar.gz
pardes-f8a56c962d5103b84453d4305cd27973a71d4aa3.zip
replica clients join again: one that diverged (a digest the session's unit did not end on) and one the session let go to upgrade dial it again, the same join as the first, and say why in a line over their frame until a key; a client of another build is told "session upgraded to a newer pardes: upgrade this client too"
tty.zig `remote` is a loop of joins over one terminal: the link ended, its reader joined, the replica let go, the session dialled again (an upgrade's exec and load, and its daemon's, retried for 20 s), its dump loaded, its view's size sent again. `Remote.notify` draws the line (`noticeLine`, the client's own, never the session's core). The welcome carries the session's semantics: the daemon judged the hello by the hash it last heard, which an upgrade under way may not have said yet. replica.zig `Peers.refuseAll`: before an Upgrade's dump each client is sent `refused` after what it was sent (up to 200 ms) and let go, its view with it. "A newer pardes is installed" is a Host call (`newer_build`) the core makes in its focus step, so replica clients take the line from the tape; the GUI still says it itself. PARDES_TEST_DIVERGE=<n> puts a client's core off the session's once quiet after its n-th unit. test/daemon.py: the clients test has one rejoin and agree; the upgrade test has a client of the old build told to upgrade and one of the build running join again and agree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/detached/wire.zig')
-rw-r--r--src/detached/wire.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index 347d45d1..78f6e76e 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -134,7 +134,7 @@ pub const ServerMsg = union(ServerTag) {
/// Who the client is now (its id and view in the session), how long the
/// dump that follows is, and the session's offset from UTC (a replica
/// guesses the session's time of day).
- welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: u8 = 0, dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0 },
+ welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: u8 = 0, dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0 },
refused: []const u8,
pong: u64,
dump: []const u8,
@@ -164,6 +164,7 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg {
.dump_len = try r.takeInt(u64, .little),
.gmtoff = try r.takeInt(i32, .little),
.digest = try r.takeInt(u64, .little),
+ .semantics = try r.takeInt(u64, .little),
} },
.refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) },
.pong => .{ .pong = try r.takeInt(u64, .little) },
@@ -188,6 +189,7 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 {
try w.writeInt(u64, h.dump_len, .little);
try w.writeInt(i32, h.gmtoff, .little);
try w.writeInt(u64, h.digest, .little);
+ try w.writeInt(u64, h.semantics, .little);
},
.refused => |words| try putSlice16(&w, words),
.pong => |v| try w.writeInt(u64, v, .little),
@@ -620,7 +622,7 @@ test "detached wire: every Event variant round-trips" {
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 }, 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 }, 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);