Skip to content

✨ Hive re-authors its own fixer-exhausted PRs; re-author pill becomes adopt - #16583

Merged
hivecommons-hive[bot] merged 4 commits into
v5from
feat/hive-auto-reauthor
Nov 4, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
v5from
feat/hive-auto-reauthor

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #16582

Engine

  • automerge_hive_reauthor.go: on fixer-exhausted for a hive-authored PR (and adoption enabled), the hive re-authors itself: marker on the issue (hive/re-authored), writeback-gated close note, hive/superseded, PATCH close. Store records Reauthor* on the old PR; ReauthoredFor(repo, issue) bounds it to one automatic re-author per issue — a second exhaustion parks at 085 with Give direction / Hand it to a person / Close as not planned (no re-author option; FixerExhaustedRoute names the earlier re-author).
  • stageengine: PRPassFacts.Reauthoring keeps the old PR on 070 re-authoring:<issue> instead of parking.
  • scheduler kick hint for issues labelled hive/re-authored: open a FRESH PR from the current base, write Supersedes #<old PR>.

Dashboard

  • decide:re-author removed from server options and UI (labels, confirm, acting caption, consequences). Contributor-PR rewrites are decide:adopt → "Adopt as hive PR" (DCO-unsigned 090 card; exhausted contributor PR). The API still accepts decision=re-author as an alias of adopt for compatibility; historical re-author ledger entries read "Re-author (now: adopt)" and map to adopt.
  • stage_tracker_reauthor.go post-pass: issue row with a re-author record and no fresh PR → PR-in-progress lane, Re-authoring · superseding #N, remediation {actor: hive, kind: kick, source: re-author} (24h window); fresh hive PR closing that issue → lineage {kind: "re-authored", from_number} → chip "re-authored from #N" (never "adopted from").
  • A server decide:adopt option is now actionable as a lead (it was filtered as a nudge-only generic action).

Tests

Go: first-exhaustion auto re-author vs second-exhaustion park, marker-label-alone blocks, stageengine stays-on-fixing, route vocabulary, tracker post-pass (issue caption / successor lineage / non-successors / stale window), decision cards (no re-author on hive PR, adopt on clanker PR, DCO card). Node: lineage text/clause/tip for re-authored, lead pill on the #16456-shaped row has no re-author, adopt wiring.

go test ./pkg/dashboard/ ./pkg/github/automerge/ ./pkg/stagelabels/ ./pkg/stageengine/... ./pkg/scheduler/ green; make dashboard-gen-check clean.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 4, 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 hanthor 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 Nov 4, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • coverage

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.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Intent-alignment review (read at head b5d7f13e; the dispatch asked for d75c30e9, which this branch has moved past).

The engine/tracker/vocabulary work matches #16582 well: first exhaustion of a hive PR auto re-authors (automerge_stage_labels.go 085 branch → reauthorExhaustedHivePR), ReauthoredFor + hive/re-authored bound it to one per issue, decide:re-author is gone from options/UI while the server alias (api_repo_item_decision.go:16-31, pre-existing) keeps old ledger entries working, and the kick hint / lineage chip land as described.

One in-scope gap, same class as the issue's own complaint ("pressing the pill is a dead end"):

"Give direction" on a fixer-exhausted hive PR promises a fixer run the dispatcher refuses.

  • src/pkg/dashboard/stage_tracker_decision_pr.go:278-279 — new lead consequence: "Tell the hive what to change; its next attempt starts from your words instead of the reviewer's."
  • src/pkg/stagelabels/human.go:815 — new 085 route action: "the hive's fixer gets one more run with your note."
  • But at head src/pkg/review/dispatch.go:710-724 routes a HumanChangeRequest (incl. /hive decision, source decision at :1836) straight into dispatchFix, and dispatch.go:1596-1601 short-circuits with FixDispatchExcludedAttemptsExhausted once attempts >= escalation.MaxReEngagements — the very condition that parked the PR. Nothing in this PR resets attempts on direction. The pill queues a comment and the PR stays at 085.

The old text on this route ("Hands the PR to a person … the hive steps back", removed at stage_tracker_decision_pr.go:289-290) was at least honest. Two routes; I'd take the first as the smallest in-scope fix, the second if you want the pill to do what the issue's option list implies:

  1. Reword to what actually happens:
	lead.Consequence = "Hands the PR to a person: say who takes it or what to change; the hive's fixer budget for this PR is spent, so it steps back until a human pushes."

and in human.go:

			"**Give direction** — reply `/hive decision <what to change>` (or *Give direction* in the tracker) to say who takes it or what to change; the hive's fixer budget for this PR is spent, so it steps back while a human owns it.",
  1. Or make direction re-arm one run: in dispatchFix, skip the attempts >= escalation.MaxReEngagements exclusion when pr.HumanChangeRequest != nil && SameHeadSHA(...) (and cover it in human_change_request_test.go, where "expired at cap" currently asserts the exclusion).

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness review @ d75c30e (read the diff plus automerge_stage_labels.go, automerge_stage_human.go, stagelabels/store.go, stageengine/derive_pr_classify.go, stage_tracker_reauthor.go at head).

1. Reauthor* lives on the closed PR's record, and the engine forgets closed PRs' records

MarkReauthored writes to the old PR's key (automerge_stage_labels.go:1172-1177). But once that PR is closed, the next observation of it is Terminal (derive_pr_classify.go:366 case "closed", "gone" → Terminal: true; automerge_contributor_lane.go:514 returns "closed" for a PR whose state is not open), and the Terminal branch does store.Forget(key) (automerge_stage_labels.go:1075-1076) — "drops key (closed/merged item)" (store.go:2234). After that:

  • stageTrackerReauthorIndex (stage_tracker_reauthor.go:46-69) finds no record → no Re-authoring · superseding #N caption on the issue row and no re-authored from #N lineage on the fresh PR. Contract item 3 of ✨ Hive re-authors its own fixer-exhausted PRs automatically; re-author pill becomes adopt #16582 then only holds in the unit tests, which seed the store directly.
  • ReauthoredFor (store.go:2041-2061) returns 0, so the second-exhaustion route is reached only through the hive/re-authored label fallback (PriorPR = -1), and FixerExhaustedRoute(..., max(-1,0)) never produces the "already the hive's re-author of #N" reason the PR body and TestFixerExhaustedHivePRReauthorsItselfOnce promise.
    The once-per-issue bound itself survives via the issue label, so this is a lost-evidence defect, not a double-re-author. Suggested fix (smallest): keep a re-authored record through the terminal observation; Prune (14d, automerge_stage_labels.go:227) still reaps it well after the 24h tracker window:
		if verdict.Terminal {
			if !(hadPrev && prevRec.Reauthored()) {
				// A re-authored record is the fresh PR's lineage and the
				// tracker's "Re-authoring" evidence; Prune reaps it later.
				store.Forget(key)
			}
			c.resolveNudge(ctx, prevRec, hadPrev, obs)

(Alternatively record the re-author on the issue key stagelabels.Key(repo, issue), which the issue sweep keeps alive — larger change.) Please add a test that observes the closed PR after the re-author and asserts ReauthoredFor/the tracker index still see it.

2. Marker label is written before the write-back gate

reauthorExhaustedHivePR calls Issues.AddLabelsToIssue(..., LabelReauthored) (automerge_hive_reauthor.go:106) before c.writebackAllowed(...) (line 114). Both existing supersession-close paths check the gate before any write (automerge_stage_human.go:332-336, 679). When the gate withholds, the function returns nil, so the pass records reauthored (automerge_stage_labels.go:1151-1153): the PR stays open at 070 re-authoring:N, the tracker shows "Re-authoring" motion, the issue stays claimed so no kick happens, and the issue already carries the durable once-per-issue marker although no re-author occurred. The // writeback:gated annotation on line 106 is not true for that call.

 	rec, _ := store.Get(key)
 	noted = rec.ReauthorNoted
+	body := reauthorCloseComment(obs, issue, fixer.Attempts)
+	item := writebackItemForObservation(obs)
+	item.HiveAuthored = true
+	if d := c.writebackAllowed(obs.Display, item, writeback.KindSupersessionClose, body); !d.Allowed {
+		c.info("stage labels: re-author close withheld by the write-back gate", append(logArgs, "writeback_reason", d.Reason)...)
+		return 0, noted, nil
+	}
 	if !rec.Reauthored() {
 		if _, _, err := c.gh.Issues.AddLabelsToIssue(ctx, obs.Owner, obs.Repo, issue, []string{stagelabels.LabelReauthored}); err != nil { // writeback:gated
 			...
 		}
 	}
-	body := reauthorCloseComment(obs, issue, fixer.Attempts)
-	item := writebackItemForObservation(obs)
-	item.HiveAuthored = true
-	if d := c.writebackAllowed(obs.Display, item, writeback.KindSupersessionClose, body); !d.Allowed {
-		c.info(...)
-		return 0, noted, nil
-	}

The caller should also treat a withheld gate as "not re-authored" (leave reauthored zero so the PR falls through to the 085 park, or at least does not read re-authoring:N).

Minor (no action needed): autoReauthorTarget does an Issues.Get every pass before the prev.Reauthored() override at automerge_stage_labels.go:1140-1142 — one avoidable API call per retry pass.

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

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

Evidence bundle `#1658334fe582` sha256:ca8725d1af2e6014124273a6570276db2428f076eb9190836835f95effef8b10 — download from the dashboard or `hivectl review evidence #16583`.

@github-actions

github-actions Bot commented Nov 4, 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
#16585 🐛 fix(dashboard): match viewer handle on a word boundary in sign-off questions same files src/pkg/dashboard/static-src/js/tracker-row-strip.js
src/pkg/dashboard/static/index.html
#16500 ✨ feat(dashboard): replace Matrix presentation with Code activity same files src/pkg/dashboard/static/index.html
#16514 ✨ feat(dashboard): replace Matrix presentation with Code activity same files src/pkg/dashboard/static/index.html

… adopt

Fixes #16582

Engine: a hive-authored PR whose fixer is exhausted is closed as
superseded (note, hive/superseded), the issue is labelled
hive/re-authored and requeued; the kick asks for a fresh PR with
'Supersedes #<old>'. One automatic re-author per issue (store record +
issue label); a second exhaustion parks at 085 with direction / hand to
a person / close as not planned.

Dashboard: decide:re-author removed; DCO/exhausted contributor PRs offer
decide:adopt 'Adopt as hive PR'. Issue row reads 'Re-authoring ·
superseding #N' (remediation kick) until the fresh hive PR is listed,
which carries lineage re-authored → 're-authored from #N'.

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

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

Every red check on this PR has a single cause: the merge with v5 no longer compiles. The branch itself is fine; it is behind v5.

v5 (currently 3536590) gained src/pkg/dashboard/stage_tracker_signoff_lead_test.go (165 lines) after this branch forked, and that file still uses the symbols this PR deletes:

  • stage_tracker_signoff_lead_test.go:101 → decisionLeadWithReauthor(...)
  • stage_tracker_signoff_lead_test.go:103 → decisionActionReauthor

This PR removes both from src/pkg/dashboard/stage_tracker_decision_pr.go (the decisionLeadWithReauthor func, the decisionActionReauthor constant and its case), which is consistent with the stated intent of retiring decide:re-author. The test file is absent from the PR head (d75c30e), so nothing on the branch shows the breakage — only the merge commit does. build-go, golangci-lint, coverage and all test (dashboard …) shards fail on exactly these two undefined: lines (checked job logs for build-go, golangci-lint and dashboard 1/4).

Fix: rebase onto v5, then update the subtest "an existing lead (Re-author) stands" (lines ~99–105). A plain rename is not enough, since the re-author lead no longer exists; the equivalent on this branch is the adopt lead (decisionActionAdopt, built at stage_tracker_decision_pr.go:238 in decisionLeadFixerExhausted), so the subtest should either assert that an existing adopt lead survives stageTrackerLeadApproveForSignOff, or be dropped if that case is already covered in stage_tracker_lead_action_test.go.

I did not review the remaining 28 files in depth; once CI compiles this is worth a second pass on automerge_hive_reauthor.go (one-re-author-per-issue bound and the PATCH-close path).

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

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

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

Security perspective (read at head d75c30e).

One in-scope issue: the new hive/re-authored marker write bypasses the write-back gate.

src/pkg/github/automerge/automerge_hive_reauthor.go:109 calls Issues.AddLabelsToIssue(... issue, LabelReauthored) (annotated // writeback:gated) before the only gate check in the function at :118 (c.writebackAllowed(..., KindSupersessionClose, ...)). The gate refuses every kind — own items included — on an operator-paused repo and on per_repo.mode: off / issues-only (src/pkg/writeback/gate.go:75-79, :423-437), and the package convention is "the one call an unsolicited write makes before touching GitHub" (automerge_writeback.go:27-33; cf. automerge_adoption_close_first.go:162-170, where the gate precedes the note/label/close). Here a paused/off repo still gets a label written on a third-party issue, and because :120 returns err == nil, automerge_stage_labels.go:1149-1150 records the PR as re-authored and the issue carries the marker that drives the scheduler kick hint (kickmessage.go) while the old PR remains open. The writeback:gated annotation also hides the call from the writeback ratchet (src/pkg/writeback/ratchet_test.go:91), so this would not be caught later.

Fix: move the gate decision above the marker write so no GitHub write happens on a refused repo:

--- a/src/pkg/github/automerge/automerge_hive_reauthor.go
+++ b/src/pkg/github/automerge/automerge_hive_reauthor.go
@@ func (c *Engine) reauthorExhaustedHivePR(
 	rec, _ := store.Get(key)
 	noted = rec.ReauthorNoted
+	body := reauthorCloseComment(obs, issue, fixer.Attempts)
+	item := writebackItemForObservation(obs)
+	item.HiveAuthored = true
+	if d := c.writebackAllowed(obs.Display, item, writeback.KindSupersessionClose, body); !d.Allowed {
+		c.info("stage labels: re-author withheld by the write-back gate", append(logArgs, "writeback_reason", d.Reason)...)
+		return 0, noted, nil
+	}
 	if !rec.Reauthored() {
 		if _, _, err := c.gh.Issues.AddLabelsToIssue(ctx, obs.Owner, obs.Repo, issue, []string{stagelabels.LabelReauthored}); err != nil { // writeback:gated
 			c.warn("stage labels: re-author marker label failed; parking the exhausted PR for a person", append(logArgs, "error", err)...)
 			return 0, false, err
 		}
 		c.info("stage labels: hive PR's fixer exhausted; re-authoring it for the issue from the current base", logArgs...)
 	}
-	body := reauthorCloseComment(obs, issue, fixer.Attempts)
-	item := writebackItemForObservation(obs)
-	item.HiveAuthored = true
-	if d := c.writebackAllowed(obs.Display, item, writeback.KindSupersessionClose, body); !d.Allowed {
-		c.info("stage labels: re-author close withheld by the write-back gate", append(logArgs, "writeback_reason", d.Reason)...)
-		return 0, noted, nil
-	}
 	if !noted {

With the gate first, a refused pass leaves no record and no marker, and the caller's else branch is not reached either — consider also having the caller fall through to the 085 park when the gate refuses (return a withheld flag), so the row does not read "Re-authoring" on a repo where the hive is deliberately quiet. A test with a paused repo asserting zero AddLabelsToIssue calls would pin this.

No other security-relevant concerns: closing-issue number comes from the hive's own PR body (ClosingIssueRefs, maintainer-editable only), the close is scoped to hiveOwnPR (App login / authorkind.Hive), and the decision=re-author alias maps to the same adopt path, widening no permission.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 0eac38d into v5 Nov 4, 2026
83 of 84 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/hive-auto-reauthor branch November 4, 2026 13:05
@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 34fe582.

@github-actions

github-actions Bot commented Nov 4, 2026

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

clubanderson added a commit that referenced this pull request Nov 4, 2026
…up to 5e0e398)

Conflicts resolved (v5 wins unless v6 intentionally diverged):
- src/pkg/config/config.go: v6 split the file; v5 GovernorConfig.Review + GovernorReviewConfig ported to governor_config.go
- src/pkg/config/dashboard_matrix.go: v5 comment wording kept, v6 DashboardMatrixConfig name kept (v6 already has a notifications MatrixConfig); dashboard_config.go comment updated to match
- src/pkg/dashboard/server.go: v6 RUnlock-before-build kept, v5 ReviewQuestionsAutodecided1h added to /api/status payload
- src/pkg/github/issue_unpark_command.go: v6 owner-step menu kept, v5 held-after-decision (#16591) gate added with v6 ensureUnparkNoticeComment signature
- src/pkg/scheduler/kickmessage.go: both hints kept (v6 upstream-sync label, v5 re-authoring #16583)
- static-src/css/overview.css + static/index.html: v5 #16601 phone KPI fix taken, with v6's 7-tile grid (repeat(7…), 1799px breakpoint) retained
- static-src/js/tracker-row-render.js + static/index.html: v6 finisher fields kept, v5 unauthorized_step added
- src/docs/maintainer-commands.md: v6 PR-approval wording kept, v5 #16579 approved-direction text spliced into /hive decision row
- src/docs/api-reference/*: ours + v5 purpose text; citations re-anchored by check-docs-citations.py --fix
- src/docs/scale-envelope.md: RankActionableIssues range re-anchored manually (5314-5324)

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

✨ Hive re-authors its own fixer-exhausted PRs automatically; re-author pill becomes adopt

1 participant