diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 02:26:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 03:05:27 -0300 |
| commit | 24fbb1e611b32924039faa2ee4886d27025a3012 (patch) | |
| tree | 6c00b21f1d6a3e00bbe9ecd98c91693dac0895cc /core/tape.zig | |
| parent | 7ec51e48d430d4bc06869c09c6cc1325124ac338 (diff) | |
| download | pardes-24fbb1e611b32924039faa2ee4886d27025a3012.tar.gz pardes-24fbb1e611b32924039faa2ee4886d27025a3012.zip | |
tape: a host call that returns nothing no longer stops a client's speculation (the reorganisation's 12a, S1; the user's rulings P14 and P16): in tape.hostCall a speculating client records such a call as made and goes on, and the session's unit confirms the record, or records more where its host wrote the core during the call (an input it made inside it, a watched field) and the client rolls back as for any misprediction; one list, `keeps_stopping`, names the entries that still stop, each with its reason (pty_write: a shell's input, a device by P14 and off the tape with screen-state terminals; spawn, write_file, write_dump, dump_themes: their hosts write the core on every call, write_file also outside any record; upgrade, hand_over, detach: the session's own; search: a host with no worker writes the rows outside any record and a client cannot know which host the session has; wait_input, present, post_present, poll_frame: the loop's), and watch_theme stops only turned on (its host loads the theme file into the core outside any record); and a client's yank, paste and link are its own frontend's (P16): Effect.perform counts each in the view the step is in (View.yanks, pastes, links and the link itself, digested, the same on both sides), and the session's host is not called for a view a client draws (`undrawn`), the record unchanged so nothing mismatches; the frontends that act on those counts are another agent's files (the lines are in reports/pardes-seam-a.md); four tests at the end of core/replica.zig through the replica's surface (a ClipYank goes on at once and is confirmed fast; the same with a host that says something into the core during the call rolls back once and agrees; ThemeFile stops and the Theme after it does not; a joined client's ClipYank and ClipPaste move its view's counts on both sides and the session's host is asked neither, while the session's own view's yank is still its host's); the semantics word did not move (adacca2db2b39264); tui core-test 829/971 (142 skipped), shell-test 1006/1009, pane-test 183/184, behaviour-test 275/275 and --replay 275/275, process-test 2 of 144 failed (lspcomplete, lspcompletemoved, the base's), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, stopped 104/133/147 -> 96/114/140, mispredicted 44/33/29 -> 44/34/29, gui unit-test 1604/1608 (its perf check's BaselineHarnessMismatch the base's), daemon.py plain, --far, --games, --window-clients pass; gate-w seam-a-1 against tree1: 77/77 frames byte-identical in Debug, perfab corpus2x -0.106%, perfops 97 counts within 0.1% (largest +0.0173%)
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 | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/core/tape.zig b/core/tape.zig index 07bf4fff..0f0678d0 100644 --- a/core/tape.zig +++ b/core/tape.zig @@ -878,6 +878,55 @@ fn Wrap(comptime i: usize) type { }; } +/// The Host entries that return nothing and still stop a speculation, each +/// with why; a speculation records any other as made and goes on (`hostCall`). +/// The entries that answer stop by nature: the answer is the session's. +const keeps_stopping = .{ + // A shell's input: a device by the user's line (a far shell may feel + // like ssh), and off the tape with screen-state terminals. + "pty_write", + // Its host says into the core on every call that the shell started + // and where (host_io.forkShell: acknowledgeShell, setCwd), and gives + // the turn away: a rollback every time, nothing gained. + "spawn", + // Its host writes the core outside any record (exec.reapplyInitFile, + // Plumb.saved, fs.writeSelf) besides `saved` or the failure, every call. + "write_file", + // Their hosts say done or failed into the core on every call + // (setLastDump, dumpFailed; setMessage, reportError): a rollback every + // time, nothing gained. + "write_dump", + "dump_themes", + // The session's own: it execs itself after the step, carries a window + // away, or lets its frontend go (writing `frontend` and `unattended`). + "upgrade", + "hand_over", + "detach", + // A host with no worker runs the search on its loop and writes the + // rows outside any record (Stream.runHere, from tui's and gui's + // `search`); whether the session has one is not the client's to know. + "search", + // The loop's, never a step's. + "wait_input", + "present", + "post_present", + "poll_frame", +}; + +fn keepsStopping(comptime name: []const u8, args: anytype) bool { + // Turned on, its host loads the theme file into the core outside any + // record (colors.loadThemeFile: custom_theme, theme_file_loaded); + // turned off it only lets the file go. + if (comptime std.mem.eql(u8, name, "watch_theme")) return args[1]; + inline for (keeps_stopping) |s| if (comptime std.mem.eql(u8, s, name)) return true; + return false; +} + +/// The entries a view's frontend makes on its own machine (P16). +fn forTheView(comptime name: []const u8) bool { + return std.mem.eql(u8, name, "set_clipboard") or std.mem.eql(u8, name, "read_clipboard") or std.mem.eql(u8, name, "open_link"); +} + fn hostCall(comptime i: usize, comptime R: type, ctx: ?*anyopaque, args: anytype) R { const t: *Tape = @ptrCast(@alignCast(ctx.?)); const name = host_fns[i]; @@ -913,10 +962,27 @@ fn hostCall(comptime i: usize, comptime R: type, ctx: ?*anyopaque, args: anytype t.record(.ret, R, &r); return r; } + // Nothing to wait for: recorded as made, and the speculation goes + // on. The session's unit records the same, or more where its host + // wrote the core during the call (an input it made, a watched field + // set), and the client rolls back. + if (R == void and !keepsStopping(name, args)) { + t.record(.host, u16, &id); + t.record(.ret, void, &{}); + return; + } t.poisoned = true; t.poisoned_by = name; return poisonOf(R); } + // A client's yank, paste or link is its own frontend's, made on its own + // machine from its view's record (Pardes.View.yanks): never the + // session's, whose host makes them for a view no client draws. + if (comptime forTheView(name)) if (t.core) |p| if (p.undrawn & (@as(u8, 1) << @intCast(p.live)) != 0) { + t.record(.host, u16, &id); + t.record(.ret, void, &{}); + return; + }; const real = @field(t.real.vtable.*, name).?; t.record(.host, u16, &id); t.seeFields(); |
