Repository navigation
review: poll statusCheckRollup + mergeStateStatus instead of gh pr checks --required - #308
Merged
Merged
Conversation
…hecks --required` `gh pr checks --required` only sees already-registered check-runs, so a late-starting `if: always()` omnibus (e.g. `check-ok-to-merge` that waits on a big `needs:` matrix) can race the polling loop: the early polls see only the fast required contexts green and exit while the real matrix is still running or has already failed. Incident trace in #305 (downstream: PRQL/prql#5807, PRQL/prql#5809). Switch the loop to `gh pr view --json mergeStateStatus,reviewDecision,statusCheckRollup`: - `statusCheckRollup` surfaces every check-run and status context on the commit, not just the required ones — filter own-run by URL and count IN_PROGRESS / QUEUED / PENDING / WAITING to decide whether to keep waiting. - `mergeStateStatus` accounts for required-but-unreported contexts that `gh pr checks` cannot see. If the PR is `BLOCKED` and `reviewDecision` is not `REVIEW_REQUIRED`/`CHANGES_REQUESTED`, a required context is still outstanding — keep polling. - Bump budget 10 → 15 minutes since the loop now waits on every check-run on the commit (not just required). Mirror the update in the `review` skill's Step 6 so the duplicate snippet does not drift. Co-Authored-By: Claude Opus 4.7 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
…check The `STATE=BLOCKED && !REVIEW_REQUIRED && !CHANGES_REQUESTED → continue` branch added in #308 deadlocked: `mergeStateStatus` stays `BLOCKED` for the entire run because our own review check is IN_PROGRESS, so the loop kept continuing until the 15-minute timeout. The API can't distinguish "self-blocking" from "required context not yet registered" without admin scope on branch protection. Use the rollup (with own run filtered out) as the sole exit signal, and add a 30s grace re-check to cover the short omnibus-registration window from #305. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 task
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
…check (#311) Fixes the deadlock introduced in #308. The CI monitor loop kept continuing until its 15-minute timeout on every bot run. ## Root cause `mergeStateStatus = BLOCKED` while our own review check is IN_PROGRESS. The loop's fallback branch `BLOCKED && !REVIEW_REQUIRED && !CHANGES_REQUESTED → continue` was intended to catch "a required context hasn't registered yet", but can't distinguish that from "our own check is still running" — the API doesn't surface which specific context is blocking without admin scope on branch protection. So with `PENDING=0` (own filtered out), `STATE=BLOCKED`, `DECISION=APPROVED`, the loop just kept going. Branch protection stayed BLOCKED until the bot exited, which it couldn't do until the loop exited. Observed on tend's own `tend-review` run 24614997930. ## Fix - Use `statusCheckRollup` (with own run filtered out) as the sole exit signal. - After rollup PENDING reaches 0, sleep 30s and re-check. This covers the short gap between `needs:` jobs finishing and an `if: always()` omnibus check-run (e.g. `check-ok-to-merge`) registering — the scenario #308 was built to catch. - Drop `mergeStateStatus` and `reviewDecision` from the exit decision. Commented inline why. ## What this gives up vs #308 The `BLOCKED + !REVIEW_REQUIRED` backstop for required contexts that never register at all (workflow file typo, etc.). In that case the loop exits cleanly; the human maintainer sees the BLOCKED state in the UI and handles it. The grace re-check covers the omnibus registration race, which was the actual scenario from #305. ## Test plan - [ ] Downstream verification on next nightly regeneration — the canonical signal is whether `tend-review` runs complete in under 15 minutes again. > _This was written by Claude Code on behalf of Maximilian_ Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
May 8, 2026
## Summary - Bumps generator version 0.0.16 → 0.0.17 - 57 commits since 0.0.16; the headline change is #375 (gate fork-exposed scheduled workflows on `github.repository_owner` so consumer-repo forks no-op on the cron and stop generating cross-repo CheckSuite notifications back to `tend-agent`) - Other notable changes: workflow header stamps tend version (#316), bot-token rebound to `GITHUB_TOKEN` (#373), review skill draft/light-mode + polling improvements (#308, #311, #315, #362) ## Test plan - [x] `uv run pytest` — 188 passed - [x] `pre-commit run --all-files` — clean - [ ] After merge: tag 0.0.17, PyPI publishes, regenerate tend's own workflows with `uvx tend@latest init` Co-authored-by: Claude <[email protected]>
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.
Fixes #305.
Summary
gh pr checks <n> --requiredpolling loop with agh pr view --json mergeStateStatus,reviewDecision,statusCheckRolluploop so late-registeringif: always()omnibus checks (e.g.check-ok-to-merge) can't race the polling and make the bot report a broken PR green.reviewStep 6 — the snippet was duplicated, flagged in my first comment on review: CI monitor'sgh pr checks --requiredracesalls-green/if: always()omnibus checks #305.Why this shape
From issue #305 + discussion with @max-sixty:
gh pr checks --requiredonly reports check-runs that are already registered on the commit. An omnibus withif: always()and a longneeds:list doesn't register its check-run until the needs start resolving — so early polls see only the fast required contexts (e.g.pre-commit.ci - pr), the loop exits green, and the real matrix is still running or has already failed.The new loop pairs two signals that between them don't have that blind spot:
statusCheckRollup— every check-run and status context on the commit, not just required ones. Filter out the current run by URL and countIN_PROGRESS/QUEUED/PENDING/WAITINGitems. This alone catches the PRQL incident because the test matrix jobs are in the rollup even though they're not directly required by branch protection.mergeStateStatus+reviewDecision— backstop for the narrow window where matrix jobs are already terminal but the omnibus check-run hasn't yet registered.mergeStateStatus = BLOCKEDwithreviewDecisionnot in{REVIEW_REQUIRED, CHANGES_REQUESTED}means a required context is outstanding and we should keep polling;BLOCKEDwith review-required means approval is the blocker (CI-wise we're done, exit).UNKNOWN(mergeStateStatushasn't been computed yet) also keeps us polling — GitHub computes it asynchronously after a push.Known limitation
BLOCKED+REVIEW_REQUIREDcan mean either (a) approval-only block with all checks done or (b) approval-needed and a required context not yet registered. These are indistinguishable from a single snapshot without reading branch protection, which most bot PATs can't do. In practice the registration window for an omnibus is seconds (between lastneeds:job completing and the job starting), so a 60-second poll cadence nearly always catches the next registered state. Documented in-comment.Test plan
jqfilter against a real PR (PRQL/prql#5807) — returnsPENDING=0on a merged PR as expected.uvx pre-commit runpasses on both files.gh pr checks --requiredracesalls-green/if: always()omnibus checks #305 is the canonical case to watch.🤖 Generated with Claude Code