Skip to content

🐛 automerge: hold same-issue PRs across lanes until a decision is recorded - #15812

Merged
clubanderson merged 2 commits into
v5from
feat/dupe-human-vs-hive-pr
Oct 30, 2026
Merged

clubanderson merged 2 commits into
v5from
feat/dupe-human-vs-hive-pr

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Closes #15810

Problem

Issue #15773 got two open PRs: the hive's own #15783 (self lane) and a trusted human's #15793 (trusted-author lane). Both were labelled conflicts-with-open-pr and both marched toward merge — #15793 in the merge queue, #15783 "Ready for auto merge" — because the merge queue's one-PR-per-issue pick (planDuplicateHolds) groups candidates within one lane and each lane only sees its own PRs.

Fix (safety gate only — no auto-resolution policy)

Tests

  • TestPlanClaimConflictsHoldsCrossLanePair — both lanes hold, log line, reason round-trip, not a duplicate-of.
  • TestPlanClaimConflictsDecidedOrAdoptionAdmits — recorded decision admits that side only; Supersedes pair and Refs are not conflicts; same-lane pair stays with the winner rule.
  • TestMergeTrainClaimConflictSentence, classify → 085, TestStageTrackerApplyClaimConflict, TestDelegatedPlanWordingClaimConflictNamesPRs.

Docs: hive-merge.md, operator-reference.md (one paragraph each). Changelog fragment at repo root.

Live #15783/#15793 are not touched by this PR.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 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 kellyaa 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 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
#15817 🐛 activity monitor: 'merging now' lingers, silent merges, closed rows vanish same files src/docs/operator-reference.md
src/pkg/dashboard/stage_tracker_build.go
src/pkg/dashboard/stage_tracker_merge_gate.go
src/pkg/dashboard/static-src/js/tracker-words-core.js
src/pkg/dashboard/static-src/js/tracker-words-gate.js
src/pkg/dashboard/static/index.html
src/pkg/github/automerge/automerge_contributor_lane.go
src/pkg/github/automerge/automerge_sweep.go
#15819 🌱 refactor: split src/pkg/github/automerge/automerge_sweep.go into 4 files CONFLICT src/pkg/github/automerge/automerge_sweep.go
#15804 ✨ Show the upgrade animation for every roll (announce + SIGTERM fallback) same files src/pkg/dashboard/static/index.html
#15831 🐛 Merge train seats only PRs green and reviewed on their current head; regressed members are ejected CONFLICT src/pkg/dashboard/stage_tracker_merge_train.go
src/pkg/github/automerge/automerge_merge_train.go
src/pkg/stageengine/prstage/merge_train.go
#15834 ✨ stage tracker: PR sub-row names the other issues it also closes same files src/pkg/dashboard/static/index.html
#15824 ✨ Activity Monitor settings: configurable toast durations and pre-merge soak same files src/docs/hive-merge.md
src/docs/operator-reference.md
src/pkg/dashboard/stage_tracker_build.go
src/pkg/dashboard/static/index.html
#15731 📖 docs: split the operator reference CONFLICT src/docs/operator-reference.md
#15757 ✨ Auto-merge hive-authored superseding PRs without operator decision same files src/docs/hive-merge.md
src/docs/operator-reference.md
src/pkg/delegatedecision/policy.go
src/pkg/github/automerge/automerge_sweep.go
#15748 🐛 [reviewer] park PRs at 085 Needs decision when the fixer exhausted its attempts same files src/docs/hive-merge.md
src/pkg/dashboard/stage_tracker_build.go
src/pkg/github/automerge/automerge_sweep.go
src/pkg/stageengine/derive_pr_classify.go
#15774 ✨ dashboard: onboarding and GitHub App errors point to the Getting Started guide same files src/docs/operator-reference.md
src/pkg/dashboard/static/index.html
#15836 🐛 Control base-refresh churn without blocking ready successors same files src/docs/hive-merge.md
src/pkg/github/automerge/automerge_contributor_lane.go
src/pkg/github/automerge/automerge_merge_train.go
src/pkg/github/automerge/automerge_sweep.go
src/pkg/stageengine/derive_pr_classify.go
#15830 ✨ dashboard: pop out the Hive activity monitor into its own window and a full-screen toggle same files src/pkg/dashboard/static/index.html
#15787 🐛 Run the reconcile pass when wakes outpace the eval interval; age unblocked rows from the lift same files src/pkg/dashboard/stage_tracker_build.go
#15783 🐛 stage tracker: Let hive decide shows it is working, covered issues drop the PR's chip, 👤 says why same files src/pkg/dashboard/static/index.html

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Failing checks:

  • coverage

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.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 071-needs-author: required-check-failing:coverage

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

Intent alignment vs #15810 — the gate matches the issue's contract (hold in every lane, decision admits, Supersedes pair/Refs exempt, 085 + tracker + recommend-only plan), but one lane path can still admit a conflicted PR.

Claim gate is blind on a targeted (webhook-nudged) pass when no forge-state source is wired — src/pkg/github/automerge/automerge_merge_train_duplicate.go:216-226 (claimantsForConflicts) returns the lane's prs unchanged when c.openPRs == nil. But on that same no-source path openPullRequests narrows prs to targets (automerge_forgestate.go:266-277), and the non-forgestate ticker loop does run targeted passes on sweepTrigger nudges ("evaluate only those now", automerge_sweep.go:1636-1641 → Targets: targets at :1693/:1713/:1732). So a CI-green nudge for #15793 alone yields byIssue with a single claimant, held stays empty, and the trusted lane admits #15793 while the undecided conflict with #15783 stands — the exact "marching toward merge" the issue says must stop in every lane. The comment on :219-221 assumes a scheduled pass fills the list; the event path does not. Suggested fix — list the repo on the no-source path too (one /pulls call per lane per targeted pass; openPullRequests(…, nil) already does exactly that):

func (c *Engine) claimantsForConflicts(ctx context.Context, owner, repo string, prs []*gh.PullRequest) []*gh.PullRequest {
	if c == nil {
		return prs
	}
	all, skip, err := c.openPullRequests(ctx, owner, repo, nil)
	if err != nil || skip != "" || len(all) == 0 {
		return prs
	}
	return all
}

Advisory (no change requested): recordedDecisionFor → review.DecisionAnswerFor (src/pkg/review/human_change_request.go:392-401) is true for any trusted-human decision on the head, not only an approval, so a /hive decision instruction asking for changes also lifts this hold. Downstream gates still block the merge, so this matches the issue's "a recorded operator decision … admits that PR"; just noting it so the docs' "Approve … is what lifts the gate" (src/docs/hive-merge.md) is read loosely.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Correctness review (head 46c12ca)

1. Gate fails open on targeted (webhook) passes when no forge-state source is wired — src/pkg/github/automerge/automerge_merge_train_duplicate.go:214-223 (claimantsForConflicts)

When c.openPRs == nil the function returns prs unchanged. But prs is the lane's list from openPullRequests(ctx, owner, repoName, opts.Targets) (automerge_sweep.go:1131, :1372), and in the legacy (no-OpenPRSource) branch that list is narrowed to the webhook-named PRs (automerge_forgestate.go:266-277). Targeted passes still run in that configuration: the ticker loop selects on sweepTrigger regardless of forge-state (automerge_sweep.go:448-454, :1637-1641), fed by SweepTrigger.NotifyPullRequests (automerge_forgestate.go:128).

So a CI-passed nudge for #15793 alone yields prs == [#15793]; byIssue[15773] contains only itself; planClaimConflicts finds no other claimant and admits it — the exact outcome #15810 is meant to prevent, and contrary to the PR body's "Held in every lane, so neither PR is admitted." The comment on claimantsForConflicts ("the lane's list, which a scheduled pass fills with every open PR") only covers tick passes. Neither new test exercises a narrowed list.

Fix: list the whole repository in the legacy branch too (guarded on c.gh so the unit tests that build a bare Engine{} keep the current path):

 func (c *Engine) claimantsForConflicts(ctx context.Context, owner, repo string, prs []*gh.PullRequest) []*gh.PullRequest {
-	if c == nil || c.openPRs == nil {
+	if c == nil || (c.openPRs == nil && c.gh == nil) {
 		return prs
 	}
-	all, skip, err := c.openPullRequests(ctx, owner, repo, nil)
+	all, skip, err := c.openPullRequests(ctx, owner, repo, nil) // nil targets: every open PR, from the snapshot or /pulls
 	if err != nil || skip != "" || len(all) == 0 {
 		return prs
 	}
 	return all
 }

If the extra /pulls list per lane on legacy tick passes is unwanted, thread opts.Targets != nil into planMergeTrains and only re-list when the pass was narrowed. Either way, please add a test that passes a one-PR prs list with a fake openPRs/lister holding the other claimant and asserts the hold.

Everything else I traced (recordedDecisionFor nil-safety automerge_decision_carry.go:39-41, snapshot items carrying Body automerge_forgestate.go:231, skip ordering in the three lane loops, claim-conflict reason round-trip and 085 classification) checks out.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

CI triage (scanner): the dashboard test shards all fail on one test, TestStageTrackerMergeTrainStateSlugsNeverLeak — not a baseline issue (v5 is green on these jobs).

The node eval dies with:

ReferenceError: stageTrackerGateClaimConflictOf is not defined
    at stageTrackerMergeGateStateWord ([stdin]:298:24)

stageTrackerMergeGateStateWord (tracker-words-core.js) now calls the new stageTrackerGateClaimConflictOf, but the lifted-JS helper that the Go tests feed to node doesn't include it. Suggested fix in src/pkg/dashboard/stage_tracker_merge_gate_test.go, stageTrackerTrainQueueJS, next to the sibling duplicate-of pair:

		jsConstLine(t, html, "STAGE_TRACKER_GATE_DUPLICATE_PREFIX"),
		jsFunc(t, html, "stageTrackerGateDuplicateOf"),
		jsConstLine(t, html, "STAGE_TRACKER_GATE_CLAIM_CONFLICT_PREFIX"),
		jsFunc(t, html, "stageTrackerGateClaimConflictOf"),
		jsFunc(t, html, "stageTrackerMergeGateStateWord"),

Log: https://github.com/hivecommons/hive/actions/runs/41086300767/job/124169023362

Not pushing to your branch (author-owned); happy to apply it if you'd like.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…orded

Two open PRs closing one issue in different lanes (hive self lane vs
trusted-author lane) both marched toward merge because the one-PR-per-
issue pick only sees its own lane. Every lane now holds its candidate
with merge-train:claim-conflict#<other>:<issue> while another open PR
claims the issue and no decision is recorded; the stage engine parks it
at 085, the tracker reads 'held · duplicate of #B · needs decision' with
options naming both PRs, and the delegate plan recommends 'keep #B,
close #A — or the reverse' instead of 'all 2 PRs'.

Closes #15810

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…PA gate word self-contained

Review: a webhook-targeted pass without a forge-state source handed the
lane only the nudged PR, so the gate saw one claimant and admitted it.
openPullRequests now remembers the full /pulls list per repo before
narrowing and the gate groups against it. The merge-gate word reads the
claim-conflict prefix inline so the node-lifted function test passes.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the feat/dupe-human-vs-hive-pr branch from 46c12ca to 48cf9be Compare October 30, 2026 17:16
@clubanderson

Copy link
Copy Markdown
Member Author

Addressed the review in 48cf9be: on the legacy (no forge-state source) path openPullRequests now remembers the full /pulls list per repo before narrowing to event targets, and claimantsForConflicts groups against it — a CI-green nudge for one PR alone no longer slips past the undecided conflict (new test TestPlanClaimConflictsSeesClaimantsOutsideNarrowedList). No extra API call per lane. Docs softened per the advisory: any recorded trusted /hive decision on the head lifts the gate; downstream gates still judge the merge. CI red was the node-lifted stageTrackerMergeGateStateWord referencing a helper not extracted with it; the prefix read is inline now.

@clubanderson
clubanderson merged commit 79e0ba6 into v5 Oct 30, 2026
77 of 78 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/dupe-human-vs-hive-pr branch October 30, 2026 17:35
@github-actions

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Merge queue admits two open PRs claiming one issue when they sit in different lanes

1 participant