diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 10:37:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 12:02:09 -0300 |
| commit | 1d92d0151bf8206823074f73b9fa90e0220bff15 (patch) | |
| tree | de2c2450bb36f036d6dff6e41e22ba659b6dca65 /core/tape.zig | |
| parent | 6cf477bd75d242c7f7fea653d5f433872f7ca66f (diff) | |
| download | pardes-1d92d0151bf8206823074f73b9fa90e0220bff15.tar.gz pardes-1d92d0151bf8206823074f73b9fa90e0220bff15.zip | |
tape: enter and leave read the field, step 9b (reports/pardes-handle-69-design.md sections 3.3, 3.4): an entry is recorded on the tape of the core it enters (for a session not made yet, its options' or, until 9c, the global's), unless nobody records it or it is a client's between its steps (the idle rule 9b-0 checked), and Entered carries the tape it entered, so leave needs neither the global nor a core that init did not make or deinit freed; the safe build still checks that a core stepped is the one the global says while the global is set; as 9b-0's list said, a client's core freed records nothing now, and an authority's core driven outside a Stepping scope records its entries as a real session's: one test leaned on that being unrecorded (test/panes.zig, a client's guessed PDF view: the effects its `jobs` drained after the open landed in the client's next unit and read as a misprediction; the drain is handed to the client as a unit of the session's own first, 2 lines); test/daemon.py --restore (new): a Restore with a client attached, the client let go, one attached after agrees and its keys reach the restored session (passes on step 7 and here); the tape's bytes do not move (semantics df1f0502317ed362, cross_replay both ways against step 7: 27 digests agree x3); tui core-test 857/1008 (151 skipped), shell-test 1048/1051, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test --replay 0 of 102, process-test 1 of 144 (pagercolor, on the known list), both soaks diverged 0 unequal 0 corpus 22 of 22 (bytes: the base's one now stop at 30 ms), daemon.py plain, --far (the Find: 0 mispredicted), --games, --window-clients, --upgrade both ways against merge31, addon-test 5/5; gui unit-test 1645/1649 (the perf check's BaselineHarnessMismatch); frames 77/77, perfab +0.051%, the 121 counts within 0.1% against tree2 (key-down on medium 10,039,587, render on medium 11,454,498: the extra load an entry is inside the noise)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/tape.zig')
| -rw-r--r-- | core/tape.zig | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/core/tape.zig b/core/tape.zig index ddfaa4b1..1c9368d0 100644 --- a/core/tape.zig +++ b/core/tape.zig @@ -411,7 +411,7 @@ pub const Tape = struct { if (!t.host_side) return .{}; t.host_side = false; t.depth += 1; - if (t.replay) return .{ .outer = true }; + if (t.replay) return .{ .tape = t }; if (p) |core| { if (t.core == null) t.core = core; t.noteWrites(); @@ -423,7 +423,7 @@ pub const Tape = struct { bare.update.args[0].output.bytes = &.{}; t.record(.input, Input, &bare); } else t.record(.input, Input, input); - return .{ .outer = true }; + return .{ .tape = t }; } fn leaveInput(t: *Tape, p: ?*Pardes) void { @@ -1023,37 +1023,22 @@ fn partsDiffer(got: []const u64, want: []const u64, a: std.mem.Allocator) []cons return said.items; } -/// A call into the core: the host's, and recorded, or the core's own. -pub const Entered = struct { outer: bool = false }; +/// A call into the core: the host's, and recorded, or the core's own. The +/// tape it entered (null: the core's own, or nobody records), so `leave` +/// needs neither the global nor a core `init` did not make or `deinit` freed. +pub const Entered = struct { tape: ?*Tape = null }; pub inline fn enter(p: ?*Pardes, input: Input) Entered { - // A core's tape is the one `on` says while both are (P20: the global - // 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()) + // While the global is (P20: the terminal's questions read it), a core + // stepped is the one it says: every entry a safe build makes checks it. + if (std.debug.runtime_safety) if (p) |core| if (on) |was| if (core.tape != was) @panic("tape: a core's field is not the tape being stepped (tape.on)"); - // The rule the field is read by next (9b), checked beside `on` first. - // Where they disagree (9b-0's list, both the rule's to keep): a - // client's core freed (Replica.deinit, inside a Stepping scope: `on` - // records its `deinit` into a buffer let go at once; the rule records - // nothing), and a test that drives an authority's core outside a - // Stepping scope (no `on`: unrecorded; the rule records it, as a real - // session's every entry is). - if (std.debug.runtime_safety) { - const t = tapeOf(p, &input); - const listed = if (on != null) input == .deinit and t.replica else !t.replica; - if (records(t) != (on != null) and !listed) @panic("tape: the idle rule and tape.on disagree"); - } - const t = on orelse return .{}; + const t = tapeOf(p, &input); + // A client's tape between its steps records nothing (its frame drawn, + // its core freed: the test "a client's frame drawn between its steps + // records nothing into its idle tape"); an authority's records every + // entry, in a Stepping scope or not, as a real session's. + if (!records(t)) return .{}; return t.enterInput(p, &input); } @@ -1076,7 +1061,7 @@ fn records(t: *const Tape) bool { } pub inline fn leave(p: ?*Pardes, e: Entered) void { - if (e.outer) on.?.leaveInput(p); + if (e.tape) |t| t.leaveInput(p); } // The entry points on `on`, the methods' (`Tape.site` and the rest). |
