summaryrefslogtreecommitdiff
path: root/core/Addon.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 23:49:29 -0300
committerGabriel Schneider <[email protected]>2026-11-19 01:35:13 -0300
commit1ca3e68f38385952fa5a2ccc3dac883ba0be71e8 (patch)
treebffbbf9e5e5b2b929d79bd81ea805c5288896623 /core/Addon.zig
parente567aadc19f58b1e36098388483294321f3502dd (diff)
downloadpardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.tar.gz
pardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.zip
core: nothing of a core is a process global, the three that were (pardes-probes P3, the reorganisation's 12c): config.tab_now goes, a tab's width is the core's settings.tab handed to every width function as `tab` (File.graphemeDisplayWidth and the 73 functions above it, test helpers among them, that had no core to read it from gained the parameter; an Editor, a Surface and the hunks' Ctx carry it; render sets Surface.tab; graphemeDisplayWidth asks its one printable ASCII byte before the tab, the two disjoint: with the tab first, as before, the parameter cost 0.2-1.7% instructions an operation in pardes-perf, with ASCII first the measured cells use 2-16% fewer than the base), so a rollback can no longer leave a stale width and replica.zig's hand-made put-back in toConfirmed goes; Addon.distrusted/ndistrusted become Addon.Distrusted, the client's own list, which its frontend owns across its joins and hands each core as Options.distrusted (in no tape, dump or digest: Options' replica .local); Kind.draw_tokens becomes each slot's `draws` (local: a draw is a frame's, so each process's count differs and no digest may hold it; the copy saves it with the slot); the two turn reads in a step stay, being shown unable to reach a client's state (the report); the soak's Proc keeps only the client's list (its tab_now and the global swaps go, forced); test/perf.zig follows three signatures, so unit-test's perf check now says BaselineHarnessMismatch until the baselines are recorded again; tui core-test 824/966 (142 skipped), shell-test 1001/1004, pane-test 183/184, behaviour-test 274/274 and --replay 274/274, process-test 2 of 144 failed (lspcomplete, lspcompletemoved), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, gui unit-test 1598/1602, lib-test, daemon.py plain, --far, --games, --window-clients 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.zig33
1 files changed, 19 insertions, 14 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index 5c3f84e2..5c23ed51 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -342,11 +342,11 @@ 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) ?*const Kind.Ops {
+pub fn need(r: *Kind.Registry, 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()) {
- r.ops[k] = plainOps(&r.kinds[k]);
+ r.ops[k] = plainOps(&r.kinds[k], distrusted);
return r.ops[k];
}
const e = &r.kinds[k];
@@ -551,12 +551,13 @@ pub fn loadedOf(ops: *const Kind.Ops, path: []const u8, hash: [32]u8, words: *[6
/// This process's code for a kind a session's core lists, which a client
/// runs itself: PA_PLAIN, of the same name, version, ABI and functions (a
/// compiled-in addon's library hash is 0: never by the hash), and not
-/// caught breaking its promise here (`distrust`). Null: its panes say so.
-pub fn plainOps(e: *const Kind.Entry) ?*const Kind.Ops {
+/// caught breaking its promise here (`distrusted`, the client's). Null: its
+/// panes say so.
+pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Kind.Ops {
if (!e.caps.plain or e.refused) return null;
// A client scans for its addons only when its session has a plain kind.
_ = scan();
- for (distrusted[0..ndistrusted]) |*d| if (std.mem.eql(u8, std.mem.sliceTo(d, 0), e.nameOf())) return null;
+ if (distrusted) |d| for (d.names[0..d.n]) |*name| if (std.mem.eql(u8, std.mem.sliceTo(name, 0), e.nameOf())) return null;
for (found[0..nfound], 0..) |*l, i| if (l.why.len == 0 and std.mem.eql(u8, l.name, e.nameOf()) and l.version == e.version and
l.abi == e.abi and @as(u16, @bitCast(l.caps)) == @as(u16, @bitCast(e.caps)))
{
@@ -568,16 +569,20 @@ pub fn plainOps(e: *const Kind.Entry) ?*const Kind.Ops {
}
/// Kinds a client found breaking PA_PLAIN: shown by the session's line
-/// from its next join on. A process's (test/replicas.zig keeps one a client).
-pub var distrusted: [Kind.max_kinds][16]u8 = undefined;
-pub var ndistrusted: usize = 0;
+/// from its next join on. The client's, which outlives each core it joins
+/// with (its frontend's, handed to them as `Options.distrusted`): no core's
+/// state, never rolled back.
+pub const Distrusted = struct {
+ names: [Kind.max_kinds][16]u8 = undefined,
+ n: usize = 0,
-pub fn distrust(name: []const u8) void {
- if (ndistrusted == distrusted.len) return;
- distrusted[ndistrusted] = @splat(0);
- @memcpy(distrusted[ndistrusted][0..@min(15, name.len)], name[0..@min(15, name.len)]);
- ndistrusted += 1;
-}
+ pub fn add(d: *Distrusted, name: []const u8) void {
+ if (d.n == d.names.len) return;
+ d.names[d.n] = @splat(0);
+ @memcpy(d.names[d.n][0..@min(15, name.len)], name[0..@min(15, name.len)]);
+ d.n += 1;
+ }
+};
/// The kind that opens `path`, by its extension (any case).
pub fn forPath(r: *const Kind.Registry, path: []const u8) ?u8 {