Repository navigation
π Close superseded hive PRs automatically and re-stage adopted originals out of the merge gate - #15011
Conversation
β¦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.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible β a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
|
@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. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson this PR is held at Failing checks:
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. |
There was a problem hiding this comment.
Style review (head 8122444) β approve; two advisory readability items, no blockers.
parkedPRDecisionlost its doc comment βsrc/pkg/stageengine/derive_pr.go:337-348. The newadoptedPRDecisionwas inserted between the existing// parkedPRDecision is the opinion β¦block (337-342) andfunc parkedPRDecision(373), so godoc now attaches the whole merged comment toadoptedPRDecisionandparkedPRDecisionis undocumented. Fix: move the new function and its comment above line 337 (or belowparkedPRDecision), 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) {- Third copy of the
dirty || conflictingpredicate βsrc/pkg/github/pr_superseded_hive_autoclose.go:264(prMergeableStateDirty) andsrc/pkg/github/automerge/automerge_sweep.go:1184(prMergeableStateConflicting) are byte-identical, and the pre-existing inline checks atautomerge_sweep.go:1701and:2149are left as a third spelling.automergealready importshgithub(it callshgithub.MergeableFromStateatautomerge_sweep.go:2490), so one exported helper would do: exportPRMergeableStateDirtyfrompr_superseded_hive_autoclose.go, deleteprMergeableStateConflicting, and usehgithub.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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
@clubanderson this PR is held at Why:
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. |
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at dd99934. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
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/Closesrefs,hive:claimmarkers) are all closed, at least one by a different merged PR, and whose head ismergeable_state=dirty(or whose files are a subset of that PR's) is closed ashive/supersededwith one comment naming the superseding PR β the same path as the dashboard's close-superseded decision. Runs in three places: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/supersededlabel short-circuits; the dup guard and claim ledger are untouched.Adopted originals leave the merge gate.
stagelabels.YieldsToAdoptionFor+stageengine.adoptedPRDecision:stage/085-needs-decisionyields to a live supersede-adoption in the adopting pass when the park was only the review swarm'srequires_humanβ no holds, sentinel, fork guard, manual-merge rule or human-appliedneeds-human/excluded label (those still keep 085, seeTestAdoptionSupersederMergedClosesOriginalParkedAt085).restageAfterAdoptionalso resolves the nudge queue. SPA:STAGE_TRACKER_ADOPTED_BY_HIVE = 74renders "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 saysSupersedes #Nis 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/stageengineyield tests,pkg/stagelabels,pkg/configgolden,pkg/dashboardSPA 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.