Repository navigation
test(copilot): the stand-in quit deadlines say what herdr logged - #3920
Conversation
When herdr still names the quit Copilot stand-in (or the stand-in never leaves the pane), the error now carries the test herdr's own log tail, without its per-request lines, and the answer of pane.release_agent. herdr 0.9.3 answers a release from herdr:copilot and ignores it: only its detection of the process exit drops the label and the reported session. The comment that credited the release with forgetting the session says so.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
One reviewer: test-only. Test-only, one file: Review reports: ~/.cache/ovis-tmp/reports/ |
|
A correction to the merge comment above. It said the cause of the failure at line 528 was established from the failing run's herdr log (herdr not detecting the stand-in's exit, and a release from |
… for the pane (#3924) ## Change When the Copilot stand-in quits in `server/copilot.contract.test.ts`, two deadlines follow. One waits for the stand-in to leave the pane ("isolated fixture did not exit"); the other waits for herdr to stop naming it ("herdr still names the quit stand-in"). Both errors now also carry the pane's agent events from herdr's `events.subscribe`, each with its time in ms from the quit (negative before it). In the runs read, herdr's log had no line for the stand-in's exit, but the pane's agent events did (below). So the next failure shows what herdr reported for the pane, which the log tail added in #3920 cannot show. - **Where the recording opens.** The test opens it at its start, long before the quit, and waits there for herdr's acknowledgement (bounded at 2 s, an early-resolving bound, not a fixed sleep). It covers `pane.agent_detected` (kept for this pane) and `pane.agent_status_changed` for this pane. - **When it ends.** It closes after the label assertion, or through `onTestFinished` when the test ends any other way. - **The quit is placed exactly as on main.** `:quit` follows the foreground-process check at once. Between the two, only `const quitAt = performance.now();` was added; nothing is awaited there. (Diff of that span against main: `2a3 > const quitAt = performance.now();`.) The flake's cause is unknown and timing-shaped, so a wait there could hide it. - **First line of the recording.** herdr's acknowledgement is recorded as the first line, with its (negative) time. A failure's message therefore shows that the recording covered the quit. - **Heading.** The recording's heading says that events arrive on herdr's poll, so the latest may be missing; an empty or short recording is not proof of absence. - **Diagnostic only.** The recording never fails or passes the test. A subscription error, or herdr closing it, becomes a line. No assertion and no timeout changed. - **Comments.** The log tail's doc comment, the recorder's, and the comment before the quit now state only what was observed in the runs read. They make no claims about herdr's internals. - **Why a dedicated connection.** The test file had no subscription of its own. The bridge's subscription lives inside the server's collector and is not reachable from a test, so this opens one with `subscribeEvents`, as the `omp`, `api` and `opencode-prompt` contract tests do. ### Recorded lines Forced failure: a scratch copy of the file (not committed) with the label deadline forced to expire. The whole file was run the CI way: `bun scripts/check.ts run`, `HERDR_TEST_MODE=integration`, `--timeout 15000`, Node 22.23.3, herdr 0.9.3, an isolated session. The test threw at 528 after 11.80 s, inside its 20 s timeout: ```text error: herdr still names the quit stand-in: {"pid":2835152,"state":"gone","front":[[2835139,["/bin/bash","--noprofile","--norc"]]],"status":"unknown"}; pane.release_agent answered {"type":"ok"} herdr agent events for w2:p1, ms from the quit (they arrive on herdr's poll: the latest may be missing): -1711 herdr acknowledged the subscription 320 pane_agent_detected {"agent":"copilot","final_status":"idle","pane_id":"w2:p1","released":true,"type":"pane_agent_detected","workspace_id":"w2"} 621 pane.agent_status_changed {"agent_status":"unknown","pane_id":"w2:p1","workspace_id":"w2"} herdr log: ... ``` On a passing whole-file run of the previous commit (a61f4ff, same run setup), a printing scratch copy recorded `201 pane_agent_detected {... "released":true ...}` for the quit stand-in. herdr sent no event for this pane before the quit in any of these runs, which is why the only negative line is the acknowledgement. ### Why these events, from herdr's source (read from herdr v0.9.3, not verified by the reviewer) - **The exit is not logged.** An exit is reported with `ReportProcessExit`, which returns `changed = false` (src/pane.rs:504-507). `agent changed` is logged only under `if changed` (src/pane.rs:2917). - **The exit does emit an event.** A process exit sets `agent_released` (src/terminal/state.rs:384), and `emit_pane_state_update` emits `pane.agent_detected` with `released` (src/app/api.rs:665). - **Delivery lags.** Subscription events go out on a 100 ms poll (`CONNECTION_POLL_INTERVAL`, src/api/server.rs:29 and 953). In a passing run the test may see the label go before the event arrives. - **No pane filter.** `pane.agent_detected` takes no pane filter in its subscription (src/api/subscriptions.rs:158), so the handler keeps only this pane's. - **A lost delivery is logged.** An undelivered state change logs `failed to deliver StateChanged event` (src/pane.rs:266). - **A delivered exit is always applied for Copilot.** Both early returns in `set_detected_state_with_screen_signals_at` require `!process_exited` (src/terminal/state.rs:850 and 414). ### What a failing run will now show - **herdr's detection never reported the exit.** No `"released":true` line after the quit, and no `failed to deliver StateChanged event` warning in the log tail. - **The exit was reported but not delivered to the pane's state.** That warning appears in the log tail. - **The exit was applied and the label came back.** A `"released":true` line, then a later `pane_agent_detected` naming `copilot` without `"released":true`, at its time from the quit. The deadline at 523 carries the same recording. ### Review points answered - **The quit's placement (t87).** As above: nothing is awaited between the foreground-process check and `:quit`. - **dori's LOW on the 2 s wait.** The subscription's set-up and its 2 s bound now happen at the test's start, so they no longer come out of the time after the quit. - **dori's LOW on the empty recording.** The heading of every recording says that events arrive on herdr's poll and the latest may be missing. - **The test timeout.** No timeout was raised. The early wait can cost at most 2 s at the start of a test with a 20 s timeout; nothing asserts on it. The LOW on #3920 about the 20 s timeout (a stand-in that left only near the end of the first 10 s deadline) stands as it was; this change adds no time after the quit. ## Validation - `server/copilot.contract.test.ts` at 3706fcf, the whole file, 10 times the CI way in a 2-core heavy slot (`~/.ovis-toolchain/heavy-run.sh`; Node 22.23.3, herdr 0.9.3): the test this PR changes passed 10/10 (2.27 to 2.54 s). 9 runs passed all 8 tests. In one run (w2), another test failed: "retries failed Copilot page reads only while fresh ownership and file generation still agree", `Copilot cursor was not ready: 200 {"source":"scrollback","turns":[]}` at line 631. Its stand-in (pane 7) was detected at 19:13:19.794, then pane 7 and pane 2 were both re-detected from `None` at 19:13:20.405, and the cursor never became ready within its 5 s. That test also failed on CI on 2026-11-12 (job 131032697803, at another assertion) before this PR existed. The recording in this PR is closed when the previous test ends, so it is not open during that test. I count it as a separate flake and did not look into it further. - Lint (this repo's lint is the conventions tests): `HERDR_TEST_MODE=unit bun test server/conventions.test.ts`: exit 0. - `bun run typecheck`: exit 0. - `bun run check fast` on 3706fcf: exit 0. - Forced failure (scratch copy, not committed): above. - **Not run:** `bun run check full`. The flake itself was not reproduced; this PR changes only what its next failure prints.
Change
server/copilot.contract.test.tssometimes fails at its post-quit deadline ("herdr still names the quit stand-in", main runs 43740263064 and 43697933558, also on an idle runner). The quit stand-in is gone and bash is in front, but herdr still labels the panecopilot, with statusidleand the reported session still attached, 10 to 14.7 s after the quit. The message did not say why. This change makes the next failure explain itself, and fixes nothing it cannot prove.herdr-server.logbeside the session socket), its last 25 lines without the per-request ones. That log records herdr's detection transitions for the pane (agent changed ...). It cannot show the exit itself: herdr 0.9.3 publishes a process exit without logging it (ReportProcessExitreturnschanged = false, src/pane.rs:504-507, andagent changedis logged only underif changed, src/pane.rs:2917). A passing run, in CI and locally, therefore logs noprevious_agent=Some(GithubCopilot) agent=Nonefor this pane; only the next stand-in'sSome→Somereplacement appears. (Corrected after review: an earlier version of this text called thatagent=Noneline herdr seeing the exit, which was wrong.) The label deadline also gives the answer ofpane.release_agent.pane.release_agentfromherdr:copilotanswers{"type":"ok"}and is ignored:AppEvent::HookAgentReleasedreturns no update for an official source (is_official_agent_source, src/app/actions.rs at v0.9.3). Only herdr's detection of the process exit drops the label and that session. The comment now says so. The call stays, as the release Copilot's own hook sends.What was found while looking for the cause:
pane.report_agent_sessionfor the quit session, right after the exit, did not hold the label.curland an exit hook in the stand-in throughNODE_OPTIONS, delayed 0, 30, 60 and 120 ms; the test file itself was not modified. The reset reached the pane and the label still cleared. So the cause stays unknown, and there is no fix here.Validation
All runs used Node 22.23.3 and the pinned herdr 0.9.3, each on its own isolated herdr session (
bun scripts/check.ts run,HERDR_TEST_MODE=integration,--timeout 15000).server/copilot.contract.test.tswith this change, 10 times unforced the CI way, in a 2-core heavy slot (commit 144a872c, before rebasing onto 6750f40; same file): all 8 tests passed every time (15.7 to 17.8 s per file). One of the ten exited 1 only becausecheck.tsreported "source changed during the check" (the commit was made while it ran). One more run on the rebased head 180a9e6: pass.bun run check faston 180a9e6, Node 22.23.3, in a heavy slot: exit 0.bun run check full(test-only change to one integration file).