summaryrefslogtreecommitdiff
path: root/src/tape.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 20:56:03 -0300
committerGabriel Schneider <[email protected]>2026-10-30 03:13:15 -0300
commitfdf74e199de7d0fc648f912875323f3dc920ffc2 (patch)
tree7e175c6fc9cb653200ff2abb7bcc5cf0fda3dc9f /src/tape.zig
parent57aa8d2f9ae851fa9806abbd1fd04abf1fd2b57f (diff)
downloadpardes-fdf74e199de7d0fc648f912875323f3dc920ffc2.tar.gz
pardes-fdf74e199de7d0fc648f912875323f3dc920ffc2.zip
replica clients over a socket: the session streams each its dump and every unit after it (replica.zig `Peers`, a writer and a reader thread a client, units at each step boundary, a client's input stepped there in its own view), and `pardes --attach=<socket>:<name>` and `--attach=<host>:<name>` (through `ssh -tt -L`) are a client in the tty host, its keys applied at once by its own replica and drawn by its own process
wire.zig version 15: welcome (the client's id and view, the dump's length, the session's UTC offset and digest), dump pieces, units (with the authority's clocks), terminal messages both ways, a check. A unit carries one digest, at its end (`unit_digests`). The client: tty.zig `Shell.remote`, `feed` (a terminal's input to the replica and the session); the session's clock guessed from the last unit's (tape.zig `Guess`); a pump woken only by a client's post reads no new time (`mail_only`), and a unit of another's ending where the last ended leaves the speculation as it is (`neutral`); the rollback copy taken while idle (`Replica.ready`); views a frontend here does not draw left undrawn. A lagging client never holds the session: its queue is cut off past 64 MiB (PARDES_REPLICA_LAG_KB). Detach in a client ends that client; a Restore lets every client go. daemon.zig: a replica the daemon hands over is the session's loop's (a note), not a stub thread's. A window session refuses one in words. test/daemon.py `--clients`: two clients (one through the delay relay) type into a detached session and agree with it, one killed outright, one detached, a third typing into a shell. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tape.zig')
-rw-r--r--src/tape.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tape.zig b/src/tape.zig
index c2ddbb9d..b30096f5 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -167,6 +167,9 @@ pub const Tape = struct {
/// output carries one, at the pty's read rate), not one a field; what
/// differs is then not named.
whole_digest: bool = false,
+ /// A digest only when asked (`recordDigest`): the replica stream's,
+ /// one a unit, not one after each of its inputs.
+ unit_digests: bool = false,
/// A replica client's guess of the session's clocks for a speculation
/// (src/replica.zig): its clock reads (a message's stamp, a file's
/// mtime) answer this instead of the clocks here.
@@ -275,7 +278,7 @@ pub const Tape = struct {
t.wrap(core);
};
t.record(.done, void, &{});
- if ((t.depth == 0 or t.every) and !t.no_digest) if (t.core) |core| {
+ if ((t.depth == 0 or t.every) and !t.no_digest and !t.unit_digests) if (t.core) |core| {
var parts: Parts = undefined;
const whole = [1]u64{digestOf(core)};
const d: []const u64 = if (t.whole_digest) &whole else digestParts(core, &parts);
@@ -802,6 +805,16 @@ fn guessed(comptime R: type, g: Guess) R {
@compileError("tape: no guess of a clock read as " ++ @typeName(R));
}
+/// The session's digest recorded now (a unit's end: the replica stream's
+/// one, `unit_digests`).
+pub fn recordDigest(t: *Tape) void {
+ const core = t.core orelse return;
+ var parts: Parts = undefined;
+ const whole = [1]u64{digestOf(core)};
+ const d: []const u64 = if (t.whole_digest) &whole else digestParts(core, &parts);
+ t.record(.digest, []const u64, &d);
+}
+
/// A core made outside the tape (a replica client's, from a dump) is the
/// one it replays into.
pub fn adoptCore(t: *Tape, p: *Pardes) void {