From 2fb0d38b1e233d8ccba0f185bc7c8acec94234e8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 19:31:57 -0300 Subject: replica: no digest is taken in a speculation: one over a terminal kept its digest to check its unit's against, and a blob born under the copy and digested there keeps its word past the epoch's free of it (src/walk.zig), so a later blob at that address read as it (the replicas harness, Debug, seed 11 at 207 ms: "not what its kept word was"; in a release build a divergence); a speculation over a terminal is confirmed by its records, as any other, its unit taken at once when more is applied on top Co-Authored-By: Claude Opus 5.5 --- src/replica.zig | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'src/replica.zig') diff --git a/src/replica.zig b/src/replica.zig index e483693a..439f71a2 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -537,9 +537,8 @@ pub const Stats = struct { }; /// `terminal`: its speculation read a terminal or moved one's view (or a -/// terminal had the keyboard), so what it did depends on the emulator, and -/// `digest` is the state it ended on: the same records are not enough. -const Pending = struct { seq: u32, msg: []u8, spec: ?[]u8 = null, sent_ns: u64 = 0, terminal: bool = false, digest: u64 = 0, guess: ?tape.Guess = null }; +/// terminal had the keyboard), so what it did depends on the emulator. +const Pending = struct { seq: u32, msg: []u8, spec: ?[]u8 = null, sent_ns: u64 = 0, terminal: bool = false, guess: ?tape.Guess = null }; /// A terminal's view as the authority's was once `after` of the units /// since the copy were taken (`Replica.since`): a delta's comes after the @@ -757,7 +756,7 @@ pub const Replica = struct { const was = Stepping.begin(&r.t, &r.epoch); defer was.end(); if (u.origin == r.id and r.pending.items.len > 0 and r.pending.items[0].seq == u.seq and r.applied > 0 and - tape.sameRecords(r.pending.items[0].spec.?, u.tape) and endsOn(r.pending.items[0], u.tape)) + tape.sameRecords(r.pending.items[0].spec.?, u.tape)) { r.stats.fast += 1; if (r.pending.items[0].terminal and r.applied > 1) { @@ -950,11 +949,9 @@ pub const Replica = struct { c.update(in.event); c.step(); p.terminal = r.t.screen_state and (keyboard or r.t.touched); - // A delta the authority's step read and this did not (one held - // back at the bound in flight) would leave the same records and - // another state: its digest says (no emulator's in it, only what - // pardes made of one). - if (p.terminal) p.digest = tape.digestOf(c); + // No digest is taken here: a blob born under the copy and digested + // keeps its word past the epoch's free of it (src/walk.zig), and a + // later blob at that address read as it. const clean = tape.endSpeculation(&r.t); const dt = nowNs() - t0; // Where a blob was written, should one be: the input that did. @@ -1169,25 +1166,6 @@ pub const Replica = struct { } }; -/// Whether a unit ends where speculation `p` did: always, but for one over -/// a terminal, whose digest must be the unit's last (a word, the stream's; -/// a unit of a traced session, a field a word, is taken on its records). -fn endsOn(p: Pending, unit: []const u8) bool { - if (!p.terminal) return true; - var r: walk.Reader = .{ .bytes = unit }; - var last: ?[]const u8 = null; - while (true) { - const head = r.take(5) catch break; - const payload = r.take(std.mem.bytesToValue(u32, head[1..5])) catch break; - if (head[0] == tape.digest_kind) last = payload; - } - var in: walk.Reader = .{ .bytes = last orelse return true }; - var room: [64]u8 = undefined; - var fixed: std.heap.FixedBufferAllocator = .init(&room); - const words = walk.decode([]const u64, &in, fixed.allocator()) catch return true; - return words.len != 1 or words[0] == p.digest; -} - /// The bytes of a unit's last digest record: the state it ended on; null /// for one that says what the host wrote or which host it is (a replica's /// core takes those only by replaying the unit). -- cgit v1.3