From 75e4787be773c8cbfd2e60e59d409b9556898365 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 15:58:05 -0300 Subject: kinds #35, the core's seam for ABI 3 (Kind.zig): each pane of a kind with view told each open view's facts by id when they change (the slot's view table, a hash a view, a stopped view told cols 0, and a step woken for a view a frame's layout changed) and ticked after, the tick's pa_tick and its prefix (placed and retag gone: the art words go on every pane of a PA_PICTURES kind from the first frame, the same bytes whichever view's step lays the tag out, by the session's first view, which was the 30 ms soak's rollbacks), found's rows the search's or appended to its +Search after, cancel's tokens dropped on every core (on the tape), a picture over PA_RASTER_MAX dropped and said once, a record of at most PA_RECORD_MAX, a Debug call over 16 ms of the kind's own (its allocations and job copies the core's) said once a site and failing --addon-test (which gains view N on|off and prints the tag the core makes), and the record ยง17.5's: a Restore, an Addon load and a reload read the pane's file as a Look does, a file not there a placeholder saying is not here, record kept, opened by the next Look or watch of it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/dump.zig | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'src/dump.zig') diff --git a/src/dump.zig b/src/dump.zig index 08736c84..52002697 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -925,9 +925,11 @@ const SlotRecord = struct { /// What decides its next calls (Kind.step): a replica joining keeps /// them, its Shadow calling where the authority's kind does. next_tick: u64 = 0, - view: u64 = 0, + views: [views.max]u64 = @splat(0), focused: bool = false, told: []const u8 = "", + /// A placeholder's why (its file not here). + refused: []const u8 = "", /// What a step reads of it that its kind's open made (Kind.reopen) or /// a call set: its tag's default words and what it has selected. A /// replica's load opens no kind; without them its tag wrapped another @@ -938,7 +940,7 @@ const SlotRecord = struct { pub fn slotWrite(s: *const Kind.Slot, gpa: std.mem.Allocator, w: *std.Io.Writer) !void { var place: [32]u8 = undefined; - var r: SlotRecord = .{ .name = s.nameOf(), .version = s.version, .path = s.path, .art = s.art, .record = s.record, .where = s.where_text.slice(), .values = s.values.slice(), .live = s.live, .next_tick = s.next_tick, .view = s.view, .focused = s.focused, .told = s.told.slice(), .tail = s.tail.slice(), .selection = s.selection }; + var r: SlotRecord = .{ .name = s.nameOf(), .version = s.version, .path = s.path, .art = s.art, .record = s.record, .where = s.where_text.slice(), .values = s.values.slice(), .live = s.live, .next_tick = s.next_tick, .views = s.views, .focused = s.focused, .told = s.told.slice(), .refused = s.refused.slice(), .tail = s.tail.slice(), .selection = s.selection }; var owned: ?[]u8 = null; defer if (owned) |o| s.gpa.free(o); if (s.ops != null) { @@ -951,22 +953,17 @@ pub fn slotWrite(s: *const Kind.Slot, gpa: std.mem.Allocator, w: *std.Io.Writer) try w.writeAll(bytes); } -/// The kind's record of a slot's state (`s.gpa`'s), or null for none: a -/// dump of at most 1 MiB, then as many bytes as it asked for. +/// The kind's record of a slot's state (`s.gpa`'s), or null for none: at +/// most PA_RECORD_MAX bytes. pub fn slotRecord(s: *Kind.Slot) !?[]u8 { const f = (s.ops orelse return null).dump orelse return null; - var cap: usize = 1 << 20; - while (true) { - const buf = try s.gpa.alloc(u8, cap); - const n = Kind.dumpCall(s, f, buf); - if (n == 0) { - s.gpa.free(buf); - return null; - } - if (n <= cap) return s.gpa.realloc(buf, n) catch buf[0..n]; + const buf = try s.gpa.alloc(u8, Kind.c.PA_RECORD_MAX); + const n = Kind.dumpCall(s, f, buf); + if (n == 0 or n > buf.len) { s.gpa.free(buf); - cap = n; + return null; } + return s.gpa.realloc(buf, n) catch buf[0..n]; } /// The pane back from its record, a placeholder holding it until its @@ -975,12 +972,13 @@ pub fn slotRead(out: *Kind.Slot, gpa: std.mem.Allocator, bytes: []const u8) !voi var arena: std.heap.ArenaAllocator = .init(gpa); defer arena.deinit(); const r = try walk.load(SlotRecord, arena.allocator(), bytes, null); - out.* = .{ .gpa = gpa, .arena = .init(gpa), .version = r.version, .art = r.art, .live = r.live, .next_tick = r.next_tick, .view = r.view, .focused = r.focused }; + out.* = .{ .gpa = gpa, .arena = .init(gpa), .version = r.version, .art = r.art, .live = r.live, .next_tick = r.next_tick, .views = r.views, .focused = r.focused }; errdefer out.free(); @memcpy(out.name[0..@min(15, r.name.len)], r.name[0..@min(15, r.name.len)]); out.path = try gpa.dupe(u8, r.path); out.where_text.set(r.where); out.told.set(r.told); + out.refused.set(r.refused); out.tail.set(r.tail); out.values.set(r.values); out.selection = try gpa.dupe(u8, r.selection); @@ -992,9 +990,12 @@ pub fn slotFree(s: *Kind.Slot, gpa: std.mem.Allocator) void { s.free(); } -/// A loaded pane of a kind opened by its kind, if this core has it, else -/// a placeholder saying what it waits for. One with no record reopens from -/// its file, its place and its words. +/// A loaded pane of a kind opened by its kind from its file as a Look +/// reads it, then given its record, if this core has the kind; else, or +/// refused (its file not here, its record not taken), a placeholder saying +/// what it waits for, its record kept. One with no record reopens at its +/// place with its words. A placeholder comes back at the next Look or +/// watch of its path, or the load of its kind. pub fn reviveSlot(p: *Pardes, id: usize, s: *Kind.Slot) void { const k = p.kinds.byName(s.nameOf()) orelse { s.live = false; @@ -1002,14 +1003,19 @@ pub fn reviveSlot(p: *Pardes, id: usize, s: *Kind.Slot) void { }; s.ops = p.kinds.ops[k]; s.gen = p.kinds.kinds[k].gen; - const bytes: ?[]u8 = if (s.record == null and s.path.len > 0) filesystem.read(p, s.path) catch null else null; + // A replica has no code to read it for: the authority's outcome is taped. + const bytes: ?[]u8 = if (s.ops != null and s.path.len > 0) filesystem.read(p, s.path) catch null else null; defer if (bytes) |b| p.gpa.free(b); - const kept = .{ s.next_tick, s.view, s.focused }; - _ = Kind.reopen(p, id, s, bytes); - // A replica's Shadow is the authority's pane as it is: it ticks when - // that one does, not because it was loaded (a kind opened here ticks - // to lay itself out). - if (s.ops == null) s.next_tick, s.view, s.focused = kept; + const kept = .{ s.next_tick, s.views, s.focused }; + if (!Kind.reopen(p, id, s, bytes)) { + s.ops = null; + s.live = false; + } else if (s.ops == null) { + // A replica's Shadow is the authority's pane as it is: it ticks + // when that one does, not because it was loaded (a kind opened + // here ticks to lay itself out). + s.next_tick, s.views, s.focused = kept; + } } /// A PDF pane of a dump from before the pdf addon: a pane of the addon's -- cgit v1.3