From 9c66cdc9049b49f128336dcf5046e2bb1321e281 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 02:31:55 -0300 Subject: kinds #5, ABI 2 and the seam: src/kinds/pardes_addon.h is ABI 2 as architecture ยง16.9 has it (pa_window 24 bytes and no art bytes, pa_placement 80 with at, from and dirty_y/dirty_h and no stride, pa_word 32 with no size and PA_WORD, tick(st, now_ns, flags) with PA_FOCUSED, PA_OK and the conventions, the dump and load rules, pa_put with attrs, pa_copy and PA_POD, whose fragment gcc -Werror refused as written and is ternaries here) and fake.c and image's table speak it; tick is called at its deadline and once after open, a taken key or click, a word, a job's answer, a load and a change of PA_FOCUSED (the pane has the keyboard in some view, its window focused), nextWake folds the deadlines, and a Debug build hashes the kind's allocations across paint and panics naming it; paint runs once a frame, the slot keeps its prefix and whether it placed a picture, the tag is that prefix, the core's art words when it did and the path, and a frame that changes it owes a step to lay the tag out again; Addon load and reload are an addon effect the host performs (memfd, BLAKE3, dlopen, the head checks and init, the bytes a process holds shared and counted) answered by an addon event carrying what the library brings as data, whose update does the collisions, the reload's validate-then-swap at a new generation and the waiting panes deterministically, while unload is the update's alone and lets the library go by effect; a kind's job is Effect.job run on the host's workers (host_io.KindJob: tui and gui on Io.concurrent, macOS and tests on the loop) answered by Event.job, stale generations dropped and a library closed after its last job; each core has its own Registry (16 kinds, their words, leaders and extensions, digested and dumped; their code a local side array a replica has none of), so a test session no longer unloads the world and Restore and -l keep the process's kinds; every call into a kind whose answer the core acts on is taped as an Outcome (its answer, refusal, message, Look, text pane) and the prefix a step reads is taped too, so a replica's core, which runs no kind's code, steps alike; a pane of a kind on a replica is a Shadow drawn from the authority's frames, painted for the peer's view and sent by Screens as row hashes with the rows that changed and each raster once a key (screen_state.Shadow), its keys going to the authority; the tail, reload and the Addon word and event are Addon.zig's, the slot's record dump.zig's, a tail word's run exec.zig's; --addon-test gains focus, blur, dump, body, ctl and the window line, its jobs done as a host does them; fake.out gains its window line, loses a body row once the tag carries the art words and lands FakeJob at once; tests rewritten: the image dump test (the replica-style load keeps the record), the Petscii/Palette/Ascii tag test in ctl.zig and test/panes.zig's image tag test (a picture decoded and shown first), fs_namespace's decode test (the job performed as a host would), Kind.zig's registry test and Addon.zig's crash-mark test, the addons suite's ABI numbers; new: a job under way across a reload (T1), a Shadow's frame codec, and a replica with no code for a kind showing its pane and passing its keys; gates: core-test 958/958 and behaviour-test 249/249 on both, unit-test 1490/1491 tui and 1533/1534 gui, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed on both, addon-test ok, hxdiff 19 and hxparity 6 mismatches by the base's names, hxgolf 0, replicas, gui-golden, monkey-gui, daemon.py main and window-clients, soak local pass, perf medium within 1% of the base 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/ninep/ctl.zig | 34 ++++++++++++++++++++-------------- src/ninep/tree.zig | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src/ninep') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index a65b3562..78fe15c1 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -527,7 +527,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? const here = if (std.meta.stringToEnum(Builtin, word)) |b| builtins.registry.here(p, b) else false; const b = (if (here) std.meta.stringToEnum(Builtin, word) else null) orelse { // An addon's word: its kind's to take or refuse as it runs. - if (pardes.Kind.word(word) != null) return null; + if (p.kinds.word(word) != null) return null; // A setting this build's frontend cannot show (Lift, GripWidth on a // terminal, the window's own words in a terminal's view) is known, // and says so rather than sound misspelt. @@ -898,12 +898,12 @@ fn writeCommands(p: *const Pardes, w: *std.Io.Writer) !void { try w.writeByte('\n'); } // The addons' words, after the core's: `(addon )` says whose. - for (pardes.Kind.wordsOf()) |kw| try w.print("{s}{s} {s} -- {s} (addon {s})\n", .{ - std.mem.span(kw.w.name), - if (kw.w.arg != pardes.Kind.c.PA_ARG_NONE) " arg" else "", - if (kw.w.opens != 0) "both" else "pane", - if (kw.w.doc == null) "" else std.mem.span(kw.w.doc), - pardes.Kind.headName(kw.ops), + for (p.kinds.words[0..p.kinds.nwords]) |*kw| try w.print("{s}{s} {s} -- {s} (addon {s})\n", .{ + kw.name.slice(), + if (kw.arg != pardes.Kind.c.PA_ARG_NONE) " arg" else "", + if (kw.opens != 0) "both" else "pane", + kw.doc.slice(), + p.kinds.kinds[kw.kind].nameOf(), }); } @@ -1536,7 +1536,7 @@ test "an address looked at in an image pane names the image, never an empty subj const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); const id = p.freeSlot().?; - const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null); _ = wr(p, Node.of(doc.serial, .look), ":/x/\n"); try testing.expect(th.logHas(p, "look: /tmp/pardes-pic.ppm is no text to address")); } @@ -1545,7 +1545,7 @@ test "Save and Save path on an image pane are refused with why, never a silent s const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); const id = p.freeSlot().?; - const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null); for ([_][]const u8{ "Save\n", "Save /tmp/pardes-copy.ppm\n" }) |line| { const r = wr(p, Node.of(doc.serial, .ctl), line); try testing.expectEqual(Status.err, r.reply.status); @@ -1575,7 +1575,13 @@ test "a builtin for one kind of pane is refused on another, and still acts on it try testing.expectEqual(Status.err, wr(p, Node.of(serial, .ctl), line).reply.status); }; const id = p.freeSlot().?; - const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + // A picture shown: the core's art words follow the kind's prefix. + pardes.image.start(testing.io, testing.allocator); + defer pardes.image.stop(); + const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03"); + while (p.nextEffect()) |e| p.perform(e); + pardes.exec.placeNew(p, 0, 0, id, .doc); + _ = try p.render(p.scratch.allocator()); const r = wr(p, Node.of(doc.serial, .ctl), "Mode\n"); try testing.expectEqualStrings("Mode: only a text or terminal pane has modes", r.reply.ename); const glyphs = doc.addon.?.art.glyph; @@ -2149,7 +2155,7 @@ test "a language server question that finds nothing, cannot be answered, or is a try testing.expectEqual(@as(u16, 0), p.fs.late_failure_len); // An image's body takes no write. const slot = p.freeSlot().?; - const img = try pardes.Kind.open(p, slot, &pardes.image.kind, "/tmp/pardes-no-such.png", "not a png"); + const img = try pardes.Kind.open(p, slot, pardes.Kind.image, "/tmp/pardes-no-such.png", "not a png"); try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno()); } @@ -2791,7 +2797,7 @@ test "a Save whose directory is missing because one above refuses says permissio test "a body write to an image pane says its body takes none, not that terminals have no text" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null); try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename); } @@ -2821,7 +2827,7 @@ test "a Rename that reaches other files previews them, says so, and is the pane test "Edit on an image pane is refused as a data write there is, EINVAL, before it runs" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null); const edit = wr(p, Node.of(doc.serial, .ctl), "Edit ,d\n"); const data = wr(p, Node.of(doc.serial, .data), "x"); try testing.expectEqual(E.INVAL, edit.errno()); @@ -2832,7 +2838,7 @@ test "Edit on an image pane is refused as a data write there is, EINVAL, before test "Petscii, Palette and Ascii take the state their tag word names, set rather than flipped" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); + const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null); const ctl_node = Node.of(doc.serial, .ctl); for ([_][]const u8{ "Petscii on\n", "Petscii on\n" }) |line| { try testing.expectEqual(Status.ok, wr(p, ctl_node, line).reply.status); diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 9c3de708..4f155b4f 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1113,7 +1113,7 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { }, .addons => addons: { var text: std.ArrayList(u8) = .empty; - pardes.Kind.list(p, &text, p.scratch.allocator()) catch break :addons Reply.fail(req.tag, E.NOMEM); + pardes.Addon.list(p, &text, p.scratch.allocator()) catch break :addons Reply.fail(req.tag, E.NOMEM); break :addons window(p, req, text.items); }, .dumps => dumps: { -- cgit v1.3