Skip to content

Decide How the Merge Bot Reads Checks to Wait on a Base Requiring None #4389

Done

Description

@ptr727

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 --auto merges at once rather than arming when the pull request reads CLEAN, HAS_HOOKS, or UNSTABLE, per isImmediatelyMergeable in gh's pkg/cmd/pr/merge/merge.go. UNSTABLE covers a pending or a failing check.
  • So on an operational develop, the three develop legs 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 UNKNOWN while mergeability was still being computed. So gh tried 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

  1. Grant the App checks: read and statuses: 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 to merge-bot-task.yml, its test, and D8.1. Where the base's rules carry no required_status_checks rule, 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.
  2. Grant GITHUB_TOKEN checks: read and statuses: read in 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's merge-bot-pull-request.yml and to the documented stub, which today states that GITHUB_TOKEN gets 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.
  3. Retry the arm, bounded, with no check read. The job waits until the pull request leaves UNKNOWN and runs gh pr merge --auto again, so gh merges 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 operational develop while 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

  1. added
    decision
    on Nov 24, 2026
  2. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Maintainer's answer, 2026-11-24 (recorded at the session handoff): option 1. Grant the codegen App checks: read and statuses: read. The fix stays in merge-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.

  3. removed
    decision
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions