diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 23:57:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 00:29:40 -0300 |
| commit | 137be286869241d19ea60ecb7737957d861162d7 (patch) | |
| tree | 854878c3a2152195b95d6b469c011db5a0d7e6a7 /src/kinds | |
| parent | 9b20d00ca5ffbab640b87249d65e4165414d22c1 (diff) | |
| download | pardes-137be286869241d19ea60ecb7737957d861162d7.tar.gz pardes-137be286869241d19ea60ecb7737957d861162d7.zip | |
kinds: a PA_PLAIN kind runs in the client that shows it (the games and veil): its head says its whole state is the one block its open allocates, plain bytes changed only by its calls, each a function of the block and what the call is handed (no statics, clock, randomness or file of its own; tick is not told PA_FRAMED); the core keeps the block (Kind.Slot.plain, the core's memory, a client's rollback epoch, which the copy saves) and its hash after each call is the call's taped outcome and in the digest (Slot.state), so a client whose block came out otherwise is caught at that call, joins again, and runs the session's frames of it from then (Addon.distrust); a client loads its own code for the kind by name, version, ABI and functions (Addon.plainOps; its scan only when the session has one), opens each such pane from the session's block byte for byte (dump.plainHere; the block is the dump's record, the kind's load given it at a Restore alone), speculates its keys, mouse and the tick after them, and draws it; one without the addon draws a line saying so; the session sends no Shadow for these panes; snake, life, snake_shader and veil say PA_PLAIN; test/liar.zig, a kind whose tick reads the clock; test/daemon.py --games: snake and life focused in two clients while a third types text for 30 s, keys stopped 0 and 0 of 451 and 450 (the base: 33 of 36 stopped in a tty client), rollbacks 385, 345, 366, every digest agreed, and the liar caught at its tick, its client joined again once and agreed; the GPU snake focused in a window client (offscreen) of a terminal's session and of a window's steps every 200 ms (2, 3, 4, 5, 7, 8, 9, 10, 12, 13), keys stopped 0 of 27, its digest agreed; the snake_shader's load tidying hover and timers made a client's block another than the session's at the first tick, caught so, hence the block itself in the dump; running.typ says a plain addon runs in a client; perf --only medium --reps 10 instructions:u 2,459.25M (base) -> 2,459.23M, --terminal-mib 8 3,928.50M -> 3,928.50M; tui core-test 811/950 (139 skipped), shell-test 993/996, pane-test 180/181, replicas pass (diverged 0, checked/wrong 0), behaviour-test 269/273 (the four addon ABI tests the base fails), --replay 20 seeds 0 failures, addon-test 157/157 steps 5/5, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's; winch failed once under load and passes alone), test/daemon.py, --far and --games pass; gui unit-test 1582/1590 (the base's), the frame corpus 77/77 against mbase, test/daemon.py --window-clients passes (its PDF window case skipped: no pdf.so built)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/kinds')
| -rw-r--r-- | src/kinds/addon.zig | 6 | ||||
| -rw-r--r-- | src/kinds/pardes_addon.h | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig index 54f26893..557547f6 100644 --- a/src/kinds/addon.zig +++ b/src/kinds/addon.zig @@ -45,7 +45,9 @@ comptime { /// `ctl`; `leader` is the keys after Space that run it ("ng": SPC n g). pub const Word = struct { name: [:0]const u8, leader: ?[:0]const u8 = null, arg: enum(u8) { none, optional, required } = .none, opens: bool = false, doc: [:0]const u8 = "" }; /// `pictures`: its panes place pictures, and their tag says how they show. -pub const Head = struct { name: []const u8, version: u32, exts: [:0]const u8 = "", words: []const Word = &.{}, pictures: bool = false }; +/// `plain`: PA_PLAIN, the kind is its extern struct and its step pure (the +/// header says what that promises): a client runs it itself. +pub const Head = struct { name: []const u8, version: u32, exts: [:0]const u8 = "", words: []const Word = &.{}, pictures: bool = false, plain: bool = false }; /// pardes's side, kept from init: about the pane of the current call. pub var api: *const c.pa_api = undefined; @@ -352,7 +354,7 @@ pub fn ops(comptime T: type) c.pa_ops { if (T.head.name.len > 15) @compileError(@typeName(T) ++ "'s name " ++ T.head.name ++ " is over 15 bytes"); var name: [16]u8 = @splat(0); @memcpy(name[0..T.head.name.len], T.head.name); - var o: c.pa_ops = .{ .init = F.init, .open = F.open, .paint = F.paint, .head = .{ .size = @sizeOf(c.pa_head), .abi = c.PA_ABI, .name = name, .version = T.head.version, .flags = if (T.head.pictures) c.PA_PICTURES else 0, .exts = T.head.exts, .words = &F.words, .nwords = F.words.len } }; + var o: c.pa_ops = .{ .init = F.init, .open = F.open, .paint = F.paint, .head = .{ .size = @sizeOf(c.pa_head), .abi = c.PA_ABI, .name = name, .version = T.head.version, .flags = (if (T.head.pictures) c.PA_PICTURES else 0) | (if (T.head.plain) c.PA_PLAIN else 0), .exts = T.head.exts, .words = &F.words, .nwords = F.words.len } }; // The kind's function, then the pa_ops field its wrapper fills. const fns = .{ .{ "close", "close" }, .{ "tick", "tick" }, .{ "prefix", "tick" }, .{ "view", "view" }, .{ "key", "key" }, diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h index 9c101fee..586b03d3 100644 --- a/src/kinds/pardes_addon.h +++ b/src/kinds/pardes_addon.h @@ -275,6 +275,20 @@ typedef struct pa_tick { /* head.flags: its panes show pictures, and the core says how in their tag * (`petscii:on palette:commodore ascii:off`, Petscii, Palette, Ascii). */ #define PA_PICTURES 0x1u +/* head.flags: its state is plain and its step pure. The kind's whole state + * is the one block its `open` allocates with api->alloc (any other alloc + * is refused): bytes with no pointer or handle in them, changed only by its + * calls, each a function of the block and what the call is handed (no + * statics, no clock, randomness or file of its own: the time is tick's + * `now`, a seed api->seed's; tick is never told PA_FRAMED, a frame being + * one view's). pardes keeps the block where its own state is (its digest, a + * client's rollback copy) and dumps it as it is, `dump` uncalled and `load` + * given it at a Restore; so a client of the session runs the kind itself + * from the session's very bytes, its keys at once + * and its pictures its own, and a client without the addon shows a line. + * A kind that breaks the promise is caught: the client's state is not the + * session's, and it joins again without the kind. */ +#define PA_PLAIN 0x2u typedef struct pa_head { uint32_t size, abi; |
