Repository navigation
cockpit wait: green only once GitHub has every run and job for the head - #118
Merged
Merged
Conversation
A wait that started 8 s after a push returned "1 of 1 green" at once from the previous head's run: the fleet view learns a new head only from its first run, and the new head's run (nine jobs, six behind `needs:`) was still queued. GitHub's check list had the same gap: a needs-gated job has no check run until its needs finish. The daemon now asks GitHub for the head first (an open PR's branch ref wins over the PR's lagging head.sha) and confirms every fleet green there: every workflow run for the head (actions/runs?head_sha=, newest per workflow) completed, every job of each and every other check passed, and nothing new for 30 s. Until then the answer is pending with GitHub's reason; GitHub not answering is not a yes. Greens carry `verified`. The CLI confirms an older daemon's unverified green itself with gh, and its GitHub fallback uses the same rule. Tests replay the race (a new head's run still queued, a workflow_run run registering after the first run finished). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cockpit wait <repo> --pr <n>(and MCPwait_for_checks) could exit 0 before a PR's checks had all registered. On a private product repo's PR #5 (2026-10-24) the wait started at 17:34:20Z, 8 s after a push, and printed1 of 1 greenin 0 s. Run 40116718009 on the new head (9 jobs) had been created at 17:34:12Z and was stillqueued. Every agent merges on exit 0.Cause
findCheckSetlearns a PR's head from theprHeadof runs the glance has seen. Right after a push the fast loop has not seen the new head's run yet, so the newest run carryingprHeadis the previous commit's. Its green set (1 of 1, the previous head's singlecirun) was returned at once, with no call to GitHub.githubStateis green when every check run GitHub lists has passed. A job behindneeds:has no check run until its needs finish, so afterguardandchangespassed, every listed check was green while the run was still in progress with six jobs to come. Nothing looked at whether the run itself had completed. There was no settle window for runs that register later (pushandpull_requestevents,workflow_run).Fix
waitForChecksasks GitHub for the head first (pulls/<n>, and the open PR's branch ref, which moves beforehead.shadoes) and decides the fleet set for that head only.githubVerdictagrees. It needs every workflow run for the head (actions/runs?head_sha=, newest per workflow) completed, every job of each completed run (jobs?filter=latest), plus other apps' checks and statuses, passed (success/skipped/neutral), and GitHub quiet for 30 s (SETTLE_MS, measured at fetch time). Until then the answer ispendingwith GitHub's reason. GitHub not answering is not a yes.verified: { head, runs, jobs, checks }. The CLI prints(GitHub: 1 run, 9 jobs).verified(an older daemon) is confirmed with the user'sghbefore it is believed. The dashboard-unreachable fallback (GHChecksProbe) uses the same rule: branch ref, runs for the head, settle.Tests
dashboard/test/checks.test.jsreplays the incident with a fake clock. The fleet holds the old head's green, and GitHub has the new head's run queued, then in progress, then complete with 9 jobs. The green now comes at ≥190 s, after the run finishes and 30 s of quiet. On the old code the same test readsgreen after 0 ms. Also covered: a second (workflow_run) run registering 12 s after the first finished, thewait=0right-after-push case, GitHub red for a run the fleet has not seen, settle, unread jobs, replaced runs, and other apps' checks.APITests.swift:GitHubCheckswith a green rollup while the run is in progress is pending, settle, and a run with no job yet is its own row. A daemon green withoutverifiedwaits for GitHub, turns red on GitHub's red, and times out when GitHub cannot confirm.npm test1107 pass;swift test126 pass; fixtures regenerated (checks-greengainsverified).Deploy
fleetd.js and lib/checks.js changed, so the daemon on ultra needs a restart via the idle-wait deploy. The CLI needs reinstalling on the laptop.
🤖 Generated with Claude Code