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/added-16582-hive-auto-reauthor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The hive re-authors its own fixer-exhausted PRs by itself instead of parking them for a person ([#16582](https://github.com/hivecommons/hive/issues/16582)): the exhausted hive PR is closed as superseded with a note, the issue is labelled `hive/re-authored` and requeued so the next kick opens a fresh PR from the current base (the kick asks for `Supersedes #<old>`). One automatic re-author per issue; a second exhaustion parks at 085 with Give direction / Hand it to a person / Close as not planned. The Activity Monitor words the issue `Re-authoring · superseding #N` (remediation evidence `kick`) and the fresh PR's chip `re-authored from #N`. `decide:re-author` is gone from the decision vocabulary: a person's rewrite of a contributor PR (unsigned DCO, exhausted) is `decide:adopt` — "Adopt as hive PR"; historical `re-author` ledger entries still read.
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
stageTrackerApplyRemediation(&activityItem, dispatchState, status, stageTrackerFixerAgent(cfg), now)
it.CodeActivity, it.Remediation, it.ReviewActivity, it.DisplayColumn, it.Caption = activityItem.CodeActivity, activityItem.Remediation, activityItem.ReviewActivity, activityItem.DisplayColumn, activityItem.Caption
}
stageTrackerApplyReauthor(resp.Items, store, status.GitHubBaseURL, now)
resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items)
resp.WaitingOnHuman = stageTrackerWaitingOnHuman(resp.Items)
resp.IntegrationQueues = s.stageTrackerNativeQueues(now)
Expand Down
1 change: 0 additions & 1 deletion src/pkg/dashboard/stage_tracker_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const (
decisionActionCloseWontfix = "decide:close-wontfix"
decisionActionMergeNow = "decide:merge-now"
decisionActionQueueMerge = "decide:queue-merge"
decisionActionReauthor = "decide:re-author"
decisionActionAcceptTriage = "accept-triage"
decisionActionHold = "hold"
decisionActionRelease = "release"
Expand Down
14 changes: 7 additions & 7 deletions src/pkg/dashboard/stage_tracker_decision_human_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func decisionForHumanMerge(it StageTrackerItem, held bool) *StageTrackerDecision
delegate := decisionDelegateOption(held, "Hive explains and recommends; merges nothing")
d.Options = decisionHumanMergeLeadOptions(mergeNow, queue)
if it.DCOUnsigned > 0 {
d.Options = append(d.Options, decisionReauthorOption(it, ref, held))
d.Options = append(d.Options, decisionAdoptSignedOption(it, ref, held))
}
d.Options = append(d.Options, delegate, direction, closeSup, closeWontfix, decisionHoldOption(held))
return d
Expand Down Expand Up @@ -182,7 +182,7 @@ func decisionDCOBlocker(it StageTrackerItem) string {
if it.DCOUnsigned <= 0 {
return ""
}
return fmt.Sprintf("%d of %s no Signed-off-by, so a required DCO check refuses the merge. Re-author as hive PR is the separate choice for that; an Approve never re-authors by itself.",
return fmt.Sprintf("%d of %s no Signed-off-by, so a required DCO check refuses the merge. Adopt as hive PR is the separate choice for that; an Approve never re-authors by itself.",
it.DCOUnsigned, pluralCommitsHave(it.DCOTotal))
}

Expand All @@ -203,19 +203,19 @@ func pluralCommitsHave(total int) string {
return "its commits have"
}

// decisionReauthorOption is the operator's explicit "re-author as hive PR"
// decisionAdoptSignedOption is the operator's explicit "adopt as hive PR"
// choice (hivecommons/hive#15136): the hive re-homes the commits on a
// hive-owned, signed-off branch and opens a superseding PR. A person's PR
// is never re-authored by the hive, so for a human author the option is
// is never adopted by the hive, so for a human author the option is
// shown disabled with the step that does unblock it.
func decisionReauthorOption(it StageTrackerItem, ref string, held bool) StageTrackerDecisionOption {
o := decisionOption(decisionActionReauthor, "Re-author as hive PR", !held && it.AuthorKind != authorKindHuman, "Release the hold first")
func decisionAdoptSignedOption(it StageTrackerItem, ref string, held bool) StageTrackerDecisionOption {
o := decisionOption(decisionActionAdopt, "Adopt as hive PR", !held && it.AuthorKind != authorKindHuman, "Release the hold first")
if it.AuthorKind == authorKindHuman {
who := "the author"
if it.Author != "" {
who = "@" + it.Author
}
o.ReasonIfDisabled = "Hive does not re-author a person's PR; ask " + who + " to sign off and push"
o.ReasonIfDisabled = "Hive does not adopt a person's PR; ask " + who + " to sign off and push"
}
o.Consequence = "Hive reopens " + ref + " as a signed-off hive PR; nothing is merged as-is"
return o
Expand Down
30 changes: 17 additions & 13 deletions src/pkg/dashboard/stage_tracker_decision_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel
if finding := decisionFixerExhaustedFinding(it, verdict); finding != "" {
d.Question += ": " + finding
}
d.Question += ". Re-author it from scratch, hand it to a person, or close it as not planned?"
d.Question += ". Give direction, hand it to a person, or close it as not planned?"
case verdict != nil && decisionFirstNonEmpty(verdict.HumanSummaries) != "":
d.AskedBy = decisionAskedByReviewer
d.Question = "A reviewer handed this to a person: " + decisionFirstNonEmpty(verdict.HumanSummaries)
Expand Down Expand Up @@ -190,7 +190,7 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel
d.Options = slices.Insert(d.Options, 0, decisionOption(decisionActionAdopt, rebasemerge.OptionAdoptFreshLabel, true, ""))
}
if fixerExhausted {
d.Options = decisionLeadWithReauthor(d.Options)
d.Options = decisionLeadFixerExhausted(d.Options, it)
}
if selfHold != nil {
// Release leads: it is the one action that answers the question.
Expand Down Expand Up @@ -269,25 +269,29 @@ func decisionLeadWithCloseSuperseded(opts []StageTrackerDecisionOption, redundan
return out
}

// decisionLeadWithReauthor puts "Re-author" at the front of opts (the lead
// action for a fixer-exhausted PR, hivecommons/hive#15744) and relabels the
// won't-fix close as "Close as not planned" so it stays in the Decide…
// submenu rather than leading a destructive answer.
func decisionLeadWithReauthor(opts []StageTrackerDecisionOption) []StageTrackerDecisionOption {
lead := decisionOption(decisionActionReauthor, "Re-author", true, "")
lead.Consequence = "The hive opens a fresh PR for the same issue from the current base and closes this one as superseded."
// decisionLeadFixerExhausted shapes the options for a fixer-exhausted PR.
// The hive re-authors its own exhausted PR by itself (once per issue; see
// automerge's reauthorExhaustedHivePR), so no "re-author" answer is
// offered here: a person gives direction (the lead), hands it to someone,
// or closes it as not planned. A contributor's PR may instead be adopted.
func decisionLeadFixerExhausted(opts []StageTrackerDecisionOption, it StageTrackerItem) []StageTrackerDecisionOption {
lead := decisionOption(decisionActionDirection, "Give direction", true, "")
lead.Consequence = "Tell the hive what to change; its next attempt starts from your words instead of the reviewer's."
lead.Lead = true
out := make([]StageTrackerDecisionOption, 0, len(opts)+1)
out := make([]StageTrackerDecisionOption, 0, len(opts)+2)
out = append(out, lead)
if it.AuthorKind != authorKindHive && it.AuthorKind != authorKindHuman {
adopt := decisionOption(decisionActionAdopt, "Adopt as hive PR", true, "")
adopt.Consequence = "The hive opens a fresh PR for the same issue from the current base and closes this one as superseded."
out = append(out, adopt)
}
for _, o := range opts {
switch o.Action {
case decisionActionReauthor:
case decisionActionDirection, decisionActionAdopt:
continue
case decisionActionCloseWontfix:
o.Label = "Close as not planned"
o.Consequence = "Closes this PR as not planned; the issue stays open for someone else."
case decisionActionDirection:
o.Consequence = "Hands the PR to a person: say who takes it or what to change; the hive steps back."
}
out = append(out, o)
}
Expand Down
16 changes: 8 additions & 8 deletions src/pkg/dashboard/stage_tracker_decision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,33 +372,33 @@ func TestStageTrackerDecisionForHumanMerge(t *testing.T) {
// presses Approve and offers re-authoring as its own choice; once a
// person approved, the row says who admitted the head and the second
// Approve is no longer offered.
t.Run("unsigned commits warn before acting and offer re-author", func(t *testing.T) {
t.Run("unsigned commits warn before acting and offer adopt", func(t *testing.T) {
agent := it
agent.Author, agent.AuthorKind, agent.DCOUnsigned, agent.DCOTotal = "hive[bot]", "hive", 2, 3
d := stageTrackerDecisionNeeded(agent, nil, "")
if !strings.Contains(d.Detail, "2 of 3 commits have no Signed-off-by") || !strings.Contains(d.Detail, "Re-author as hive PR is the separate choice") {
if !strings.Contains(d.Detail, "2 of 3 commits have no Signed-off-by") || !strings.Contains(d.Detail, "Adopt as hive PR is the separate choice") {
t.Fatalf("details lack the DCO warning: %q", d.Detail)
}
if got := []string{d.Options[0].Action, d.Options[1].Action, d.Options[2].Action}; got[2] != decisionActionReauthor || got[0] != decisionActionQueueMerge || got[1] != decisionActionMergeNow {
t.Fatalf("options = %v, want queue-merge, merge-now, re-author", got)
if got := []string{d.Options[0].Action, d.Options[1].Action, d.Options[2].Action}; got[2] != decisionActionAdopt || got[0] != decisionActionQueueMerge || got[1] != decisionActionMergeNow {
t.Fatalf("options = %v, want queue-merge, merge-now, adopt", got)
}
for _, a := range []string{decisionActionMergeNow, decisionActionQueueMerge} {
if o := decisionOptionByAction(t, d, a); !o.Enabled || !strings.Contains(o.Consequence, "no Signed-off-by") {
t.Errorf("%s must stay available with the DCO caveat: %+v", a, o)
}
}
re := d.Options[2]
if !re.Enabled || re.Label != "Re-author as hive PR" || !strings.Contains(re.Consequence, "nothing is merged as-is") {
if !re.Enabled || re.Label != "Adopt as hive PR" || !strings.Contains(re.Consequence, "nothing is merged as-is") {
t.Fatalf("re-author = %+v", re)
}
human := it
human.DCOUnsigned, human.DCOTotal = 1, 1
d = stageTrackerDecisionNeeded(human, nil, "")
if o := decisionOptionByAction(t, d, decisionActionReauthor); o.Enabled || !strings.Contains(o.ReasonIfDisabled, "@Karibhou to sign off") {
if o := decisionOptionByAction(t, d, decisionActionAdopt); o.Enabled || !strings.Contains(o.ReasonIfDisabled, "@Karibhou to sign off") {
t.Fatalf("re-author on a person's PR = %+v", o)
}
if d := stageTrackerDecisionNeeded(it, nil, ""); decisionHasAction(d, decisionActionReauthor) {
t.Fatalf("re-author offered without unsigned commits: %+v", d.Options)
if d := stageTrackerDecisionNeeded(it, nil, ""); decisionHasAction(d, decisionActionAdopt) {
t.Fatalf("adopt offered without unsigned commits: %+v", d.Options)
}
})

Expand Down
24 changes: 18 additions & 6 deletions src/pkg/dashboard/stage_tracker_fixer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,44 @@ func TestStageTrackerFixerExhaustedCaption(t *testing.T) {
}
}

func TestDecisionForPRFixerExhaustedLeadsWithReauthor(t *testing.T) {
// The hive re-authors its own exhausted PR by itself, so the 085 card on a
// hive-authored PR never offers "re-author": Give direction leads, close
// reads "not planned". A contributor clanker's PR gets Adopt instead.
func TestDecisionForPRFixerExhaustedNoReauthorOnHivePR(t *testing.T) {
it := StageTrackerItem{
Repo: "hivecommons/hive", Number: 15308, Kind: "pr", Stage: trackerNumberNeedsDecision,
AuthorKind: authorKindHive,
Reason: stagelabels.FixerExhaustedReason(6),
}
d := decisionForPR(it, &review.Aggregate{HumanSummaries: []string{"tests fail on arm64"}}, "", false)
if d == nil || !strings.Contains(d.Question, "6 attempts") || !strings.Contains(d.Question, "tests fail on arm64") {
if d == nil || !strings.Contains(d.Question, "6 attempts") || !strings.Contains(d.Question, "tests fail on arm64") || strings.Contains(d.Question, "Re-author") {
t.Fatalf("decision = %+v", d)
}
if len(d.Options) == 0 || d.Options[0].Action != decisionActionReauthor || !d.Options[0].Lead || !d.Options[0].Enabled {
if len(d.Options) == 0 || d.Options[0].Action != decisionActionDirection || !d.Options[0].Lead || !d.Options[0].Enabled {
t.Fatalf("lead option = %+v", d.Options)
}
var sawClose bool
for i, o := range d.Options {
if o.Action == "decide:re-author" || o.Action == decisionActionAdopt {
t.Fatalf("hive-authored PR offered %q at %d: %+v", o.Action, i, d.Options)
}
if o.Action == decisionActionDirection && i != 0 {
t.Fatalf("duplicate direction option at %d: %+v", i, d.Options)
}
if o.Action == decisionActionCloseWontfix {
sawClose = true
if i == 0 || o.Lead || o.Label != "Close as not planned" {
t.Fatalf("close option = %+v at %d", o, i)
}
}
if o.Action == decisionActionReauthor && i != 0 {
t.Fatalf("duplicate re-author option at %d: %+v", i, d.Options)
}
}
if !sawClose {
t.Fatalf("no close-as-not-planned option: %+v", d.Options)
}
agent := it
agent.AuthorKind, agent.Author = authorKindClanker, "thatguywob"
d = decisionForPR(agent, nil, "", false)
if len(d.Options) < 2 || d.Options[0].Action != decisionActionDirection || d.Options[1].Action != decisionActionAdopt || d.Options[1].Label != "Adopt as hive PR" {
t.Fatalf("contributor options = %+v", d.Options)
}
}
16 changes: 9 additions & 7 deletions src/pkg/dashboard/stage_tracker_lead_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,26 @@ assert.strictEqual(leads[1].target, human, 'delegate carries the decide target')
assert.strictEqual(leads[1].enabled, true);
// The parked issue whose lead already is delegate: one pill, never two.
assert.strictEqual(stageTrackerLeadActionsOnRow(parked, ctx).length, 1);
// A Re-author lead (the #16456 row): both pills, delegate disabled with its
// reason for a reader.
const reauthor = { ...human, number: 16456, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:re-author', label: 'Re-author', enabled: true, lead: true }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
// A Give-direction lead (the #16456 row, a hive-authored PR whose fixer
// gave up — the hive re-authors those itself, so no re-author pill is
// offered): both pills, delegate disabled with its reason for a reader.
const reauthor = { ...human, number: 16456, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:direction', label: 'Give direction', enabled: true, lead: true, consequence: 'Tell the hive what to change; its next attempt starts from your words.' }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
h = stageTrackerLeadActionHtml(reauthor, ctx);
assert.strictEqual(buttons(h), 2, h);
assert.strictEqual(labelOf(h), 'Re-author', h);
assert.strictEqual(labelOf(h), 'Give direction', h);
assert.ok(!h.includes('re-author'), 'no re-author pill on a hive-authored row: ' + h);
assert.ok(h.includes('data-ham-act="decide:delegate"'), h);
// Owner on that row: "Re-author" read as a record of what happened — the
// Owner on that row: the lead read as a record of what happened — the
// action pills and the record pills ("adopted from #N", the base branch)
// wore the same outline. Inline actions are <button>s with the filled
// action class (primary / secondary / danger), never the record class;
// a record pill never carries the action class. The server's
// consequence is the lead's hover text; a lead without one gets the
// client's clause for its verb.
assert.ok(h.includes('<button type="button" class="ham-lead-act ham-act-primary" data-ham-act="decide:re-author" title="The hive opens a fresh PR for the same issue from the current base and closes this one as superseded."'), 'lead: filled primary button with the consequence tooltip: ' + h);
assert.ok(h.includes('<button type="button" class="ham-lead-act ham-act-primary" data-ham-act="decide:direction" title="Tell the hive what to change; its next attempt starts from your words."'), 'lead: filled primary button with the consequence tooltip: ' + h);
assert.ok(!h.includes('ham-badge'), 'action pills never wear the record class: ' + h);
assert.strictEqual((h.match(/<button type="button" class="ham-lead-act ham-act-(primary|secondary)"/g) || []).length, 2, h);
const withConsequence = { ...reauthor, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:re-author', label: 'Re-author', enabled: true, lead: true, consequence: 'Hive opens a fresh PR for the issue and closes this one as superseded' }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
const withConsequence = { ...reauthor, decision_needed: { question: 'Changes requested', options: [{ action: 'decide:direction', label: 'Give direction', enabled: true, lead: true, consequence: 'Hive opens a fresh PR for the issue and closes this one as superseded' }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
assert.ok(stageTrackerLeadActionHtml(withConsequence, ctx).includes('title="Hive opens a fresh PR for the issue and closes this one as superseded"'), 'the server consequence wins');
const closeLead = { ...human, decision_needed: { question: 'Superseded?', options: [{ action: 'decide:close-superseded', label: 'Close as superseded by #9', enabled: true, lead: true }, { action: 'decide:delegate', label: 'Let hive decide', enabled: true }] } };
h = stageTrackerLeadActionHtml(closeLead, ctx);
Expand Down
9 changes: 9 additions & 0 deletions src/pkg/dashboard/stage_tracker_lineage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ assert.ok(stageTrackerLineageChipHtml(orig, nowMs).includes('href="https://githu
assert.strictEqual(stageTrackerLineageClause(orig), '');
assert.strictEqual(stageTrackerLineageText({ lineage: { kind: 'adopted', from_number: 7 } }, nowMs), 'adopted from #7');
assert.ok(stageTrackerLineageTip({ lineage: { kind: 'adopted', from_number: 7, reason: 'operator-asked' } }).includes("maintainer's request"));
// A hive self re-author (fixer exhausted on the hive's own PR): the chip
// says "re-authored from", never "adopted from", and the hover says why.
const reauthored = { kind: 'pr', number: 95, author_kind: 'hive', lineage: { kind: 're-authored', from_number: 90, from_url: 'https://github.com/acme/docs/pull/90', from_author_kind: 'hive', from_state: 'closed', at: '2026-10-29T04:56:00Z', reason: 'fixer-exhausted' } };
assert.strictEqual(stageTrackerLineageText(reauthored, nowMs), 're-authored from #90 · 6h');
assert.strictEqual(stageTrackerLineageClause(reauthored), ' (re-authored from #90)');
const reTip = stageTrackerLineageTip(reauthored);
assert.ok(reTip.includes('fixer gave up on its own #90') && reTip.includes('#90 is closed as superseded.'), reTip);
assert.ok(!reTip.includes('adopt'), reTip);
assert.ok(stageTrackerLineageChipHtml(reauthored, nowMs).includes('href="https://github.com/acme/docs/pull/90"'));
`,
}, "\n")
runStageTrackerRowActionsScript(t, script)
Expand Down
Loading
Loading