Repository navigation
test(copilot): wait for the resumed transcript, not any history change, after an unobserved switch-back - #2224
Conversation
…e, after an unobserved switch-back The fixture logs a switch's unregistering and registering as two writes, and a read between them fails closed, which the loop took for the switch-back (run 40646297534).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Merging e5fb9a2, a test-only fix from lane main-integration for an Integration flake seen on main. After an unobserved switch-back, the Copilot contract test now waits for the resumed transcript, not for any history change. The HTTP fallback's empty scrollback without a |
…he first agent ends (#2222) Found by the main-integration lane: Integration failed on main run 40644839354 (30cd84f) and on #2176's run 40643516119. ## Cause (test flake, not a product regression) `a create request's first message > is bound to the agent process it was queued under: a replacement of the same kind ...` started SESSION2 from the shell (`recorder SESSION1; exec recorder SESSION2`). Between SIGKILL of SESSION1 and the `exec`, bash alone is in front. A pane event in that gap makes `launchGone` (shell back in front, `server/core/pending.ts`) hold the message as `first_message_launch_ended`. That is the documented behaviour from #1969: the launched agent did end, and no agent was in front. The test expected `pending_target_changed`, so it failed whenever a read landed in the gap. **Reproduced:** keeping the shell busy for a moment before the `exec` (a builtin loop, so the shell itself stays in front) fails the old test 3 of 3, with exactly CI's `Received: "first_message_launch_ended"`. A `sleep 1` there does not reproduce it, because `sleep` is another process and reads as a changed target. ## Change - The npm-style launcher fixture now also handles SIGUSR1: it starts SESSION2, and ends SESSION1 once SESSION2 has spawned, so an agent is in front throughout. Its exit-driven path (used by the #1545 test) is unchanged. - The test uses that launcher and waits until herdr no longer lists SESSION1 before it reports idle. ## Proof - **Mutation:** with `samePendingIdentity` ignoring process pid and birth, the new test fails 2 of 2 (the message is typed into SESSION2). - **Stress:** the first-message block plus the two replacement tests (21 tests) passed 10 of 10 on CI's Node 22 and herdr 0.9.3, through `dori heavy` on a loaded host. - **Local checks:** `bun run check fast` ok. Test-only: no app code changes. Splits from the same lane: #2223 and #2224. ## Reviews - **omo-native-code-reviewer**, round 1 on the combined change: BLOCK with two HIGHs, both fixed. One was a loop shape that `scripts/conventions.test.ts` counts as a fixed sleep; the other was the OpenCode helper not waiting for its own Ctrl-L. Round 2 on these heads: APPROVE, no findings above LOW. - Test-only, so no Codex review (notes/pr-policy.md: the test-only gate is omo alone).
…omplete (#2223) Found by the main-integration lane: Integration failed on main run 40643422650 (7dc187a). ## Cause (test flake from #1991's test order, not a regression from #2185 or #2200) `refuses a confirmed Tab agent switch during immediate delivery without Enter` runs right after `delivers a queued message completely when Tab leaves the skill unconfirmed`, and that test leaves @effect's autocomplete row selected (the recorded screen whose status row names no agent). The stand-in redraws only when it is typed to. If herdr has not yet drawn the screen that the next send's own `@effect` produces, `typeWithSkills` (`server/opencode-skill-attach.ts`) reads the old box. The agent before Tab is then unknown, and the Build to Plan switch cannot be seen, so the send succeeds. The queue case then fails on the outcome the immediate case left behind. **Reproduced:** delaying the stand-in's `@effect` redraw by 400 ms fails both cases 3 of 3, with CI's `ok: true` and the recorded outcome. ## Change - The stand-in draws the recorded closed-autocomplete screen on Ctrl-L. - `closedPrompt()` sends Ctrl-L, then waits until the stand-in has logged it and herdr shows no selected @effect row. Both Tab-switch cases call it before they note what was typed. ## Proof - **With the fix:** the same 400 ms delay passes 4 of 4, and 3 of 3 again after review. - **Stress:** `server/opencode.contract.test.ts` (24 tests) passed 10 of 10 on CI's Node 22 and herdr 0.9.3. That includes #2200's `closes the shared stream when its last verified pane ends or stops being OpenCode`. Its failure in run 40639664878 was #2200's pre-merge head, which still had the stop-then-create test that the merged version replaced. - **Local checks:** `bun run check fast` ok. Test-only. Splits: #2222 and #2224. ## Reviews - **omo-native-code-reviewer**, round 1 on the combined change: BLOCK with two HIGHs, both fixed. One was a loop shape that `scripts/conventions.test.ts` counts as a fixed sleep; the other was the OpenCode helper not waiting for its own Ctrl-L. Round 2 on these heads: APPROVE, no findings above LOW. - Test-only, so no Codex review (notes/pr-policy.md: the test-only gate is omo alone).
…t read every answer as a transcript A conversation read checks ownership before and after reading the page: one whose checks straddle the stand-in's Unregistering/Registering lines answers 409 history_changed, which has no turns, and the switch polls read turns[0] off it (TypeError, three times in 417 CI runs, also after #2224). Poll for an HTTP 200 copilot-transcript answer with the expected first turn, keeping the last answer for the timeout message; poll both panes to scrollback after the peer starts; and have the read-retry test wait for a cursor before arming each injected failure, printing every answer it waits past (that test's CI failures had no logged cause). Fail-first with a scratch spy forcing the straddle: old 3/3 TypeError, new 3/3 pass. Plain runs on CI's herdr 0.9.3 and Node 22: 4/5 at this head (the fifth is the read-retry test's open finding); bun run check fast ok.
…t read every answer as a transcript (#2385) Found by the flake-hunt lane: `server/copilot.contract.test.ts` "reads a resumed CLI without marker or report and follows foreground switches rather than stale reports" failed with `TypeError: undefined is not an object (evaluating '(await read()).turns[0]')` in its switch polls three times in the 417 CI runs from 2026-10-28 03:26Z to 2026-10-29 18:22Z (jobs 122685036108, 122847698843, 123297359877), including after #2224. Each passed on a rerun. ## Cause (test flake) The Copilot stand-in logs a switch as two lines: `Unregistering`, then `Registering`. A conversation read resolves ownership, reads the page, and checks ownership again (`server/conversation.ts`, about lines 1682-1686). A read whose two checks straddle the switch rightly answers HTTP 409 `{"error":{"code":"history_changed"}}`, which has no `turns`. A read between the two lines rightly answers scrollback. The test's polls treated every answer as a conversation and read `turns[0]` off the 409 body. **Reproduced:** a scratch spy appended a real `Registering` line during a read, forcing the straddle. The old test failed 3/3 with CI's TypeError, and the new one passed 3/3 while it saw the real 409s. A 400 ms gap between the two lines alone did not reproduce it (3/3 passed). ## Change - `read()` returns nothing for a non-200 answer and keeps the last answer for the timeout message. - `waitForTranscript(text, previousHistory?)` waits for HTTP 200, source `copilot-transcript` and the expected first turn (and a new `history_id` when asked). Every switch poll uses it. - After the peer pane starts, both panes are polled until they fail closed to scrollback, rather than read once. herdr names the peer before it logs its own `Registering` line. - The sibling test "retries failed Copilot page reads only while fresh ownership and file generation still agree" waits for a 200 with a cursor before arming each injected read failure. It prints every answer it waits past. ## Proof These runs used CI's herdr 0.9.3 and Node 22, with checksum-verified binaries under the run's own tools directory. As #2224 notes, this file cannot run on herdr 0.9.5 with Node 24. - **Fail-first:** with the forced straddle, the old test failed 3/3 and the new one passed 3/3. - **Plain runs of the whole file:** the final head passed 4 of 5 runs, 5 tests each. Earlier heads passed 3 of 3 and 3 of 3. - **The one failure** is the separate finding below, in the sibling test. - **Local checks:** `bun run check fast` ok. Test-only. ## Not fixed here: the sibling test's cursor wait (reproduced, cause unknown) The sibling test's last loop failed on CI twice (jobs 122661979002, 122801012396; `before.cursor` undefined, then line 448). Locally it failed once in five runs with the new wait. The server answered `200 {"source":"scrollback","turns":[]}` for the whole 5 s after the transcript file was replaced and the session registered again. A read-only analysis ruled out the timestamp cache and the generation map: a registration with identical timestamps is picked up at once. It could not name the cause, because `ConnectionDiagnostics` suppresses repeat failures for 30 s and the underlying `ConversationUnavailable` reason is never logged. The wait added here prints each answer it skips, so the next CI failure says what it saw. Because the wait only retries until a cursor shows, a real regression there still fails, now as a timeout with its answers printed. ## Reviews - **omo-native-code-reviewer:** APPROVE (WATCH). Both MEDIUMs were taken. - MEDIUM-1: the peer's single scrollback read had the same startup race. It now polls both panes. - MEDIUM-2: the cursor wait could hide an unknown failure. It now prints every answer it waits past, and the test's own first read uses it too. - LOWs noted: two asserts after `waitForTranscript` repeat what it guarantees. - Test-only, so no Codex review (notes/pr-policy.md). ## Second commit: the quit wait at line 320 (red on main) "binds only the reported UUID to the foreground process's home and rejects old cursors after a switch" failed at `:320` ("isolated fixture did not exit") on every main push since c5851e7 and on several PRs, #2385 itself included. **Cause:** after `:quit` the test waited 10 s for herdr's agent label on the pane to stop saying `copilot`. The label is not the exit: the test itself reported the Copilot session for that pane (`pane.report_agent_session`, source `herdr:copilot`), and on the CI runner the label outlasted the 10 s. `startFixture` then waited on the same label for the next stand-in. **Change:** - The test waits for the stand-in's own pid to leave the pane's foreground. - It then releases the session it reported (`pane.release_agent`, as Copilot's own hook would at its exit), waits for the label to go, and starts the next stand-in by its own process. - A timeout now prints the pid's state, the foreground, the label and its session, so CI says which signal never came. **Proof:** - **Local:** on CI's herdr 0.9.3 and Node 22, the case passed 4/4, run as two pairs side by side in two checkouts, and the whole file passed 5/5. - **Local checks:** `bun run check fast` ok. - **Not reproduced:** the stuck label. Here herdr cleared it 150 to 320 ms after the exit, and a report repeated just after `:quit` did not hold it. So there is no local fail-first for that part, and this PR's CI run is the first real test of it.
Found by the main-integration lane: Integration failed on run 40646297534 (ci/self-hosted-runner-cache, main 70e19f4).
Cause (test flake)
The Copilot stand-in writes a
:switchas two log lines,Unregisteringand thenRegistering. A conversation read between them rightly fails closed: scrollback, no turns, and anotherhistory_id. The test's wait for the unobserved switch-back stopped at anyhistory_idchange, so it could stop on that read and then fail withturns[0]...textundefined.Reproduced: with 400 ms between the two writes, the old test fails 3 of 3 with CI's
Expected: "...a03" Received: undefined, and the fixed one passes 3 of 3.Change
The loop waits for the Copilot transcript itself: source
copilot-transcript, a newhistory_id, and the resumed session's first turn. It still throws after 5 s if the binding never advances.Proof
server/copilot.contract.test.tspassed 10 of 10 on CI's Node 22 and herdr 0.9.3.MainThreadand herdr never names it Copilot. The runs above use CI's versions.bun run check fastok.Test-only. Splits: #2222 and #2223.
Reviews
scripts/conventions.test.tscounts as a fixed sleep; the other was the OpenCode helper not waiting for its own Ctrl-L. Round 2 on these heads: APPROVE, no findings above LOW.