Skip to content

πŸ› reviewer: close already-landed empty-diff PRs for any author instead of parking at 085 - #15741

Merged
hivecommons-hive[bot] merged 5 commits into
v5from
fix/landed-contrib-autoclose
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
v5from
fix/landed-contrib-autoclose

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Closes #15732

Problem

#15671 made the hive close its own already-landed PRs as superseded. #15544 (trusted contributor, +0/βˆ’0 against v5, for #15543) was superseded by merged #15545, yet the reviewer's requires_human ("@clubanderson should decide whether #15544 can be closed as a no-op now that #15545 (merged) carries this change") parked it at 085 for 9h. The "Let hive decide" preview then gave the right action with the wrong reason ("Author @Karibhou is untrusted and their clanker is offline").

Change

  • pkg/github β€” CloseAlreadyLandedHivePRIfEligible now closes any author's PR when the diff against the base is empty (no files / every file byte-identical on the base tip) and the landing is proven: the reviewer-named PR is merged, the linked issue was closed by a merged PR (detectSupersessionDetail), or the compare lists no commits (head contained in base). New HiveEmptyDiffAutoCloseFacts.LandingProven. Close comment for non-hive authors: "Already landed via #N β€” closing as superseded; thank you @author." Still gated by the supersession-close write-back, L6, held/keep-open/parked-by-person. Non-empty diff β†’ unchanged.
  • pkg/github/automerge β€” the 085 route runs the already-landed closer for any author kind whose verdict claims already-landed (the hive's own superseded rule stays hive-only). Log reason already-landed:<author_kind> (stagelabels.AlreadyLandedAuthorReason); caption unchanged "already landed via #N β€” closing as superseded". Trust changes nothing.
  • pkg/review β€” "#N (merged)" in reviewer wording names the landing PR (the exact phrasing that parked πŸ› fix: quiet the merged-count odometerΒ #15544).
  • pkg/dashboard / pkg/delegatedecision β€” new Input.DiffEmpty; for a RuleAlreadyFixed close the preview's why is "Diff is empty β€” the change already landed via #N (merged)." and never mentions author trust.
  • Docs: src/docs/hive-merge.md paragraph after πŸ› review: the hive closes its own already-landed PRs instead of asking a personΒ #15671's; changelog.d/fixed-15732-already-landed-any-author.md.

Tests

Contributor + trusted author with empty diff β†’ closes (github closer, stage engine); non-empty diff β†’ kept / still parks; unproven landing β†’ human note; head-on-base proof; reviewer wording; plan why. No time.Sleep.

Refs #15544 #15545 #15671

The already-landed close (#15671) only covered the hive's own PRs. #15544
by a trusted contributor was +0/βˆ’0 against v5 because #15545 (merged)
carried the same change, yet it parked at 085 for 9h on the reviewer's
"should decide whether #15544 can be closed as a no-op now that #15545
(merged) carries this change".

- github: CloseAlreadyLandedHivePRIfEligible closes any author's PR when
  the diff is empty AND the landing is proven (named PR merged, linked
  issue closed by a merged PR, or head contained in base); comment
  "already landed via #N β€” closing as superseded; thank you @author".
- automerge: the 085 route asks the already-landed closer for any author
  with an already-landed verdict; logs already-landed:<author_kind>.
- review: "#N (merged)" names the landing PR like "via #N".
- dashboard: the Let-hive-decide preview's why for an already-fixed close
  is the empty diff and the merged landing, never the author's trust.

Closes #15732

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/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
#15755 πŸ› [reviewer] carry operator decision over the hive's base refresh same files src/docs/hive-merge.md
src/pkg/github/automerge/automerge_stage_labels_test.go
#15748 πŸ› [reviewer] park PRs at 085 Needs decision when the fixer exhausted its attempts same files src/docs/hive-merge.md
src/pkg/github/automerge/automerge_stage_human.go
src/pkg/stagelabels/human.go
#15757 ✨ Auto-merge hive-authored superseding PRs without operator decision same files src/docs/hive-merge.md
src/pkg/dashboard/api_repo_item_decide_delegated.go
src/pkg/delegatedecision/policy.go
src/pkg/github/automerge/automerge_stage_human.go
src/pkg/stagelabels/human.go

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

Read src/pkg/github/pr_empty_diff_hive_autoclose.go and src/pkg/github/automerge/automerge_stage_human.go at c5d931d against the v5 tree. The gating is sound β€” a person's PR still only reaches the closer through the reviewer's already-landed entry (automerge_stage_human.go:146-171, pr_empty_diff_hive_autoclose.go:365-369), and the plain sweep rule stays hive-only. One concrete defect in the proof-to-credit handoff:

Low β€” close comment and issue note can credit an unmerged PR (pr_empty_diff_hive_autoclose.go:233-246, :383-392)

alreadyLandedProof tries the reviewer-named redundantOf first and only accepts it if merged. If it is not merged, it falls through to detectSupersessionDetail, then to headOnBase, returning (0, true). Back in closeHiveRedundantPR (:388), redundantOf is only overwritten when landed > 0, so the stale unmerged number survives into supersessionCloser{Number: redundantOf}, alreadyLandedCloseReason(redundantOf, …) β†’ "Already landed via #N β€” closing as superseded", renderEmptyDiffCloseComment's hive-redundant-of marker, and alreadyLandedIssueNote on every issue closeIssuesAlreadyLanded closes. The landing is real (head contained in base), but the public credit names a PR that did not land it, and the dashboard's dedupe key reads the wrong superseder.

Suggested fix: when proven comes from headOnBase (landed == 0), reset redundantOf = 0 and out.RedundantOf = 0 so the existing "Already landed on base" wording at :538 is used. TestCloseAlreadyLandedAnyAuthorClosesOnProvenLanding could add the case "named PR open, head on base" to pin it.

Everything else I checked holds: DecideHiveEmptyDiffAutoClose only moves the !HiveAuthored case behind LandingProven and the Held/KeptOpen/ParkedByPerson guards still follow it (:149-152); ParkedByPerson is now computed for any author's empty PR (:381-383), which is the right direction. Non-empty diff β†’ unchanged path, matching the body. go build ./pkg/github/... ./pkg/github/automerge/... passes on this head.

Note for whoever approves: this widens an auto-close action from hive-authored PRs to any author's PR. The gate (empty diff + proven merged landing + reviewer claim) is as described in #15732, so I am not raising a decision question β€” just flagging that this is a write-policy change on contributors' PRs.

β€” 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.

Read the closer (pkg/github/pr_empty_diff_hive_autoclose.go at c5d931d), the 085 route (automerge_stage_human.go:138-186), review/already_landed.go, and the v5 tree they sit in. The change does what the body says, and the safety argument holds: another author's PR reaches the closer only when the head-keyed verdict claims already-landed (contributorLaneVerdictFor(fullRepo, number, headSHA)), closeHiveRedundantPR still refuses unless the compare is empty or tree-identical (pr_empty_diff_hive_autoclose.go:382), and DecideHiveEmptyDiffAutoClose:154 additionally requires LandingProven for non-hive authors before the write-back gate, L6, held/keep-open/parked guards. The hive's own superseded rule is correctly kept hive-only (automerge_stage_human.go:170-172, :240-244). Tests cover both author kinds, the kept-still-parks path, and the regex. Looks correct to me.

One guard I would add before this closes a person's PR:

Low β€” no head-SHA check between the observed verdict and the PR that gets closed. closeSupersededBeforeHumanRoute decides landedClaimed from obs.Detail.Verdict, which was recorded against obs.HeadSHA, then re-fetches the PR (automerge_stage_human.go:165) and hands that fresh object to the closer without comparing pr.GetHead().GetSHA() to obs.HeadSHA. If the author pushes between the sweep's observation and this GET, a verdict for the old head drives the compare of the new one. The empty-diff requirement makes a wrong close unlikely, but the one head state where it is empty β€” the author resets the branch to the base tip before pushing their rework (headOnBase then proves the landing with redundantOf=0) β€” is exactly a human mid-rework, and the freshness guard does not apply on this path because ReviewerConfirmed is always true here (:362). A pr.GetHead().GetSHA() != obs.HeadSHA β†’ return false before :170 closes it; the next tick re-observes the new head with no verdict and parks as before. Pre-existing for hive-authored PRs, but now a person absorbs it.

Info: AlreadyLandedFromVerdict returns claimed on any summary matching the phrase list (redundant, no-op, in place, already done…), not only the decision question, so a correctness summary like "the nil guard is already in place" opens this path for a contributor PR. It is harmless given the empty-diff + proof requirement, just noting that the trigger is wider than the body's "when the reviewer raised it" suggests.

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

Looks correct to me. Read the tree at 3ddc572 with an eye on the one thing that could go wrong here β€” closing a person's PR that is merely a branch mid-push β€” and the gating holds:

  • A non-hive author only reaches the close through the reviewed entry: closeHiveRedundantPR returns human early when !reviewed && !facts.HiveAuthored (src/pkg/github/pr_empty_diff_hive_autoclose.go:366-371), and the sweep side mirrors it β€” closeSupersededBeforeHumanRoute requires alreadyLandedClaimed(obs.Detail.Verdict) for another author (automerge_stage_human.go:146-149) and closeEmptyDiffBeforeHumanRoute returns false for !hiveAuthored before the plain empty-diff rule (:240-244). So ReviewerConfirmed bypassing EmptyDiffMinHeadAge is justified: a verdict exists for this exact head.
  • On top of the empty diff, alreadyLandedProof (:229-243) needs one of: the named PR fetched and Merged, detectSupersessionDetail returning a merged closer for the claimed issue, or the compare listing zero commits (head is an ancestor of base). DecideHiveEmptyDiffAutoClose still runs Held / KeptOpen / ParkedByPerson / L6 after LandingProven (:150-160), and ParkedByPerson is now computed for every empty PR (:382-384), not only hive ones.
  • closer, ok := c.transport.(supersededCloserTransport) may be a nil interface for a non-hive author (automerge_stage_human.go:150-153); that is safe because the PR is read via c.gh.PullRequests.Get and the non-hive branch returns before closer is used (:170-173); the already-landed transport is separately type-asserted with its own ok.
  • The close comment and issue note now carry the author's login and drop "its own" for non-hive PRs (alreadyLandedCloseReason, alreadyLandedIssueNote), matching the body's wording.

src/docs/hive-merge.md and the changelog fragment are updated with the behaviour. Could not run go test in this pod (blocked for agents).

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

Looks correct to me; the three proofs and the gates match what #15732 asks for, and the fail-closed order in DecideHiveEmptyDiffAutoClose is preserved.

What I verified (v5 tree + diff):

  • pr_empty_diff_hive_autoclose.go: the !f.HiveAuthored && !f.LandingProven β†’ human case keeps its position before Held / KeptOpen / ParkedByPerson / Level / HeadAge, so a person's PR with a proven landing still has to clear every guard the hive's own PR does. ParkedByPerson is now computed for every empty PR (previously hive-only), which is what makes the "parked by a person keeps the question" promise in the doc true.
  • closeHiveRedundantPR: the early return flipped from reviewed && !HiveAuthored to !reviewed && !HiveAuthored, so the sweep's bare empty-diff rule (CloseEmptyDiffHivePRIfEligible, automerge_sweep.go:1836) still never closes a person's PR; only the reviewer-confirmed entry (CloseAlreadyLandedHivePRIfEligible) does. alreadyLandedProof tries the named PR (must be merged, and != pr.GetNumber()), then the issue's merged closer, then headOnBase.
  • automerge_stage_human.go: a non-hive PR reaches closeEmptyDiffBeforeHumanRoute(…, false, …) only when obs.Detail.VerdictKnown && alreadyLandedClaimed(...), and inside it the !hiveAuthored return sits after the already-landed branch, so the plain empty-diff closer is never reached for another author. The supersededCloserTransport assertion is correctly relaxed to !ok && hiveAuthored since that transport is not used on the non-hive path.
  • already_landed.go: alreadyLandedMergedRefRE reuses AlreadyLandedPR's conflict rule (two different numbers β†’ 0), so "#15545 (merged)" and "via #15545" in the same text agree rather than double-count.

One open question (not a defect): alreadyLandedProof accepts headOnBase alone β€” compare lists no commits β€” as proof, while the comment two lines above the call says "the compare alone could be a branch mid-push". The reconciliation is that this path only runs when a reviewer verdict on this head already claimed already-landed, and ParkedByPerson/Held still apply. If that reliance is intended, a sentence saying so next to the headOnBase fallback would stop the two comments reading as contradictory. The issue body lists "the PR's commits are all contained in the base" as acceptable evidence, so I am not asking anyone to decide it.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 060-reviewed β†’ 050-review-pending: required-check-pending:build-and-test

@hivecommons-hive
hivecommons-hive Bot merged commit 0037265 into v5 Oct 30, 2026
73 of 74 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/landed-contrib-autoclose branch October 30, 2026 13:03
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#157416f648d9` sha256:52166d85c577f37ac8752fef5b574018627bd7a9fba9bf0472faa454cc731c37 β€” download from the dashboard or `hivectl review evidence #15741`.

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

@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

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.

πŸ› [reviewer] already-landed empty-diff contributor PRs park at 085 instead of closing as superseded

1 participant