Skip to content

dev-lead: PR auto-merged mid-run fails the job on push (hold auto-merge while working) #452

Closed

Description

@don-petry

Summary

A dev-lead run can fail with a red ✗ on git push when its PR is auto-merged out from under it mid-run. The PR's branch is deleted on merge, so the straggler push is rejected:

! [remote rejected] fix/... -> fix/... (cannot lock ref 'refs/heads/fix/...':
  unable to resolve reference 'refs/heads/fix/...')
##[error]git push failed — check remote access and branch permissions

Observed in run 27078382804: the review-changes run committed at 00:54:45 — 1 second after PR #449 auto-merged (00:54:44) and its branch was deleted.

Root cause

Two recently-landed features interact badly:

  • feat(dev-lead): enable auto-merge (squash) by default on every PR it touches #447 — auto-merge (squash) enabled by default on every PR dev-lead touches.
  • GitHub's auto-merge is asynchronous and is not gated by the workflow concurrency lane. So while dev-lead is mid-edit on a PR, a review approval landing can satisfy branch protection and make GitHub merge + delete the branch immediately — even though a dev-lead run still holds that branch and will push to it.

Per-PR concurrency serialization (#450) prevents two dev-lead runs from fighting, but it cannot stop GitHub's auto-merge, because the merge is not a dev-lead run.

Fix

  1. Hold auto-merge OFF while dev-lead works a PR. Disable auto-merge at the start of any PR-modifying run; restore it on the way out via an EXIT trap (so it is restored on success, error, or timeout). This prevents a mid-flight approval from merging the branch out from under the agent. Auto-merge is only restored if the run disabled it — it never newly enables auto-merge on a PR that did not have it.
  2. Push defensively. If git push is still rejected because the PR was merged/closed (branch deleted) mid-run, treat it as a benign no-op (::notice::, exit 0) instead of a hard failure.
  3. Lock same-PR serialization with a test. The existing test_concurrency_config.sh still asserted the pre-fix(dev-lead): per-issue/per-PR concurrency lanes so issue pickups aren't cancelled #450 repo-wide group and was stale (failing against main); update it to assert the per-PR/per-issue lanes + cancel-in-progress: false that serialize same-PR runs, on both the inline and reusable workflows.

Backstop for the rare hard-kill (SIGKILL escapes the trap): the existing enable-auto-merge-on-bot-approval intent re-enables auto-merge on the next approval.


Update — also fix: dev-lead resolves review threads without replying, and leaves fixed bot threads open

While validating this PR, two related defects in dev-lead's review-thread handling surfaced (they're why a Copilot thread on this very PR stayed open and blocked re-review):

  1. Silent resolves. The review prompts told the engine to resolve a fixed thread but never to reply with what it changed. Reviewers got a resolved thread with no explanation of the fix.
  2. Trigger-gated resolution. fix-reviews.md only resolved threads whose author matched ${TRIGGERING_REVIEWER}. So a thread fixed during a different reviewer's run (e.g. a Copilot thread addressed in a Codex-triggered run) was never resolved — and pr-review won't approve until all comments are resolved, so the PR stalls.

Fix (prompts): the three review prompts (fix-reviews, review-changes, fix-bot-comment) now instruct the engine to, for every thread it fixes, post a reply naming the specific file/function changed and how it addresses the concern (addPullRequestReviewThreadReply, body passed as a GraphQL variable), then resolve. fix-reviews now resolves every bot thread it fixed regardless of which reviewer triggered the run (human threads stay gated to the trigger). The rubber-duck phase verifies each fixed thread was replied-to and resolved. test_prompt_coverage.sh asserts these instructions are present.

Activity

  1. 23 remaining items

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

    bugBug reports

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions