Repository navigation
Description
Question
How should merge-bot-task.yml read a pull request's checks, so that on a base whose ruleset requires none it can wait for them and then merge?
This blocks #4377. No pull request is open for it yet. Its branch burndown/merge-bot-operational-race holds no commits.
Why it needs the maintainer
Fixing #4377 while keeping D8.1's meaning, the checks are the gate, needs the job to wait for the head's checks and then merge with a bound. The job cannot read checks today. Every call runs under the App token, and the ptr727-codegen App's public permission set is contents: write, metadata: read, and pull_requests: write. Reading check runs needs checks: read, and reading commit statuses needs statuses: read. The operational repositories are private, so a public read does not cover them. Each way of giving the job that read reaches past the tree or changes every caller.
What was measured
gh pr merge --automerges at once rather than arming when the pull request readsCLEAN,HAS_HOOKS, orUNSTABLE, perisImmediatelyMergeableingh'spkg/cmd/pr/merge/merge.go.UNSTABLEcovers a pending or a failing check.- So on an operational
develop, the threedeveloplegs Merge Bot Fails on an Operational Develop When a Check Is Still Running #4377 cites as merging merged before their lint job finished. Today's merge on that base is not gated on checks at all. - The failing leg ran eight seconds after the pull request opened, before any of its test checks had started. It read a state outside that set, most likely
UNKNOWNwhile mergeability was still being computed. Soghtried to arm, and GitHub refused to arm on a branch with no required rules. - The merge-bot's own check runs post on the pull request's head commit. A wait that reads the head's checks therefore has to leave out its own workflow's runs, or it waits on itself.
Options, recommended first
- Grant the App
checks: readandstatuses: read. Recommended. Both are read-only, and the job already makes every call with the App token. The change to the hub is then confined tomerge-bot-task.yml, its test, and D8.1. Where the base's rules carry norequired_status_checksrule, the merge step waits for every check on the pinned head except its own workflow's, under a bound inside the job's timeout. It merges directly once they all pass, and fails visibly on a failed check, a moved head, or the bound. A base with required checks keeps arming as today. Effect on the parked work: it resumes as a hub-only change once the grant is made and each installation has accepted it. It must not reach an operational repository's pin before then, or every wait fails on its first read. - Grant
GITHUB_TOKENchecks: readandstatuses: readin each caller stub. The task reads with that token and writes with the App token. No App setting changes. The cost is a change to every repository'smerge-bot-pull-request.ymland to the documented stub, which today states thatGITHUB_TOKENgets no scope. A caller left on the old stub fails its first read. Effect on the parked work: the same task change, plus a stub edit in every fleet repository and in the hub's catalog, outside this group's claimed files. - Retry the arm, bounded, with no check read. The job waits until the pull request leaves
UNKNOWNand runsgh pr merge --autoagain, soghmerges at once. This closes the race Merge Bot Fails on an Operational Develop When a Check Is Still Running #4377 reports and needs no permission. It keeps merging on an operationaldevelopwhile checks are pending or failing, which makes D8.1's "the required checks are the gate" vacuous there. It is a merge-without-checks choice. Effect on the parked work: a small hub-only change, mergeable without waiting on anything.
🤖 Generated with Claude Code
Activity
ptr727 commentedon Nov 24, 2026
Maintainer's answer, 2026-11-24 (recorded at the session handoff): option 1. Grant the codegen App
checks: readandstatuses: read. The fix stays inmerge-bot-task.yml, its test and WORKFLOW.md D8.1: wait for the pinned head's checks with a bound inside the job timeout, then merge. Owed maintainer step before the parked group resumes: change the App's permissions, then accept the new permissions on each installation. The fix must not reach an operational repository's pin until each installation has accepted, or every wait fails on its first read. #4377 is marked blocked on that step.