fix(server): a PR watch tells the agent when the checks finish after a failure #39596
main fromrefs/pull/39596/head·merged by juliusmarminge View on GitHubProblem#
A PR watch stays silent when the remaining checks finish after an early failure.
- A check fails while other checks still run. The watch wakes the agent with "checks failed".
- The agent ends its turn and says that it waits for the other checks.
- The other checks finish. No wake follows.
checks-passed needs the required checks to pass, or every check when none is required. The failed check blocks that. checks-failed reports only new failures. So nothing tells the agent that the run finished. Since #33214 the thread leaves Working at that moment, but the agent still hears nothing, and its last message still says that it is waiting.
main at 732c03f410 still behaves this way. One existing test asserted it: "reports failures on the first read only when CI was pending at the start" expected no change when the last check finished.
Change#
evaluatePullRequestWatch gets one more change kind, checks-finished. The watch stays on.
- While a failed check keeps the required checks from passing, the watch records that it owes the agent one wake. It records this when it sees a new failure, or a failed check that ran again, while other checks still run.
- On the first read where no check is running, the watch sends the wake and clears the record. The wake does not repeat. A job that starts later and passes does not wake the agent again.
- A check that waits for a maintainer's approval counts as running. So does a read that could not see the approval state.
- A rerun that starts and ends between two reads sends the same wake.
- A new head clears the record.
The wake text:
- Every check has finished on 1111111: 2 passed, 1 still failing:
- Lint
The record lives in the existing owedChecks field. #23904 added that field for checks that still run after the required ones passed, and that path is unchanged. The reactor, the schema and the watch_pull_request description are unchanged. One contract comment and one clause in the user guide changed.
Two existing expectations changed, because they pinned the missing wake:
- "reports failures on the first read only when CI was pending at the start" now expects
checks-finishedwhen the last check finishes. - "baselines existing failures and conflicts, then reports new ones" now expects
checks-finishednext tochecks-failedwhen the last running check fails. Both changes share one wake.
What this takes from the earlier PRs#
This PR replaces #28020 by @Rhinomcd and my closed #25539. The pipeline stopped on #28020 on November 13 because it conflicts with main.
- From #28020: the watch stays on, the
checks-finishedkind, the reuse ofowedChecks, thefailedoutcome and the "checks finished" summary. The commit names Ryan McDonough as co-author. - From #25539: the wake waits for every check and not only for the required ones. It gives the number of passed and failing checks, and only
successcounts as passed. A rerun owes the wake again. - New in this PR: a watch that starts after the failure gets the wake too.
Not covered#
- A failure that arrives in the same read as the last result, with nothing owed before, sends only
checks-failed, as onmain. - A watch saved by an older version, with a failure already reported and checks still running, gets no wake for that head. Its stored state is the same as the state of a watch that already got the wake.
- An advisory check that fails while the required checks pass. Existing tests define that path, so I left it as it is.
Scope#
Bug fix for #30530. #25497 is the earlier report of the same bug.
Verification#
I hit this bug on 0.1.2, reported in #25497, and again on 0.1.9 on November 14. In both cases a required label check fails until a person adds a label. The timeline and traces are in this comment on #30530.
Scenario proof. vp run scenarios:prove exits 0 with this verdict:
Proven: the scenario fails on base `732c03f410` and passes on head `1daa69fb52`.
base: ASSERTION_FAILED: expect.toBeVisible failed
locator: getByText("#42: checks finished")
observed: no node (match count 0)
It runs the real server, watch reactor, replay agent and web client. Only GitHub's responses are synthetic. I used the scenario and the forge fixture that the pipeline posted on #28020, with three changes:
- The fixture returns
mergeCommit,mergedByandmergeQueueRemovals, whichPullRequestCorereads since #26271 and #24141. - The database wait helpers also poll every 500 ms. On macOS the directory watcher missed the last write.
- The final assertion runs outside the MCP session helper, so the prover counts its failure as an assertion failure.
Persisted wakes of the head run, read from the scenario database:
Agent turns: 3, all completed
Wake 1 #42: checks failed
- Checks failed on 1111111:
- Lint
Wake 2 #42: checks finished
- Every check has finished on 1111111: 2 passed, 1 still failing:
- Lint
Tests. pullRequestWatch.test.ts has three new cases and the two changed expectations. With the evaluator of main, 6 tests fail and 48 pass. With the fix, all 54 pass. The new cases cover:
- The two sequences from the maintainer's reproduction on #25497, one with required checks and one without. They also cover no repeat on the next read, no wake for a job that starts later, and a watch that starts after the failure.
- An advisory check that is still running, an approval hold, an unreadable approval read, and a failure that arrives with the last result.
- A rerun that passes while another failure stands, seen as pending or not, and a new head.
Replay. The real evaluator on those two sequences, read 2 is the read after the running check finished:
base read 1: ["checks-failed"] read 2: [] read 3: []
head read 1: ["checks-failed"] read 2: ["checks-finished"] read 3: []
Random sequences. I ran 60,000 random check sequences of 9 reads through the evaluator. checks-finished never came while a check was running or while the required checks were not failing. It never repeated on an unchanged read. Every failure wake sent while checks were running was followed by checks-finished once nothing ran, as long as a failure kept blocking.
Review. A second agent reviewed the commit without my conclusions. It found that the record was lost when only an approval hold was outstanding. That is fixed and has a test.
vp run check:changed passes.
Not checked.
- Live GitHub CI. The scenario uses synthetic GitHub responses.
- Model evals for the new wake text. This machine has no API key for them, and
evals/mcp-tool-usehas no case for this wake. - Desktop and mobile clients. No client code changed.
Written by Claude Fable 5.2 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code
- 1
- 2
Pushed83c52f5
Note
Written by
Claude Fable 5.2on behalf of AdamVerified on live GitHub CI#
I tested head
83c52f5310on a real pull request on github.com with real GitHub Actions runs. The repository is private, so its name and the URLs are left out.Setup#
- A dev server built from
83c52f5310ran on isolated state with the replay agent. It read GitHub through the normal two-minute sweep. - The pull request has 12 checks, and 5 of them are required. The required check
[C2] Check labelsfails within seconds until a person adds a label. The other required checks run for about one minute. - A released 0.1.10 server watched the same pull request at the same time, as the comparison.
Steps#
- Wait until the first CI run has finished, then call
watch_pull_request. - Push a second commit 45 seconds before the next sweep.
- Leave the pull request alone. No label, no comment and no further push.
Result#
Times are UTC on 2026-11-20.
Time GitHub 83c52f53100.1.10 08:42:52 New head b7d4903is pushed08:43:07 [C2] Check labelsfails08:43:37 Three required [T1]checks still runWake "checks failed" Wake "checks failed", received before 08:44:27 08:44:29 The last check, [T1] Behat, passes08:45:40 Wake "checks finished" No wake 08:46:22, 08:48:24, 08:50:24 Sweeps exit Success, no wakeThe wakes that the server with the fix stored, with the URLs removed:
08:43:37Z - Checks failed on b7d4903: - [C2] Check labels 08:45:40Z - Every check has finished on b7d4903: 9 passed, 1 still failing: - [C2] Check labels - 1 new comment: - coderabbitai: "No actionable comments were generated in the recent review. ..."The replay agent completed one turn for each wake. Of the 12 checks, 9 succeeded, 1 failed, 1 was skipped and 1 was neutral.
The watch that 0.1.10 stored, read after its 08:50:24 sweep:
"failedChecks": ["[C2] Check labels"], "passed": false, "owedChecks": [], "checksPending": false, "wakes": 0Not covered#
- This was one run with one ordering. The watch was armed before the failure. The unit tests cover the other orderings.
- The server polled GitHub. GitHub app event subscriptions were not in use.
- The web client ran in headless Chromium. Desktop and mobile were not exercised.
- A dev server built from
Evidence#
Steps: Start a PR watch with no required checks. Report an early labels failure while unit and docs remain pending. Let the agent response finish, then pass unit and docs without fixing labels and wait for the next normal watch read.
Environment: real Linux web app, Chromium, 1280×900, light theme, fresh isolated state. A synthetic GitHub upstream supplies identical check states; the replay fixture echoes the actual delivered watch message.
Proven: the scenario fails on base 019e55bad5 and passes on head 83c52f5310.
Before 019e55bad5 After 83c52f5310 Result No checks-finished notification after checks settle One completion wake: 2 passed, 1 still failing; labels named Early failure 

Checks finished 

Recording Before recording After recording Scenario · Synthetic feed and replay echo · Reproduction driver
Not shown:
- The failing-required-check variant, approvals, and reruns were not exercised; this capture covers no required checks.
- Live GitHub CI was not used; the real GitHub adapter read a deterministic synthetic upstream.
- Suppression of duplicate completion wakes on later polls was not separately exercised.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged thise6d5210
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.
No actionable comments were generated in the recent review.
Walkthrough
The pull-request watch adds a
checks-finishednotification for settled checks after a failure. It tracks when a completion wake is owed, renders the remaining failures and successful-check count, and updates the watch documentation and regression tests.Changes: Pull-request check completion
apps/server/src/orchestration-v2/pullRequestWatch.ts,packages/contracts/src/threadPullRequest.ts,apps/server/src/orchestration-v2/pullRequestWatch.test.tschecks-finishedafter outstanding checks and approvals settle. Tests cover failure ordering, approvals, reruns, and head changes. TheowedChecksdocumentation describes the failed-check case.apps/server/src/orchestration-v2/pullRequestWatch.ts,apps/server/src/orchestration-v2/pullRequestWatch.test.ts,docs/user/source-control.mdEstimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
t3dotgg,tiborrr,juliusmarmingeMerge Risk:
Minimal · up to
83c52Merge Risk: ⚪ Minimal · up to
83c52This adds a one-time wake when remaining checks finish after a reported failure. The change is narrowly scoped, has regression tests, and no merge-blocking risk was identified.
Pre-merge checks:
4
#30530, the earlier…#25539. It is closed and completed, so it supplies background only. No active directly linked targets remain, so no linked-issue coding requirements apply to this PR. The PR d…Full details: Title check
Explanation
The title names the fix and the main change: a PR watch now tells the agent when checks finish after a failure. It follows the conventional commit form and matches the changeset, which adds a checks-finished wake.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope and Verification sections, and each section has specific content. It explains the bug, the fix, the linked issue
#30530, the earlier PRs it replaces, the tests and scenario proof, and what was not checked. It does not add a separate note on agent model and harness in the header, but it ends with a model and harness line, which the template asks for.Full details: Linked Issues check
Explanation
The only linked issue is
#25539. It is closed and completed, so it supplies background only. No active directly linked targets remain, so no linked-issue coding requirements apply to this PR. The PR description names#30530as the bug it fixes, but#30530is not a linked issue in this assessment. The#25497and#25539references are historical context. The PR's stated goal is a fix for the watch that stays silent after checks finish following an early failure. The change summary matches that goal. It adds a checks-finished change kind to evaluatePullRequestWatch, reuses owedChecks, and adds tests for the described sequences.Full details: Out of Scope Changes check
Explanation
Every changed file relates to the watch behavior the PR describes. apps/server/src/orchestration-v2/pullRequestWatch.ts adds the checks-finished kind, the owed-wake logic, and the rendering. pullRequestWatch.test.ts adds the regression cases and updates the two expectations that pinned the missing wake. docs/user/source-control.md adds one clause that lists the new wake. packages/contracts/src/threadPullRequest.ts only updates the owedChecks comment, and the schema is unchanged. The PR states that the reactor, schema, and watch_pull_request description are unchanged. The review relies on the change summary and the PR description. I did not read the full diff, so the per-hunk match is inferred from those summaries.
Finishing Touches
Generate unit tests (beta)
acd55bdc-56c6-4924-be95-66473164de3fReviewing files that changed from the base of the PR and between 019e55bad5f9d5bea0ad69fe4b6a44f2c2ba52a9 and 1daa69fb52058efac1e52913118405f264d191f2.
apps/server/src/orchestration-v2/pullRequestWatch.test.tsapps/server/src/orchestration-v2/pullRequestWatch.tsdocs/user/source-control.mdpackages/contracts/src/threadPullRequest.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.