diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 23:58:17 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 23:58:22 -0300 |
| commit | 6cb805ff4989af6dfef7426a96b3abb4c22e3a0a (patch) | |
| tree | 03626c267644c9153ae72a8630927eb63790275c /test | |
| parent | 544eee368537eea98e7552e730948c2c8fb380e9 (diff) | |
| download | pardes-6cb805ff4989af6dfef7426a96b3abb4c22e3a0a.tar.gz pardes-6cb805ff4989af6dfef7426a96b3abb4c22e3a0a.zip | |
replica: an addon's landing is on the tape, and a client on the session's machine runs a kind loaded by path from that path while its bytes are the session's (P51): `Addon load <path>` typed in a session with any client attached parted every client (core/Effect.zig ran `Addon.perform` inside the core's pump entry, where the nested `update(.addon)` is no recorded input (core/tape.zig `enterInput` records none on the core's side) and a replay skipped the perform: the session's core took the kind, no client's did); the perform is now a recorded value call of the core's (`p.tape.value(.landing, Addon.perform, ...)`, `Site.landing` at the end of the tape's sites: the tape's shape and so `wire.semantics` change, the wire's version does not), its event recorded inside it and applied by a replay, a speculation waiting for the session's (`authorityOnly`); and `Addon.plainOps`, after a client's own addons, reads the library at the kind's path (its own copy, head and init as a load's) and runs it when its BLAKE3 is the one the session lists, else lets it go and the pane shows the kind's line, which now says so (core/Kind.zig `draw`); nothing is fetched over the link and no bytes the session sent are run; test/panes.zig: a session's `Addon load` of the image addon at a temporary path lands on its in-process client with no divergence (it diverged before), the client's picture pane runs the kind's code from that path (it fails with the path load taken out), and a client joining after the file was written over (one byte more) shows its line; the corpus through a client window (PARDES_PAIR, terminals by bytes) now runs to its end, 77 frames, 68 byte-identical to tree3's (63 the veil, 64-65 the snake loaded and its first frame, 75-76 the 2x display), 66-74 the snake's own pictures four animation steps ahead (the session's clock, not a client's: the same in two runs); the own window through the same prefix 77/77
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/panes.zig | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index 38eb0a71..0a5b4eeb 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -4316,6 +4316,61 @@ const PdfAddon = struct { try std.testing.expect(a.core.panes[c.id] == null and win.core().panes[c.id] == null); try std.testing.expect(win.diverged == null); } + + test "Addon load <path> typed in a session lands on its client too, which runs the kind from that path while its bytes are the session's and shows its line once they are not" { + const R = pardes.replica; + const gpa = std.testing.allocator; + const io = std.testing.io; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const r = try R.Replica.init(gpa, 1, try a.unit(0, 0), false); + defer r.deinit(); + const Land = struct { + a: *R.Authority, + r: *R.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }; + const land: Land = .{ .a = a, .r = r }; + // The image addon at a path of its own, in no addons directory. + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const lib = try std.Io.Dir.cwd().readFileAlloc(io, addons.image, gpa, .limited(256 << 20)); + defer gpa.free(lib); + try tmp.dir.writeFile(io, .{ .sub_path = "libpic.so", .data = lib }); + try tmp.dir.writeFile(io, .{ .sub_path = "dot.ppm", .data = "P6\n1 1\n255\n\x01\x02\x03" }); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(io, &buf)]; + var line: [4200]u8 = undefined; + try land.step(.{ .command = try std.fmt.bufPrint(&line, "Addon load {s}/libpic.so", .{dir}) }); + try std.testing.expect(r.diverged == null); + try std.testing.expect(a.core.kinds.byName("image") != null and r.core().kinds.byName("image") != null); + // A picture: the client runs the kind from the session's path. + try land.step(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/dot.ppm", .{dir}) }); + try jobs(a.core, land); + const id = for (a.core.panes, 0..) |slot, i| { + if (slot) |pane| if (pane.addon != null) break i; + } else return error.NoPicture; + try std.testing.expect(r.core().panes[id].?.addon.?.ops != null); + r.settle(); + try std.testing.expect(r.diverged == null); + // The file written over since (one byte more): a client joining + // now finds other bytes there and shows the kind's line. + const longer = try std.mem.concat(gpa, u8, &.{ lib, "\x00" }); + defer gpa.free(longer); + try tmp.dir.writeFile(io, .{ .sub_path = "libpic.so", .data = longer }); + const was = pardes.tape.on; + pardes.tape.on = &a.t; + const bytes = try pardes.dump.byteDump(a.core); + pardes.tape.resync(&a.t); + pardes.tape.on = was; + defer a.core.gpa.free(bytes); + const late = try R.Replica.initDump(gpa, 2, 0, bytes, .{ .cols = 80, .rows = 24 }); + defer late.deinit(); + try std.testing.expect(late.loaded(pardes.tape.digestOf(a.core))); + try std.testing.expect(late.core().panes[id].?.addon.?.ops == null); + } }; test { |
