summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 15:52:33 -0300
committerGabriel Schneider <[email protected]>2026-11-19 15:52:33 -0300
commit8fea4ab90a04acd5f20528b00342c23d42f8c83e (patch)
treebe264d2cd8ba57492e227d9d6a65027f3d7680c9 /core
parent553a62bac675bfc0a64254718488d3c8012f533e (diff)
parentee2e79dea10c93c104b70cf1eedccd7ba85003fc (diff)
downloadpardes-8fea4ab90a04acd5f20528b00342c23d42f8c83e.tar.gz
pardes-8fea4ab90a04acd5f20528b00342c23d42f8c83e.zip
integration: the soak on the real session loop and the cli's serve thread joined, with the tape's handle through the kinds, the core's own files and the small ones: pardes-runners-d (10c's last changes) and pardes-handle-2 (the handle's steps 3 to 5 and its two rules as tests), merged without a conflict; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/Addon.zig13
-rw-r--r--core/Core.zig33
-rw-r--r--core/File.zig2
-rw-r--r--core/Kind.zig60
-rw-r--r--core/Messages.zig12
-rw-r--r--core/Output.zig6
-rw-r--r--core/Plumb.zig3
-rw-r--r--core/Query.zig6
-rw-r--r--core/Store.zig2
-rw-r--r--core/Stream.zig2
-rw-r--r--core/builtins.zig6
-rw-r--r--core/dump.zig6
-rw-r--r--core/mouse.zig2
-rw-r--r--core/ninep/events.zig2
-rw-r--r--core/ninep/tree.zig2
-rw-r--r--core/tape.zig118
16 files changed, 196 insertions, 79 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;
diff --git a/core/Core.zig b/core/Core.zig
index b4745b24..769d16cd 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -514,16 +514,17 @@ pub const perform = @import("Effect.zig").perform;
/// second copy of this drifted once, leaving restored tags without an
/// allocator and every 9P mtime 0.
pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
+ // The global still set beside the field (P20): a core made while
+ // a tape records (PARDES_RECORD, a replica's step) is its.
+ const tape = opts.tape orelse pardes.tape.on orelse &pardes.tape.none;
const p = try gpa.create(Pardes);
p.* = .{
.gpa = gpa,
.image_gpa = opts.image_allocator orelse gpa,
- .kinds = .started(opts.addons),
+ .kinds = .started(tape, opts.addons),
.tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa,
.opts = opts,
- // The global still set beside the field (P20): a core made while
- // a tape records (PARDES_RECORD, a replica's step) is its.
- .tape = opts.tape orelse pardes.tape.on orelse &pardes.tape.none,
+ .tape = tape,
.tty_toggle = opts.tty_toggle,
.views = .{ View{
.frontend = .{ .windowed = opts.windowed },
@@ -710,7 +711,7 @@ pub fn recentGpa(_: *const Pardes) std.mem.Allocator {
pub fn loadRecent(p: *Pardes) void {
// A replica's Recent is its own, in memory: the recording session's
// state file is every session's of its user (core/tape.zig).
- if (pardes.tape.replaying()) p.db.kind = .off;
+ if (p.tape.replaying()) p.db.kind = .off;
p.db.readRecent(p);
}
@@ -773,11 +774,11 @@ pub fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col:
/// reads them: its process's options, so the authority's
/// (`tape.authority`); a replica's are its own process's.
pub fn configDir(p: *Pardes) ?[]const u8 {
- return pardes.tape.authority(optsConfigDir, .{p});
+ return p.tape.authority(optsConfigDir, .{p});
}
pub fn startupPath(p: *Pardes) ?[]const u8 {
- return pardes.tape.authority(optsStartupPath, .{p});
+ return p.tape.authority(optsStartupPath, .{p});
}
fn optsConfigDir(p: *Pardes) ?[]const u8 {
@@ -792,7 +793,7 @@ fn optsStartupPath(p: *Pardes) ?[]const u8 {
/// in scratch. Recent is the authority's (every window of its user
/// writes it): a replica has its answer (`tape.authority`).
pub fn recentByHash(p: *Pardes, hash: u64) ?recent_files.Entry {
- return pardes.tape.authority(recentFound, .{ p, hash });
+ return p.tape.authority(recentFound, .{ p, hash });
}
fn recentFound(p: *Pardes, hash: u64) ?recent_files.Entry {
@@ -926,7 +927,7 @@ fn reportFocus(p: *Pardes) void {
// session's step makes the write, off the tape on both sides
// (tape.hostCall's pty_write), so the switch shows at once and the
// program hears of it a round trip later.
- if (pardes.tape.speculating() and pardes.tape.screenState()) return;
+ if (p.tape.speculating and p.tape.screen_state) return;
if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
@@ -1360,7 +1361,7 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void {
// The script is there; the program its `#!` names is not.
var said: pardes.Kind.Buf(320) = .{};
var interp: [256]u8 = undefined;
- const name = pardes.tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
+ const name = p.tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
p.reportFailure(id, if (name) |n| said.print("shell: interpreter {s} not found", .{n}) else "shell: interpreter not found");
} else {
p.reportError(id, "shell", err);
@@ -1744,15 +1745,15 @@ fn fsReport(p: *Pardes) void {
pub fn readSessionFacts(p: *Pardes) void {
// A dump made since carries them all: its shell is never empty.
if (p.session_shell_len != 0) return;
- if (p.session_dir_len == null) if (pardes.tape.value(.env, processDir, .{&p.session_dir})) |dir| {
+ if (p.session_dir_len == null) if (p.tape.value(.env, processDir, .{&p.session_dir})) |dir| {
std.mem.copyForwards(u8, &p.session_dir, dir);
p.session_dir_len = @intCast(dir.len);
};
- if (pardes.tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
+ if (p.tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
@memcpy(p.session_home[0..home.len], home);
p.session_home_len = @intCast(home.len);
};
- const shell = pardes.tape.value(.env, config.defaultShell, .{});
+ const shell = p.tape.value(.env, config.defaultShell, .{});
const kept = shell[0..@min(shell.len, p.session_shell.len)];
@memcpy(p.session_shell[0..kept.len], kept);
p.session_shell_len = @intCast(kept.len);
@@ -1955,7 +1956,7 @@ pub fn sync(p: *Pardes) void {
// A directory pane's entries follow its width, as acme's
// columns do (Dir.fit).
if (pane.file) |file| if (file.listing != null and r.h > pane.tag_rows) pardes.panes.Dir.fit(p, pane, pane.cols);
- if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, pardes.tape.value(.prompt, struct {
+ if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, p.tape.value(.prompt, struct {
fn ready(at: *const Pane) bool {
return pardes.Term.prompt(at.terminal).input_ready;
}
@@ -1967,7 +1968,7 @@ pub fn sync(p: *Pardes) void {
// its shell's FIRST prompt, or never: typed later it would land
// in whatever runs then, or in the middle of a line someone
// typed (Pane.greeting).
- if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (pardes.tape.value(.prompt, Pane.greeting, .{pane})) {
+ if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (p.tape.value(.prompt, Pane.greeting, .{pane})) {
.wait => {},
.never => pane.greet = false,
.now => {
@@ -2103,7 +2104,7 @@ fn advanceInner(p: *Pardes, now_ns: u64) void {
// The session's ticks are the recording session's: a picture still
// decoding or a fade still moving asks for frames the way a message
// waiting to go does, and a replica that draws nothing has none.
- while (pardes.tape.value(.wake, nextWake, .{p})) |due| {
+ while (p.tape.value(.wake, nextWake, .{p})) |due| {
if (due > now_ns) break;
// Only waiting until `due`: its counters move there at once.
const held = (due - p.clock.stepped_ns) / frame;
diff --git a/core/File.zig b/core/File.zig
index 09dc44f1..820447ac 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -779,7 +779,7 @@ fn edit(p: *Pardes, f: *State, off: usize, len: usize, bytes_in: []const u8, who
f.saved_revision = f.revision;
};
// The clock the session that recorded read (core/tape.zig).
- f.mtime = pardes.tape.value(.mtime, pardes.ctlfs.events.now, .{});
+ f.mtime = p.tape.value(.mtime, pardes.ctlfs.events.now, .{});
if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights);
f.highlights = &.{};
f.highlight_start = 0;
diff --git a/core/Kind.zig b/core/Kind.zig
index 2bf8e9fb..13ef8edd 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -19,7 +19,6 @@ const builtin = @import("builtin");
pub const c = @import("pardes_addon");
const pardes = @import("root.zig");
const walk = @import("walk.zig");
-const tape = @import("tape.zig");
const surface = @import("surface.zig");
const views = @import("views.zig");
const Addon = @import("Addon.zig");
@@ -104,10 +103,10 @@ pub const Registry = struct {
nexts: u8 = 0,
ops: [max_kinds]?*const Ops = @splat(null),
- /// What the scan at start found.
- pub fn started(found: []const Loaded) Registry {
+ /// What the scan at start found, taken on `tape` (a replica's holds no code).
+ pub fn started(tape: *pardes.tape.Tape, found: []const Loaded) Registry {
var r: Registry = .{};
- for (found) |l| _ = r.take(l, "");
+ for (found) |l| _ = r.take(tape, l, "");
return r;
}
@@ -297,25 +296,25 @@ pub fn openFile(p: *Pardes, id: usize, k: u8, path: []const u8) !*Pane {
/// The slot's kind state made (`open`, then `load` with its record, or
/// `address` with its place and its words' last values): its refusal,
/// if the kind refused, in `slot.refused`. One call for both cores.
-pub fn reopen(p: ?*Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool {
+pub fn reopen(p: *Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool {
// A replica has no kind's code: what the open says is the authority's.
- if (tape.authorityOnly("a kind's open")) return false;
+ if (p.tape.authorityOnly("a kind's open")) return false;
var cl: Call = .{ .p = p, .id = id, .slot = s };
const prev = cl.begin("open");
- if (p) |core| if (core.kinds.byName(s.nameOf())) |k| {
+ if (p.kinds.byName(s.nameOf())) |k| {
// Its code: its library loaded at the first pane of its kind.
- if (s.ops == null) s.ops = Addon.need(&core.kinds, k, &cl.refused, core.opts.distrusted);
+ if (s.ops == null) s.ops = Addon.need(&p.kinds, p.tape, k, &cl.refused, p.opts.distrusted);
// Its block made afresh by this open.
- if (core.kinds.kinds[k].caps.plain) {
+ if (p.kinds.kinds[k].caps.plain) {
if (s.plain) |b| if (b.len > 0) s.gpa.free(b);
s.plain = &.{};
}
var w: std.Io.Writer = .fixed(&s.tail.bytes);
w.writeAll(" Term") catch {};
- for (core.kinds.words[0..core.kinds.nwords]) |*kw| if (kw.kind == k and kw.opens == 0) w.print(" {s}", .{kw.name.slice()}) catch {};
+ for (p.kinds.words[0..p.kinds.nwords]) |*kw| if (kw.kind == k and kw.opens == 0) w.print(" {s}", .{kw.name.slice()}) catch {};
w.writeAll(" Collapse Del") catch {};
s.tail.len = @intCast(w.buffered().len);
- };
+ }
s.opened = if (bytes) |b| std.hash.Wyhash.hash(0, b) else 0;
// Its file not read (not here): it waits for it, a placeholder.
if (s.ops != null and bytes == null and s.path.len > 0) _ = cl.refused.print("{s} is not here", .{s.path}) else if (s.ops) |ops| {
@@ -346,7 +345,7 @@ pub fn reopen(p: ?*Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool {
if (s.record) |r| s.gpa.free(r);
s.record = null;
s.live = true;
- if (p) |core| poke(core, s);
+ poke(p, s);
return true;
}
@@ -397,7 +396,7 @@ pub fn close(p: *Pardes, pane: *Pane) void {
// A client's pane of a plain kind closed in a speculation: its kind's
// own memory (its pictures) is left be, as the rollback brings the pane
// back; the session's order closes it.
- const kept = s.plain != null and s.ops != null and s.ops.?.close != null and tape.authorityOnly("a kind's close");
+ const kept = s.plain != null and s.ops != null and s.ops.?.close != null and p.tape.authorityOnly("a kind's close");
if (!kept) {
var i: usize = 0;
while (i < ready.items.len) if (ready.items[i].draw == p and ready.items[i].serial == pane.serial) ready.orderedRemove(i).drop() else {
@@ -559,7 +558,7 @@ fn colorOf(v: u32, default: surface.Color) surface.Color {
pub fn prefix(p: *const Pardes, arena: std.mem.Allocator, pane: *const Pane) ![]const u8 {
const slot = pane.addon.?;
var buf: [400]u8 = undefined;
- return arena.dupe(u8, tape.value(.addon, prefixOf, .{ p, slot, &buf }));
+ return arena.dupe(u8, p.tape.value(.addon, prefixOf, .{ p, slot, &buf }));
}
fn prefixOf(p: *const Pardes, slot: *const Slot, buf: *[400]u8) []const u8 {
@@ -584,7 +583,7 @@ fn prefixOf(p: *const Pardes, slot: *const Slot, buf: *[400]u8) []const u8 {
pub fn key(p: *Pardes, id: usize, k: pardes.Key) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
if (!caps(p, slot).key) return false;
- if (!runsHere(slot) and tape.authorityOnly("a key into a kind's pane")) return true;
+ if (!runsHere(slot) and p.tape.authorityOnly("a key into a kind's pane")) return true;
const pk: c.pa_key = .{ .cp = k.cp, .ctrl = @intFromBool(k.ctrl), .alt = @intFromBool(k.alt), .shift = @intFromBool(k.shift), .view = p.live + 1 };
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("key");
@@ -608,7 +607,7 @@ pub fn takesKeys(p: *const Pardes, s: *const Slot) bool {
pub fn search(p: *Pardes, id: usize, pat: []const u8) ?[]const u8 {
const slot = (p.panes[id] orelse return null).addon orelse return null;
if (!caps(p, slot).search) return null;
- if (tape.authorityOnly("a kind's search")) return null;
+ if (p.tape.authorityOnly("a kind's search")) return null;
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("search");
if (slot.ops) |o| o.search.?(slot.st, pat.ptr, @intCast(pat.len));
@@ -624,7 +623,7 @@ pub fn address(p: *Pardes, id: usize, text: []const u8, said: *Buf(160)) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
// By its caps, not its code: a replica without it calls as the authority does.
if (!caps(p, slot).address) return false;
- if (tape.authorityOnly("a kind's address")) return true;
+ if (p.tape.authorityOnly("a kind's address")) return true;
var cl: Call = .{ .p = p, .id = id, .slot = slot, .missing = said };
const prev = cl.begin("address");
if (slot.ops) |o| cl.ret = o.address.?(slot.st, text.ptr, @intCast(text.len));
@@ -641,7 +640,7 @@ pub fn takesMouse(p: *const Pardes, s: *const Slot) bool {
pub fn mouse(p: *Pardes, id: usize, m: pardes.Mouse, col: u16, row: u16) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
if (!caps(p, slot).mouse) return false;
- if (!runsHere(slot) and tape.authorityOnly("the mouse in a kind's pane")) return true;
+ if (!runsHere(slot) and p.tape.authorityOnly("the mouse in a kind's pane")) return true;
const pm: c.pa_mouse = .{
.button = switch (m.button) {
.left => c.PA_LEFT,
@@ -684,8 +683,8 @@ pub fn step(p: *Pardes, due: bool) void {
// A kind's call is the authority's alone but a plain kind's here: a
// speculation's tick after a call into the pane waits with that call's
// input (it stopped there).
- const speculating = tape.speculating();
- if (speculating) for (p.panes) |pslot| if (pslot) |pane| if (pane.addon) |slot| if (slot.next_tick == 1 and !runsHere(slot)) return tape.poison("a kind's tick");
+ const speculating = p.tape.speculating;
+ if (speculating) for (p.panes) |pslot| if (pslot) |pane| if (pane.addon) |slot| if (slot.next_tick == 1 and !runsHere(slot)) return p.tape.poison("a kind's tick");
for (p.panes, 0..) |pslot, id| if (pslot) |pane| if (pane.addon) |slot| {
if (speculating and !runsHere(slot)) continue;
if (due and caps(p, slot).view) for (0..views.max) |k| {
@@ -875,7 +874,7 @@ pub fn ctl(p: *Pardes, id: usize, line: []const u8, reply: *[160]u8) ?[]const u8
const slot = (p.panes[id] orelse return "no such pane").addon orelse return "not a kind's pane";
if (!slot.live) return "its addon is not loaded";
if (!caps(p, slot).ctl) return "its kind takes no words";
- if (tape.authorityOnly("a kind's word")) return null;
+ if (p.tape.authorityOnly("a kind's word")) return null;
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("ctl");
@memset(reply, 0);
@@ -975,19 +974,20 @@ const Call = struct {
current = prev;
if (checked) overBudget(cl);
if (cl.quiet) return .{};
+ // One that is not quiet is a step's, made with its core.
+ const t = cl.p.?.tape;
var place: [32]u8 = undefined;
// A refused open closed its state: no `where` to ask.
const at: ?[]const u8 = if (cl.refused.len == 0) where(cl.slot, &place) else null;
// Hashed while it records or replays: no client, no cost.
- const state: u64 = if (tape.on == null) 0 else if (cl.slot.plain) |b| std.hash.Wyhash.hash(0, b) else 0;
- const o = tape.value(.addon, same, .{Outcome{ .state = state, .ret = cl.ret, .text = cl.refused.slice(), .said = cl.said.slice(), .err = cl.err, .look = cl.look.slice(), .pane_name = cl.pane_name.slice(), .pane_text = cl.pane_text, .exec = cl.exec.slice(), .selected = cl.selected, .rows = cl.rows, .prefix = cl.prefix, .where = at, .jobs = cl.jobs, .cancels = cl.cancels }});
+ const state: u64 = if (t.through) 0 else if (cl.slot.plain) |b| std.hash.Wyhash.hash(0, b) else 0;
+ const o = t.value(.addon, same, .{Outcome{ .state = state, .ret = cl.ret, .text = cl.refused.slice(), .said = cl.said.slice(), .err = cl.err, .look = cl.look.slice(), .pane_name = cl.pane_name.slice(), .pane_text = cl.pane_text, .exec = cl.exec.slice(), .selected = cl.selected, .rows = cl.rows, .prefix = cl.prefix, .where = at, .jobs = cl.jobs, .cancels = cl.cancels }});
if (o.where) |w| cl.slot.where_text.set(w);
// Run here, it came out otherwise than the session's: it broke its
// promise (PA_PLAIN), and the client joins again without it.
- if (cl.slot.ops != null and cl.slot.plain != null and tape.replaying() and o.state != state) {
+ if (cl.slot.ops != null and cl.slot.plain != null and t.replaying() and o.state != state) {
if (cl.p) |p| if (p.opts.distrusted) |d| d.add(cl.slot.nameOf());
- var why: Buf(160) = .{};
- tape.diverged(why.print("addon {s}: its state after {s} is not the session's (it breaks PA_PLAIN): the session's alone now", .{ cl.slot.nameOf(), cl.name }));
+ if (t.replay) t.diverge("addon {s}: its state after {s} is not the session's (it breaks PA_PLAIN): the session's alone now", .{ cl.slot.nameOf(), cl.name });
}
cl.slot.state = o.state;
// Its last job's token the session's, on a core whose kind asked
@@ -1120,7 +1120,7 @@ pub const api: c.pa_api = .{
const asked = std.mem.indexOfScalar(u32, &cl.jobs, 0) orelse return 0;
// A client's (a plain kind's code here) runs none: its token
// alone, as the session's; the answer comes on the tape.
- const free = if (tape.replaying()) null else for (&s.jobs) |*j| {
+ const free = if (cl.p.?.tape.replaying()) null else for (&s.jobs) |*j| {
if (j.* == null) break j;
} else return 0;
const copy = if (free != null) s.gpa.dupe(u8, if (in) |b| @as([*]const u8, @ptrCast(b))[0..n] else "") catch return 0 else "";
@@ -1317,7 +1317,7 @@ pub const test_kind = struct {
pub fn of(p: *Pardes) u8 {
if (p.kinds.byName("test")) |k| return k;
var words: [64]LoadedWord = undefined;
- _ = p.kinds.take(loadedOf(&ops, "", @splat(0), &words), "");
+ _ = p.kinds.take(p.tape, loadedOf(&ops, "", @splat(0), &words), "");
return p.kinds.n - 1;
}
};
@@ -1356,10 +1356,10 @@ test "a kind's head is checked before a core takes it, and a core's kinds are it
var a: Registry = .{};
var b: Registry = .{};
var words: [64]LoadedWord = undefined;
- try std.testing.expect(a.take(loadedOf(&ops, "", @splat(1), &words), "") == null);
+ try std.testing.expect(a.take(&pardes.tape.none, loadedOf(&ops, "", @splat(1), &words), "") == null);
try std.testing.expect(a.byName("zzzab") != null);
try std.testing.expect(b.byName("zzzab") == null);
- try std.testing.expectEqualStrings("refused: kind zzzab is here already", a.take(loadedOf(&ops, "", @splat(1), &words), "").?);
+ try std.testing.expectEqualStrings("refused: kind zzzab is here already", a.take(&pardes.tape.none, loadedOf(&ops, "", @splat(1), &words), "").?);
a.drop(a.byName("zzzab").?);
try std.testing.expect(a.byName("zzzab") == null);
}
diff --git a/core/Messages.zig b/core/Messages.zig
index de10b845..767eb297 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -111,9 +111,11 @@ pub const Message = struct {
}
pub fn stamp(buf: []u8, verb: []const u8, subject: []const u8) []const u8 {
- // The time of day as the session that said it read it, in its
- // zone: a replica's clock and TZ are its own (core/tape.zig).
- const clock = pardes.tape.value(.clock, timeOfDay, .{});
+ // The time of day of the host that stamps it, in its zone: only a
+ // host stamps a message (a file reloaded, a save, a language
+ // server's status), between steps, and the message it then hands
+ // the core (`setMessage`, an input) is what the tape carries.
+ const clock = timeOfDay();
const head = std.fmt.bufPrint(buf, "{s} {s} ", .{ &clock, verb }) catch return buf[0..0];
const room = buf.len - head.len;
const tail = if (subject.len <= room) subject else subject[subject.len - room ..];
@@ -161,7 +163,7 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void {
pane.msg_len = @intCast(n);
// The clock when it was said (the session clock is the last pump's,
// and a 9P write after an idle hour would say it an hour ago).
- pane.msg_said_ms = pardes.tape.value(.clock, nowMs, .{});
+ pane.msg_said_ms = p.tape.value(.clock, nowMs, .{});
p.needs_frame = true;
// New, the same line again or a status update: fresh, so it stays.
pane.msg_life = .{};
@@ -185,7 +187,7 @@ fn nowMs() i64 {
pub fn expireUnattended(p: *Pardes) void {
if (!p.unattended) return;
// The clock as the session that recorded read it (core/tape.zig).
- const now = pardes.tape.value(.clock, nowMs, .{});
+ const now = p.tape.value(.clock, nowMs, .{});
for (p.panes) |slot| {
const pane = slot orelse continue;
if (pane.msg_len == 0 and pane.msg_older_len == 0) continue;
diff --git a/core/Output.zig b/core/Output.zig
index 1395b06f..750baf8f 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -532,7 +532,7 @@ pub fn openJumps(p: *Pardes, id: usize) !void {
/// it (exec.operandAt), and a look at the line is the same (look.zig).
/// Asked of the authority: the state file is its host's.
pub fn openHistory(p: *Pardes, id: usize) !void {
- const text = pardes.tape.authority(dumpsText, .{p}) orelse return error.NoStateFile;
+ const text = p.tape.authority(dumpsText, .{p}) orelse return error.NoStateFile;
if (text.len == 0) return error.NoDumps;
var out: std.Io.Writer.Allocating = .init(p.gpa);
errdefer out.deinit();
@@ -723,7 +723,7 @@ pub fn openFonts(p: *Pardes, id: usize) !void {
if (builtins.capabilities.font_picker) {
// The session's machine's fonts, a question to its disk: a client's
// replay takes the session's answer, never its own.
- const content = try pardes.tape.site(.fonts, p.gpa, fontsListed, .{ p.gpa, p.scratch.allocator() });
+ const content = try p.tape.site(.fonts, p.gpa, fontsListed, .{ p.gpa, p.scratch.allocator() });
try openStepped(p, id, .{ .cmd = .Fonts }, content);
}
}
@@ -854,7 +854,7 @@ pub fn openConfig(p: *Pardes, id: usize) !void {
try p.locations_config.write(&located.writer);
try config.Runtime.writeReport(&out.writer, .{
.locations = located.written(),
- .default_dump_dir = pardes.tape.authority(dumpDirectory, .{@as([]u8, &dir_buf)}),
+ .default_dump_dir = p.tape.authority(dumpDirectory, .{@as([]u8, &dir_buf)}),
.startup_config_path = p.startupPath(),
.platform = builtins.viewPlatform(p),
.theme_name = p.theme().name,
diff --git a/core/Plumb.zig b/core/Plumb.zig
index a28ba5a8..fdb7ad8c 100644
--- a/core/Plumb.zig
+++ b/core/Plumb.zig
@@ -12,7 +12,6 @@ const fs = @import("fs.zig");
const look = @import("look.zig");
const layout = @import("layout.zig");
const Kind = @import("Kind.zig");
-const tape = @import("tape.zig");
const events = @import("ninep/events.zig");
const Regex = @import("regexp.zig").Regex;
const Pardes = pardes.Pardes;
@@ -901,7 +900,7 @@ pub fn send(p: *Pardes, from: ?usize, msg: Msg, seen: ?Seen) Sent {
// whom only the authority knows (its 9P opens); with none, what the
// rule set starts.
const i = port orelse return .done;
- if (tape.authority(portRead, .{ p, i })) {
+ if (p.tape.authority(portRead, .{ p, i })) {
fanOut(p, i, &m);
return .done;
}
diff --git a/core/Query.zig b/core/Query.zig
index e8011a1f..ce83a6ac 100644
--- a/core/Query.zig
+++ b/core/Query.zig
@@ -719,7 +719,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
.recent => {
var out: std.Io.Writer.Allocating = .init(gpa);
defer out.deinit();
- var lines = std.mem.splitScalar(u8, pardes.tape.authority(recentRows, .{ p, &out }), '\n');
+ var lines = std.mem.splitScalar(u8, p.tape.authority(recentRows, .{ p, &out }), '\n');
while (lines.next()) |ln| {
if (ln.len == 0) continue;
const rel = relative(ln, dir);
@@ -742,7 +742,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
// `(closed)` and dimmer (makeNameRows): Enter brings one back
// where it was. Its name alone is matched, not the word. The
// session's, which a replica has from the authority.
- for (pardes.tape.authority(Store.closedNames, .{p})) |c| {
+ for (p.tape.authority(Store.closedNames, .{p})) |c| {
var buf: [4096 + 48]u8 = undefined;
const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}" ++ closed_word, .{ c.serial, relative(c.name, dir) }) catch continue;
const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1;
@@ -1668,7 +1668,7 @@ fn displayPreview(p: *Pardes, qid: usize, path: []const u8, at: look.Spot) void
const f = &pane.file.?;
if (!std.mem.eql(u8, f.path, path)) {
if (exec.kindOf(p.tape, path)) |kind| if (kind != .file) return;
- const bytes = pardes.tape.site(.preview, p.gpa, filesystem.read, .{ p, path }) catch return;
+ const bytes = p.tape.site(.preview, p.gpa, filesystem.read, .{ p, path }) catch return;
if (std.mem.indexOfScalar(u8, bytes[0..@min(bytes.len, 8000)], 0) != null) {
p.gpa.free(bytes);
return;
diff --git a/core/Store.zig b/core/Store.zig
index 25b41bcb..0c46e7d9 100644
--- a/core/Store.zig
+++ b/core/Store.zig
@@ -192,7 +192,7 @@ pub fn closedBySerial(s: *const Store, serial: u32) ?*Closed {
/// load; the keyboard on it otherwise.
pub fn reopen(s: *Store, p: *Pardes, serial: u32, from: usize) bool {
// This session's: a replica has the authority's (`tape.authority`).
- const place = pardes.tape.authority(record, .{ s, serial }) orelse return false;
+ const place = p.tape.authority(record, .{ s, serial }) orelse return false;
const free = p.freeSlot() orelse {
p.reportError(from, "Panes", error.NoPaneSlots);
return false;
diff --git a/core/Stream.zig b/core/Stream.zig
index d5246211..2d7cd018 100644
--- a/core/Stream.zig
+++ b/core/Stream.zig
@@ -652,7 +652,7 @@ pub fn runHere(p: *Pardes, gen: u32) void {
// Its reads a site of the tape's (a 9P write's Grep or Find runs here):
// a replica takes the batches the session got, as it takes a worker's
// (Event.search), and reads no file.
- const batches = pardes.tape.site(.search, p.gpa, searchHere, .{ p.gpa, job });
+ const batches = p.tape.site(.search, p.gpa, searchHere, .{ p.gpa, job });
defer p.gpa.free(batches);
for (batches) |*b| {
receive(p, b);
diff --git a/core/builtins.zig b/core/builtins.zig
index a79e4b66..7add3d9c 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -494,7 +494,7 @@ pub const Restore = struct {
var full_buf: [4096]u8 = undefined;
var label_buf: [256]u8 = undefined;
const file = if (typed) |t| dump.restoreFile(c.p.tape, t, c.p.settings.dump_dir.get(), &full_buf) else null;
- const name = if (file) |path| path else pardes.tape.authority(pardes.Db.labelled, .{ &c.p.db, c.p, typed, @as([]u8, &label_buf) }) orelse {
+ const name = if (file) |path| path else c.p.tape.authority(pardes.Db.labelled, .{ &c.p.db, c.p, typed, @as([]u8, &label_buf) }) orelse {
var buf: pardes.Kind.Buf(320) = .{};
return c.p.reportFailure(c.id, if (typed) |t| buf.print("Restore: no dump labelled {s}", .{t}) else "Restore: no dump yet; name one");
};
@@ -593,7 +593,7 @@ pub const Mount = struct {
};
// A mount that cannot be reached is said now, and taken back, not
// found out by the first look through it.
- const reached = pardes.tape.site(.probe, null, @import("runtime").ninep_io.Client.probeMount, .{ c.p.gpa, dial });
+ const reached = c.p.tape.site(.probe, null, @import("runtime").ninep_io.Client.probeMount, .{ c.p.gpa, dial });
reached catch |err| {
if (c.p.fs.mounts.pop()) |gone| {
c.p.gpa.free(gone.name);
@@ -1182,7 +1182,7 @@ pub const Term = struct {
if (arg.len > 0) {
var why: [320]u8 = undefined;
// The authority's lookup, taped, as Shell's (exec.zig).
- if (pardes.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ arg[0..@min(arg.len, 200)], &why })) |refused| {
+ if (c.p.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ arg[0..@min(arg.len, 200)], &why })) |refused| {
var said: pardes.Kind.Buf(340) = .{};
return c.p.reportFailure(c.id, said.print("Term: {s}", .{refused}));
}
diff --git a/core/dump.zig b/core/dump.zig
index 4775ad63..6f143daa 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -499,7 +499,7 @@ fn loadImage(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: ?*
/// build's dump could not give): a terminal, a new emulator for its shell.
fn ensureKind(p: *Pardes, pane: *pardes.panes.Pane) !void {
if (pane.terminal != null or pane.file != null or pane.addon != null or pane.pdf != null) return;
- if (pardes.tape.authorityOnly("open a terminal")) return error.OutOfMemory;
+ if (p.tape.authorityOnly("open a terminal")) return error.OutOfMemory;
pane.terminal = try pardes.Term.open(pardes.panes.emulatorGpa(p.gpa), @max(1, pane.cols), @max(1, pane.rows));
}
@@ -572,7 +572,7 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
errdefer p.deinit();
// Its kinds are this process's, not the dump's: the session's it
// replaces, or what the scan found (a dump of another session's).
- p.kinds = if (previous) |old| old.kinds else .started(opts.addons);
+ p.kinds = if (previous) |old| old.kinds else .started(p.tape, opts.addons);
for (p.panes, on_disk, 0..) |slot, was_on_disk, i| if (slot) |pane| {
if (kept) |k| if (k[i] and pane.terminal != null) continue;
revivePane(p, i, pane, was_on_disk);
@@ -876,7 +876,7 @@ pub fn reviveSlot(p: *Pardes, id: usize, s: *Kind.Slot) void {
s.gen = p.kinds.kinds[k].gen;
// A replica has no code to read it for: the authority's outcome is taped.
// The authority's code may not be loaded yet: its open loads it.
- const bytes: ?[]u8 = if ((s.ops != null or !pardes.tape.replaying()) and s.path.len > 0) filesystem.read(p, s.path) catch null else null;
+ const bytes: ?[]u8 = if ((s.ops != null or !p.tape.replaying()) 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.views, s.focused };
if (!Kind.reopen(p, id, s, bytes)) {
diff --git a/core/mouse.zig b/core/mouse.zig
index 8e761453..6fb97787 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -974,7 +974,7 @@ pub fn reportRange(
chord_arg: ?[]const u8,
) bool {
const scripted = p.panes[id] orelse return false;
- if (!pardes.tape.authority(readsEvents, .{ p, id })) return false;
+ if (!p.tape.authority(readsEvents, .{ p, id })) return false;
const is_look = cmd == config.look_cmd;
const action: ctlfs.events.Action = if (is_look)
(if (on_tag) .tag_look else .body_look)
diff --git a/core/ninep/events.zig b/core/ninep/events.zig
index 2d539cca..1e740345 100644
--- a/core/ninep/events.zig
+++ b/core/ninep/events.zig
@@ -158,7 +158,7 @@ pub fn announce(p: *Pardes) void {
/// joined from a dump, is empty, and its step must not announce (taped
/// reads, Recent's) where the session's, booted long ago, does not.
fn bootFirst(p: *Pardes) void {
- if (newest(p) == null and !pardes.tape.replaying()) announce(p);
+ if (newest(p) == null and !p.tape.replaying()) announce(p);
}
/// Records `<kind> <serial> <name>`.
diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig
index 85723991..d5a6b2fe 100644
--- a/core/ninep/tree.zig
+++ b/core/ninep/tree.zig
@@ -1147,7 +1147,7 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply {
.sessions => sessions: {
if (comptime !daemon.supported) break :sessions stagedReply(p, req);
// Out of the turn: the daemon answers within 2 s, or not at all.
- const said = pardes.tape.site(.sessions, p.gpa, daemonList, .{p.gpa}) catch |err| break :sessions switch (err) {
+ const said = p.tape.site(.sessions, p.gpa, daemonList, .{p.gpa}) catch |err| break :sessions switch (err) {
error.OutOfMemory => Reply.fail(req.tag, E.NOMEM),
else => failText(req.tag, E.NOENT, "no pardes daemon answers"),
};
diff --git a/core/tape.zig b/core/tape.zig
index bb55ce5a..e0bc95e7 100644
--- a/core/tape.zig
+++ b/core/tape.zig
@@ -491,7 +491,9 @@ pub const Tape = struct {
return bytes;
}
- fn diverge(t: *Tape, comptime why: []const u8, args: anytype) void {
+ /// A replay came to another state than the authority's (`why`, the
+ /// first said): its replica joins again.
+ pub fn diverge(t: *Tape, comptime why: []const u8, args: anytype) void {
if (t.diverged != null) return;
t.diverged = std.fmt.allocPrint(t.gpa, why ++ " (tape byte {d}, in {s})", args ++ .{ t.in.at, t.applying }) catch why;
}
@@ -1009,6 +1011,14 @@ pub inline fn enter(p: ?*Pardes, input: Input) Entered {
// goes at the last step): every entry a safe build makes checks it.
// With none on, a client's core is entered between its steps (its own
// frame drawn, Replica.draw), its tape idle.
+ //
+ // The idle tape, the rule for the step that has this read the field
+ // (P20's last): a client's tape between its steps is neither replaying
+ // nor speculating, and its core is entered all the same (its frame);
+ // `enter` must not record into an idle replica's tape. Only a tape
+ // stepping its core records. The test "a client's frame drawn between
+ // its steps records nothing into its idle tape" (this file's end)
+ // fails when it does.
if (std.debug.runtime_safety) if (p) |core| if (if (on) |t| core.tape != t else core.tape.stepping())
@panic("tape: a core's field is not the tape being stepped (tape.on)");
const t = on orelse return .{};
@@ -1675,3 +1685,109 @@ test "a replay that finds no answer where its core reads one diverges, and the r
try std.testing.expect(t.diverged != null);
try std.testing.expect(!value(.denied, read, .{}));
}
+
+/// The functions of core/ that set `on` and leave a core's field be, each
+/// with why the field is that tape already.
+const sets_on_alone = [_]struct { []const u8, []const u8, []const u8 }{
+ .{ "tape.zig", "startFromEnv", "no core yet: the one made next takes `on` (Pardes.create)" },
+ .{ "tape.zig", "replayBytes", "its replay's core is made with this tape in its options (apply)" },
+ .{ "replica.zig", "begin", "Stepping: the core stepped holds this tape already (adoptCore), which `enter` checks in a safe build" },
+ .{ "replica.zig", "end", "Stepping: `on` put back as `begin` found it" },
+};
+
+/// The function a line of code declares, or null.
+fn declares(code: []const u8) ?[]const u8 {
+ var words = std.mem.tokenizeScalar(u8, code, ' ');
+ while (words.next()) |w| {
+ if (std.mem.eql(u8, w, "pub") or std.mem.eql(u8, w, "inline") or std.mem.eql(u8, w, "export")) continue;
+ if (!std.mem.eql(u8, w, "fn")) return null;
+ const rest = words.rest();
+ return rest[0 .. std.mem.indexOfScalar(u8, rest, '(') orelse return null];
+ }
+ return null;
+}
+
+test "every place that sets the global tape aside sets the core's field aside: a function of core/ that writes `on` writes a core's `tape` too, or is listed with why" {
+ const gpa = std.testing.allocator;
+ const io = std.testing.io;
+ var dir = try std.Io.Dir.cwd().openDir(io, "core", .{ .iterate = true });
+ defer dir.close(io);
+ var walker = try dir.walk(gpa);
+ defer walker.deinit();
+ var wrong: usize = 0;
+ var seen: [sets_on_alone.len]bool = @splat(false);
+ var writers: usize = 0;
+ while (try walker.next(io)) |e| {
+ if (e.kind != .file or !std.mem.endsWith(u8, e.basename, ".zig")) continue;
+ const src = try e.dir.readFileAlloc(io, e.basename, gpa, .limited(16 << 20));
+ defer gpa.free(src);
+ const own = std.mem.eql(u8, e.path, "tape.zig");
+ var name: []const u8 = "";
+ var sets_on = false;
+ var sets_field = false;
+ var in_test = false;
+ var lines = std.mem.splitScalar(u8, src, '\n');
+ while (true) {
+ const line = lines.next();
+ const text = line orelse "";
+ if (std.mem.startsWith(u8, text, "test ")) in_test = true;
+ if (in_test) {
+ if (std.mem.eql(u8, text, "}")) in_test = false;
+ if (line != null) continue;
+ }
+ const code = std.mem.trim(u8, text[0 .. std.mem.indexOf(u8, text, "//") orelse text.len], " \t");
+ const next = declares(code);
+ if (next != null or line == null) {
+ // The function before, judged.
+ if (sets_on) {
+ writers += 1;
+ const listed = for (sets_on_alone, 0..) |a, i| {
+ if (std.mem.eql(u8, a[0], e.path) and std.mem.eql(u8, a[1], name)) {
+ seen[i] = true;
+ break true;
+ }
+ } else false;
+ if (!sets_field and !listed) {
+ wrong += 1;
+ std.debug.print("core/{s}: {s} sets tape.on and no core's `tape`: put the core's field aside with it (as dumpRoundTrip does), or list it in tape.zig's sets_on_alone with why\n", .{ e.path, name });
+ }
+ }
+ if (line == null) break;
+ name = next.?;
+ sets_on = false;
+ sets_field = false;
+ }
+ // A core's field: `p.tape = `, never an options' (`opts.tape`).
+ if (std.mem.indexOf(u8, code, ".tape = ")) |at| if (!std.mem.endsWith(u8, code[0..at], "opts")) {
+ sets_field = true;
+ };
+ if (std.mem.indexOf(u8, code, "tape.on = ") != null) sets_on = true;
+ if (own) if (std.mem.indexOf(u8, code, "on = ")) |at| if (at == 0 or code[at - 1] == ' ') {
+ sets_on = true;
+ };
+ }
+ }
+ for (sets_on_alone, seen) |a, s| if (!s) {
+ wrong += 1;
+ std.debug.print("core/{s}: {s} is on sets_on_alone and sets no tape.on: delete its line\n", .{ a[0], a[1] });
+ };
+ try std.testing.expect(writers >= sets_on_alone.len + 3);
+ try std.testing.expectEqual(@as(usize, 0), wrong);
+}
+
+test "a client's frame drawn between its steps records nothing into its idle tape" {
+ const gpa = std.testing.allocator;
+ const p = try @import("ninep/testing.zig").withFile(gpa, "x\n");
+ defer p.deinit();
+ const bytes = try pardes.dump.dumpBytes(p);
+ defer p.gpa.free(bytes);
+ const r = try pardes.replica.Replica.initDump(gpa, 1, 0, bytes, .{ .cols = 80, .rows = 24 });
+ defer r.deinit();
+ // Between its steps: no tape on, its core's field its own tape, idle.
+ try std.testing.expect(on == null and r.core().tape == &r.t and !r.t.stepping());
+ const was = r.t.buf.items.len;
+ _ = r.draw(.{ .ctx = null, .f = null });
+ _ = r.draw(.{ .ctx = null, .f = null });
+ try std.testing.expectEqual(was, r.t.buf.items.len);
+ try std.testing.expect(!r.t.stepping() and r.t.host_side);
+}