Skip to content

CI shepherd: a permanent auto-merge refusal (token lacks workflow scope) fails every pass and flaps needs-fix -> run storm #6061

Closed

Description

@squid-protocol

What happened (2026-10-22, ~16:21Z–20:03Z)

PR #5950 had shepherd:merge and edited .github/workflows/det-sweep.yml. AUTOMATION_PAT lacked the Workflows permission, so every gh pr merge --auto call failed:

#5950 auto-merge on: FAILED: GraphQL: Pull request refusing to allow a Personal Access Token to create or update workflow `.github/workflows/det-sweep.yml` without `workflow` scope (enablePullRequestAutoMerge)

shepherd_gh.py exited 1 on that failure, and the PR's shepherd:needs-fix label kept flipping on and off: each reconcile pass removed it, and it was then re-added. Every add or remove fired another shepherd-event.yml run, which failed the same way. Result: about 100 label flips on #5950, about 195 red shepherd runs (99 label-event, 95 reconcile on main) and about 950 runner-minutes, until the owner merged #5950 by hand.

Fix (shepherd only)

  1. In apply(), recognise a permanent permission refusal (the without \workflow` scope` / "refusing to allow a Personal Access Token" GraphQL error, and similar 403 or permission errors) as distinct from a transient failure.
  2. On that error, label the PR once with an owner-facing status (e.g. shepherd:needs-owner, or reuse an existing one) and post one comment that says why ("this PR edits workflow files; the shepherd token can't enable auto-merge. Merge it by hand, or give AUTOMATION_PAT Workflows: read and write"). Don't exit non-zero for it.
  3. decide() must skip auto-merge attempts on a PR carrying that status, so neither reconcile nor the label event retries it every pass.
  4. Stop the needs-fix flapping: a pass must not remove a status label that the same or the next pass will put straight back. Add a regression test in tests/tools/test_shepherd_gh.py that replays the Det Sweep: Db2 shards restore the pinned Db2's first start instead of repeating it (Part of #5882) #5950 sequence (merge-ready + auto-merge refused) and asserts there is no label churn and the run does not fail.

Optional: decide() could pre-check whether a PR touches .github/workflows/ and go straight to the owner label, without trying auto-merge first.

Owner side

The owner has updated the token (2026-10-22, ~20:05Z); not yet confirmed on a live workflow-editing PR. The fix above should land regardless, because any future permission gap would cause the same storm.

Evidence: runs 39813308373 (first reconcile failure) … 39844551634 (last label-event failure); #5950 issue events.

Activity

  1. added
    bug
    ci-cd
    priority: high
    scope:infra
    on Oct 22, 2026
  2. squid-protocol commented on Oct 22, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host nyx, lease renewed 2026-10-23T19:20Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:nyx label.

  3. squid-protocol commented on Oct 23, 2026

    @squid-protocol
    OwnerAuthor

    Fixed by #6290: permanent auto-merge refusal now labels shepherd:needs-owner once, posts one comment, exits 0; decide() skips retries; needs-fix flapping suppressed; regression test replays the #5950 sequence. The optional workflow-path pre-check was not done and is not needed for acceptance.

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

    bugci-cdclaim:nyxpriority: highscope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions