summaryrefslogtreecommitdiff
path: root/core/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 03:43:55 -0300
committerGabriel Schneider <[email protected]>2026-11-23 03:43:55 -0300
commit4faf94b72b60ecb0656e7e90ca693b63b1fde71c (patch)
treed5f23e93b7f19ed373e1c644c8ae3f364d30d84d /core/dump.zig
parent1ebae0db0a185455b2a03f22f5106113c6407a2f (diff)
parentaac453a5bf4730405cdeac4b42bffbcd24d73947 (diff)
downloadpardes-4faf94b72b60ecb0656e7e90ca693b63b1fde71c.tar.gz
pardes-4faf94b72b60ecb0656e7e90ca693b63b1fde71c.zip
integration (a base for the next rounds, not yet the gathered line): a join's dump with its digest on the one decision: pardes-m62-base (`lkzwnmls`: pardes-merge60 + pardes-one-decision) and pardes-dump-digest (`rwmqumpw` on `oyournly` on `ollusskr` on `xsutplvu`, on pardes-m60-base: a join's digest is taken with its dump (`dumpJoin`), which makes no host call: a 9P request served in a dump's gap no longer leaves a client refused its own load; the hand-walked types listed with the tests that join over each; a refused load names its field); no conflict; core-test 924/1088 (164 skipped), shell-test 1130/1133 (2026-11-23)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/dump.zig')
-rw-r--r--core/dump.zig50
1 files changed, 43 insertions, 7 deletions
diff --git a/core/dump.zig b/core/dump.zig
index 5fd933b9..d09f18c2 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -259,13 +259,43 @@ pub fn image(p: *Pardes, name: []const u8) ![]u8 {
/// out and noted in `deferred` (they are the session's, alive while pinned:
/// memory.zig `pin`), each terminal whole (as the join's step reloaded it
/// on every side: panes.reloadTerminals), its sequence in flight with it.
-/// What is left is the session's mutable state, made in its step.
-pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) ![]u8 {
+/// What is left is the session's mutable state, made in its step. With it
+/// the session's digest at that moment, which the client checks its load
+/// by, and after it that digest a field at a time (`joinParts`), which
+/// names what a load that is not the session has otherwise.
+///
+/// One moment: nothing in it gives up the turn (pardes.turn: a host call
+/// does, tape.out), or a 9P request answered meanwhile is in the dump and
+/// in the client's next unit both, and moves the core between the dump and
+/// the digest: the client then refused its own load and went (a script
+/// reading /screen at a rejoin, 2026-11-22). So a join's dump asks the host
+/// nothing (`on_disk`, a revival's, is none in it).
+pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) !struct { bytes: []u8, digest: u64 } {
// The join's file reads are the session's host's, between its steps:
// with its io, which the core's tape holds (a walk's hook takes no more).
join_files = p.tape.io;
defer join_files = null;
- return dumpWith(p, deferred);
+ const yields = pardes.turn.yields;
+ const bytes = try dumpWith(p, deferred);
+ errdefer p.gpa.free(bytes);
+ if (pardes.turn.yields != yields) return error.TurnGivenUp;
+ return .{ .bytes = bytes, .digest = pardes.tape.digestOf(p) };
+}
+
+/// What a join's dump ends with: the session's digest a field at a time
+/// (tape.digestParts), their count, this word.
+const parts_word = "parts\x00\x00\x01";
+
+/// The session's digest a field at a time that a join's dump `bytes` ends
+/// with, in `gpa`; null for a dump with none.
+pub fn joinParts(gpa: std.mem.Allocator, bytes: []const u8) ?[]u64 {
+ const tail = parts_word.len + 8;
+ if (bytes.len < tail or !std.mem.endsWith(u8, bytes, parts_word)) return null;
+ const n = std.mem.bytesToValue(u64, bytes[bytes.len - tail ..][0..8]);
+ if (n > (bytes.len - tail) / 8) return null;
+ const out = gpa.alloc(u64, @intCast(n)) catch return null;
+ @memcpy(std.mem.sliceAsBytes(out), bytes[bytes.len - tail - out.len * 8 ..][0 .. out.len * 8]);
+ return out;
}
/// `dumpExit`'s: a terminal dumps its size, not its emulator.
@@ -281,10 +311,9 @@ fn dumpWith(p: *Pardes, deferred: ?*std.ArrayListUnmanaged(walk.Deferred)) ![]u8
try d.put(Pardes, p);
const mounts: []const filesystem.Mount = p.fs.mounts.items;
try d.put([]const filesystem.Mount, &mounts);
- var on_disk: OnDisk = @splat(false);
- for (p.panes, &on_disk) |slot, *on| if (slot) |pane| {
- on.* = onDisk(p.tape, pane);
- };
+ // Which files were on disk is a revival's (`image`): a client's load
+ // never reads it, and a join asks the host nothing.
+ const on_disk: OnDisk = @splat(false);
try d.put(OnDisk, &on_disk);
const theme: []const u8 = colors.themes[@min(p.settings.theme, colors.themes.len - 1)].name;
try d.put([]const u8, &theme);
@@ -295,6 +324,13 @@ fn dumpWith(p: *Pardes, deferred: ?*std.ArrayListUnmanaged(walk.Deferred)) ![]u8
}
const kept: []const views.Shares = others;
try d.put([]const views.Shares, &kept);
+ const parts = try p.gpa.create(pardes.tape.Parts);
+ defer p.gpa.destroy(parts);
+ const each = pardes.tape.digestParts(p, parts);
+ const w = &d.out.writer;
+ try w.writeAll(std.mem.sliceAsBytes(each));
+ try w.writeAll(std.mem.asBytes(&@as(u64, each.len)));
+ try w.writeAll(parts_word);
return d.finish();
}