diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 04:58:49 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 05:34:09 -0300 |
| commit | 60d4db7046f5cfe130eedbc9dabad680373e3e94 (patch) | |
| tree | 9a216a77a1f5f63ded841285c2178604b4f46210 /src | |
| parent | a9529fa5712298e9005b77b471400529a2ebbc32 (diff) | |
| download | pardes-60d4db7046f5cfe130eedbc9dabad680373e3e94.tar.gz pardes-60d4db7046f5cfe130eedbc9dabad680373e3e94.zip | |
kind: a kind's open is the authority's alone (Kind.reopen, authorityOnly as a key's or a word's into its pane is): a replica has no kind's code, so its guess of a word that opens a pane with no file (Snake, Life, Fake) made the open's outcome a default and was always mispredicted; it waits for the authority's unit now, as do a Look, a revived placeholder and a reload that reach the same open
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/Kind.zig | 2 | ||||
| -rw-r--r-- | src/replica.zig | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/Kind.zig b/src/Kind.zig index 619a9c53..d3feed96 100644 --- a/src/Kind.zig +++ b/src/Kind.zig @@ -275,6 +275,8 @@ pub fn openFile(p: *Pardes, id: usize, k: u8, path: []const u8) !*Pane { /// `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 { + // A replica has no kind's code: what the open says is the authority's. + if (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| { diff --git a/src/replica.zig b/src/replica.zig index ef4ea39b..0b22f8b2 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -4362,3 +4362,24 @@ test "a kind's place moved in a step of another view's: a replica's key that rea try std.testing.expectEqual(fast + 1, r.stats.fast); try agrees(a, r); } + +test "a replica's word that opens a kind's pane with no file waits for the authority's open: never mispredicted" { + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); + defer a.deinit(); + const r = try Replica.init(gpa, 1, try a.unit(0, 0), false); + defer r.deinit(); + var words: [64]pardes.Kind.LoadedWord = undefined; + const placed = pardes.Kind.loadedOf(&Placed.ops, "/x/placed.so", @splat(7), &words); + r.confirm(try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &placed } })); + // Its replica has no code for the kind: the open's outcome (its place, + // `1:0 0`) is the authority's to say. + const msg = try gpa.dupe(u8, try r.input(.{ .command = "Placed" })); + defer gpa.free(msg); + try std.testing.expectEqual(@as(usize, 0), r.applied); + r.confirm(try a.take(msg)); + r.settle(); + try std.testing.expectEqual(@as(u32, 0), r.stats.mispredicted); + try agrees(a, r); + try std.testing.expect(r.core().panes[r.core().view().active].?.addon != null); +} |
