Skip to content

fix(pr-merge): re-read the head before closing an empty-diff pull request - #17689

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/pr-merge-empty-diff-head-recheck
Nov 20, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/pr-merge-empty-diff-head-recheck

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: review advisory from pr-pipeline-sandbox#403 on synced code

Summary

enable-auto-merge.mjs closes a lanes App pull request whose diff against main is empty. decide judges the diff empty from the changed-files read made earlier in the run, and the close was a plain PATCH state: closed with no head check in between, so a push in that window closed a pull request that now changes files.

Fix

Before the disarm and the close, the close path reads the pull request again (GET /repos/{repo}/pulls/{n}) and leaves it open, with no disarm, close or note, when its head is not the head the run judged. The run logs left open: its head moved to <sha> after its diff read empty, and a PR-scoped run hands on that reason as its outcome instead of the empty-diff refusal; the next run judges the new head. A failed read goes to the existing catch: it counts as a failure and the next sweep tries again. This is the same fresh-head read the approval lift already makes before its label delete.

Verification

  • node --test --test-concurrency=4 .github/scripts/pr-merge/enable-auto-merge.test.mjs: 247 pass, 0 fail. The new test, "an empty-diff pull request whose head moved after its diff read is left open", checks that an armed empty-diff pull request whose head moved gets no disarm, no close and no note.
  • scripts/check-affected.sh: 13 passed, 7 skipped.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 20, 2026 14:47
…uest

decide judges the diff empty from the changed-files read made earlier in
the run, and the close was a plain PATCH with no head check between them,
so a push in that window closed a pull request that now changes files.
The close now reads the pull request's head again first and leaves it
open, with no disarm, close or note, when the head is not the one judged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 20, 2026 20:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T20:08:02.499631Z e8dbd45 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 45344be5cccd142f2ab7728abe87905bfe3e42a3: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found.

This review covers only the changes since e8dbd45b. The only file that changed is .github/scripts/pr-merge/enable-auto-merge.test.mjs, and I read its whole hunk.

  • Test-only change: the push adds three assertions to the existing test "an empty-diff pull request whose head moved after its diff read is left open". They run the script in PR-scoped mode (workflow_dispatch with EVENT_PR: "2") against an empty-diff pull request whose head moved. They check that nothing is closed and that the outcome is the moved-head skip reason. Running no code in CI and granting nothing, the change touches no security surface. It does not change the merge-hold control in enable-auto-merge.mjs, which this lane reviewed at the previous head and found only narrowed.
  • Prior findings: the earlier summary comment reported 0 findings, so nothing is repeated here.
  • Blocking only: this lane already reviewed an earlier head, so only CRITICAL and IMPORTANT findings would be reported. There are none.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on e8dbd45b3a279296841846ac4e96a05760349774; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 45344be5cccd142f2ab7728abe87905bfe3e42a3: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #17689, incremental since e8dbd45b, blocking findings only

This push changes one file, .github/scripts/pr-merge/enable-auto-merge.test.mjs. It adds the test my earlier advisory asked for (thread).

The new test is a PR-scoped workflow_dispatch run aimed at PR #2. In it, #2 has an empty diff (files: []) and its head moved after the diff read (freshHead: "e".repeat(40)). The test asserts two things:

  • No note is sent.
  • outcome equals skipped: its head moved to <sha> after its diff read empty.

That assertion now fails if the outcome override at enable-auto-merge.mjs:2509 is removed, so the gap I raised is closed.

The env literal it passes matches the module's WAKE constant (enable-auto-merge.test.mjs:2481). run gives back outcome (L454), so the assertion checks real output. I did not run the tests: I have no shell in this run.

No new findings. This review was blocking only, because the lane already reviewed an earlier head.

Loosened checks would be marked: fail (the default, because the wrapper wrote no loosened_check_verdict: or loosened_check_patterns: lines). That means 0 patterns and no consumer entries. With no decision-record line, I did not check the citation requirement. The change only adds a test assertion and loosens nothing.

No closing issue: the PR names none, so there are no acceptance criteria to check. I found no embedded directives in the PR context.

Verifier dropped 0 of 0 candidates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit bbdd011 Nov 20, 2026
52 checks passed
@kyle-sexton
kyle-sexton deleted the fix/pr-merge-empty-diff-head-recheck branch November 20, 2026 20:46
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant