Skip to content

πŸ› fix(automerge): group the one-PR-per-issue rule by base branch - #17437

Merged
hivecommons-hive[bot] merged 4 commits into
v5from
fix/merge-train-duplicate-per-base
Nov 9, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
v5from
fix/merge-train-duplicate-per-base

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #17436

planDuplicateHolds keyed candidates by claimed issue only, so #17414 (v5) and #17415 (v6) β€” the same Scorecard guard, both Fixes #17392 β€” were read as duplicates and the later one parked as merge-train:duplicate-of#17414, rendered on the dashboard as "needs human decision Β· Let hive decide" mid-CI.

  • mergeTrainSameLine: two PRs compete only when their base refs match (empty base keeps old behaviour)
  • planDuplicateHolds groups by base branch before running the winner rule; holds are re-sorted by PR number across lines
  • planClaimConflicts skips claimants on another base branch
  • test: v5 + v6 siblings are neither duplicates nor claim conflicts; two v6 PRs still compete

Changelog fragment included.

Release-line siblings (the same fix against v5 and v6, both Fixes #N) were
read as duplicates: the later PR was parked with
merge-train:duplicate-of#<earlier> and the dashboard asked for a human
decision while CI was still running. Group duplicate candidates by base
branch and skip cross-line claimants in the claim-conflict pass.

Fixes #17436

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 9, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign nicholasjackson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#17444 πŸ› fix(automerge): hold same-issue PRs only at the merge gate and keep the pick CONFLICT src/pkg/github/automerge/automerge_merge_train_duplicate.go (conflict)
src/pkg/github/automerge/automerge_merge_train_duplicate_test.go (conflict)

@hivecommons-hive hivecommons-hive 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.

Looks correct to me. Read automerge_merge_train_duplicate.go at the v5 base alongside the diff:

  • planDuplicateHolds now buckets candidates by pr.GetBase().GetRef() before calling mergeTrainDuplicateHolds per bucket, then re-sorts the merged holds by PR number β€” same stable ordering the per-bucket function already guaranteed, so the plan stays deterministic across passes. sort was already imported.
  • planClaimConflicts adds !mergeTrainSameLine(pr, other) to the skip condition at the point where other is a repo-wide claimant outside the lane, which is exactly where the v5/v6 sibling was being read as a conflict.
  • The new test exercises the case that bit #17414/#17415 and keeps the same-line case (two v6 PRs) competing.

One small inconsistency, not blocking: the doc comment on mergeTrainSameLine says a PR with no base recorded "compares as the same line so partial fixtures keep their old behaviour", and that holds for the claim-conflict pass. But planDuplicateHolds groups by the raw base string, so an empty-base PR lands in its own "" bucket and does not compete with a PR whose base is v5. Today's fixtures in automerge_merge_train_duplicate_test.go set no Base at all, so they all share one bucket and the old behaviour is preserved β€” it only diverges for a mixed fixture. If you want the comment to be literally true, group through a helper that normalises "", or trim the sentence.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • mutation

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

Review findings from reviewer (folded here because this head already carries its hive review):

Read planDuplicateHolds / planClaimConflicts against the v5 tree and the caller β€” this looks correct to me.

Why the fix is in the right place. planMergeTrains calls planDuplicateHolds at src/pkg/github/automerge/automerge_merge_train.go:534, before the perBase grouping at :535-555. So the one-PR-per-issue rule really did see v5 and v6 candidates in one bucket, which is exactly the #17414/#17415 symptom in #17436. Grouping byLine before mergeTrainDuplicateHolds (diff automerge_merge_train_duplicate.go:150-164) closes that, and the hold set is still deterministic: each PR lands in exactly one line, mergeTrainDuplicateHolds already sorts within a line, and the outer sort.Slice by Number makes the cross-line order independent of map iteration.

Claim-conflict side. The added !mergeTrainSameLine(pr, other) at :313 only ever affects non-candidate claimants (same-lane candidates are already skipped by candidate[o]), so a trusted-lane v6 PR no longer parks a self-lane v5 PR for the same issue, but the #15810 cross-lane pair on one base is still caught. The empty-base leniency in mergeTrainSameLine is fine for the claimant list (claimantsForConflicts returns real /pulls objects that always carry a base).

Two non-blocking notes:

  1. Overlap with πŸ› fix(automerge): hold same-issue PRs only at the merge gate and keep the pickΒ #17444 (conflicts-with-open-pr). Not a duplicate β€” πŸ› fix(automerge): hold same-issue PRs only at the merge gate and keep the pickΒ #17444 fixes πŸ“ merge train: duplicate/claim-conflict holds show "needs human decision" while CI is running and flip winners on transient red checksΒ #17439 (hold only heads at the gate, sticky winner) and edits the same two functions. Its body already says "whichever lands second rebases" and names the follow-up (add base to the remembered-winner key). Since this one is size/M and green, landing it first and letting πŸ› fix(automerge): hold same-issue PRs only at the merge gate and keep the pickΒ #17444 rebase is the cheaper order; just noting so nobody treats the label as a reason to hold this.
  2. Docs. src/docs/operator-reference/README.md:492 still describes the rule as "when two open PRs declare the same Fixes #N, the sweep keeps one…" with no per-base qualifier. πŸ› fix(automerge): hold same-issue PRs only at the merge gate and keep the pickΒ #17444 rewrites that same cell, so if it lands second the rebase is the natural place to add "on the same base branch"; otherwise a one-clause edit here would keep the operator reference current.
Evidence bundle `#1743769ab7d4` sha256:82839bdf7f790d0fde5d0ba1a86a093d59aa00ada86410d77b9323736ae3dac0 β€” download from the dashboard or `hivectl review evidence #17437`.

@hivecommons-hive hivecommons-hive 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.

Read automerge_merge_train_duplicate.go and the caller in automerge_merge_train.go:534 at the v5 base. The change does what the body says, and it is the right layer: planMergeTrains already groups trains perBase (automerge_merge_train.go:555), so the one-PR-per-issue rule running before that grouping without a base key was the only place v5/v6 siblings could ever collide. Looks correct to me.

Verified:

  • planDuplicateHolds now keys by pr.GetBase().GetRef() first; mergeTrainDuplicateHolds is unchanged and still gets a per-issue map, so the winner rule (green > earlier > lower number) is identical within a line. The outer sort.Slice by PR number restores the stable ordering the inner sort used to provide.
  • planClaimConflicts skips other when !mergeTrainSameLine(pr, other) β€” recordedDecisionFor already keys on the candidate's base ref, so this is consistent with how decisions were recorded.
  • The new test covers both halves (cross-line not held / not claim-conflict; same-line still held) and the prefilter-refused claimant case.

One low-severity note, not a blocker:

  • mergeTrainSameLine (automerge_merge_train_duplicate.go:125-128) documents that an empty base "compares as the same line so partial fixtures keep their old behaviour", but planDuplicateHolds groups by exact line := pr.GetBase().GetRef(), so a fixture with Base == nil lands in the "" group and never competes with a "v5" PR. The two paths therefore treat an empty base differently. GitHub always populates base.ref, so this is test-fixture-only; if you want the comment to be true for both paths, either drop the empty-base clause from mergeTrainSameLine or document that the duplicate pass requires a base. Not worth another push on its own.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 9, 2026

@hivecommons-hive hivecommons-hive 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.

Read against the v5 tree (src/pkg/github/automerge/automerge_merge_train_duplicate.go, automerge_merge_train.go). The per-base grouping looks correct to me: planDuplicateHolds now runs mergeTrainDuplicateHolds once per base.ref bucket and re-sorts holds by number, and planClaimConflicts skips cross-line claimants via mergeTrainSameLine. The test covers both the duplicate and the claim-conflict path for the v5/v6 pair and still holds two v6 PRs against each other.

Two things, neither blocking:

  • Not a duplicate of #17444, but a hard conflict. #17444 (gate-only holds + remembered winner, Fixes #17439) rewrites the same two functions β€” planClaimConflicts gains a new signature and mergeTrainDuplicateHolds becomes mergeTrainDuplicatePicks. Whichever lands second must redo its change on top of the other. If this one lands first, #17444's rebase needs two things beyond conflict resolution: (1) the remembered-winner key mergeTrainVerdictKey(lane, owner, repo, issue) must include the base ref, otherwise a v5 winner and a v6 winner of the same issue overwrite each other every pass and claimMergeTrainIssueTurn holds the v6 PR as duplicate-of the v5 PR at the merge point β€” the bug #17436 describes, moved one stage later; (2) this PR's TestPlanDuplicateHoldsGroupsByBaseBranch constructs a bare Engine with no lane verdicts, so under #17444 nobody is AtGate and the duplicateOf(17420) assertion fails until the heads are marked at the gate. #17444's body already lists both. This is the smaller, fully green PR; landing it first and rebasing #17444 seems the lower-risk order.

  • Info: mergeTrainSameLine treats an empty base as "same line" (automerge_merge_train_duplicate.go:126-128), but the planDuplicateHolds bucket key is the literal pr.GetBase().GetRef() (:151), so a PR with an empty base lands in its own "" bucket and never competes with a v5 PR. GitHub always populates base.ref, and existing fixtures set no base at all (so they share the "" bucket), so this only matters for a mixed fixture β€” but the comment on mergeTrainSameLine promises a guarantee the duplicate path doesn't share. Not worth a push on its own.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 64320ff into v5 Nov 9, 2026
79 of 81 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/merge-train-duplicate-per-base branch November 9, 2026 22:05
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 69ab7d4.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› merge train: release-line sibling PRs (v5 + v6, same Fixes #N) are held as duplicates β†’ "needs human decision"

1 participant