Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a PR watch tells the agent when the checks finish after a failure #39596

Mergedaglowienka(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/39596/headmerged by juliusmarminge View on GitHub

Problem

A PR watch stays silent when the remaining checks finish after an early failure.

  1. A check fails while other checks still run. The watch wakes the agent with "checks failed".
  2. The agent ends its turn and says that it waits for the other checks.
  3. 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-finished when the last check finishes.
  • "baselines existing failures and conflicts, then reports new ones" now expects checks-finished next to checks-failed when 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-finished kind, the reuse of owedChecks, the failed outcome 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 success counts 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 on main.
  • 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, mergedBy and mergeQueueRemovals, which PullRequestCore reads 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-use has 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. Pushed83c52f5

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The pull-request watch adds a checks-finished notification 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

      Layer / File(s)Summary
      Track and detect check completion
      apps/server/src/orchestration-v2/pullRequestWatch.ts, packages/contracts/src/threadPullRequest.ts, apps/server/src/orchestration-v2/pullRequestWatch.test.ts
      The evaluator tracks owed failed checks and reruns, then emits checks-finished after outstanding checks and approvals settle. Tests cover failure ordering, approvals, reruns, and head changes. The owedChecks documentation describes the failed-check case.
      Render and classify completion notifications
      apps/server/src/orchestration-v2/pullRequestWatch.ts, apps/server/src/orchestration-v2/pullRequestWatch.test.ts, docs/user/source-control.md
      The watch renders the completion message, adds its summary label, and classifies it as a failed notification outcome. Tests check that the notification occurs once. The documentation adds completion of other checks after a failure as a wake condition.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: t3dotgg, tiborrr, juliusmarminge

      Merge Risk: Minimal · up to 83c52

      Merge Risk: ⚪ Minimal · up to 83c52

      This 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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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-f…
      Description checkPassedThe 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…
      Linked Issues checkPassedThe 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 d…
      Out of Scope Changes checkPassedEvery 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. pullReque…
      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 #30530 as the bug it fixes, but #30530 is not a linked issue in this assessment. The #25497 and #25539 references 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)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 019e55bad5f9d5bea0ad69fe4b6a44f2c2ba52a9 and 1daa69fb52058efac1e52913118405f264d191f2.

      Files selected for processing: 4

      • apps/server/src/orchestration-v2/pullRequestWatch.test.ts
      • apps/server/src/orchestration-v2/pullRequestWatch.ts
      • docs/user/source-control.md
      • packages/contracts/src/threadPullRequest.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    3. Note

      Written by Claude Fable 5.2 on behalf of Adam

      Verified on live GitHub CI

      I tested head 83c52f5310 on 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 83c52f5310 ran 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 labels fails 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

      1. Wait until the first CI run has finished, then call watch_pull_request.
      2. Push a second commit 45 seconds before the next sweep.
      3. Leave the pull request alone. No label, no comment and no further push.

      Result

      Times are UTC on 2026-11-20.

      TimeGitHub83c52f53100.1.10
      08:42:52New head b7d4903 is pushed
      08:43:07[C2] Check labels fails
      08:43:37Three required [T1] checks still runWake "checks failed"Wake "checks failed", received before 08:44:27
      08:44:29The last check, [T1] Behat, passes
      08:45:40Wake "checks finished"No wake
      08:46:22, 08:48:24, 08:50:24Sweeps exit Success, no wake

      The 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": 0

      Not 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.
    4. 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 019e55bad5After 83c52f5310
      ResultNo checks-finished notification after checks settleOne completion wake: 2 passed, 1 still failing; labels named
      Early failureBefore: early failureAfter: early failure
      Checks finishedBefore: missing completion wakeAfter: completion counts and remaining failure
      RecordingBefore recordingAfter 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.
    5. juliusmarminge added labelstakeover:ready

    6. juliusmarminge removed labelstakeover:in-progress

    7. juliusmarminge merged thise6d5210

    8. juliusmarminge closed this

    9. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.