Skip to content

✨ Auto-merge hive-authored superseding PRs without operator decision - #15757

Merged
clubanderson merged 1 commit into
v5from
fix/hive-superseder-automerge
Oct 30, 2026
Merged

clubanderson merged 1 commit into
v5from
fix/hive-superseder-automerge

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Closes #15756

Owner rule

"if a pr is superseded by a pr that a hive agent creates, it should auto merge" — "the only exception would be if this is sentinel or some other emergent problem with the pr."

What changes

Detection — github.PullRequest.Supersedes (parsed from Supersedes #N), github.HiveSupersedingPR(hiveAuthored, body) / IsHiveSupersedingPR(pr). The verdict relay stamps hive_superseding on requires_human / decision reports when the PR author is the hive App login and the body declares a supersession.

Review aggregate (pkg/review/review.go, extending the self-authored resolution path, not a parallel one) — hiveSupersedingFixRoute: on a hive superseding PR a requires_human (risk-class question, security-sensitive finding, unresolved escalation) becomes changes_requested + FixCycle, so the existing fix dispatch picks it up and the swarm re-reviews. A reject is not converted; the fix cap still parks it (fix cycle cap reached (n/m)).

Hard stops (automerge.hiveSupersederHardStop(e, verdict, sentinelAckBy) (reason, ok)) — the one exception list, in order: sentinel-unacknowledged (sentinel label on and no sentinel_acknowledged in the review evidence bundle), hold, ci-red-after-fixes / base-conflict-unresolved / fix-attempts-exhausted (fix cap reached), base-conflict-unresolved (rebase failed twice). stagelabels.RouteHuman parks at 085 with lane reason hive-superseder-hard-stop:<token> and a caption naming the stop; otherwise a requires_human is captioned "hive-authored superseding PR — auto-merging once CI/review are clean" (hive-superseder:fixer) and the head stays on the fixing stage.

Dashboard / delegate — decisionForPR reads the hard-stop reason and asks "The hive's superseding PR would auto-merge (owner rule), but …"; delegatedecision.RuleHiveSuperseder releases without a stop, recommends-only naming the stop.

Knob — auto_merge.hive_superseding.auto_merge (default true; yaml-only, allowlisted in settings parity, golden updated); wired to the review sweep, the automerge Engine (Options.HiveSupersedingAutoMerge, Options.SentinelAcknowledgedBy hook) and the dashboard.

Prompts / docs — hiveSupersedingGuidance in the single, combined and decision reviewer prompts; new section in docs/hive-merge.md, note in docs/review-swarm.md, row in docs/operator-reference.md; changelog.d/changed-hive-superseding-automerge.md.

Tests (no time.Sleep)

  • pkg/review: hive superseding + security finding → fixer; plain requires_human → fixer; contributor / non-superseding hive PR → still 085; knob off → old behaviour; fix cap → parks; reject not converted.
  • pkg/stagelabels: fixer caption route; every hard-stop token → 085 with its lane reason + prose; non-superseder still parks.
  • pkg/github/automerge: every hiveSupersederHardStop branch incl. acknowledged sentinel, first conflict, pending/red-before-fixes not stops; hiveSupersedingPR incl. knob off; sentinel-ack hook.
  • pkg/github, pkg/delegatedecision, pkg/dashboard, pkg/config accessor.

go vet and go test ./pkg/github/... ./pkg/review/... ./pkg/dashboard/... ./pkg/stageengine/... ./pkg/stagelabels/... ./pkg/config/... ./pkg/delegatedecision/... pass.

Not duplicated here: head-carry of operator approvals across v5 refreshes (agent b1db9704), also-landed/empty-diff closing (#15741).

@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 clubanderson 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
#15886 🐛 Bound review-slot handoff for active base preparation heads same files src/cmd/hive/main_sweeps.go
src/docs/hive-merge.md
src/pkg/review/prompts.go
#15877 ✨ feature: show abandoned counts on contributor cards and status same files src/docs/operator-reference.md
#15819 🌱 refactor: split src/pkg/github/automerge/automerge_sweep.go into 4 files same files src/pkg/github/automerge/automerge_sweep.go
#15885 ✨ Add integration-aware orchestration above preparation and native queues same files src/cmd/hive/main.go
src/cmd/hive/main_sweeps.go
src/pkg/config/config.go
src/pkg/dashboard/api.go
src/pkg/github/automerge/automerge_sweep.go
#15865 ✨ feature: carry abandoned counts through the hub leaderboard same files src/cmd/hive/main.go
#15731 📖 docs: split the operator reference CONFLICT src/docs/operator-reference.md
#15748 🐛 [reviewer] park PRs at 085 Needs decision when the fixer exhausted its attempts CONFLICT src/pkg/dashboard/stage_tracker_decision_pr.go
#15876 🐛 Fold hive PR notes into one edited status comment and stop no-findings review spam CONFLICT src/docs/scale-envelope.md

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 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:

  • relative links and anchors resolve

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

hive/ci-report: relative links and anchors resolve is red at b3dfc17 for a PR-local cause (the same check is green on v5 at 1d45dde), so this is a FIX_DIFF, not a shared incident.

From job 124067735377:

DRIFT src/docs/scale-envelope.md:37 src/pkg/github/client.go:4936-4946 -> src/pkg/github/client.go lacks anchor(s) near cited range: AgeMinutes

The additions to src/pkg/github/client.go on this branch shift RankActionableIssues down by 4 lines; it now spans 4942-4952 (the AgeMinutes comparison is at 4950). Either run

python3 src/scripts/check-docs-citations.py --fix

or apply:

     (`RankActionableIssues`, `src/pkg/github/client.go:4940-4950`, descending `AgeMinutes` within each tier).

in src/docs/scale-envelope.md:37. Not pushing to this branch since the PR is not hive-authored.


🐝 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

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

  • relative links and anchors resolve

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

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

Failing checks:

  • relative links and anchors resolve

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

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

Failing checks:

  • relative links and anchors resolve

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

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

Failing checks:

  • relative links and anchors resolve

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: optional-check-failing:relative links and anchors resolve

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

Decision needed: @clubanderson should decide whether the sentinel hard-stop for hive-authored superseding PRs may key off the alert label (which the sentinel does not apply to the Hive App under the default sentinel.trusted_authors_block: false), or must read the recorded sentinel findings so a superseding copy of a contributor PR that touches workflows/OWNERS cannot auto-merge unseen.

Read the aggregate route (src/pkg/review/review.go), the hard-stop list (automerge_hive_superseder.go:62-77) and the sentinel sweep on v5. The owner rule is implemented as described, and the reject-stays-reject and fix-cap paths are sound. One gap in the "sentinel is the exception" guarantee, which is the trust question above.

The sentinel hard-stop does not fire for the Hive App by default — high, src/pkg/github/automerge/automerge_hive_superseder.go:64.

  • The stop is e.Sentinel && sentinelAckBy == "", and stagelabels.Evidence.Sentinel is documented as "true when the sentinel alert label is on the PR" (src/pkg/stagelabels/human.go:102-103).
  • The sentinel only applies that label when decision.Block is true, and DecideSentinelAction sets Block: !trust.Trusted || trustedAuthorsBlock (src/pkg/github/sentinel_sweep.go:137). The Hive App is a trusted author (src/pkg/config/sentinel.go:50-53: "Trusted authors (Hive App, …) … The default false still evaluates and comments, but only as an informational notice").
  • So on a default config, a sentinel finding on a hive-authored superseding PR is recorded and commented but not labelled, e.Sentinel stays false, and none of the hard-stops at :64-76 match.
  • Meanwhile hiveSupersedingFixRoute (review.go) turns the reviewer's requires_human — including a security-sensitive finding, per the HiveSuperseding field comment — into changes_requested + FixCycle; the only remaining park is the fix cap.

Why this matters more than for other hive PRs: adoption supersedes a contributor PR with a hive-authored copy of the contributor's head (AdoptionPRBody writes the Supersedes #N line this detector keys on, pr_hive_superseding.go:5-8). So the contributor's workflow/OWNERS edit arrives in a PR this rule auto-merges, with the one named exception silently off unless the operator has set trusted_authors_block: true.

Two ways to close it, for whoever decides: (a) have the hard-stop consult the review-evidence sentinel findings (recordReviewEvidenceSentinel, sentinel_sweep.go:390) rather than the label, or (b) have hiveSupersederHardStop also stop on agg.DecisionFinding being a security finding (it is already computed at the route site via securityFindingAcross). I have no finding on the rest of the diff; the relative links and anchors resolve failure is a docs-link check on src/docs/hive-merge.md I did not trace.

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

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 30, 2026
@github-actions github-actions Bot added conflicts-with-open-pr Open PR has a merge conflict with another open PR and removed conflicts-with-open-pr Open PR has a merge conflict with another open PR labels Oct 30, 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 branch conflicts with the base and needs a rebase

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: conflicting

@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/awaiting-ci: merged origin/v5 into this branch (f004002) to clear the conflict in src/docs/hive-merge.md — both additive doc blocks kept (v5's same-issue claim gate paragraph, then this PR's superseding-PR section); author commits untouched. CI pending — sweep will merge when green.


🐝 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

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: required-check-pending:build-and-test

1 similar comment
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: required-check-pending:build-and-test

@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-contributor (linux/amd64, true, false, 60)
  • docker (contributor)

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.

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/awaiting-ci (scanner): failing on 53e432b: docker (contributor) (and dependent build-contributor (linux/amd64, ...)) — npm error notarget No matching version found for @aws-sdk/credential-provider-env@^3.972.80, a registry propagation lag that has since resolved. Suggested fix: no code change; re-push or re-run the failed jobs. The hive does not push to this branch; once green the sweep merges it.


🐝 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

@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=adjudicator-3 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 (delta re-review @ 53e432b) — one new finding in the delta; nothing else from this perspective.

permissionsTighteningGuidance lost its doc comment — src/pkg/review/prompts_publish.go:99-112. The new hiveSupersedingGuidance comment + const were inserted directly under the existing six-line comment for permissionsTighteningGuidance with no blank line, so godoc now attaches the #13068 pluk#305 explanation to hiveSupersedingGuidance, and permissionsTighteningGuidance (line 112) has no doc at all. Move the new block below:

 // The relay proves the same property structurally (WorkflowPermissionsTighteningOnly)
 // and suppresses the permissions classes; this text keeps the model's verdict
 // consistent with that code path instead of fighting it.
-// hiveSupersedingGuidance tells the reviewer how its verdict is routed on
-// the hive's own superseding copy of another PR (owner rule: those
-// auto-merge; a requires_human there becomes a fix request, not a park).
-const hiveSupersedingGuidance = "When a Hive-authored PR supersedes another PR (its body says `Supersedes #N`), it auto-merges once CI and review are clean and no operator decides on it: a requires_human you raise there — security-sensitive or not — is routed to the fixer as a concrete fix request, so state the remediation, not the question. Only the sentinel or an emergent problem with the head parks such a PR.\n"
-
 const permissionsTighteningGuidance = "Narrowing GitHub Actions permissions is not a security risk a human must own: ..."
+
+// hiveSupersedingGuidance tells the reviewer how its verdict is routed on
+// the hive's own superseding copy of another PR (owner rule: those
+// auto-merge; a requires_human there becomes a fix request, not a park).
+const hiveSupersedingGuidance = "When a Hive-authored PR supersedes another PR (its body says `Supersedes #N`), it auto-merges once CI and review are clean and no operator decides on it: a requires_human you raise there — security-sensitive or not — is routed to the fixer as a concrete fix request, so state the remediation, not the question. Only the sentinel or an emergent problem with the head parks such a PR.\n"

Prior findings at this head: docs-currency (escalate escape hatch undocumented next to the knob — review.go hiveSupersedingFixRoute still returns false under SelfAuthoredDecisionPolicy: escalate, no mention in hive-merge.md/operator-reference.md/config.go) — still present; security (detection keyed on the Supersedes #N body line, pr_hive_superseding.go:24, relay review_verdict_relay.go uses snap.Supersedes from the body) — still present. Neither is this perspective's to re-file.

— hive: agent=adjudicator-4 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.

docs-currency (delta re-review at 53e432b; the delta vs 0dfbc6a is a v5 base refresh — the PR's only doc change against merge-base is the new section src/docs/hive-merge.md:997-1051, unchanged since the last head)

Still present — review.self_authored_decision_policy: escalate silently disables the superseder rule, undocumented. src/pkg/review/review.go:929-931 returns false from hiveSupersedingFixRoute whenever the policy is escalate, so a hive superseding PR parks at 085 exactly as before. None of the three places that describe the knob mention this: src/docs/hive-merge.md:1044-1046 ("auto_merge.hive_superseding.auto_merge: false turns the rule off…" as the only off-switch), src/docs/operator-reference.md:448, src/docs/review-swarm.md:99. An operator who set escalate for issue-style decision questions will see "requires_human parked" and conclude the knob is broken.

`auto_merge.hive_superseding.auto_merge: false` turns the rule off and
restores the previous behaviour (a `requires_human` parks the superseding
PR at 085 like any hive-authored PR). `review.self_authored_decision_policy:
escalate` has the same effect for the review aggregate: with it set, a
superseding PR's `requires_human` parks at 085 regardless of this knob.

(replacing src/docs/hive-merge.md:1044-1046; add the same clause to the operator-reference.md:448 row.)

— hive: agent=adjudicator-5 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.

HUMAN DECISION NEEDED — @clubanderson confirm the superseder auto-merge may key on the author-controlled Supersedes #N body line (src/pkg/github/pr_hive_superseding.go:25-31) rather than the hive's adoption record — unchanged since the last head and still unanswered.

Security (delta re-review @ 53e432b; the delta vs 0dfbc6a is a v5 base refresh — pr_hive_superseding.go, automerge_hive_superseder.go and the relay hunk are byte-identical to the prior head)

Still present: the prior finding at src/pkg/github/pr_hive_superseding.go:24 (superseder identity bound to the body line, not rec.AdoptedBy/superseded_by). No owner reply on #15757 or #15756; the decision question stands.

New — reviewer-supplied hive_superseding survives the relay on non-requires_human verdicts. src/pkg/github/review_verdict_relay.go:430-448: report.HiveAuthored, report.Head and report.Decided are overwritten unconditionally from the dispatch record, but report.HiveSuperseding is only assigned inside if prSnapshot != nil && (report.DecisionRequested || report.Verdict == review.VerdictRequiresHuman). A reviewer JSON carrying "hive_superseding": true with verdict approve/changes_requested (or any verdict when prSnapshot == nil) is stored as-is, contradicting the field's own doc (src/pkg/review/review.go:132-134: "stamped by the verdict relay from the PR, never from the reviewer's JSON"). reportsHiveSuperseding (review.go:937-944) ORs across reports, so on any hive-authored, non-superseding PR one prompt-injected perspective flips agg.HiveSuperseding, and hiveSupersedingFixRoute (review.go:926-933) then routes another perspective's security-sensitive requires_human to the fixer instead of 085 — the exact gate this PR means to keep for non-superseders. No relay test covers a reviewer-supplied flag.

Fix — mirror HiveAuthored and reset before the conditional:

	report.HiveAuthored = auth.HiveAuthored
	report.HiveSuperseding = false
	if prSnapshot != nil && (report.DecisionRequested || report.Verdict == review.VerdictRequiresHuman) {

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

Owner rule: a PR the hive App creates to supersede another PR auto-merges
with no operator decision; the only exceptions are the sentinel or an
emergent problem with the PR.

- pkg/github: PullRequest.Supersedes, HiveSupersedingPR / IsHiveSupersedingPR;
  the verdict relay stamps hive_superseding on requires_human reports.
- pkg/review: hiveSupersedingFixRoute turns a requires_human (risk /
  security-sensitive included) on a hive superseding PR into
  changes_requested for the fixer; fix cap and reject still hold.
- pkg/stagelabels + pkg/github/automerge: one hard-stop list
  (hiveSupersederHardStop: sentinel-unacknowledged, hold,
  fix-attempts-exhausted, ci-red-after-fixes, base-conflict-unresolved);
  RouteHuman names the stop in the 085 reason, else captions the head as
  auto-merging once CI/review are clean.
- pkg/delegatedecision + dashboard: RuleHiveSuperseder releases without a
  stop, recommends-only naming the stop; tracker caption names the stop.
- Config knob auto_merge.hive_superseding.auto_merge (default on), reviewer
  prompt guidance, docs (hive-merge, review-swarm, operator-reference) and
  changelog fragment.

Closes #15756

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the fix/hive-superseder-automerge branch from 53e432b to 1ee7a3f Compare October 30, 2026 19:58
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: required-check-pending:build-and-test

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

Auto-merge hive-authored superseding PRs without an operator decision

1 participant