Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-delegate-human-merge-approves.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- "Let hive decide" on a contributor PR at *Ready for human merge · untrusted author* now approves and lets the merge sweep merge the PR under its own number when the review is good, CI is green and the head is mergeable (the same path as *Approve — let hive merge*, with the head admitted as the person's trust override); adoption in supersede mode is only the fallback for a head that cannot merge as it is (review not good, CI red, conflicting, sign-off missing). The chosen path is in the decision reason, so the ✓ hover reads *the hive decided: approve · review passed, CI green, mergeable*. Before, the hive only answered "I can't merge this". (#15173)
2 changes: 1 addition & 1 deletion src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ The glyph is drawn for **every** row on the gate, so two rows in the same state

| State the pill shows | Lead actions in ⋯ and in the popover (consequence) |
|---|---|
| PR at 090 *Ready for human merge* (untrusted author, workflow files, manual-merge path, branch protection…) | **Approve & merge as maintainer** (merges #N into *base* now via hive's identity, attributed to you — a comment on the PR names you, the audit log records `repo_item_decision_merge`, `source: dashboard`) · **Approve — let hive merge** (records your approval as the owner decision — an APPROVE review and the automerge label; the hive's merge sweep merges it on its next pass once CI is green and the head has soaked) · Give direction (hive-authored PRs only) · Close as superseded · Close as won't fix · Hold. Both merge actions need the merger or owner role and confirm first (with *Don't ask again*); the toast reads *merged* / *queued for merge*; the badge records `merge-now` / `queue-merge`. **Let hive decide** is here too (third): on a 090 PR it never runs the policy — the hive answers at once through the no-effect toast, *I can't merge this: author @Karibhou is untrusted on hotshot — …*, with *Approve & merge as maintainer · Approve — let hive merge* as buttons and the 👥 Contributors fix in the next line. **Either Approve is the trust override for that head** ([#15136](https://github.com/hivecommons/hive/issues/15136); owner, 2026-10-29: "I approved these and then they went to adopted…"): the stage record gets `admitted_by: operator-approval:<you>`, the contributor lane merges the head as-is after checks and soak, and the adoption engine refuses to adopt or supersede it while the admission stands (the row reads *not adopted: a maintainer approved this head; the hive merges it as-is*; the 090 tooltip and popover say *Approved by @you as the owner decision…* and the second Approve greys out). When the record's commit check found commits without a `Signed-off-by`, the popover's blocker line and both Approve confirms say so **before** acting (*2 of 3 commits have no Signed-off-by, so a required DCO check refuses the merge*) and a third lead action appears, **Re-author as hive PR** — the explicit, separate choice: the hive re-homes the commits on a signed-off hive branch and opens a superseding PR; nothing is merged as-is. It is greyed with the reason on a person's PR. Renderer test: `TestStageTrackerReauthorAndApprovalCaveats`. |
| PR at 090 *Ready for human merge* (untrusted author, workflow files, manual-merge path, branch protection…) | **Approve & merge as maintainer** (merges #N into *base* now via hive's identity, attributed to you — a comment on the PR names you, the audit log records `repo_item_decision_merge`, `source: dashboard`) · **Approve — let hive merge** (records your approval as the owner decision — an APPROVE review and the automerge label; the hive's merge sweep merges it on its next pass once CI is green and the head has soaked) · Give direction (hive-authored PRs only) · Close as superseded · Close as won't fix · Hold. Both merge actions need the merger or owner role and confirm first (with *Don't ask again*); the toast reads *merged* / *queued for merge*; the badge records `merge-now` / `queue-merge`. **Let hive decide** is here too (third). On a contributor PR at 090 the hive decides itself ([#15173](https://github.com/hivecommons/hive/issues/15173); live: hive#15118, hotshot#317 — both Karibhou, MERGEABLE, 0 failing checks, yet the old answer was only *I can't merge this*): when the reviewer's verdict for the head is good (approve, or merge-eligible with nothing for a person — no verdict recorded counts as good, since the lane itself found nothing wrong at 090), CI is green, the head is not conflicting and no sign-off is missing, the decision is **approve** — the same path as *Approve — let hive merge*: an APPROVE review + the automerge label, the head admitted as `operator-approval:<you>`, and the merge sweep merges the PR **under its own number** after soak; it is never copied into a hive-owned PR. Only when the head cannot merge as it is — review not good, CI red, conflicting (needs a rebase), sign-off missing — does the hive fall back to **adopt in supersede mode** (`human-merge-adopt`), re-homing the commits on its own branch and fixing what blocks the merge. The chosen path is in the decision reason, so the ✓ hover reads *the hive decided: approve · review passed, CI green, mergeable (rule: human merge approve)* or *… adopt-supersede · CI red, conflicting, needs rebase (rule: human merge adopt)*. The plain-words hand-back — *I can't merge this: author @Karibhou is untrusted on hotshot — …*, with *Approve & merge as maintainer · Approve — let hive merge* as buttons and the 👥 Contributors fix in the next line — remains only when the hive has no way forward of its own: a hive-authored PR, or a head that cannot merge as-is on a hive with `governor.labels.stage.adoption` off. Tests: `TestDecideHumanMergePaths`, `TestDelegatedDecisionReadyForHumanMergeApprovesWhenGreen`, `…AdoptsWhenNotMergeable`, `TestStageTrackerActedPlainDecisionPathJS`. **Either Approve is the trust override for that head** ([#15136](https://github.com/hivecommons/hive/issues/15136); owner, 2026-10-29: "I approved these and then they went to adopted…"): the stage record gets `admitted_by: operator-approval:<you>`, the contributor lane merges the head as-is after checks and soak, and the adoption engine refuses to adopt or supersede it while the admission stands (the row reads *not adopted: a maintainer approved this head; the hive merges it as-is*; the 090 tooltip and popover say *Approved by @you as the owner decision…* and the second Approve greys out). When the record's commit check found commits without a `Signed-off-by`, the popover's blocker line and both Approve confirms say so **before** acting (*2 of 3 commits have no Signed-off-by, so a required DCO check refuses the merge*) and a third lead action appears, **Re-author as hive PR** — the explicit, separate choice: the hive re-homes the commits on a signed-off hive branch and opens a superseding PR; nothing is merged as-is. It is greyed with the reason on a person's PR. Renderer test: `TestStageTrackerReauthorAndApprovalCaveats`. |
| PR at 085 *Needs human decision* | Let hive decide · Approve · Give direction · Close as superseded · Close as won't fix · Hold (unchanged). |
| Issue at 045 *Needs decision* (direction) | Let hive decide · Give direction · Approve direction · Send back to the hive · Hold (unchanged). |
| Human-authored PR at 071 *Needs author* / 072 *Returned to contributor* | Let hive decide · Close as superseded · Close as won't fix · Hold — the hive never rewrites a person's PR, so the choice is wait or close. (A hive-authored PR there carries *Adopt now* when adoption applies.) |
Expand Down
18 changes: 18 additions & 0 deletions src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,24 @@ re-authoring and is not refused.
|---|---|---|
| `re-author` — *Re-author as hive PR* | Offered as its own lead action on a 090 PR whose head cannot merge as-is — the stage record's commit check counted commits without a `Signed-off-by` (`dco_unsigned` / `dco_total` on the row). The popover and both Approve confirms say so **before** acting (*2 of 3 commits have no Signed-off-by, so a required DCO check refuses the merge*); approving never re-authors by itself. Re-author posts its own note and the `adoption/supersede` request label; the hive re-homes the commits on a hive-owned, signed-off branch and opens a superseding PR. Disabled with the reason on a person's PR (the hive does not re-author a human's PR — ask them to `git commit -s --amend`). | `repo_item_decision_adopt` with `decision=re-author`; `last_operator_action.action: re-author`; toast *adopted*. |

**Let hive decide on a 090 PR takes the approve path when it can
([#15173](https://github.com/hivecommons/hive/issues/15173)).** Delegating a
contributor PR at *Ready for human merge* runs `DecideHumanMerge`: with the
reviewer's verdict for the head good (approve, or merge-eligible with
nothing for a person; no recorded verdict counts as good — the lane found
nothing wrong at 090), CI green, no conflict and no missing sign-off, the
rule is `human-merge-approve` — the `queue-merge` path above (APPROVE
review, automerge label, `admitted_by: operator-approval:<login>`), so the
merge sweep merges the PR **under its own number** after soak, never a
hive-owned copy. Otherwise the rule is `human-merge-adopt`: adopt in
supersede mode, with the reasons in the decision (`review not good`, `CI
red`, `conflicting, needs rebase`, `sign-off missing`). The decision's
`path` is in the audit detail and the ledger line — *hive decided: approve ·
review passed, CI green, mergeable (human-merge-approve)* — and the ✓ hover
renders it in plain words. The hive hands back with *I can't merge this…*
only for a hive-authored PR, or when the head cannot merge as-is and
`governor.labels.stage.adoption` is off.

Neither merge action widens who the lanes trust: to stop a contributor's PRs parking at 090
give them the `trusted` / `merger` tier under 👥 Contributors
(`auto_merge.contributor_lane.require_tiers`), add them as a repository
Expand Down
47 changes: 47 additions & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand All @@ -18,6 +18,7 @@
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/delegatedecision"
ghpkg "github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/review"
"github.com/hivecommons/hive/pkg/stagelabels"
)

Expand Down Expand Up @@ -487,6 +488,9 @@
return out
}
d, deciderNotes := s.decideDelegated(ctx, in)
if hm, ok := s.delegatedHumanMergeDecision(in); ok {
d, deciderNotes = hm, []string{"ready for human merge: " + hm.Path}
}
// An adoption whose copy was closed unmerged (hivecommons/hive#15052)
// overrides the policy: the recorded decision no longer stands, so the
// answer is to re-adopt, not "already decided".
Expand Down Expand Up @@ -594,6 +598,7 @@
if err := s.gatherDelegatedPRContext(ctx, repoFull, pr, &in); err != nil {
return in, err
}
in.HeadSHA = strings.TrimSpace(pr.GetHead().GetSHA())
state := strings.ToLower(pr.GetMergeableState())
in.Conflicting = state == "dirty" || (pr.Mergeable != nil && !pr.GetMergeable())
green, err := delegatedHeadCIGreen(ctx, api, owner, repoName, pr, in.Conflicting, state)
Expand Down Expand Up @@ -630,9 +635,41 @@
in.AdoptionStalled = strings.HasPrefix(lowerReason, stagelabels.LaneReasonAdoptionStalledPrefix)
in.ReporterTrustHold = strings.Contains(lowerReason, "reporter-trust") || strings.Contains(lowerReason, "reporter trust")
in.DCOMissing = strings.Contains(lowerReason, "dco")
s.gatherDelegatedHumanMergeInput(&in)
return in, nil
}

// gatherDelegatedHumanMergeInput fills what DecideHumanMerge reads for a
// PR at 090 (hivecommons/hive#15173): the reviewer's verdict for the head
// from the review artifact, and the stage record's sign-off check. Both
// are local reads; a missing artifact or record leaves the fields unknown.
func (s *Server) gatherDelegatedHumanMergeInput(in *delegatedecision.Input) {
if in.Kind != delegatedecision.KindPR || !slices.Contains(in.Labels, stagelabels.ReadyForHumanMerge.Label()) {
return
}
in.ReadyForHumanMerge = true
if art, err := review.LoadArtifact(""); err == nil {
if agg, ok := stageTrackerVerdictLookup(&art)(in.Repo, in.Number, in.HeadSHA); ok {
in.ReviewKnown = true
in.ReviewGood = delegatedReviewGood(agg)
}
}
if rec, ok := s.stageStoreOrShared().Get(stagelabels.Key(in.Repo, in.Number)); ok {
if _, unsigned, ok := rec.DCOFor(in.HeadSHA); ok && unsigned > 0 {
in.DCOMissing = true
}
}
}

// delegatedReviewGood: the reviewer approved the head, or found it
// merge-eligible with nothing for a person and no close recommendation.
func delegatedReviewGood(agg review.Aggregate) bool {
if agg.RequiresHuman || agg.CloseRecommended {
return false
}
return agg.Verdict == review.VerdictApprove || agg.MergeEligible
}

// delegatedHeadCIGreen decides Input.CIGreen for the PR under decision.
// mergeable_state alone cannot carry it: GitHub reports "blocked" both for a
// missing required review and for red required checks, and "unknown" /
Expand Down Expand Up @@ -728,6 +765,16 @@
}
notes = append(notes, "`/lgtm` + `/approve` recorded; the merge gate takes it from here")
}
// The delegated approval of an untrusted author's PR is the
// person's trust override for this head (hivecommons/hive#15136,
// #15173): the contributor lane merges it as it is instead of
// adopting it. A PR at 090 is untrusted by the lane's own
// judgement, whatever the author's repo permission says.
if !in.HiveAuthored && (in.ReadyForHumanMerge || !in.TrustedAuthor) {
if by := s.admitPullRequestHead(repoFull, number, in.HeadSHA, user); by != "" {
notes = append(notes, "head admitted as "+by+"; the contributor lane merges it as it is, no adoption")
}
}
case delegatedecision.ActionLabelsAdd:
for _, l := range a.Labels {
color, desc := delegatedLabelMeta(l)
Expand Down
Loading
Loading