fix(ci): add GraphQL fallbacks to gh-merge-green

Merged
TE
19d ago
+87-15

Summary

gh-merge-green currently refuses a green exact-head PR when GitHub REST is exhausted, even when the shared GraphQL budget and the coordinator's exact-head cache are healthy. That stranded the feed-route merge after all checks passed.

This adds GraphQL fallbacks for:

  • base workflow detection and ci-status routing;
  • exact-head check runs, preserving app and check-suite identity;
  • legacy commit status contexts.

REST remains the first route. The fallback is only used after the REST read fails, and it still fails closed if GraphQL cannot return a complete verdict. The final merge remains the normal guarded gh pr merge --match-head-commit mutation.

Validation

  • bash -n scripts/gh-merge-green
  • git diff --check
  • python3 scripts/verify-local.py --help
  • With REST exhausted, a simulated merge of HQ #2451 exact head c8aeadeaa59c90ad752a78071df86dad61d2d9ca reached the normal merge command through the GraphQL fallback; the merge operation itself was intercepted for the test.

Changelog

Fixed: keep exact-head merge verification available when REST is rate-limited but GraphQL remains healthy.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Adds GraphQL and verified-Git fallbacks to gh-merge-green so exact-head merges stay available when GitHub REST is rate-limited. REST remains the primary route; fallbacks activate only after a REST read fails and still fail closed if they cannot return a complete verdict. They cover base workflow detection, exact-head check runs (preserving app and check-suite identity), legacy commit status contexts, changed-file listing, and diff retrieval via a verified cmux checkout. Paginated check-run results with remaining pages are treated as incomplete, missing workflows are distinguished from other lookup errors, and the final merge mutation is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of pull request validation when standard checks for workflow files, check runs, changed files, or commit statuses are unavailable.
    • Improved handling of workflow responses, including clearer distinction between missing workflows and lookup failures.
    • Added a verified fallback for retrieving pull request changes when the GitHub diff service is unavailable; validation still fails safely if the changes cannot be verified.