summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 21:55:10 -0300
committerGabriel Schneider <[email protected]>2026-11-22 21:59:50 -0300
commit18e674964e5db67d35e1cf5ded128757ced22a98 (patch)
treef99ed84b30ecfcbc028b2c9c16deadc282dd06ce /test
parent9acf9f558de00f4588b51dee2cd56b9150c7fb35 (diff)
downloadpardes-18e674964e5db67d35e1cf5ded128757ced22a98.tar.gz
pardes-18e674964e5db67d35e1cf5ded128757ced22a98.zip
replicas: one decision a unit, by one count in the core (pardes-term-join-11, item 2; P54, the coordinator's lean, held against the code first): `Replica.confirm` asked one question four ways from three sources ("did applying this unit write state outside the rollback copy, an emulator?"): the speculation's own observation (`Pending.terminal` from `Tape.touched`, set by `touchTerminal` at a grid it owed and at every READ of a terminal's rows), the unit's records (`tape.feedsTerminal`), a process-wide counter (`Term.writes`, seven increments, shared by every side of the soak's one process) and a dead read (`read_terminal`, always false); round 10's predicate over the records failed because no record names the unit whose `sync` reflows a grid, a load or a teardown; now the core counts its emulators' writes itself (`Pardes.outside`, a `Term.Outside`): a field, so copied with a speculation, digested and dumped, a function of the tape, the same on every side; every write of the `calls` table's WRITE rows takes it first and counts (core/Term.zig `open`, `close`, `revive`, `reload`, `feed`, `resize`, `endOutputHere`, and `replies` when it drained any), a comptime block fails the build if a WRITE row's entry does not take it (the compiler holds the call sites; S1's `calls` test holds that a new write is listed); `resize` owes under a speculation (counted, not made: the grid's guard moved there from panes.zig `resizeGrid`); a load sets it (the walk loads the field; `dumpRead` counts nothing); the one read in `confirm`: on the fast path the count's movement over the input's speculation (`Pending.outside`, a number, equal to the unit's by the path's premise: moved, the unit is replayed once on the confirmed core), on the replay paths its movement over `replayUnit` on the core that applied it (moved over a copy held ahead, the copy goes), and on the neutral path no read at all: the session's digest after the unit holds the count, so a unit that wrote an emulator never ends where it began (`feedsTerminal` deleted with its one use); the predicted echo is judged at every unit that moved it; DELETED: `Tape.touched`, both `touchTerminal`s and the read-touch in edit.zig `shellRows` (a read writes nothing outside the copy; on the one road a speculation reads the confirmed emulator), `Term.writes` and its seven increments, `feedsTerminal`, `read_terminal`; where the lean does not stretch, said and not built: a picture's pixels, a kind's state and the Store's closed list are written BY a speculation, so the fast path must let the copy go, not replay: `panesMoved`, the serials and `retiring` stay for them; the dump changes (a core field): the wire stays at 31 (its history line says so); tests: the existing path tests green (fast, neutral, ahead, owed grid, "a view that sized a terminal closing leaves nothing queued ..." among them); new: a session's reflow of a terminal's grid over a copy held ahead is the count's to decide (a unit with no output record: the copy goes, a rollback does not reflow again), and the count digested (one side's emulator written outside any unit, a colour set no other digested field shows: `partsApart` names `outside` alone); core-test 917/1079 (162 skipped), shell-test 1121/1124 (3 skipped), the gate below
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/kitty.zig4
-rw-r--r--test/perf.zig5
-rw-r--r--test/terminal.zig8
3 files changed, 9 insertions, 8 deletions
diff --git a/test/kitty.zig b/test/kitty.zig
index 22b62fb2..0bd849c2 100644
--- a/test/kitty.zig
+++ b/test/kitty.zig
@@ -641,7 +641,7 @@ test "kitty: an image follows its text when the shell scrolls, resizes and reflo
try std.testing.expectEqual(o.y + 2, (try r.placesOf(10))[0].dst.y);
// A narrower pane reflows the text; the image stays on its row.
const pane = r.pane(0);
- pane.resizeGrid(0, 40, pane.rows);
+ pane.resizeGrid(r.p, 40, pane.rows);
const text = try pardes.Term.scrollback(pane.terminal, r.frame.allocator());
var row: usize = 0;
var lines = std.mem.splitScalar(u8, text, '\n');
@@ -1167,7 +1167,7 @@ fn fuzzRun(seed: u64, steps: usize, trace: bool) !bool {
r.p.update(.{ .resize = .{ .cols = cols, .rows = rows, .cell_pixels = .{ .w = 1 + rng.uintLessThan(u16, 30), .h = 1 + rng.uintLessThan(u16, 60) } } });
r.drain();
},
- 1 => r.pane(0).resizeGrid(0, 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)),
+ 1 => r.pane(0).resizeGrid(r.p, 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)),
2, 3 => {
const drawn = try r.places();
if (trace) std.debug.print(" {d} places, {d} placements, {d} images\n", .{ drawn.len, r.placementCount(0), r.storage(0).images.count() });
diff --git a/test/perf.zig b/test/perf.zig
index 30e15dcc..8622e31b 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -316,6 +316,7 @@ fn measureCreation(io: std.Io, reps: usize, json: bool) !void {
for ([_]bool{ false, true }) |terminal| {
var cold_ns: u64 = 0;
var cold_deinit_ns: u64 = 0;
+ var outside: pardes.Term.Outside = .{};
var calls: usize = 0;
var bytes: usize = 0;
var live: usize = 0;
@@ -325,12 +326,12 @@ fn measureCreation(io: std.Io, reps: usize, json: bool) !void {
const allocator = counter.allocator();
const begin = nowNs();
const pane = if (terminal)
- try pardes.panes.createTerminal(allocator, screen_cols, screen_rows)
+ try pardes.panes.createTerminal(&outside, allocator, screen_cols, screen_rows)
else
try pardes.panes.createDoc(allocator, screen_cols, screen_rows);
const constructed = nowNs();
const retained = counter.live;
- if (pane.terminal) |state| pardes.Term.close(state, allocator);
+ if (pane.terminal) |state| pardes.Term.close(&outside, state);
allocator.destroy(pane);
const destroyed = nowNs();
if (counter.live != 0) return error.LeakedPaneMemory;
diff --git a/test/terminal.zig b/test/terminal.zig
index bad70081..03bcd294 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -82,9 +82,10 @@ fn lineBreaks(comptime n: usize) [2 * n]u8 {
test "replay ownership is terminal-only and construction rolls back on allocation failure" {
const Case = struct {
fn run(gpa: std.mem.Allocator, terminal: bool) !void {
- const pane = if (terminal) try panes.createTerminal(gpa, 40, 12) else try panes.createDoc(gpa, 40, 12);
+ var outside: Term.Outside = .{};
+ const pane = if (terminal) try panes.createTerminal(&outside, gpa, 40, 12) else try panes.createDoc(gpa, 40, 12);
defer gpa.destroy(pane);
- defer if (pane.terminal) |state| close(state, gpa);
+ defer if (pane.terminal) |state| close(&outside, state);
try std.testing.expectEqual(terminal, pane.terminal != null);
}
};
@@ -98,7 +99,6 @@ test "document construction allocates only the pane and has inert terminal defau
const allocator = failing.allocator();
const pane = try panes.createDoc(allocator, 40, 12);
defer allocator.destroy(pane);
- defer if (pane.terminal) |state| close(state, allocator);
try std.testing.expect(pane.terminal == null);
try std.testing.expectEqual(@as(usize, 1), failing.alloc_index);
try std.testing.expectEqual(@as(usize, 0), failing.resize_index);
@@ -109,7 +109,7 @@ test "document construction allocates only the pane and has inert terminal defau
try std.testing.expectEqual(Term.Prompt{}, prompt(pane.terminal));
pane.scrollBy(100);
pane.followOutput();
- pane.resizeGrid(0, 80, 24);
+ pane.resizeGrid(undefined, 80, 24); // no terminal: the core is never read
try std.testing.expectEqual(Term.Grid{}, grid(pane.terminal));
try std.testing.expectEqualStrings("", try scrollback(pane.terminal, allocator));
try std.testing.expect(!failing.has_induced_failure);