Skip to content
Merged
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-human-author-pr-never-adopted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A PR a person pushed themselves β€” an owner or maintainer in `dashboard.authorized_users`, or any `author/human` PR β€” is never adopted by the hive ([#15202](https://github.com/hivecommons/hive/issues/15202)). The contributor-lane "contributor offline" rule now applies only to clanker and registered-contributor PRs; a `requires_human` or changes-requested verdict on a human-authored PR routes to 071 Needs author and tells the author what the reviewer asked (or that the branch conflicts and needs their rebase) instead of parking at 085; and "Let hive decide" on such a PR can only approve-admit a reviewed, green head, return it to its author with the reviewer's question or the fix, or hold. The adoption path itself β€” the engine's `adoption/supersede` label handler, the delegate executor and the 090 "ready for human merge" decider from #15181 β€” refuses a person's PR with a logged reason that the stage tracker row shows as "not adopted: the hive asks them, not adopts". Folded from #15191: a DCO-less clanker head at 090 adopts in supersede mode rather than waiting on a person.
19 changes: 19 additions & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

import (
Expand Down Expand Up @@ -125,6 +125,7 @@
HiveID: cfg.HiveID,
AuthorKindLabels: cfg.Governor.Labels.Author.Names(),
RelayKnown: contributorRelayKnown,
OwnerAuthor: dashboardOwnerLogin(cfg),
SharedCIIncident: stageSharedCIIncident,
BaseBranchRed: stageBaseBranchRed,
ForkGuard: stageForkGuard,
Expand All @@ -134,6 +135,24 @@
}
}

// dashboardOwnerLogin answers StageLabelPolicy.OwnerAuthor from
// dashboard.authorized_users: an owner's PR is a person's, never adopted
// (hivecommons/hive#15202).
func dashboardOwnerLogin(cfg *config.Config) func(login string) bool {
return func(login string) bool {
login = strings.TrimSpace(strings.TrimPrefix(login, "@"))
if login == "" || cfg == nil {
return false
}
for _, entry := range cfg.Dashboard.AuthorizedUsers {
if name, _ := dashboard.AuthorizedUserEntry(entry); strings.EqualFold(name, login) {
return true
}
}
return false
}
}

// contributorRelayKnown answers authorkind's weakest author/clanker signal:
// the login has a contributor profile on this hive, i.e. runs a relay that
// targets it. It only decides a PR whose body carries no hive marker.
Expand Down
3 changes: 3 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 Down Expand Up @@ -806,6 +806,9 @@
if in.Kind != delegatedecision.KindPR || in.HiveAuthored {
return notes, fmt.Errorf("supersede adoption requires a contributor PR")
}
if in.PersonAuthored() {
return notes, fmt.Errorf("a person pushed %s#%d themselves (@%s); the hive asks the author instead of adopting it", repoFull, number, in.Author)
}
if !s.stageAdoptionEnabled() {
// The engine only consumes the request label with adoption
// on; queuing it would be a silent no-op with a stale label.
Expand Down
15 changes: 15 additions & 0 deletions src/pkg/dashboard/delegated_decision_human_merge.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -118,6 +118,7 @@
delegatedHumanMergeAdoptCIRedRule = "human-merge-adopt-ci-red"
delegatedHumanMergeAdoptRebaseRule = "human-merge-adopt-conflicting"
delegatedHumanMergeAdoptReviewRule = "human-merge-adopt-review"
delegatedHumanMergeAdoptDCORule = "human-merge-adopt-dco"
)

// delegatedHumanMergeDecidedPath is the chosen path and its reason for a
Expand All @@ -133,6 +134,10 @@
return "adopt Β· conflicting, needs rebase"
case delegatedHumanMergeAdoptReviewRule:
return "adopt Β· review not passed"
case delegatedHumanMergeAdoptDCORule:
return "adopt Β· DCO sign-off missing"
case delegatedecision.RuleReturnToAuthor:
return "return to author Β· a person pushed this PR; the hive asked them, not adopted it"
}
return ""
}
Expand Down Expand Up @@ -174,6 +179,14 @@
}
ref := "#" + strconv.Itoa(in.Number)
adopt := func(rule, why string) (delegatedecision.Decision, []string, bool) {
if in.PersonAuthored() {
// A person pushed this PR: it is theirs to fix, never the
// hive's to adopt (hivecommons/hive#15202).
if d, ok := delegatedecision.ReturnToAuthor(in); ok {
return d, []string{"hive decided: return to author Β· " + why}, true
}
return delegatedecision.Decision{}, nil, false
}
if !s.stageAdoptionEnabled() {
return delegatedecision.Decision{}, nil, false
}
Expand All @@ -189,6 +202,8 @@
switch {
case in.Conflicting:
return adopt(delegatedHumanMergeAdoptRebaseRule, "the branch conflicts with the base and needs a rebase")
case in.DCOMissing:
return adopt(delegatedHumanMergeAdoptDCORule, "the DCO sign-off is missing from its commits")
case !in.CIGreen:
return adopt(delegatedHumanMergeAdoptCIRedRule, "CI is not green on its head")
case !s.delegatedHumanMergeReviewPassed(in):
Expand Down
60 changes: 60 additions & 0 deletions src/pkg/dashboard/delegated_decision_human_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,63 @@ func TestDelegatedDecisionUntrustedReadyForHumanMergeDecides(t *testing.T) {
})
}
}

// hivecommons/hive#15202: a person's 090 PR (owner or author/human) is never
// adopted. A conflicting, red or unsigned head is returned to its author with
// the fix spelled out; a clean head is still approved; and a DCO-less clanker
// head still adopts (the one branch folded from hivecommons/hive#15191).
func TestDelegatedHumanMergeDecisionPersonAuthoredNeverAdopts(t *testing.T) {
srv := newDelegatedServer(t, &repoItemDecisionMock{})
srv.deps.Config.Governor.Labels.Stage.Adoption.Enabled = boolPtr(true)
base := delegatedecision.Input{
Repo: "testorg/testrepo", Number: 15157, Kind: delegatedecision.KindPR, Author: "clubanderson",
Labels: []string{stagelabels.ReadyForHumanMerge.Label(), "role/newcomer"}, CIGreen: true,
}
req := delegatedDecisionRequest{Type: "pr", Reason: "contributor-lane:author-association"}
cases := []struct {
name string
mutate func(in *delegatedecision.Input)
wantRule string
wantNote string
wantText string
}{
{name: "owner conflicting returns to author", mutate: func(in *delegatedecision.Input) { in.OwnerAuthor = true; in.Conflicting = true },
wantRule: delegatedecision.RuleReturnToAuthor, wantNote: "hive decided: return to author Β· the branch conflicts with the base and needs a rebase",
wantText: "@clubanderson: rebase onto the base branch on #15157; then it merges"},
{name: "author/human red CI returns to author", mutate: func(in *delegatedecision.Input) { in.HumanAuthor = true; in.CIGreen = false },
wantRule: delegatedecision.RuleReturnToAuthor, wantNote: "hive decided: return to author Β· CI is not green on its head",
wantText: "make CI green"},
{name: "owner DCO missing returns to author", mutate: func(in *delegatedecision.Input) { in.OwnerAuthor = true; in.DCOMissing = true },
wantRule: delegatedecision.RuleReturnToAuthor, wantNote: "hive decided: return to author Β· the DCO sign-off is missing from its commits",
wantText: "add the DCO sign-off"},
{name: "owner clean head approves", mutate: func(in *delegatedecision.Input) { in.OwnerAuthor = true },
wantRule: delegatedHumanMergeApproveRule, wantNote: "hive decided: approve Β· review passed, CI green"},
{name: "clanker DCO missing adopts", mutate: func(in *delegatedecision.Input) { in.DCOMissing = true },
wantRule: delegatedHumanMergeAdoptDCORule, wantNote: "hive decided: adopt Β· DCO sign-off missing"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
in := base
in.Labels = append([]string(nil), base.Labels...)
tc.mutate(&in)
d, notes, ok := srv.delegatedHumanMergeDecision(in, req, "writer", true)
if !ok || d.Rule != tc.wantRule {
t.Fatalf("ok=%v decision=%+v, want rule %q", ok, d, tc.wantRule)
}
if len(notes) != 1 || notes[0] != tc.wantNote {
t.Fatalf("notes = %q, want %q", notes, tc.wantNote)
}
if tc.wantText != "" && !strings.Contains(d.Text, tc.wantText) {
t.Fatalf("text = %q, want it to contain %q", d.Text, tc.wantText)
}
for _, a := range d.Actions {
if in.PersonAuthored() && a.Kind == delegatedecision.ActionAdoptSupersede {
t.Fatalf("a person's PR must never carry an adopt action: %+v", d)
}
}
if d.Rule == delegatedHumanMergeAdoptDCORule && d.Verdict != delegatedecision.VerdictAdoptSupersede {
t.Fatalf("clanker DCO-less head should adopt: %+v", d)
}
})
}
}
50 changes: 49 additions & 1 deletion src/pkg/dashboard/delegated_pr_context.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -71,7 +71,11 @@
func (s *Server) gatherDelegatedPRContext(ctx context.Context, repo string, pr *gh.PullRequest, in *delegatedecision.Input) error {
owner, name, _ := strings.Cut(repo, "/")
now := time.Now().UTC()
if !in.HiveAuthored {
in.HumanAuthor = s.delegatedHumanAuthor(in.Labels)
in.OwnerAuthor = s.isAuthorizedUserLogin(in.Author)
// A person's PR is never a contributor with an expected connected hive;
// "offline" has no meaning for it (hivecommons/hive#15202).
if !in.HiveAuthored && !in.PersonAuthored() {
window := config.DefaultPresenceWindow
if s.deps.Config != nil {
window = s.deps.Config.Governor.Labels.Stage.EffectivePresenceWindow()
Expand Down Expand Up @@ -132,6 +136,50 @@
// Only the author's own activity proves presence: bot nudges and other people's
// reviews must not keep an absent contributor online. Read every page before
// declaring absence; API failures abort gathering rather than authorizing adoption.
// delegatedHumanAuthor reads the author-kind label (author/human by default,
// renamed via governor.labels.author) from the PR's labels. hive beats
// clanker beats human when labels disagree, as in pkg/authorkind.
func (s *Server) delegatedHumanAuthor(labels []string) bool {
human, clanker, hive := authorKindLabelPfx+authorKindHuman, authorKindLabelPfx+authorKindClanker, authorKindLabelPfx+authorKindHive
if s != nil && s.deps != nil && s.deps.Config != nil {
a := s.deps.Config.Governor.Labels.Author
if strings.TrimSpace(a.Human) != "" {
human = a.Human
}
if strings.TrimSpace(a.Clanker) != "" {
clanker = a.Clanker
}
if strings.TrimSpace(a.Hive) != "" {
hive = a.Hive
}
}
isHuman := false
for _, l := range labels {
switch l = strings.TrimSpace(l); {
case strings.EqualFold(l, hive), strings.EqualFold(l, clanker):
return false
case strings.EqualFold(l, human):
isHuman = true
}
}
return isHuman
}

// isAuthorizedUserLogin: login is one of this hive's dashboard.authorized_users.
func (s *Server) isAuthorizedUserLogin(login string) bool {
login = strings.TrimSpace(strings.TrimPrefix(login, "@"))
if login == "" || s == nil || s.deps == nil || s.deps.Config == nil {
return false
}
for _, entry := range s.deps.Config.Dashboard.AuthorizedUsers {
name, _ := dashboardAuthorizedUserEntry(entry)
if name != "" && strings.EqualFold(name, login) {
return true
}
}
return false
}

func (s *Server) delegatedContributorOnline(ctx context.Context, owner, repo string, pr *gh.PullRequest, cutoff time.Time) (bool, error) {
author := pr.GetUser().GetLogin()
// Unknown identity is not evidence of absence.
Expand Down
6 changes: 6 additions & 0 deletions src/pkg/dashboard/server.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -2229,6 +2229,12 @@
return ""
}

// AuthorizedUserEntry splits a dashboard.authorized_users entry
// ("login" or "login:role") into its login and role.
func AuthorizedUserEntry(entry string) (name, role string) {
return dashboardAuthorizedUserEntry(entry)
}

func dashboardAuthorizedUserEntry(entry string) (name, role string) {
entry = strings.TrimSpace(entry)
if idx := strings.LastIndex(entry, ":"); idx >= 0 {
Expand Down
7 changes: 5 additions & 2 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,11 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
stageTrackerApplyMergeTrain(it)
it.Caption, it.Actor = stageTrackerCaption(stage, it.Reason, it.Author, it.Kind, it.Mirrored, rec, hasRec, it.LinkedPR, it.Head)
// Adoption is clanker-only (a human's PR is never adopted), so a
// human-authored 072 row keeps its plain caption.
if stage == stagelabels.ReturnedToContributor && it.Kind == "pr" && it.AuthorKind != authorKindHuman {
// human-authored 072 row keeps its plain caption. The one exception
// is a person's PR the engine was asked to adopt and refused
// (hivecommons/hive#15202): that row says "not adopted" wherever it sits.
personRefused := hasRec && it.Kind == "pr" && rec.AdoptionBlocked(it.Head) == stagelabels.AdoptBlockedAuthorPerson
if personRefused || (stage == stagelabels.ReturnedToContributor && it.Kind == "pr" && it.AuthorKind != authorKindHuman) {
if it.Adoption = stageTrackerAdoption(*it, rec, hasRec, presence, maintainerPolicy, now); it.Adoption != nil {
it.Caption = stageTrackerAdoptionCaption(it.Caption, it.Adoption)
}
Expand Down
19 changes: 18 additions & 1 deletion src/pkg/dashboard/stage_tracker_adoption.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -101,7 +101,21 @@
// when the row was never nudged at its current head (nothing to adopt
// yet) or is already adopted.
func stageTrackerAdoption(it StageTrackerItem, rec stagelabels.Record, hasRec bool, presence func(login string) (automerge.ContributorPresence, bool), policy string, now time.Time) *StageTrackerAdoption {
if it.Kind != "pr" || !hasRec || rec.NudgeCount == 0 || rec.NudgeStart().IsZero() {
if it.Kind != "pr" || !hasRec {
return nil
}
if rec.AdoptionBlocked(it.Head) == stagelabels.AdoptBlockedAuthorPerson {
// A person's PR was asked to be adopted and refused: say so on the
// row even though no nudge clock ever ran (hivecommons/hive#15202).
out := &StageTrackerAdoption{Author: it.Author, Policy: policy, Due: true, BlockedBy: stagelabels.AdoptBlockedAuthorPerson}
if !rec.AdoptBlockedAt.IsZero() {
since := rec.AdoptBlockedAt
out.Since = &since
}
out.Text = stageTrackerAdoptionText(it.Author, *out, now)
return out
}
if rec.NudgeCount == 0 || rec.NudgeStart().IsZero() {
return nil
}
if it.Head != "" && rec.NudgeHead != "" && rec.NudgeHead != it.Head {
Expand Down Expand Up @@ -148,6 +162,9 @@
if author != "" {
who = "@" + author
}
if a.BlockedBy == stagelabels.AdoptBlockedAuthorPerson {
return who + " pushed this PR themselves β€” not adopted: the hive asks them, not adopts"
}
var facts []string
if a.AuthorMaintainer {
facts = append(facts, "maintainer")
Expand Down
38 changes: 38 additions & 0 deletions src/pkg/dashboard/stage_tracker_adoption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,41 @@ func TestStageTrackerAdoptionEndpointShape(t *testing.T) {
t.Fatalf("endpoint body lacks adoption: %s", rr.Body.String())
}
}

// hivecommons/hive#15202: an owner's / author-human PR the engine refused to
// adopt says so on its row, with no Adopt offer and no nudge clock needed.
func TestStageTrackerAdoptionPersonAuthoredSaysNotAdopted(t *testing.T) {
now := time.Date(2026, 10, 28, 20, 30, 0, 0, time.UTC)
s := newTestServer()
store := stagelabels.NewStore("", func() time.Time { return now })
s.stageStore = store
s.deps = &Dependencies{Config: &config.Config{}}
key := stagelabels.Key("hivecommons/hive", 15157)
store.Observe(key, stagelabels.NeedsDecision, "contributor-lane:decision-requested")
store.NoteAdoptionBlocked(key, "cafe", stagelabels.AdoptBlockedAuthorPerson, now.Add(-2*time.Minute))
status := minimalPayload()
status.HiveID = "hive"
status.Repos = []FrontendRepo{{
Name: "hive", Full: "hivecommons/hive",
OpenPrs: []any{FrontendPR{PullRequest: github.PullRequest{Number: 15157, Title: "Owner change", Author: "clubanderson", HeadSHA: "cafe", Labels: []string{"stage/085-needs-decision", "author/human", "role/trusted"}}}},
}}
s.UpdateStatus(status)
it := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 15157)
a := it.Adoption
if a == nil || !a.Due || a.BlockedBy != stagelabels.AdoptBlockedAuthorPerson || a.Action != "" {
t.Fatalf("adoption = %+v", a)
}
if a.Text != "@clubanderson pushed this PR themselves β€” not adopted: the hive asks them, not adopts" {
t.Fatalf("text = %q", a.Text)
}
if !strings.Contains(it.Caption, "not adopted") {
t.Fatalf("caption = %q", it.Caption)
}
if d := it.DecisionNeeded; d != nil {
for _, o := range d.Options {
if o.Action == decisionActionAdopt {
t.Fatalf("adopt offered on a person's PR: %+v", d)
}
}
}
}
1 change: 1 addition & 0 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17394,6 +17394,7 @@ <h2 class="config-title" id="activity-monitor-labels-title">All labels</h2>
"reporter-trust": {"kind": "rule", "plain": "the hold on an unknown reporter is cleared because the fix is sound", "detail": "The PR was held until the reporter's trust was known; its fix is green and mergeable, so the hold is cleared."},
"request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."},
"requires_human": {"kind": "reason", "plain": "marked needs-human; a person must remove the label", "detail": "The item is marked needs-human: automated fixes ran out or a person flagged it. The hive waits until the label is removed."},
"return-to-author": {"kind": "rule", "plain": "a person pushed this PR; the hive asked them, not adopted it", "detail": "The PR was pushed by a person (author/human or one of this hive's owners), so the hive never adopts it. It told the author by name what to fix (rebase, sign-off, CI) and relayed the reviewer's question."},
"review-backlog": {"kind": "rule", "plain": "the PR closed without merging, so the issue stays open", "detail": "The fixing PR closed unmerged; the issue stays open and is re-triaged rather than auto-closed."},
"reviewer-verdict:request_changes": {"kind": "reason", "plain": "a reviewer asked for changes; a new commit is needed", "detail": "A reviewer asked for changes on this branch. Approving cannot override that: only a new commit, or a maintainer merging by hand, moves it."},
"self-decision-read-as-changes": {"kind": "reason", "plain": "hive's own decision comment was read as a reviewer asking for changes", "detail": "The merge gate read the hive's own `/hive decision` comment as a reviewer asking for changes, so the decision blocked the PR it meant to advance (hivecommons/hive#14822). A new commit or a maintainer merge clears it."},
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/delegatedecision/decision_glossary.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ var glossary = []GlossaryEntry{
Detail: "An older issue already tracks the same work; one thread keeps it moving."},
{Slug: "fix-then-merge", Kind: GlossaryRule, Plain: "the branch isn't mergeable yet",
Detail: "The branch cannot merge as it is (conflicts, red CI or a missing sign-off); the hive told the author agent exactly what to fix."},
{Slug: RuleReturnToAuthor, Kind: GlossaryRule, Plain: "a person pushed this PR; the hive asked them, not adopted it",
Detail: "The PR was pushed by a person (author/human or one of this hive's owners), so the hive never adopts it. It told the author by name what to fix (rebase, sign-off, CI) and relayed the reviewer's question."},
{Slug: "owner-only", Kind: GlossaryRule, Plain: "only the hive owner can do this",
Detail: "This needs a secret, token or organization permission that only the hive owner holds; the hive cannot do it for you.", Aliases: []string{"owner_only"}},
{Slug: "prefer-contributor", Kind: GlossaryRule, Plain: "a contributor's PR and a hive PR do the same work",
Expand Down
1 change: 1 addition & 0 deletions src/pkg/delegatedecision/decision_glossary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestGlossaryCoversEveryRuleSlug(t *testing.T) {
regexp.MustCompile(`\b(?:recommendOnly|approveIssue|releasePR)\("([a-z0-9-]+)"`),
regexp.MustCompile(`\bruleDefault[A-Za-z]+\s*=\s*"([a-z0-9-]+)"`),
regexp.MustCompile(`\bRuleLLM\s*=\s*"([a-z0-9-]+)"`),
regexp.MustCompile(`\bRuleReturnToAuthor\s*=\s*"([a-z0-9-]+)"`),
}
found := map[string]bool{}
for _, file := range []string{"policy.go", "llm.go"} {
Expand Down
Loading
Loading