Skip to content

🐛 Close the hive's own empty-diff PRs as superseded instead of asking a person - #15584

Merged
clubanderson merged 7 commits into
v5from
fix/empty-diff-adoption-autoclose
Oct 30, 2026
Merged

clubanderson merged 7 commits into
v5from
fix/empty-diff-adoption-autoclose

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Why

Hive's adoption of @Karibhou's #15400 (#15499) sat a day at stage 085 "needs decision". Its tree is identical to v5 — #15427/#15449 already landed the fix — and the reviewer swarm asked @clubanderson "close as a no-op?" on six heads in a row (~16 "Decision needed" reviews + 085 entry comments). The owner's question: "hive adopted by hive agent — why does hive need me?"

Exact block: reviewer requires_human / decision-requested verdict with <!-- hive-redundant-of: #15427 -->, surfaced to the owner as contributor-lane:decision-requested with the generic "handed to a person without a specific question" prompt.

Root cause (bug, not policy)

The adoption's dispatch records carried no author_agent, so review_verdict_relay judged the App's own PR non-hive → aggregate HiveAuthoredKnown=true, HiveAuthored=false → contributor-lane routing to a person. Dispatch records now carry hive_authored; the relay also falls back to the PR author's login against the hive identity.

Fixes

  1. Empty-diff auto-close (pkg/github/pr_empty_diff_hive_autoclose.go): hive-authored PR with changed_files == 0, confirmed by base...head compare → closed through the writeback gate as superseded by the hive-redundant-of PR (sweep comment edited in place, hive/superseded label, terminal superseded stage). Guards: auto_close_superseded on, ACMM L6, not held/keep-open/draft/parked-by-person, head ≥15 min old. Never closes a person's PR — they keep the prompt. Hooked from the self-authored sweep and the 085 route; supersededCheckWarranted now fires for a decision verdict carrying hive-redundant-of; the aggregate never self-approves such a question.
  2. Decision-question dedupe: writeback.DecisionKey = hive-redundant-of PR, else normalised question words (mentions/item refs/digits/punctuation stripped — content dedupe missed these because a model reworded each). Relay refreshes the standing COMMENTED review in place rather than posting again; 085 entry comment not repeated across heads or 50↔85 flaps; a PR with no diff against its base re-stamps its prior verdict on each new head (delta re-review), so a merge-from-base no longer draws a review round.
  3. Tracker decision_needed: a row parked on a reviewer decision quotes the newest decision-requested verdict on any head (the current head has none during a re-review), carries redundant_of, shows a redundant of #N chip and leads with Close as superseded.

Invariants kept: never auto-merge ⚠️/needs-owner-merge; never auto-merge a human-authored PR without trust; never auto-close a human-authored PR.

Tests

DecideHiveEmptyDiffAutoClose, PRChangedFilesClaimsEmpty, close-comment markers, dispatchRecordHiveAuthored, reviewRedundantOfNumber, DecisionKey/content dedupe, EntryCommentRepeatsDecision, planDelta empty-base-diff restamp, aggregate keeps RedundantOf decision, supersededCheckWarranted, tracker lookup fallback + lead option.

Docs: hive-merge.md (new "Empty-diff PRs of the hive's own"), review-swarm.md; changelog fragment.

Refs #15499

A hive-authored adoption whose fix had already landed through another PR
sat a day at "needs decision" (#15499) while the swarm
asked the owner "close as a no-op?" on six heads in a row.

Root cause: the adoption's dispatch records carried no author_agent, so the
verdict relay judged the App's own PR non-hive and routed its decision down
the contributor lane. Dispatch records now carry hive_authored and the relay
falls back to the PR author's login against the hive identity.

Then three fixes on top:

- Empty-diff auto-close. A hive-authored PR with changed_files == 0, confirmed
  by the base...head compare, is closed through the writeback gate as
  superseded by the PR the reviewer named (hive-redundant-of), with the sweep's
  edited-in-place comment and hive/superseded label. Same guards as the
  superseded rule (L6, held, keep-open, draft, parked by a person) plus a
  15-minute head age. A person's empty PR is never closed by the hive.
  supersededCheckWarranted now runs for a decision verdict that carries
  hive-redundant-of; the aggregate never self-approves such a question.

- Decision-question dedupe. writeback.DecisionKey identifies a question by its
  hive-redundant-of PR, else its normalised words; content dedupe collapses
  reworded bodies to it. The relay refreshes the hive's standing COMMENTED
  review in place instead of posting again, and the 085 entry comment is not
  repeated across heads or 50<->85 flaps. A PR with no diff against its base
  re-stamps its prior verdict on every new head (delta re-review), so a
  merge-from-base no longer draws a review round.

- Tracker decision_needed. A row parked on a reviewer decision quotes the
  newest decision-requested verdict on any head (the current head has none
  during a re-review), carries redundant_of, shows a "redundant of #N" chip
  and leads with "Close as superseded".

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 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 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/XXL Denotes a PR that changes 1000+ 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
#15582 🐛 fix: warn once per PR on review dispatch promotion same files src/cmd/hive/main.go
#15308 ✨ feature: enqueue eligible PRs into GitHub native merge queues same files src/pkg/github/automerge/automerge_sweep.go
#15574 🌱 dashboard: split stage_tracker.go into 4 files same files src/pkg/dashboard/stage_tracker.go
#15564 🐛 review: split the grounding budget across fan-out sub-agents same files src/pkg/review/prompts.go
#15526 🌱 dashboard: split stage_tracker.go into 4 files same files src/pkg/dashboard/stage_tracker.go
#15530 🐛 fix(dashboard): issue-row linked PR passes null when the lineage chip is empty same files src/pkg/dashboard/static/index.html

@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

stage 080-awaiting-merge-admission → 071-needs-author: optional-check-failing:relative links and anchors resolve

…nds on it

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@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

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: required-check-missing: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:

  • test (rest 3/4)

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.

…generates byte-exact

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: check-pending

@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 head 0af7642.

1. Decision dedupe collapses different perspectives on the same head (medium). findOwnOpenDecisionReview (src/pkg/github/review_revise.go:166-196) matches any of the App's COMMENTED reviews with the same DecisionKey, with no head or perspective filter, and handleOneReviewRequest (src/pkg/github/review_request_watcher.go:532-540) then UpdateReviews it with the new body. The #15499 case had ~2–3 perspectives per head carrying the same hive-redundant-of: #15427; with this change the second perspective's review on a head overwrites the first's body, so any findings the first perspective reported alongside the question disappear from GitHub (the artifact still has them, the person does not). The PR body scopes this to "an earlier head"; the code does not. Suggested: only refresh reviews from a previous head.

--- a/src/pkg/github/review_request_watcher.go
+++ b/src/pkg/github/review_request_watcher.go
-	} else if existing := c.findOwnOpenDecisionReview(ctx, owner, repoName, req.Number, req.Body); existing != nil && apiEvent == "COMMENT" {
+	} else if existing := c.findOwnOpenDecisionReview(ctx, owner, repoName, req.Number, req.Body, c.reviewedPRSnapshotFunc(ctx, req)().Head); existing != nil && apiEvent == "COMMENT" {
--- a/src/pkg/github/review_revise.go
+++ b/src/pkg/github/review_revise.go
-func (c *Client) findOwnOpenDecisionReview(ctx context.Context, owner, repoName string, number int, reqBody string) *gh.PullRequestReview {
+func (c *Client) findOwnOpenDecisionReview(ctx context.Context, owner, repoName string, number int, reqBody, currentHead string) *gh.PullRequestReview {
 ...
 			if !strings.EqualFold(safeGetLogin(r.GetUser()), login) || !strings.EqualFold(r.GetState(), "COMMENTED") {
 				continue
 			}
+			// Same head: another perspective's review, not a re-ask on a new head.
+			if currentHead != "" && strings.EqualFold(strings.TrimSpace(r.GetCommitID()), currentHead) {
+				continue
+			}

2. In-place edit bypasses the review.revise_repos allowlist (medium). reviseReview refuses to edit a standing review outside review.revise_repos as a terminal policy denial (src/pkg/github/review_revise.go:117-119, :94-96; watcher denies at review_request_watcher.go:565-571). refreshDecisionReview (review_revise.go:201-213) calls PullRequests.UpdateReview on any repo with no allowlist check, and also outside the effects.ExecuteReconciling mutation boundary the normal post uses (review_request_watcher.go:542-560). Suggested minimal fix — honour the allowlist and fall through to the ordinary path when not granted:

	} else if existing := c.findOwnOpenDecisionReview(ctx, owner, repoName, req.Number, req.Body); existing != nil && apiEvent == "COMMENT" && reviseReviewAllowed(req.Repo, c.reviseRepos) {

3. Review-link ledger records the old head after a refresh (low). After the dedupe path created is the updated (or, when the body is unchanged, the untouched) existing review, and RecordReviewLink stores created.GetCommitID() (review_request_watcher.go:606-616) — the previous head's SHA, since UpdateReview does not move commit_id. perHeadReviewRefusal compares that against the live head (:884), so the per-head cap is silently off for the new head and the ledger misreports which head was reviewed. Record the current head instead when decisionDeduped is true.

Advisory (no change requested): emptyDiffHeadAge (src/pkg/github/pr_empty_diff_hive_autoclose.go:244-253) measures from updated_at, which GitHub bumps on every label/comment, not from the head commit; the docs call it "a head at least 15 minutes old". It only delays the close, never mis-fires, so just noting the drift.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@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

@clubanderson
clubanderson merged commit 635ce73 into v5 Oct 30, 2026
78 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/empty-diff-adoption-autoclose branch October 30, 2026 01:41
@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

@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 Bot added a commit that referenced this pull request Oct 30, 2026
…racker hunks onto the split files

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant