diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 09:41:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 09:41:32 -0300 |
| commit | 0fb10f2748bc1593b9c0dda0e74b53cb66a69a95 (patch) | |
| tree | 4cd15cc3ca1b9eb17c66a518d18b8126fb1c2aaf | |
| parent | aa3ff349f840f568ea0f052c1f051cdc0dbb18c1 (diff) | |
| download | pardes-0fb10f2748bc1593b9c0dda0e74b53cb66a69a95.tar.gz pardes-0fb10f2748bc1593b9c0dda0e74b53cb66a69a95.zip | |
exec, replica: a line run again in its directory's finished command pane waits for the session's order from the first line of that branch, at a stop may_wait lists (`run a command`), as a new command pane's run waits at `open a terminal` (agent T23's find: the no-pdf soak, seed 3 rtt 80, had one client key stop at `spawn`, which may_wait does not list, so the run failed); NOT AN ORDERING FAULT: the speculation was refused and rolled back as it should be (the reused pane's emulator writes refused by feedOutput, `a terminal's output`, and the spawn effect stopped by its host entry, a keeps_stopping one, which as the last poison names the stop), but it ran the reused pane's whole rerun first (its command line freed and set, its last run's errors taken out of the live messages, its diff output dropped, its mode, its /log notes), all of it rolled back, and named the stop by whichever refusal came last; a new pane's run (panes.newCommand) has always stopped at its first line; THE FIX: exec.runCommand's reuse branch asks `authorityOnly("run a command")` before it changes anything, and may_wait lists the stop on a new `On.command` (a pane in a directory with a finished command pane), which the walk stands in none of: the soak judges it by name, and the new test by its row; (a far client reaches that branch only where its speculation passes missingDir: a session whose host has no spawn entry, or a directory that is no local one, `/virtual/...`; elsewhere the directory's `kind` stops it first, as `Exec *`'s row says); RUN (TEST FIRST): replica.zig "a far client's line run again in its directory's finished command pane waits for the session's order, at a stop may_wait lists: ..." runs `Exec true` at the session (a command pane, exited and at its end of file), joins a client, and has the client run `Exec true` from the file's pane: asks one stop, at a name may_wait lists, then the session's order runs it again in that pane and the client agrees: fails on M2 (stopped at `a terminal's output`), passes now; a user could hit it as a far client rerunning a build from a finished command pane: the soak's failure only (the input waited a round trip either way, and nothing it changed outlived the rollback); NEW HOT PATHS: none (one flag read in a branch that starts a process); GATES: shell-test 1379/1382 (3 skipped: +2, this test and the preview one before it), the far-client tests 25/25 (the every-word-and-key walk among them, no row stale); load 4.7 to 6.8
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
| -rw-r--r-- | core/exec.zig | 4 | ||||
| -rw-r--r-- | core/replica.zig | 40 |
2 files changed, 43 insertions, 1 deletions
diff --git a/core/exec.zig b/core/exec.zig index 44cfea64..47fea012 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -751,6 +751,10 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { if (other.command != null and other.command_done and !other.command_pty and std.mem.eql(u8, other.cwdSlice(), dir) and !leased(p, other.serial)) break i; } else null; if (reuse) |id| { + // A process started and its emulator written, as a new command + // pane's (panes.newCommand): the session's, which a speculation + // waits for, nothing of the pane changed first. + if (p.tape.authorityOnly("run a command")) return null; const pane = p.panes[id].?; const owned = p.gpa.dupe(u8, line) catch |err| { p.reportError(.at(from), "exec", err); diff --git a/core/replica.zig b/core/replica.zig index 9e6183a1..86f8d8cb 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7320,7 +7320,10 @@ test "a client's n in a kind's pane is a motion: it steps to the next place a re /// `addon`: a kind whose state is its own on the session (a PDF's), which /// the walk does not stand in (its Still has no search, place or word): /// the soak's (test/replicas.zig) PDF and pictures are, judged by name. -const On = enum { any, file, kind, shell, shell_normal, addon, dir }; +/// `command`: a pane in a directory with a finished command pane, which a +/// line run there runs in again (exec.runCommand); the walk stands in none: +/// the soak's are, judged by name, and the test after the walk. +const On = enum { any, file, kind, shell, shell_normal, addon, dir, command }; /// What a far client may wait a round trip for (the user's line, P14: a /// side effect on the system may be slow; motions, edits and layout are @@ -7354,6 +7357,7 @@ const may_wait = [_]Wait{ .{ .what = "Find *", .on = .any, .stop = "kind", .why = "the work tree it lists from, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the listing itself is the session's" }, .{ .what = "Grep *", .on = .any, .stop = "kind", .why = "the work tree it searches, a `.jj` or `.git` above the pane's directory asked of the session's disk (Pick.workTree), as the search itself is the session's" }, .{ .what = "Exec *", .on = .any, .stop = "tty_taken", .why = "a program run in a shell: whether one has it, the session's" }, + .{ .what = "Exec *", .on = .command, .stop = "run a command", .why = "a line run again in its directory's finished command pane: its process and its emulator are the session's" }, .{ .what = "Term", .on = .any, .stop = "kind", .why = "a shell opened: its name asked of the disk first" }, .{ .what = "A-n", .on = .any, .stop = "open a terminal", .why = "a shell opened" }, .{ .what = "* A-n", .on = .any, .stop = "open a terminal", .why = "a shell opened (Alt-n after a prefix is still the global key)" }, @@ -7717,6 +7721,40 @@ test "a far client's every word and key, on a file's pane, a kind's and a shell' try std.testing.expectEqual(@as(u32, 0), stale); } +test "a far client's line run again in its directory's finished command pane waits for the session's order, at a stop may_wait lists: its process and its emulator are the session's" { + // The soak's (test/replicas.zig, seed 3 rtt 80): a client's key stopped + // at `spawn`, which may_wait does not list. Its speculation ran the + // reused pane's whole run (exec.runCommand): the emulator's writes + // refused (`a terminal's output`), then the spawn effect (a host entry + // that keeps stopping), the last one naming the stop. + if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane's terminal + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host()); + defer a.deinit(); + const file = a.core.view().active; + _ = try a.local(.{ .command = "Exec true" }); + const cmd = for (a.core.panes, 0..) |slot, id| { + if (slot) |pane| if (pane.command != null) break id; + } else return error.NoCommandPane; + _ = try a.local(.{ .exited = .{ .pane = .at(cmd), .status = 0 } }); + _ = try a.local(.{ .eof = .{ .pane = .at(cmd) } }); + try std.testing.expect(a.core.panes[cmd].?.command_done); + a.core.view().active = file; + const r = try joinedFresh(a); + defer r.deinit(); + // The same line from the file's pane: its directory's finished pane runs it. + const stopped = r.stats.stopped; + const msg = try gpa.dupe(u8, try r.input(.{ .command = "Exec true" })); + defer gpa.free(msg); + try std.testing.expectEqual(stopped + 1, r.stats.stopped); + if (!mayWait(r.t.poisoned_by)) std.debug.print("stopped at `{s}`\n", .{r.t.poisoned_by}); + try std.testing.expect(mayWait(r.t.poisoned_by)); + r.confirm(try a.take(msg)); + r.settle(); + try agrees(a, r); + try std.testing.expect(!a.core.panes[cmd].?.command_done); +} + test "a far client's click into a shell whose program asked for focus events is instant: the session's step tells the program, a round trip later, and the client's guess is confirmed" { if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const gpa = std.testing.allocator; |
