diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 23:56:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 03:37:59 -0300 |
| commit | 961e4cc938615de45294c78d42792706376c577e (patch) | |
| tree | 220a2d8e2b00059ecd9d45c01358cc88ba610505 /core/dump.zig | |
| parent | f52b6256927431e90af58af2f91eaac7e9799bf5 (diff) | |
| download | pardes-961e4cc938615de45294c78d42792706376c577e.tar.gz pardes-961e4cc938615de45294c78d42792706376c577e.zip | |
walk, dump, replica: a field's dump and its digest cannot disagree unseen: what one walk cannot hold is listed and tested, and a client refused its own load names the field: the copy, the digest and the dump of the core already come from one walk with one declaration a struct (core/walk.zig `replica`: local, derived and authority fields in none of the three, every other in all three), so a field cannot be in the digest and out of the dump; what escapes that walk is a type that walks itself by hand, a `digest` or a dump of its own (eight reach the core: fs.Namespace, tree.Open.What, the pane's 9P state, Term.State, Kind.Slot, locations.Row, jj.Session, File.Layers), and the moment the two are taken at (the previous change); `walk.handWalked(roots)` lists at comptime every type the walk reaches that walks itself by hand, and replica.zig's `hand_walked` names, for each, the test that joins a client from a dump of a session holding it and checks the load by the welcome's digest: the test of that name fails for a type that walks itself by hand with no line (dropping File.Layers' line: "File.Layers walks itself by hand and no test joins a client over it") and for a line whose type no longer does; jj.Session and File.Layers had none (their tests replay a client from the start): `loadsAsSession` (any test's session, a client joined from its dump, the fields named) ends the jj test that replays Changes, its pins and lanes crossing a join whole; and a join's dump ends with the session's digest a field at a time (tape.digestParts, after the walk with nothing between; `dump.joinParts` reads it; the loader reads its roots and stops before it), so a client whose load is not the session says which field in its words and its log (`fromDump`: "the session's dump loaded as another session: fs differs", a warning line `client N: ...`), the diagnostic build's naming kept in the product, tested by a dump made before a 9P open checked by the digest after it; what this cannot hold: a hand walk's body (the list makes it seen and tested, a reviewer reads the walk), a load's own changes after it reads (Replica.made, loadKnowing's fixups: the roundtrip tests catch them only for the state the tests build), a host call in the join's dump on a road no test session reaches (`error.TurnGivenUp` refuses that join in words), and the dump of a type a test session never holds; its gate (this tree, .scratch/sketch/reorg/pardes-dump-digest/g1, loads 0.6-13.5): IN THE WORKSPACE core-test 922/1082 (160 skipped), shell-test 1124/1127 (3 skipped), each the base's plus the five new tests, addon-test 5/5, term-test 17/17, kitty-test 45/45, process-test 0 of 146 failed, pane-test 182/183, behaviour-test and --replay 275/275, consumer-test; the soak --clients 5 three times: diverged 0, unequal 0, unlisted 0 at 30/80/207 ms, quiet checks all agreeing, the corpus 22 of 22, no leak; daemon.py on Debug and ReleaseSafe: plain 3/3, --clients 3/3, --far, --restore; --upgrade from the installed build (wire 30) 3/3, --upgrade --gui 3/3, between the tree's own builds 3/3 each way; cross-builds 3/3; the frame and perf gate against tree4: 77/77 frames, perfab corpus2x -0.009% (noise 0.021%), 121 counts within 0.1% (largest terminal on all +0.0786%; no key's path changed, no field left the digest); the one-CPU upgrade rows: every run past the rejoin step fault D failed, 28 of 30 whole (the next change)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/core/dump.zig b/core/dump.zig index 82098449..547f9f7d 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -261,7 +261,8 @@ pub fn image(p: *Pardes, name: []const u8) ![]u8 { /// on every side: panes.reloadTerminals), its sequence in flight with it. /// 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. +/// 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 @@ -281,6 +282,22 @@ pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) !s 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. pub var slim_terminals = false; /// `dumpJoin`'s: a plain kind's pane carries its file (SlotRecord.file), @@ -307,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(); } |
