Skip to content

🐛 [v6] merge: a PR merges even when the merge would close an issue it says stays open, or another PR named in a commit message #15025

Closed

Description

@Danathar

Target: v6.

Target branch: v6 only. Open the PR with --base v6. hive-open-pr defaults to the repo's default branch (v5) when --base is omitted.
Citations: path:line against v6 @ 7f89f9d01, paths relative to src/.

A PR can merge when the merge would close something the PR does not mean to close: an issue its own body says stays open, or another PR named in a commit message.

What happened

Both cases are from projectbluefin/testsuite on 2026-10-28.

1. A body that says an issue stays open and also closes it. #1057 has "Refs #1023 — partial … remain open" on line 15 and a bare "Closes #1023" on line 33. Its closingIssuesReferences is [1023]. A maintainer comment on #1023 (16:09Z) lists three items explicitly left for later. GitHub closes #1023 when #1057 merges.

  • The hive's own partial handling cannot help: partialForDirectClose (pkg/github/close_on_merge.go:740-748) honours Refs only when there is no closing keyword, and no hive path reopens an issue that GitHub closed.
  • The reviewer flagged the contradiction as a medium intent-alignment finding, which is below review.severity.block_at, so nothing gated on it. fix: data races in classify and tokens packages #1051 had the same shape until its author edited it.
  • In these two PRs the Closes line was appended by the contributor wrapper's auto-close step. A wrapper PR to v6 stops that append when the body says the issue stays open: 🐛 fix(gh-wrapper): stop posting empty, blanked and @path bodies for agents #15024. A person or an agent can still write both lines by hand, so the merge itself needs a gate.

2. A commit message that closes another PR. PR #1054's single commit (0636aabff) says "Apply the same fix #1036 makes for Files/apps". On the default branch, GitHub treats "fix #N" as a closing keyword. The hive squash-merged #1054 at 16:07:00Z, and GitHub closed the open PR #1036 at 16:07:02Z with no comment. The timeline closed event carries commit_id 0636aabff and the actor hivecommons-hive[bot], because the App did the merge.

Fix

A. Contradiction gate (all lanes, early).

  • Detector: add a pure function next to bodySaysIssueStaysOpen (pkg/github/pr_issue_link.go:363), e.g. ClosingContradictions(body, repo string) []int. It returns each same-repo issue N that the body both closes (FindClosingKeywordReference, pkg/github/prclaims.go:507) and says stays open or is partial. "Stays open or partial" means a phrase bodySaysIssueStaysOpen already recognises, or a Refs/References/Part of … #N line that also says partial, remaining, deferred, follow-up or not (yet) addressed.

  • Gate: add an Engine helper with no API cost, returning reason closing-contradiction:#N, with the constant in pkg/stageengine/prstage/reasons.go. Call it early in each lane so the PR never reaches 090/095:

    • contributor lane after contributorLaneConflictReason (automerge_contributor_lane.go:1199), before admission;
    • the self-authored, trusted-author and queued lanes at their first label and exempt checks in automerge_sweep.go.

    The existing linkedIssueGate (automerge_linked_issue.go:67) is too late for this: it runs only for a head that would otherwise merge, after the soak.

  • Routing: add the reason to stageFixingReasons (pkg/stageengine/derive_pr_classify.go:304), giving 070 for a hive PR, 072 for a relay and 071 for a human.

  • Nudge: add a nudgeDiagnosis case (automerge_contributor_nudge.go:90) with this ask: "The body says #N stays open (Refs … partial) and also Closes #N, so GitHub would close #N on merge. Keep one: drop the closing keyword, or the partial note. No new commit is needed." Make the nudge's "will not merge it until the head changes" sentence depend on the reason, because here a body edit clears it.

B. Closing keywords that target a PR (merge-ready head).

  • Detector: before the hive merges with squash or merge, find every closing keyword in the PR body and in each commit message on the head. Reuse the commit list MergeCreditor.Prepare already reads where possible (pkg/github/merge_credit.go:187).
  • Gate: for each target #N in the same repo that is a pull request, hold the merge with reason closing-keyword-targets-pr:#N. The number is known for a closing claim; use Issues.Get and IsPullRequest(), at most one call per number per head, cached. Route it like A, with an ask to reword the commit ("fix #1036 closes PR feat: event-driven watcher via pub-sub-tmux #1036 on merge; write same change as #1036 instead"). A PR is never the intended target of a closing keyword.
  • Placement: this one can sit with linkedIssueGate, since it only matters for a head that is about to merge.

Acceptance criteria

  • A PR whose body both closes #N and says #N stays open or is partial cannot reach 090, 095 or a merge until the body is fixed. Editing the body (no new commit) releases it.
  • A body with only Refs #N, only Closes #N, or Closes #N plus a bare Refs #N (reporter confirmation required) is unaffected.
  • A merge-ready PR whose body or commit message has a closing keyword targeting an open or closed PR in the same repo is not merged. It is returned to its author with the ask, and the PR is not closed.
  • Closing keywords that target issues behave as today.

Test plan

Out of scope

  • Making the reviewer's intent-alignment finding blocking by class. Severity routing is per severity only (review_backlog_routing.go:362-388), and findings carry no class, so the deterministic gate above is the cheaper fix.
  • Rewriting the squash commit message.
  • Reopening issues GitHub has already closed.

Activity

  1. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 28, 2026
  2. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    Contributor

    🔒 Claimed by @Karibhou (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  3. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    Contributor

    🔓 Claim by @Karibhou released (lease revoked).

  4. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    Contributor

    PR #15035 covers this issue: #15035

    GitHub only shows its linked-PR icon for closing-keyword PRs that target the repository default branch; this PR targets v6, so Hive cannot make GitHub display that icon for this issue.

  5. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    Contributor

    Fixed by #15079 (merged 08e2b44). Closing. Reply /reopen if the problem persists.

  6. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    Closed by #15079 (merged to v6).

  7. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    @Danathar this issue was closed by @hivecommons-hive[bot] as completed.

    If this was closed by a merged PR, the fix only takes effect once it ships in a tagged release and your deployment updates to it — check your running version against the fix before concluding the fix failed.

    If you are still seeing the problem, comment /reopen and it will be reopened for you — you do not need write access. Please add what you are still observing (running version, logs, steps) so it is not closed the same way again.

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

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions