summaryrefslogtreecommitdiff
path: root/core/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 05:28:45 -0300
committerGabriel Schneider <[email protected]>2026-11-24 05:49:28 -0300
commit4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c (patch)
treeeeee707f41a480fdcf038179ff1a527105b620c1 /core/dump.zig
parentda985ae98180c2394ccdf48cf8bdf5bd85873c2f (diff)
downloadpardes-4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c.tar.gz
pardes-4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c.zip
layout: a view's geometry is read back as its session holds it, never laid out again at a load, and held to its screen (walk.zig `.within`): a dump whose rect or column is off its screen is REFUSED, the field named: RUN FIRST (the soak, `replicas -- --clients 5`, Debug): `rpplxwst` ALONE diverged 124 at rtt 30 (225 clients parted at their first unit after a join, `addon pdf: its state after view is not the session's (it breaks PA_PLAIN)` and `the tape's answer to addon is short`; then 532 keys into the pdf's pane stopped at `a key into a kind's pane`, the kind distrusted; the witness's replay past a divergence panicked, `integer overflow` in Core.advanceInner), `pardes-merge67` 0 at 30, 80 and 207 ms; THE CAUSE: a join opens its client a view (views.zig `open`: the live one's screen and columns, NO rects: laid out at that view's first input), and rpplxwst's load (dump.zig `afterLoad`) laid every view out again, so the client had rects for its own view the session had not, told its plain kinds a view the session never told them (Kind.zig `step`, `viewOf`), and parted at the session's next step; a join's dump is the session: THE FIX: `rects`, `col_x`, `col_w` back in the digest, the dump and the copy as merge67 had them, `afterLoad`'s relayout gone (and walk.zig `pastHeld`'s pass over a derived buffer with it), and where a value read back may be is declared beside the field: `replica.within` (a predicate of the struct by the entry's place in the field, as far as its length says), checked with the indexes (`heldIndexes`) in all three decoders (a tape's `decode`, a byte dump's and an image's `holdTo`): `View.rects` on its screen (`onScreen`: x + w <= screen_w, y + h <= screen_h, as the layout pass puts every one, and a view not laid out yet has empty ones), a column's edge with its width (`columnOnScreen`, declared on `col_w`), refused in words (`Core.View.rects[0] is not within Core.View.onScreen: refused`), never clamped (a clamped rect is a state no session had); `cols` stays held to `ncol` (a column past `ncol` is a dropped one's, which the index rule would read); TESTS FIRST: replica.zig "a client joins with its session's geometry as the session holds it ..." (a plain kind keeping the rows its view was told; on pardes-load-index: `expected 0, found 5`, the joined view's rect, and without that line `the tape's answer to addon is short (tape byte 241, in tick)`), dump.zig "a view's geometry is read back as the session holds it, never laid out again; a rect or a column off its screen is refused, the field named" (the fuzz's restore seed 589: a pane 534 rows tall on a 24-row screen; a column 900 wide; a column's edge at 900), walk.zig's index test gains an entry not where it may be (`S.edges[1] is not within`, a tape, a dump and an image)
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.zig59
1 files changed, 36 insertions, 23 deletions
diff --git a/core/dump.zig b/core/dump.zig
index 9dcc076e..b4561ae2 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -143,14 +143,6 @@ pub fn dumpExit(p: *Pardes) !void {
/// view showed in a dump made before the layer's lines were the buffer's
/// (wire 31 and older: a view's bit, no lines), its lines in it (jj.loaded).
fn afterLoad(p: *Pardes) void {
- // Each view laid out again over its columns and its screen, as a resize
- // lays it out: its geometry is derived, never read (View.replica).
- const live = p.live;
- for (p.views, 0..) |slot, k| if (slot != null) {
- p.live = @intCast(k);
- layout.compute(p);
- };
- p.live = live;
for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| {
const text = pardes.panes.File.fileText(f, p.scratch.allocator()) catch continue;
f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision);
@@ -1036,24 +1028,45 @@ test "a dump keeps the session's settings, and a restore applies them" {
try std.testing.expect(!restored.settings.wrap);
}
-test "a view's geometry is laid out again at a load, never read: a pane's rect past its screen in a dump is the layout's after it" {
- // The fuzz's restore road, seed 589: an image whose pane 0 said 534
- // rows on a 24-row screen, drawn: surface.zig's `at` asserted.
+test "a view's geometry is read back as the session holds it, never laid out again; a rect or a column off its screen is refused, the field named" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
- const want = p.view().rects[0];
- p.view().rects[0].h = 534;
- p.view().col_w[0] = 900;
- const dumped = try dumpBytes(p);
- defer gpa.free(dumped);
- p.view().rects[0] = want;
- const q = try load(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }, dumped, null);
- defer q.deinit();
- try std.testing.expectEqual(want, q.view().rects[0]);
- try std.testing.expectEqual(@as(u16, 80), q.view().col_w[0]);
- _ = q.frame_arena.reset(.retain_capacity);
- _ = try q.render(q.frame_arena.allocator());
+ // Not what the layout pass would make of its columns (a view opened
+ // and not laid out yet has no rects at all): as the session has it.
+ p.view().rects[0].h -= 1;
+ const held = p.view().rects[0];
+ inline for (.{ byteDump, dumpBytes }) |dumpOf| {
+ const bytes = try dumpOf(p);
+ defer gpa.free(bytes);
+ const q = try load(gpa, p.opts, bytes, null);
+ defer q.deinit();
+ try std.testing.expectEqual(held, q.view().rects[0]);
+ }
+ // The fuzz's restore road, seed 589: an image whose pane 0 said 534
+ // rows on a 24-row screen, drawn: surface.zig's `at` asserted.
+ const Off = struct { at: *u16, to: u16, why: []const u8 };
+ for ([_]Off{
+ .{ .at = &p.view().rects[0].h, .to = 534, .why = "View.rects[0] is not within" },
+ .{ .at = &p.view().col_w[0], .to = 900, .why = "View.col_w[0] is not within" },
+ // A column's edge is held with its width.
+ .{ .at = &p.view().col_x[0], .to = 900, .why = "View.col_w[0] is not within" },
+ }) |off| {
+ const was = off.at.*;
+ off.at.* = off.to;
+ defer off.at.* = was;
+ inline for (.{ byteDump, dumpBytes }) |dumpOf| {
+ const bytes = try dumpOf(p);
+ defer gpa.free(bytes);
+ var notes: std.ArrayList(u8) = .empty;
+ defer notes.deinit(gpa);
+ try std.testing.expectError(error.BadDump, load(gpa, p.opts, bytes, &notes));
+ std.testing.expect(std.mem.indexOf(u8, notes.items, off.why) != null) catch |err| {
+ std.debug.print("refused, but not by {s}: {s}\n", .{ off.why, notes.items });
+ return err;
+ };
+ }
+ }
}
test "a dump whose index names no view or pane there is refused, the field named; a top past its text is its last line; a key's replay is not dumped" {