From 18e674964e5db67d35e1cf5ded128757ced22a98 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:55:10 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Term.zig | 72 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 26 deletions(-) (limited to 'core/Term.zig') diff --git a/core/Term.zig b/core/Term.zig index b82017f6..d1065b49 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -14,11 +14,15 @@ const dump = @import("dump.zig"); const File = @import("File.zig"); const iface = plain.term; -/// Writes into this process's emulators (a read fed, a grid reflowed, one -/// opened, closed, loaded or made again): whether a unit's -/// replay made one, the replica engine's one rule (core/replica.zig -/// `confirm`) reads across that replay, on its one thread. -pub var writes: u32 = 0; +/// The writes of a core's emulators, which live outside its rollback copy +/// (`Pardes.outside`): a field of the core, so copied with a speculation, +/// digested and dumped, a function of the tape, the same on every side (one +/// side's emulator written where the others' are not is a digest that says +/// `outside`). Every write below takes it and counts, and so does a write a +/// speculation owes (`resize`): over an input's apply, the count moved is +/// "this input wrote, or owes, state outside the copy", the one question +/// core/replica.zig `confirm` asks a unit. A load sets it from the dump. +pub const Outside = struct { n: u64 = 0 }; /// The reloads this process made (a join's, on every side) and their time, /// for the soak's join line (test/replicas.zig `--bytes`). pub var reloads: struct { n: u32 = 0, ns: u64 = 0, worst_ns: u64 = 0 } = .{}; @@ -96,7 +100,6 @@ pub const State = struct { const parts = try walk.load(iface.Parts, arena.allocator(), bytes[8..][0..n], null); o.media(media); out.* = .{ .impl = try o.load(gpa, bytes[8 + n ..], &parts) }; - writes +%= 1; } }; @@ -112,13 +115,13 @@ pub fn emulatorOf(s: *State) *@import("term").terminal.State { /// A new terminal, `cols` by `rows`, allocated with `gpa` (its own from /// then on). Refused in a core without one: `error.NoTerminal`, which a /// word reports as `none` says it. -pub fn open(gpa: std.mem.Allocator, cols: u16, rows: u16) !*State { +pub fn open(outside: *Outside, gpa: std.mem.Allocator, cols: u16, rows: u16) !*State { const o = ops orelse return error.NoTerminal; const s = try gpa.create(State); errdefer gpa.destroy(s); o.media(media); s.* = .{ .impl = try o.open(gpa, cols, rows) }; - writes +%= 1; + outside.n +%= 1; return s; } @@ -137,9 +140,9 @@ fn readMedium(read: *const fn (*const anyopaque) iface.MediumError![]u8, ctx: *c /// It and what it holds, freed, all of it with its own allocator (the /// one it was opened with): the allocator a caller hands is not used. -pub fn close(s: *State, _: std.mem.Allocator) void { +pub fn close(outside: *Outside, s: *State) void { const own = the().gpa(s.impl); - writes +%= 1; + outside.n +%= 1; the().close(s.impl); own.destroy(s); } @@ -148,8 +151,8 @@ pub fn close(s: *State, _: std.mem.Allocator) void { /// every side does it, so that all hold the same pages (ghostty prunes its /// history a page at a time, and a snapshot does not say how its rows were /// cut into pages). The snapshot's hash, which every side compares. -pub fn reload(s: *State) !u64 { - writes +%= 1; +pub fn reload(outside: *Outside, s: *State) !u64 { + outside.n +%= 1; const t0 = @import("FrameStats.zig").nowNs(); defer { reloads.n += 1; @@ -170,8 +173,8 @@ pub fn due(s: *const State) ?u64 { /// Loaded from a dump without its shell: its program's modes reset, its /// history marked off from what the next shell prints. -pub fn revive(s: *State) void { - writes +%= 1; +pub fn revive(outside: *Outside, s: *State) void { + outside.n +%= 1; s.written = true; the().revive(s.impl); } @@ -190,8 +193,8 @@ pub fn stop() void { /// One read of its program's output (`Told` says where the tracked rows /// went), every view's place in its history carried through it (`resize`). -pub fn feed(s: *State, bytes: []const u8, tracked: []const i32, rows: []i32, erased: []bool, places: []?usize) Told { - writes +%= 1; +pub fn feed(outside: *Outside, s: *State, bytes: []const u8, tracked: []const i32, rows: []i32, erased: []bool, places: []?usize) Told { + outside.n +%= 1; s.written = true; return the().feed(s.impl, bytes, tracked, rows, erased, places); } @@ -205,8 +208,11 @@ pub fn grid(s: ?*const State) Grid { /// Its grid reflowed, every view's place in its history (Pane.scrolled_to, /// each view's) carried through it as ghostty carries a view of its own. -pub fn resize(s: *State, cols: u16, rows: u16, places: []?usize) void { - writes +%= 1; +/// A speculation owes it (counted, not made): its input is replayed when it +/// is confirmed (core/replica.zig `confirm`), never taken as speculated. +pub fn resize(outside: *Outside, s: *State, cols: u16, rows: u16, places: []?usize) void { + outside.n +%= 1; + if (tape.speculating()) return; s.written = true; the().resize(s.impl, cols, rows, places); } @@ -218,8 +224,10 @@ pub fn cellPixels(s: *State, w: u32, h: u32) void { /// What it answered its program since the last call, to be written to its /// pty. -pub fn replies(s: *State) []const u8 { - return the().replies(s.impl); +pub fn replies(outside: *Outside, s: *State) []const u8 { + const r = the().replies(s.impl); + if (r.len > 0) outside.n +%= 1; + return r; } // ---- input ---- @@ -277,7 +285,8 @@ pub fn commandOutput(s: ?*State, gpa: std.mem.Allocator, max_rows: usize) !Comma /// The shell exited in the middle of a command: its output ends at the /// cursor. -pub fn endOutputHere(s: *State) void { +pub fn endOutputHere(outside: *Outside, s: *State) void { + outside.n +%= 1; the().endOutputHere(s.impl); } @@ -399,14 +408,14 @@ pub fn hasImages(s: ?*const State) bool { /// and pardes-image-loop's tables, kept as a test). pub const calls = [_]struct { []const u8, []const u8, []const u8 }{ // ---- writes: outside the copy ---- - .{ "open", "dump.zig:1 panes.zig:1", "WRITE: a terminal made by a step (a shell's pane) or a load; a copy held across a pane's opening is let go (replica.zig `confirm`: serials)" }, - .{ "close", "panes.zig:1", "WRITE: let go by a step that closes its pane: a copy held across it is let go (retiring panes); a unit that closes one is never kept over a copy" }, + .{ "open", "dump.zig:1 panes.zig:1", "WRITE: a terminal made by a step (a shell's pane) or a load, counted (`Outside`); a speculation is refused it" }, + .{ "close", "panes.zig:1", "WRITE: let go by a step that closes its pane, counted; a speculation is refused it" }, .{ "revive", "dump.zig:1", "WRITE: a load's (a join's dump, a Restore): no copy is held" }, .{ "reload", "panes.zig:1", "WRITE: a join's step remakes each terminal written since its last reload, on every side (panes.reloadTerminals, the session's choice taped, the snapshot's hash compared)" }, - .{ "feed", "keys.zig:1 panes.zig:3", "WRITE: the pty's bytes in a unit, every side in the tape's order, every view's place (Pane.scrolled_to, in the copy) carried through it; a unit that feeds lets a copy held ahead go (`Term.writes`), so none is replayed (keys.zig's: a test's)" }, - .{ "resize", "panes.zig:1", "WRITE: a step's reflow, every view's place carried through it; a speculation owes it (`touchTerminal`): its input is taken when confirmed, never as speculated" }, + .{ "feed", "keys.zig:1 panes.zig:3 replica.zig:1", "WRITE: the pty's bytes in a unit, every side in the tape's order, every view's place (Pane.scrolled_to, in the copy) carried through it, counted: a unit that moved the count is applied once, to the confirmed core (replica.zig `confirm`); a speculation is refused it (keys.zig's, replica.zig's: tests')" }, + .{ "resize", "panes.zig:1", "WRITE: a step's reflow, every view's place carried through it, counted; a speculation owes it (counted, not made): its input is taken when confirmed, never as speculated" }, .{ "endOutputHere", "ninep/pty.zig:1", "WRITE: a 9P pty/run's step ends a command's output at the cursor: the session's step, replayed as such" }, - .{ "replies", "Core.zig:1", "WRITE: a step drains the reply buffer (in the digest); only the session writes it to the pty (pty_write is off the tape)" }, + .{ "replies", "Core.zig:1", "WRITE: a step drains the reply buffer (in the digest), counted when it held any (the feed's own unit, which filled it); only the session writes it to the pty (pty_write is off the tape)" }, // ---- reads by a step: in the digest ---- .{ "grid", "Core.zig:2 ansi.zig:3 body_layer.zig:3 draw.zig:2 dump.zig:4 echo.zig:8 exec.zig:2 layout.zig:2 panes.zig:5 replica.zig:2", "READ: the size, the history's length, the cursor: in the digest (a view's place is its pane's; ansi.zig, body_layer.zig, draw.zig, echo.zig: a draw's)" }, .{ "modes", "Core.zig:5 draw.zig:1 dump.zig:2 echo.zig:3 exec.zig:3 mouse.zig:4 ninep/pty.zig:3 panes.zig:2 replica.zig:1", "READ: the program's modes (mouse, focus, bracketed paste, the alternate screen): in the digest (draw.zig, echo.zig: a draw's; panes.zig: a view scrolls no history on the alternate screen)" }, @@ -502,6 +511,17 @@ test "every call of the core's into a terminal is listed with its rule (S1): a n try std.testing.expectEqual(@as(usize, 0), wrong); } +// Every WRITE above takes its core's count first (`Outside`): a call +// cannot be written without one, so the count cannot be forgotten at a call +// site (the compiler holds that); that a new op is listed as a WRITE is the +// test's above and a reviewer's. +comptime { + for (calls) |c| if (std.mem.startsWith(u8, c[2], "WRITE")) { + const params = @typeInfo(@TypeOf(@field(@This(), c[0]))).@"fn".param_types; + if (params.len == 0 or params[0] != *Outside) @compileError("Term." ++ c[0] ++ " writes an emulator: it takes its core's count (`*Outside`) first"); + }; +} + fn listedCall(name: []const u8, file: []const u8) bool { for (calls) |c| { if (!std.mem.eql(u8, c[0], name)) continue; -- cgit v1.3 From de0e85daa8ad0bf9618734e16568823aa2b61a54 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 22:48:28 -0300 Subject: replicas: what a core field points to is the rollback copy's, or lives outside the core by its own declaration (pardes-term-join-12, item 1: the double free of round 11's gate): the copy skipped memory two ways, by inference and by a list, and each let a write survive a put-back: (1) `unwalked` took any type with a digest of its own and no `replica` annotation as outside the copy, so `jj.Session` (`Pardes.changes`, added with the layers) was saved as bytes and its heap never: a splice of the pinned lines at a client's edit (jj.edited) wrote a new `lines` into the answers buffer in place, the put-back freed it and left the pointer, and the next splice or the core's end freed it again (the test before this: allocated at jj.spliceValues under the speculation, freed at Epoch.discard, freed again at jj.spliceValues; the soak's abort at jj.Session.deinit); now a type is outside the copy only by declaring it (`outside_copy`: Term.State, the emulator written by confirmed units alone and counted; locations.Row, made again and never written, in a pinned blob), and every other type is walked, whatever digest it has; (2) `unsaved` skipped the rows cache (`Pardes.shell_rows`, `.derived`) and the replica kept it apart by hand (`speculate` emptied it before its take, `toConfirmed` set it `.{}` after a put-back), which an idle client's copy (`ready`) never emptied: the rows read before it were orphaned in the epoch at every rollback; now the cache is the copy's like any state: its text and rows are made whole and freed whole, so they are blobs the copy pins (no copy of a grid's text; freed raw), the put-back restores the cache with the core (valid: no emulator is written while a copy is held: a unit that writes one lets the copy go, or is applied after it is put back), and both hand resets are deleted; THE RULE the compiler holds: a type is skipped by the copy only by its own `outside_copy`, and a cache (`.derived`) on the copy's skip list (`unsaved`) is a compile error ("a cache the core holds is the copy's, or lives beside what it caches, outside the core"); the copy pins a blob once whoever reaches it (a text and the allocation it starts: never pinned twice nor also saved); not changed: the arenas (the copy saves their bytes, not their nodes: scratch content), the queues (asserted empty at a take), the host's and the process's own (store, Recent, the echo, the tape), a picture's pixels under a speculation (replica.zig's ponytail at `initDump`); the three tests of the change before: pass (the jj test and the rows test under a DebugAllocator as the epoch's child too, no double free reported); the gate (g12, a frozen copy; loads 1.5-12): core-test 918/1082 (164 skipped), shell-test 1124/1127 (3 skipped), term-test 17/17, kitty-test 45/45, pane-test 182/183 (1 skipped), behaviour-test and --replay 275/275, process-test 0 of 146 own and as pairs, the soak 3 of 3 whole and 10 of 10 at seed 0 and 80 ms (diverged 0, unequal 0, unlisted 0, quiet checks all agreed, the corpus 22 of 22, no leak, no abort), daemon.py every mode on Debug and ReleaseSafe (plain 3 of 3 each, --far 7 of 7 on ReleaseSafe, --games on ReleaseSafe with the Debug prefix's game libraries), --upgrade from the installed build 3 of 3, R2D 1 of 1, D2R 4 of 7 (two known test races: Exit's clunk answered after the window ended, far_exec's environment read at the exec; one quiet check of a Debug window client's key not in 30 s, load 6.1), --upgrade --gui 3 of 3, the cross-builds, the frame and perf gate against tree4: 77/77 frames, perfab corpus2x +0.014% (noise 0.049%), 121 counts within 0.1% (largest terminal on all +0.0794%), the gui unit-test 1719/1723 in the workspace (4 skipped, none failing; the copy's longer build root fails six tests whose messages name a temporary path: a 9P error's room is Plan 9's 128 bytes, ninep/tree.zig:549-556) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Term.zig | 5 +++++ core/edit.zig | 11 ++++++++--- core/locations.zig | 4 ++++ core/replica.zig | 12 +----------- core/rollback.zig | 36 +++++++++++++++++++++--------------- 5 files changed, 39 insertions(+), 29 deletions(-) (limited to 'core/Term.zig') diff --git a/core/Term.zig b/core/Term.zig index d1065b49..f0329852 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -71,6 +71,11 @@ pub const State = struct { /// same snapshot again from the dump. written: bool = true, + /// Not walked by a replica's rollback copy (core/rollback.zig): its + /// emulator is written by confirmed units alone, each write counted + /// (Pardes.outside), never by a speculation, so no copy holds any of it. + pub const outside_copy = {}; + /// The emulator as its program has made it, for the replay digest. pub fn digest(s: *const State, h: *walk.Hasher) void { the().digest(s.impl, h); diff --git a/core/edit.zig b/core/edit.zig index 129b004c..70b765cc 100644 --- a/core/edit.zig +++ b/core/edit.zig @@ -427,8 +427,13 @@ pub var drawing = false; /// A terminal's rows as text (`Term.rows`), kept for one pane until its /// grid moves. Returned slices remain valid until the next cache rebuild -/// or reset. +/// or reset. A replica's rollback copy holds it as any state: its text and +/// rows are made whole and freed whole, never written, so the copy pins +/// them (blobs, freed raw) and puts the cache back with the core: no +/// emulator is written while a copy is held (replica.zig `confirm`: a unit +/// that writes one lets the copy go or is applied after it is put back). pub const RowsCache = struct { + pub const replica = .{ .blob = .{ "text", "rows", "text_alloc" } }; /// whose grid this describes; null = the slot is free pane: ?*const Pane = null, /// the rows joined by '\n' — `flatSurface` hands this back verbatim @@ -442,8 +447,8 @@ pub const RowsCache = struct { stale: bool = false, pub fn reset(c: *RowsCache, gpa: std.mem.Allocator) void { - if (c.text_alloc.len > 0) gpa.free(c.text_alloc); - if (c.rows.len > 0) gpa.free(c.rows); + pardes.memory.freeRaw(gpa, c.text_alloc); + pardes.memory.freeRaw(gpa, c.rows); c.* = .{}; } diff --git a/core/locations.zig b/core/locations.zig index 6972647e..10704912 100644 --- a/core/locations.zig +++ b/core/locations.zig @@ -25,6 +25,10 @@ pub const Row = struct { code_start: usize, colors: []u8 = &.{}, + /// Not walked by a replica's rollback copy (core/rollback.zig): made + /// again, never written, in a blob the copy pins whole. + pub const outside_copy = {}; + /// The replay digest's (core/walk.zig): all of it but its colours. They /// are painted from what this process has painted (the owner's /// highlights a frame made, the locations cache: both derived), so a diff --git a/core/replica.zig b/core/replica.zig index 936eb3e4..b37dcdb2 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -608,10 +608,7 @@ pub const Replica = struct { if (r.t.core) |c| { const was = Stepping.begin(&r.t, &r.epoch); // The state it ends on is whole as it is: the copy let go, its - // put-off frees done. Put back, it would bring back what was - // freed between steps meanwhile (the shell's rows a draw read - // again after a delta), which `toConfirmed` drops and this - // freed again (a held copy across an input of its own, a + // put-off frees done (a held copy across an input of its own, a // rejoin's old replica). if (r.copy.held) r.copy.release(); c.deinit(); @@ -901,11 +898,6 @@ pub const Replica = struct { if (!whole) return r.fail("out of memory for a rollback"); // The frame its host drew is of the memory put back: drawn again. r.moved = true; - // The rows a terminal was read as are no copy's: what the - // speculation built was the epoch's, freed with it, and what - // was there before is of a grid the deltas since moved on - // from (a rollback never brings a terminal's past back). - r.core().shell_rows = .{}; } r.applied = 0; for (r.since.items) |u| if (tape.replayUnit(&r.t, u)) |why| { @@ -942,8 +934,6 @@ pub const Replica = struct { const c = r.core(); if (!r.copy.held) { const t0 = nowNs(); - // A grid's worth of text the copy would save, and put back stale. - c.shell_rows.reset(c.gpa); r.copy.take(&r.epoch, c) catch return false; r.keepSerials(); rollback.Epoch.select(&r.epoch); diff --git a/core/rollback.zig b/core/rollback.zig index a55d3c87..61fb7b89 100644 --- a/core/rollback.zig +++ b/core/rollback.zig @@ -441,7 +441,8 @@ pub const Copy = struct { // the speculation freed would come back as that. Not the // queues a step drains (undefined between steps), nor the // authority's. - if (attr.@"comptime" or comptime (annotated(T, "authority", name) or ((annotated(T, "local", name) or annotated(T, "derived", name)) and unsaved(name)))) continue; + if (comptime annotated(T, "derived", name) and unsaved(name)) @compileError("rollback: " ++ @typeName(T) ++ "." ++ name ++ " is a cache the copy would skip: a cache the core holds is the copy's, or lives beside what it caches, outside the core"); + if (attr.@"comptime" or comptime (annotated(T, "authority", name) or (annotated(T, "local", name) and unsaved(name)))) continue; // A text and its index: written in place, the epoch // notes what each write takes out (`Epoch.wrote`). if (comptime opaqueTo(F) or annotated(T, "journal", name)) continue; @@ -483,7 +484,7 @@ pub const Copy = struct { const s = @typeInfo(T).@"struct"; inline for (s.field_names, s.field_types, s.field_attrs) |name, F, attr| { if (attr.@"comptime") continue; - if (comptime (annotated(T, "local", name) or annotated(T, "derived", name) or annotated(T, "authority", name)) and unsaved(name)) continue; + if (comptime (annotated(T, "local", name) or annotated(T, "authority", name)) and unsaved(name)) continue; const at = @intFromPtr(&@field(v, name)); if (comptime walk.lengthOf(T, name) != null and @typeInfo(F) == .array) { try c.save(at, walk.lengthIn(v, comptime walk.lengthOf(T, name).?) * @sizeOf(@typeInfo(F).array.child)); @@ -501,7 +502,10 @@ pub const Copy = struct { if (try c.reached([]const E, addr)) return; if (c.pinnable and s.len * @sizeOf(E) >= blob_min and c.epoch.?.owns(addr) != null) { // A blob of rows with allocations of their own is pinned whole: - // they are as immutable as it, and kept alive with it. + // they are as immutable as it, and kept alive with it. Once, + // whatever reaches it (a text and the allocation it is the + // start of), and never saved as well. + if (try c.reached(void, addr)) return; const bytes = std.mem.sliceAsBytes(s); try c.pins.append(c.meta, .{ .addr = addr, .len = bytes.len, .hash = if (checked) std.hash.Wyhash.hash(0, bytes) else 0, .where = c.where }); return; @@ -511,14 +515,16 @@ pub const Copy = struct { } }; -/// A type that hashes itself and says nothing of its fields (`replica`): -/// a terminal, the authority's (its emulator is never written by a -/// speculation: terminal.zig's guards), or a location row, made again and -/// never written. One that says its fields' kinds is walked by them, -/// whatever digest it has (the 9P state, fs.Namespace and a pane's: a -/// replayed request writes its buffers in place). +/// A type the copy does not walk: one that says so (`outside_copy`, with +/// why: a terminal's handle, its emulator written by confirmed units alone, +/// counted in Pardes.outside; a location row, made again and never +/// written). Every other type is walked, whatever digest it has: what a +/// core field points to is the copy's, saved or pinned, so that a write +/// into it in place is put back with the rest (jj.Session's answers, whose +/// lines an edit splices: walked by no one while its digest said "skip +/// me", a rollback over a client's edit freed them twice). fn unwalked(comptime T: type) bool { - return @hasDecl(T, "digest") and @TypeOf(T.digest) == fn (*const T, *walk.Hasher) void and !@hasDecl(T, "replica"); + return @hasDecl(T, "outside_copy"); } fn annotatedStruct(comptime T: type) bool { @@ -527,10 +533,10 @@ fn annotatedStruct(comptime T: type) bool { /// The queues every step drains (empty between steps, asserted when a copy /// is taken: what is in their slots is nothing), the frame statistics -/// (numbers), and the rows a terminal was last read as -/// (a grid's worth of text, emptied when a copy is taken and when it is -/// put back: core/replica.zig), and a replica's predicted echo (core/term/echo.zig: -/// the replica's, never its core's). And the store and Recent, a replica's +/// (numbers), and a replica's predicted echo (core/term/echo.zig: the +/// replica's, never its core's). Never a cache (`.derived`): what a core +/// field caches is the copy's, or lives beside what it caches, outside the +/// core (a compile error says so). And the store and Recent, a replica's /// own: on the host's heap (Pardes.recentGpa), which the epoch never puts a /// free off for, so their bytes put back would point at what is freed. A /// step reads what the authority holds of them off the tape @@ -538,7 +544,7 @@ fn annotatedStruct(comptime T: type) bool { /// `Options.tape`): the process's, which a rollback leaves where it is. fn unsaved(comptime name: []const u8) bool { return std.mem.eql(u8, name, "effects") or std.mem.eql(u8, name, "in_q") or std.mem.eql(u8, name, "frames") or std.mem.eql(u8, name, "own_frames") or - std.mem.eql(u8, name, "shell_rows") or std.mem.eql(u8, name, "echo") or std.mem.eql(u8, name, "store") or + std.mem.eql(u8, name, "echo") or std.mem.eql(u8, name, "store") or std.mem.eql(u8, name, "recent") or std.mem.eql(u8, name, "tape"); } -- cgit v1.3