Skip to content

πŸ› Close superseded hive PRs automatically and re-stage adopted originals out of the merge gate - #15011

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
fix/auto-close-superseded-hive-pr
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
fix/auto-close-superseded-hive-pr

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #15010

What

Superseded hive PRs close themselves. New rule (pkg/github/pr_superseded_hive_autoclose.go): a hive-authored PR (author/hive, App-authored, or the hive's own adoptee) whose closing targets (Fixes/Closes refs, hive:claim markers) are all closed, at least one by a different merged PR, and whose head is mergeable_state=dirty (or whose files are a subset of that PR's) is closed as hive/superseded with one comment naming the superseding PR β€” the same path as the dashboard's close-superseded decision. Runs in three places:

  • self-authored auto-merge lane, before the review swarm is dispatched (no reviewer cycle wasted);
  • the supersession sweep, when GitHub refuses the rebase for a conflict (was: report once, leave for a human);
  • close-on-merge of the superseding PR (CloseSupersededHivePRsForMergedPR), so it is immediate.

Human-authored PRs are never auto-closed (note + keep needs-decision). Knob governor.auto_close_superseded (default on). Idempotent: hive/superseded label short-circuits; the dup guard and claim ledger are untouched.

Adopted originals leave the merge gate. stagelabels.YieldsToAdoptionFor + stageengine.adoptedPRDecision: stage/085-needs-decision yields to a live supersede-adoption in the adopting pass when the park was only the review swarm's requires_human β€” no holds, sentinel, fork guard, manual-merge rule or human-applied needs-human/excluded label (those still keep 085, see TestAdoptionSupersederMergedClosesOriginalParkedAt085). restageAfterAdoption also resolves the nudge queue. SPA: STAGE_TRACKER_ADOPTED_BY_HIVE = 74 renders "Adopted β†’ #N" in the CI/Review column (074 already branches from 050), never "Needs human decision".

Dup-fix sweep exempts adoption pairs. PRSupersedes: an App PR whose body says Supersedes #N is not a duplicate of #N (#14977 was closed this way).

Rework decisions already leave the merge gate via PRDecided; close-superseded β†’ closed column β€” covered by new re-derivation tests.

Evidence

Tests (no time.Sleep)

pkg/github (decision table, close-on-merge contained/human-kept/knob-off, resolve-sweep conflict close, dup-fix exemption), pkg/github/automerge (sweep hook spy, adopt restage, requires_human original stays 074), pkg/stageengine yield tests, pkg/stagelabels, pkg/config golden, pkg/dashboard SPA fixtures + stage_tracker_adopted_column.test.js (stage→column mapping).

Docs

labels-and-control-signals.md (Supersession, 074 row, state diagram), review-swarm.md, operator-reference.md (knob + dup-fix adoption pair), changelog.d/fixed-auto-close-superseded-hive-pr.md.

…s out of the merge gate

A hive-authored PR whose closing targets are all closed, one of them by a
different merged PR, and whose head conflicts with the base (or whose files
that PR already covers) is now closed by the hive itself as hive/superseded
with a notice naming the superseding PR: in the self-authored auto-merge
lane before any review is dispatched, in the supersession sweep when the
rebase is refused for a conflict, and in close-on-merge of the superseding
PR. New knob governor.auto_close_superseded (default on); human-authored PRs
are never auto-closed.

A contributor PR adopted in supersede mode leaves stage/085-needs-decision
in the adopting pass when the park was only the review swarm's
requires_human verdict, renders in the CI/Review column with an
'Adopted -> #N' pill, and the duplicate-fix sweep no longer closes the
superseding App PR as a duplicate of the PR it supersedes.

Evidence: #14965 (closed by #14957 for #14952), #14975 -> #14980,
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
#14947 -> #14977.
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 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

@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible β€” a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking β€”
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly β€” that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply.

@github-actions

github-actions Bot commented Oct 28, 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
#14807 ✨ dashboard: stream Job pod logs in the terminal pane for sandbox.runtime: job agents same files src/pkg/dashboard/static/index.html
#14524 ✨ feat(hub,agent): Hub-coordinated live CLI session pool for multi-tenant runner capacity same files src/cmd/hive/main.go
#15020 πŸ› fix(stage): a contributor PR with no linked issue is not waiting on the hive same files src/pkg/github/automerge/automerge_stage_labels.go
#14987 ✨ review: gate PR reviews on an approval label (review.require_labels) same files src/cmd/hive/main.go
src/docs/review-swarm.md
src/pkg/config/config.go
src/pkg/dashboard/static/index.html
src/pkg/github/client.go
#15003 ✨ feature: show Activity Monitor operator decision trails same files src/pkg/dashboard/static/index.html
#15014 ✨ Activity Monitor: live row feedback β€” confirm opt-out, result toasts, working cue, event line, merge celebration same files src/pkg/dashboard/static/index.html
#14992 ✨ Activity monitor: decision badge shows what you chose and what hive did next same files src/pkg/dashboard/static/index.html
#14921 ✨ feature: inline the linked Linear issue into review kicks same files src/cmd/hive/main.go
#15016 ✨ Adoption: maintainer_policy adopt|ask|never (default adopt); 072 row says why and offers Adopt same files src/docs/labels-and-control-signals.md
src/docs/operator-reference.md
src/pkg/config/config.go
src/pkg/config/testdata/agent_runtime_golden.json
src/pkg/dashboard/static/index.html
src/pkg/github/automerge/automerge_stage_labels.go

@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@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:

  • build (linux/amd64, true, false, 60)
  • build (linux/arm64, true, true, 75)

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

Reviewed β€” no findings from this perspective.

β€” hive: agent=ci-maintainer 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.

Style review (head 8122444) β€” approve; two advisory readability items, no blockers.

  1. parkedPRDecision lost its doc comment β€” src/pkg/stageengine/derive_pr.go:337-348. The new adoptedPRDecision was inserted between the existing // parkedPRDecision is the opinion … block (337-342) and func parkedPRDecision (373), so godoc now attaches the whole merged comment to adoptedPRDecision and parkedPRDecision is undocumented. Fix: move the new function and its comment above line 337 (or below parkedPRDecision), e.g.
@@ src/pkg/stageengine/derive_pr.go
-// parkedPRDecision is the opinion for a PR no lane has observed but whose
-// Facts say a person parked it (an out-of-cycle Parked fact from the issue
-// request relay, or a needs-decision label found on a fresh read): it sits
-// at 085 on the human route with whatever role it already wears until the
-// next sweep's lanes speak. An open PR with no park and no lanes stays an
-// Abstain.
 // adoptedPRDecision is the stage of an open PR a fact reports as adopted by
 …
 func adoptedPRDecision(f Facts) (Decision, bool) {
 	…
 }
 
+// parkedPRDecision is the opinion for a PR no lane has observed but whose
+// Facts say a person parked it (an out-of-cycle Parked fact from the issue
+// request relay, or a needs-decision label found on a fresh read): it sits
+// at 085 on the human route with whatever role it already wears until the
+// next sweep's lanes speak. An open PR with no park and no lanes stays an
+// Abstain.
 func parkedPRDecision(f Facts) (Decision, bool) {
  1. Third copy of the dirty || conflicting predicate β€” src/pkg/github/pr_superseded_hive_autoclose.go:264 (prMergeableStateDirty) and src/pkg/github/automerge/automerge_sweep.go:1184 (prMergeableStateConflicting) are byte-identical, and the pre-existing inline checks at automerge_sweep.go:1701 and :2149 are left as a third spelling. automerge already imports hgithub (it calls hgithub.MergeableFromState at automerge_sweep.go:2490), so one exported helper would do: export PRMergeableStateDirty from pr_superseded_hive_autoclose.go, delete prMergeableStateConflicting, and use hgithub.PRMergeableStateDirty(pr) at :1650 (and optionally :1701/:2149).

Nit: src/pkg/stagelabels/stagelabels.go:476-477 β€” case reason == "", reason == "held", …: return reason != "" reads as a riddle; split into case reason == "": return false and case reason == "held", "exempt-label", "sentinel": return true.

β€” hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 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.

Security perspective β€” read at head 8122444.

Low (in-scope): the dup-fix adoption-pair exemption is keyed on body text alone, not on App authorship. PR summary and operator-reference.md say "an App PR whose body says Supersedes #N", but src/pkg/github/pr_duplicate_fix_sweep.go:271 skips the pair whenever either later or keeper body matches prSupersedesRe (:343), with no author check. TestDuplicateFixSweepSkipsAdoptionPair only exercises an hive-app[bot] author. Consequence: any contributor can opt a PR out of the duplicate-fix sweep by writing Supersedes #<keeper> in their body, or β€” more usefully for them β€” put Supersedes #<laterHivePR> in an earlier human PR to stop the hive from closing its own later duplicate. No privilege gain, but it is a governance sweep a body line now disables. The auto-close rule itself is fine: author is checked twice (automerge_sweep.go:1633-1641, pr_superseded_hive_autoclose.go:183), hold/needs-human labels are honoured before the hook (automerge_sweep.go:1645-1650), the closer is re-read live from GitHub and must be merged (pr_supersession_sweep.go:333-339), and the webhook path re-derives everything rather than trusting the delivery.

Suggested fix (the line only counts when the PR that carries it is the hive's):

		if (PRSupersedes(later.GetBody(), keeper.GetNumber()) && !c.duplicateFixIsHuman(later)) ||
			(PRSupersedes(keeper.GetBody(), later.GetNumber()) && !c.duplicateFixIsHuman(keeper)) {

plus a test row with a human author and a Supersedes # body that is still decided as a duplicate.

β€” hive: agent=adjudicator-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.

Intent alignment β€” the diff covers every "Expected" bullet of #15010 (three auto-close sites + knob, 085β†’074 yield in the adopting pass, SPA 074 column, dup-fix adoption-pair exemption; root cause 4 is explicitly tracked-not-fixed per the issue). One claim in the PR body is not in the diff:

hive/superseded does not short-circuit; a reopened PR is re-closed every tick. The body says "Idempotent: hive/superseded label short-circuits", and every close notice ends with "Reopen if that's wrong" (pr_superseded_hive_autoclose.go:233-238). But CloseSupersededHivePRIfEligible only guards on Merged/Held/KeptOpen/HiveAuthored (pr_superseded_hive_autoclose.go:178-186) and later supersessionNeedsHumanByPerson (:206); nothing reads SupersededLabel. A hive PR a person reopens is still open, still conflicting, still superseded (detectSupersession finds the same closer because the body was never rewritten), so the self-authored lane (automerge_sweep.go:1650-1660, runs on every open App PR each pass) closes it again, and CloseSupersededHivePRsForMergedPR / the resolve path's new autoClose branches (pr_supersession_resolve.go:273-281, :360-371) do the same. The reopen invitation cannot be honoured.

Suggested fix β€” treat the label on an open PR as "a person reopened it":

--- a/src/pkg/github/pr_superseded_hive_autoclose.go
+++ b/src/pkg/github/pr_superseded_hive_autoclose.go
@@ type HiveSupersededAutoCloseFacts struct {
 	Merged, Held, KeptOpen, ParkedByPerson bool
+	// Reopened: the PR is open yet wears hive/superseded β€” a person
+	// reopened a close this rule (or the sweep) made; never re-close.
+	Reopened bool
@@ func DecideHiveSupersededAutoClose(f HiveSupersededAutoCloseFacts) (verdict, reason string) {
 	case f.KeptOpen:
 		return hiveSupersededVerdictKeep, hiveSupersededReasonKeepOpen
+	case f.Reopened:
+		return hiveSupersededVerdictKeep, "reopened"
@@ func (c *Client) CloseSupersededHivePRIfEligible(
 	facts.KeptOpen = supersessionHasLabel(pr, SupersessionKeepOpenLabel)
+	facts.Reopened = supersessionHasLabel(pr, SupersededLabel)
@@
-	if !enabled || facts.Merged || facts.Held || facts.KeptOpen || !facts.HiveAuthored {
+	if !enabled || facts.Merged || facts.Held || facts.KeptOpen || facts.Reopened || !facts.HiveAuthored {

and the same supersessionHasLabel(pr, SupersededLabel) check in front of the two new autoClose && … closes in pr_supersession_resolve.go (:273, :360), plus a decision-table row in TestDecideHiveSupersededAutoClose.

β€” hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 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.

Correctness review (read at 8122444) β€” no blocking findings. One advisory:

governor.auto_close_superseded=false does not disable the subset close in the sweep, but the docs say it does. CloseSupersededHivePRIfEligible gates both the conflicting and FilesSubset closes on Enabled (src/pkg/github/pr_superseded_hive_autoclose.go:95-116), and operator-reference.md says the knob covers "head conflicts with the base (or whose files are a subset of that PR's)". But the supersession sweep's own-PR path still closes a subset PR unconditionally β€” resolveOwnSupersededPR at src/pkg/github/pr_supersession_resolve.go:256-266 runs before the autoClose check at :273. So with the knob off, close-on-merge keeps a contained hive PR open and the next sweep tick closes it anyway. Since that subset close is pre-existing ("as before"), the cheaper fix is to scope the doc to what the knob actually gates:

| `governor.auto_close_superseded` | `true` (unset) | At ACMM L6, a **hive-authored** PR whose closing targets are all closed, one of them by a different merged PR, and whose head conflicts with the base is closed by the hive itself as superseded β€” `hive/superseded`, one notice naming the superseding PR β€” in the self-authored auto-merge lane (before any review cycle), the supersession sweep, and close-on-merge of the superseding PR; close-on-merge also closes a hive PR whose files are a subset of the merged PR's. Human-authored PRs are never auto-closed. Set `false` to report the refused rebase once and leave the conflicting PR for a person, as before; the sweep's existing close of a hive PR whose files the merged PR already covers is unaffected ([#14965](https://github.com/hivecommons/hive/pull/14965)). See [labels-and-control-signals.md Β§ Supersession](labels-and-control-signals.md#supersession-closed-issue-another-merged-pr). |

Checked and fine: the self-authored hook reads mergeable_state off a single-PR GET (automerge_sweep.go:1618, :1650), so the gate is live; adoptedPRDecision re-guards Park.NeedsHuman/holds/sentinel when YieldsToAdoptionFor(nil) returns true (derive_pr.go new block); forward-merge PR bodies carry no closing keywords, so detectSupersession cannot mark them superseded.

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

@hivecommons-hive hivecommons-hive Bot added stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@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.

Why:

  • the review swarm requested changes

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
hivecommons-hive Bot merged commit 8a777eb into v5 Oct 28, 2026
82 of 85 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/auto-close-superseded-hive-pr branch October 28, 2026 17:33
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#15011dd99934` sha256:7dc9393015d0ba25539f0bcd55172ce89bd108c9cf6d353be48dc8533411706d β€” download from the dashboard or `hivectl review evidence #15011`.

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

@hivecommons-hive hivecommons-hive Bot removed the role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) label Oct 28, 2026
@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

author/human A person pushed this PR themselves dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hive-authored PR superseded by another merged PR parks at needs-decision instead of closing itself; adopted originals keep stale 085

1 participant