summaryrefslogtreecommitdiff
path: root/core/Addon.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 12:56:12 -0300
committerGabriel Schneider <[email protected]>2026-11-19 13:57:28 -0300
commit1553f31259f545329dd8032b73888b688520dd38 (patch)
treedebfd95a282d697f1b0aafc1e21e51ff62d5d7a8 /core/Addon.zig
parenta355c7fee38bd940da12f330408639fc3875234b (diff)
downloadpardes-1553f31259f545329dd8032b73888b688520dd38.tar.gz
pardes-1553f31259f545329dd8032b73888b688520dd38.zip
kinds and addons: a kind's and an addon's tape calls are the handle's, the step's core's tape or a `tape: *Tape` parameter (the handle's step 3, P20, pardes-handle-sizing section 3's third noun): Kind.zig's fourteen (a kind's open, close, key, search, address, mouse and word refused to a speculation, `p.tape.authorityOnly`; its tag's prefix, `p.tape.value(.addon, ..)`; a tick's `p.tape.speculating` and `poison`; a call's end, `Call.end`, on its core's tape: its outcome taped, its plain block hashed only on a tape that is not `none` (`t.through`, where `tape.on == null` was: the one read of the global outside tape.zig and replica.zig is gone), and a client's plain kind that broke its promise diverging the replay through `Tape.diverge`, made public, under `t.replay` as `tape.diverged` was), and the C callback `api.job` (callconv(.c), no parameter to give) reaching its handle through `Kind.current`, the call under way, whose core it holds at that line (a call that asks a job and is not quiet is a step's: `cl.p.?.tape`), which holds at its one site: the other callbacks ask nothing of the tape; Addon.zig's three, its import gone with Kind.zig's (`const tape = @import("tape.zig")`, 2 lines apart from the count): Addon.need, Addon.take and Kind.Registry.started take `tape` (3 functions, the row said 1 + 20: the graph tied `take` by name to walk.Reader.take and the rest), `swap` reads `p.tape`; Kind.reopen takes the core it was always handed (`*Pardes`, was `?*Pardes`: no caller passed null); Pardes.create names its tape once, for `.kinds = .started(tape, ..)` and `.tape`; the count asked for first: Addon.zig's 48 machine lines are all in functions handed no core (hold 17, scan 11, mark 4, scanDir 3, readSmall 3, closeIdle 2, read 2, listed 2, fileOf, loadListed, unmark, crashedPath), 0 in one that holds it; a step reaches 29 of them through `need` (a kind's first pane, the session's: loadListed, mark, hold, closeIdle) and all 48 on a client's first plain kind (need -> plainOps -> scan), and the addon effect (Effect.perform's arm, not replaying) reaches the same 29 through readLoaded; none of these host halves asks the tape anything, the one question (`replaying`) sits above them in `need` and in perform's arm, so none took the tape, none is handed `&tape.none`, and none needed splitting: `need` is already the split (the step's question, then the host's body); the five numbers: (1) functions that gained the parameter 3 (row: 1 + 20); (2) the 97 per-operation counts within 0.1%, the largest image-frame on longline +0.0308% (the base's own spread); no function on a per-row or per-grapheme path gained it; (3) nothing stopped compiling for want of an io (no io moved: Addon's reads are libc); (4) global io uses 7 (6 and the tape's default, unchanged), free calls into the tape 80 -> 63 (count.py, a call on a `tape` parameter not counted), machine_lines rows unchanged; (5) lines changed: tests 4 (the take calls of three tests), code +41/-37 (with tape.zig's `pub` of diverge and the two import lines). Lines in files not this work's: none (no line in dev/, runtime/, core/replica.zig or test/). Gate: tui core-test 840/983 (143 skipped; Places' "a session's places loaded from its dump find what an edit makes as the session's do" failed once in the whole run, an edit's second crossing a clock second, and passed alone three times of three), shell-test 1018/1021, pane-test 183/184, term-test 15/15, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds 0 failures, process-test lspcomplete and lspcompletemoved (the base's; headersweep and headersweep-restored failed once and passed on the runner's retry), replicas --clients 5 diverged 0, unequal 0, deltas wrong 0 (2033/0, 1978/0, 1682/0), quiet 568/0, 581/0, 748/0, stops not at may_wait 0; its "corpus through a client" fails at steps 18 to 21 (the client's frame 34 or 35 cells otherwise than the own frontend's, row 20) on this change and on the base alike (pardes-entries with the rules' tests, run the same hour), so not this change's; gui unit-test 1616/1620 (the perf check's BaselineHarnessMismatch, the base's); daemon.py plain, --far, --games, --window-clients pass; a session recorded and replayed (test/cross_replay.py, tui to tui, private runtime directory): 28 digests agree in each of the three replicas; semantics 313a99190b93a8c5 (unmoved); frames (gpu/handle2-3 against tree1) 77/77 byte-identical in Debug, gui unit-test 1616/1620 there too, perfab corpus2x +0.083% (session noise 0.071%, threshold 0.4%), pictures identical in all 10 runs, perfops PASS
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Addon.zig')
-rw-r--r--core/Addon.zig13
1 files changed, 6 insertions, 7 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index 5c23ed51..d52462e0 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -21,7 +21,6 @@ const std = @import("std");
const Kind = @import("Kind.zig");
const dump = @import("dump.zig");
const pardes = @import("root.zig");
-const tape = @import("tape.zig");
const Pardes = pardes.Pardes;
const Why = Kind.Buf(160);
@@ -342,7 +341,7 @@ fn listed(data: []const u8, path: []const u8, n: usize, why: *Why) Loaded {
/// Kind `k`'s code, a session's (a replica's is `plainOps`'s or none): its
/// library loaded at the first pane of its kind, from the file the start
/// listed it from (`listed`); null, and why, when it will not load.
-pub fn need(r: *Kind.Registry, k: u8, why: *Why, distrusted: ?*const Distrusted) ?*const Kind.Ops {
+pub fn need(r: *Kind.Registry, tape: *pardes.tape.Tape, k: u8, why: *Why, distrusted: ?*const Distrusted) ?*const Kind.Ops {
if (r.ops[k] != null) return r.ops[k];
// A client's: its own code for a plain kind, loaded at its first pane.
if (tape.replaying()) {
@@ -612,7 +611,7 @@ pub fn leader(r: *const Kind.Registry, keys: []const u8) union(enum) { none, pre
/// `l` taken in, its words and extensions with it, or listed refused,
/// and why: collisions with the core's names and the kinds here
/// (`except`'s own looked past, a reload's old one).
-pub fn take(r: *Kind.Registry, l: Loaded, except: []const u8) ?[]const u8 {
+pub fn take(r: *Kind.Registry, tape: *pardes.tape.Tape, l: Loaded, except: []const u8) ?[]const u8 {
if (r.n == Kind.max_kinds) return "refused: no room for another kind";
const e = &r.kinds[r.n];
e.* = .{ .version = l.version, .abi = l.abi, .hash = l.hash, .caps = l.caps };
@@ -775,7 +774,7 @@ pub fn landed(p: *Pardes, op: Op, pane: u8, l: Loaded) void {
while (i < p.kinds.n) {
if (p.kinds.kinds[i].refused and std.mem.eql(u8, p.kinds.kinds[i].path.slice(), l.path)) p.kinds.drop(i) else i += 1;
}
- if (p.kinds.take(l, "")) |why| {
+ if (p.kinds.take(p.tape, l, "")) |why| {
if (l.why.len == 0) release(p, l.hash);
return p.reportFailure(id, std.fmt.bufPrint(&said, "Addon load: {s}: {s}", .{ base, why }) catch "Addon load: refused");
}
@@ -812,7 +811,7 @@ fn swap(p: *Pardes, l: Loaded, why: *Why) bool {
if (p.kinds.collides(l, name, &scratch)) |r| return fail(why, "{s}", .{r});
if (!std.mem.eql(u8, l.name, name)) return fail(why, "refused: its kind is now {s}, not {s}", .{ l.name, name });
const old_ops = p.kinds.ops[k];
- const new_ops: ?*const Kind.Ops = if (tape.replaying()) null else @ptrFromInt(l.ops);
+ const new_ops: ?*const Kind.Ops = if (p.tape.replaying()) null else @ptrFromInt(l.ops);
const gen = p.kinds.kinds[k].gen +% 1;
var fresh: [pardes.MAX_PANES]?*Kind.Slot = @splat(null);
defer for (fresh) |f| if (f) |s| {
@@ -857,7 +856,7 @@ fn swap(p: *Pardes, l: Loaded, why: *Why) bool {
};
const old_hash = p.kinds.kinds[k].hash;
p.kinds.drop(k);
- _ = p.kinds.take(l, "");
+ _ = p.kinds.take(p.tape, l, "");
p.kinds.kinds[p.kinds.n - 1].gen = gen;
release(p, old_hash);
return true;
@@ -899,7 +898,7 @@ test "addon reload gives migration the old record version and saves the new vers
var old = std.mem.zeroInit(Kind.Ops, .{ .head = std.mem.zeroInit(Kind.c.pa_head, .{ .size = @sizeOf(Kind.c.pa_head), .abi = Kind.abi, .version = 1 }), .open = Fake.open, .paint = Fake.paint, .dump = Fake.save, .load = Fake.load });
@memcpy(old.head.name[0..7], "migrate");
var words: [64]LoadedWord = undefined;
- try std.testing.expect(p.kinds.take(loadedOf(&old, "test.so", @splat(0), &words), "") == null);
+ try std.testing.expect(p.kinds.take(p.tape, loadedOf(&old, "test.so", @splat(0), &words), "") == null);
const pane = try Kind.open(p, 1, p.kinds.byName("migrate").?, null, null);
var new = old;
new.head.version = 2;