Skip to content

πŸ› Activity Monitor: Rebase, then merge as maintainer; fixer owns parked conflicting PRs; dismiss self-inflicted changes_requested - #15104

Merged
hivecommons-hive[bot] merged 10 commits into
v5from
fix/rebase-then-merge
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 10 commits into
v5from
fix/rebase-then-merge

Conversation

@clubanderson

@clubanderson clubanderson commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #15103

Context: #14822 sat 14 h at Needs human decision while v5 moved under it and nobody β€” not the hive, not the operator β€” could get it rebased or merged from the tracker. Builds on #15087 (merge-as-maintainer actions; this branch carries its commits until it merges) and #15063 (no-effect guard).

Why hive never rebased its own PR

classifyMergeEligibility skipped PRs carrying the needs-decision park label before classifying a conflict, and the conflict route only admits hive-authored or adopted PRs β€” #14822 is a fork PR touching .github/workflows/, fenced from adoption, so no lane ever owned the rebase.

What changes

  • Rebase, then merge as maintainer (decision: merge-now on a dirty/behind PR): approval recorded first (/lgtm + /approve in your name), follow-through armed (pkg/rebasemerge, /data/rebase-merge-followups.json), rebase kicked (update-branch for the hive's own PR when merely behind; otherwise the fixer lane), 202 rebase-queued. A 2-minute ticker merges the rebased head when GitHub reports it clean, or settles failed with the conflicting files and the options Adopt into fresh branch / Close as superseded (badge + PR note). Row: Rebasing β†’ merge queued (approved by @you) with the working cue, then the normal merge-gate pills. last_operator_action.followed[] records approval-recorded β†’ rebase-kicked β†’ rebased β†’ ci-green β†’ merged / failed. Offered at 085 (after Approve) and in place of merge-now at 090 when the row wears needs-rebase. A fork without maintainer edits answers a refused result instead of an HTTP error.
  • Fixer router: conflict classified before the needs-decision skip; an armed follow-through routes as pushable (like in-place adoption).
  • Reconcile: on each unpark sweep, a recorded changes_requested whose source is the hive's own /hive decision comment is dismissed with an Info log line (pre-πŸ› Let hive decide: say when a decision never took effect, in plain words, and never block the PR with hive's own decisionΒ #15063 records).
  • Tests: Go (state machine greenβ†’merge / conflictβ†’failed w/ options / approval-first; handler 202; driver + ledger; row view; 085/090 options; reconcile; router), node fixture (relabel, acting caption, toast, cue-working, ledger trail). Docs: dashboard-sections.md, operator-reference.md. Changelog fragment.

Autonomous rebase-resolve (follow-up evidence: #15070/#15074/#15085/#15087 under clubanderson)

Live logs confirmed the wider gap: the self and trusted-author lanes return label:needs-rebase before reaching their update-branch call, and the fixer router listed only hive-authored or adopted PRs as rebase work β€” so no lane ever rebased an owner-authored PR, and nothing anywhere dispatched a fixer to rebase-and-resolve a dirty one.

  • behind: prow's needs-rebase label no longer blocks the self or trusted-author lane when GitHub says mergeable_state: behind; updateBranchAndSkip runs and clears the label.
  • dirty: the fixer router admits a trusted author's PR (auto_merge.trusted_authors enabled, repo allowed, author at the required role, head pushable, no exclude label) as rebase work with reachable_action: push; the kick carries rebase-resolve (attempt n/2): checkout, git rebase origin/<base>, resolve, re-run build/tests, --force-with-lease to the PR's OWN branch; never a new PR.
  • Loop guard (pkg/rebasemerge.Attempts, /data/rebase-attempts.json): counts distinct dirty heads per PR per conflict episode β€” first dirty head = attempt 1, a fixer push still dirty = attempt 2, a third dirty head = exhausted β†’ the router stops listing it (Warn log) and the gate pill reads Rebase failed Β· 2/2 β€” needs a person; while running it reads Rebasing Β· attempt n/2 (spinning). The episode clears when the PR stops conflicting. (Interpreted "max 2 attempts per head" as two fixer rebases per conflict episode, keyed on the head each one produces.)
  • Manual action uses the same task: in the follow-through a rebased head that is still dirty goes back to Rebasing (step still-conflicting, rebase clock restarting) while attempts remain, and settles failed with the conflicting files once exhausted.
  • Tests: Attempts ledger, state-machine retry/exhaustion, router admit/guard/clear + untrusted/tier-off refusals, trusted-author sweep stale-label bypass (behind β†’ update, dirty β†’ fixer), kick text, dashboard pill + driver exhaustion, node pill assertions.

Approve on a dirty/behind PR (live 17:59 evidence on #14822)

The plain Approve on a dirty PR used to answer "/lgtm + /approve posted … The merge gate takes it from here" β€” untrue, the gate skips conflicting forever and the "Approving…" spinner lingered beside the green βœ“.

  • handlePullRequestDecision reads GetPRMergeState after recording the approval; when NeedsRebase() it calls queueRebaseOnApprove: a Request episode in the attempts ledger (requested_by: @you) that the fixer router admits as rebase work on its next pass (push-reachable heads), and update-branch at once for a hive-authored PR that is only behind.
  • The toast now reads "Approved β€” πŸ› fix: preserve owner intent through PR decision pathsΒ #14822 conflicts with v5; hive will rebase it next pass (attempt 1/2)" (or is behind v5; hive is updating the branch), and carries the Rebase, then merge as maintainer button; past the loop guard it says so and offers the same button. The response's rebase field puts the row straight into Rebasing Β· attempt n/2.
  • The row's acting caption clears as soon as an approved decision records (no more waiting for a state change the gate never makes).
  • Tests: TestRepoItemDecisionApproveOnDirtyPRQueuesRebase (dirty foreign β†’ attempt 1/2 + option + episode, no update; hive-authored behind β†’ update-branch + wording; clean β†’ unchanged plain toast); node fixture asserts toast options/outcome, the plain-approve toast has no buttons, item state moves with rebase, and runRowAction clears the spinner on approved.

Honest note on #14822 itself: its live changes_requested on head b0f5f80 is the swarm's real verdict (review-verdicts.json), not the self-inflicted one, so the reconcile leaves it; the operator's click records the approval that answers it.

Review responses (head 1df4584 β†’ this head)

  • Security 🌱 Sync workflows from kubestellar/infraΒ #1 (high) β€” approval bound to head A, head B merges. Fixed, fail-closed as proposed. rebasemerge.Observation.HeadByHive is set by the driver from GHClient.CommitByHive (GET /commits/{sha}: author or committer resolves to the App bot or the pane identity domain β€” the fixer's rebase or update-branch under the App). On a contributor PR a new head that the hive did not commit settles the follow-through as failed / foreign-head: nothing merges, the ledger and a PR note say whose head it is, and the row offers Approve the new head & merge (decide:merge-now, which re-binds the approval to the head as it is now) / Close as superseded. A read error waits for the next tick rather than guessing. Hive-authored PRs keep today's behaviour (the self lane is already trusted to move them). Tests: TestAdvanceForeignHeadFailsClosed, TestDriveRebaseMergeForeignHeadFailsClosed; docs: operator-reference, dashboard-sections, api-reference, changelog fragment.
  • Security docs: add EXECUTOR MODE pattern and multi-agent topologyΒ #2 (medium) / intent-alignment β€” unattended trusted-author rebase + Approve-opens-a-rebase go beyond Activity Monitor: hive never rebased its parked PR; "Approve & merge as maintainer" would 405 on a needs-rebase PRΒ #15103's text. Policy call for @clubanderson, left as-is in this PR: both routes only ever push to a branch the hive can already push to (trusted author at the configured tier, or a push-reachable head on a write-permission Approve), and both are documented in operator-reference / dashboard-sections. If you want them split out, say so and I'll move trustedAuthorRebasePR + staleNeedsRebaseLabel + queueRebaseOnApprove to a sibling PR.
  • Security low β€” ReconcileSelfDecisionChangeRequests matches the body marker alone. Kept deliberately: the records it exists to clear predate the guard and were posted with the owner's own token, so r.Actor is the owner, not the hive login β€” requiring IsHiveAuthorLogin(r.Actor) would leave exactly those records in place. The marker is the delegate's HTML comment that only a /hive decision relay writes, and the dismissal is scoped to Source == decision records.
  • Docs-currency β€” api-reference.md not updated. Done: GET …/items/{n} row documents rebase_merge: {…} (incl. foreign-head) and rebase: {…}; POST …/decision documents the 202 rebase-queued answer and the rebase response field. Citation guard passes.

Landed-meanwhile integration. v5 merged #15157 (conflict-aware merge train) with an automerge.RebaseResolver hook and an unwired "Rebase, then merge" placeholder reserved for this PR. This head wires the hook in cmd/hive/main.go β€” a dirty train member is handed to the fixer's rebase-resolve episode (requested_by: merge-train) β€” removes the duplicate rebaseMergeFollowThroughLabel/mergeNowWired placeholders so the exhausted row's option goes live, and follows the #15213 approve-toast wording and #15200 history-icon lift in tests.

Rebase notes (v5 878554651). #15122's TestDirectWriteRatchet baselines rebase_merge_followthrough.go at 2 wrapper writes: both comments are operator-solicited (the ack on the request and that request's outcome note), the class the gate's doc excludes. #15278's TestSweepSelfAuthoredNeedsRebaseLabelAsksSupersededCloser fixture now says dirty rather than behind: the superseded question still precedes the label block, while a needs-rebase label on a merely-behind head stays stale and the lane updates the branch (this PR, #15103).

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 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 kellyaa 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 Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 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
#15294 πŸ› fix(writeback): gate adoption close-first writes instead of baselining them same files src/docs/operator-reference.md
src/pkg/writeback/testdata/direct-writes-baseline.txt
#15134 πŸ› Delegated decision on a capability gap: model the blocker, stop the un-park/re-park loop, name the missing App permission same files src/docs/api-reference.md
src/docs/dashboard-sections.md
src/docs/operator-reference.md
src/internal/testutil/dashboard_import_allowlist.txt
src/pkg/dashboard/server.go
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/stage_tracker_decision.go
src/pkg/dashboard/stage_tracker_row_actions_test.go
src/pkg/dashboard/static/index.html
#15297 πŸ› fix: clarify dashboard item and row counters same files src/docs/dashboard-sections.md
src/pkg/dashboard/static/index.html
#15253 πŸ› decision toast: issue decisions no longer read as 'approved for merge' CONFLICT src/pkg/dashboard/static/index.html
#15287 πŸ“– docs: clarify rework push detection without a nudge same files src/docs/dashboard-sections.md
src/docs/operator-reference.md
#15226 ✨ feature: enqueue eligible PRs into GitHub native merge queues same files src/pkg/github/automerge/automerge_sweep.go
src/pkg/github/automerge/automerge_sweep_test.go
#15236 πŸ› Prefer covering PR progress in Activity Monitor messages same files src/pkg/dashboard/stage_tracker.go
#15282 πŸ“– docs: make Hive guides easier to follow same files src/docs/dashboard-sections.md

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Failing checks:

  • build-and-test

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.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

CI triage (scanner, head 75bdd49) β€” PR-local, not a shared-baseline failure (v5 tip is green):

  • golangci-lint / build: pkg/dashboard/rebase_merge_followthrough.go:259:6: shortSHA redeclared in this block β€” shortSHA already exists at pkg/dashboard/contribute_fixqueue.go:104. Drop the new definition (or reuse the existing helper); this one typecheck error cascades into every build, docker, coverage and test shard failure listed.
  • test (rest 2/4): TestDashboardImportRatchet in internal/testutil fails β€” a new import was added under pkg/dashboard above the ratchet baseline; either remove it or bump the baseline in the same PR.
  • build-and-test on run 40773097850 died on the shared node tool cache guard ([CI runner canary] self-hosted runner pool unhealthyΒ #10518, infra) β€” re-runs on the next push.

Held at stage/071-needs-author, so leaving the fix to you rather than pushing.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

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

Reviewed β€” no findings from this perspective.

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

Security (delta re-review at 2cb583a; commits 693e972β†’2cb583a β€” the rest of the delta is v5 commits picked up by the rebase)

Foreign-head fail-closed is spoofable via commit email metadata β€” src/pkg/github/pr_merge_state.go:110-113 β†’ src/pkg/github/pr_signed_reconcile.go:316-335

driveRebaseMerge (src/pkg/dashboard/rebase_merge_followthrough.go:224-235) accepts a head that moved after the operator's approval when CommitByHive returns true, and Advance then sets RebasedHead = head and merges it with the approval on record (src/pkg/rebasemerge/rebasemerge.go:254-263, rebase_merge_followthrough.go:249-258). CommitByHive decides from the commit's author or committer email: in hiveCommitIdentity, when GitHub resolves no login for the address (login == ""), any address in signedTrailerDomain() (a fixed, repo-visible domain) returns true (line 325-327), and a <id>+<bot>@users.noreply.github.com address resolves to the bot login on GitHub's side (line 318-319). Both fields are set by whoever creates the commit.

Exploit: contributor opens a fork PR with maintainer edits allowed (PushReachable, pr_merge_state.go:53-55), operator clicks Rebase, then merge as maintainer on head A, contributor force-pushes head B with arbitrary content and git -c user.email=x@<pane-domain> (or the bot's noreply address). Next tick: CommitByHive β†’ true, B becomes RebasedHead, CI green + clean β†’ MergePRVia(B) merges content the operator never read, with their /lgtm + /approve attributed. The commit message a1cbc057 ("fails closed on a head the hive did not produce") and src/docs/operator-reference.md:475 ("only when GitHub says the hive committed it") both claim a guarantee the code does not provide β€” GitHub is not asserting anything; the hive is trusting a self-declared email.

Fix: bind the identity to something GitHub authenticates, not commit metadata. Minimal version β€” require the resolved login and GitHub's signature verification, and drop the email-only fallback for this call:

--- a/src/pkg/github/pr_merge_state.go
+++ b/src/pkg/github/pr_merge_state.go
@@ func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) {
 	rc, _, err := c.client.Repositories.GetCommit(WithRESTCaller(ctx, "hive:rebase_merge_head_identity"), owner, repoName, sha, nil)
 	if err != nil {
 		return false, fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(sha), err)
 	}
-	if c.hiveCommitIdentity(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) {
-		return true, nil
-	}
-	return c.hiveCommitIdentity(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil
+	// Author/committer email is whatever the pusher wrote; only a login
+	// GitHub resolved on a commit GitHub verified is the hive's.
+	bot := strings.TrimSpace(c.appBotLogin)
+	if bot == "" || !commitVerified(rc) {
+		return false, nil
+	}
+	return strings.EqualFold(safeGetLogin(rc.GetCommitter()), bot), nil
 }

If the fixer's --force-with-lease push is not GitHub-verified (only update-branch is), this makes the fork/dirty path fail closed until the fixer rewrites the head through the API like pr_signed_reconcile.go does β€” or, alternatively, have the ticker read the PR timeline head_ref_force_pushed/committed event and compare its actor.login (GitHub-authenticated) to the App bot. Either is sound; the email-domain check is not.

Prior findings re-checked at this head: operator-reference.md:475 identity claim β€” still present (and now contradicted by the above); main.go:2580-2583 RebaseResolver closure still calls rebasemerge.SharedAttempts() directly (style, unchanged); merge_eligibility.go:1148 comment reads fine now.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Why:

  • the review swarm requested changes

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.

…se-resolve with loop guard; approve on a dirty PR queues the rebase; dismiss self-inflicted changes_requested

Squashed and rebased onto v5 after #15087 and #15074 landed.

Fixes #15103

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…ase fields, import ratchet, window shim)

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

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

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…roduce; document the new API shapes

The approval is bound to the head the operator read. A contributor PR whose
head moves after the click now counts as rebased only when GitHub reports
the hive (App bot or pane identity) as the commit's author or committer;
any other head settles the follow-through as failed (foreign-head) with
nothing merged, a note on the PR, and 'Approve the new head & merge' as the
way out. api-reference.md gains the 202 rebase-queued answer, the rebase
response field, and the rebase_merge / rebase row fields.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…e; the exhausted row's rebase-then-merge option goes live

v5 landed the conflict-aware merge train (#15157) with a RebaseResolver hook
reserved for this PR and a duplicate rebaseMergeFollowThroughLabel. The hook
now opens the shared rebase episode (requested_by: merge-train); the
mergeNowWired flag and its disabled reason go, since the option it guarded
is wired here.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…NS for the history badge in the rebase-then-merge row test

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…e rebase-then-merge follow-through

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…e a needs-rebase label on a merely-behind head stays stale

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.

Reviewed β€” no findings from this perspective.

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

Delta re-review (style) β€” read head 3b401b0f against prior head 9404ecfd. The delta is a rebase onto v5 (9 upstream commits); the PR-owned changes are conflict resolutions only (automerge_sweep.go stale-label check moved under the merged blocked block, automerge_sweep_test.go fixture β†’ dirty, api-reference.md citation renumber, test wording for #15213/#15200). Nothing in the delta changes what the previously reviewed code does.

Prior findings at this head

  • src/cmd/hive/merge_eligibility.go:1200-1203 β€” still present. rebaseAttempts().Clear runs for every bucket != mergeBucketConflict, but classifyMergeEligibility returns Skip/Failing for draft (:537), block labels (:553), CI failing (:593) and hold (:604) before conflictMergeState (:612), so a conflicting PR in any of those states loses its episode and the operator's RequestedBy each cycle.
  • src/pkg/github/pr_merge_state.go:110-113 β†’ pr_signed_reconcile.go:316-327 β€” still present. CommitByHive accepts a commit whose GitHub login is unresolved (login == "") on the strength of a pane-domain committer/author email alone; that email is contributor-controlled git metadata.
  • src/docs/api-reference.md:286,288 β€” remains fixed (rebase_merge/rebase fields and the 202 rebase-queued answer are documented).

Style (in-scope, low) β€” src/pkg/github/automerge/automerge_sweep.go:1230-1241: staleNeedsRebaseLabel was inserted between prMergeableStateConflicting's doc comment and its declaration, so godoc now attaches "prMergeableStateConflicting reads GitHub's conflict flag…" to staleNeedsRebaseLabel and leaves prMergeableStateConflicting undocumented.

-// prMergeableStateConflicting reads GitHub's conflict flag off a single-PR
-// GET payload.
-// staleNeedsRebaseLabel: prow's needs-rebase label lags GitHub's
+// staleNeedsRebaseLabel reports whether blocked is a needs-rebase label GitHub
+// no longer agrees with: prow's needs-rebase label lags GitHub's
 // mergeable_state. When GitHub says the branch is merely "behind" (clean
 // update), the label must not block the lane β€” the lane's UpdateBranch is
 // exactly what clears it, and before hivecommons/hive#15103 no lane ever
 // reached that call under the label.
 func staleNeedsRebaseLabel(blocked string, pr *gh.PullRequest) bool {
 	return blocked == "label:needs-rebase" && strings.EqualFold(strings.TrimSpace(pr.GetMergeableState()), "behind")
 }
 
+// prMergeableStateConflicting reads GitHub's conflict flag off a single-PR
+// GET payload.
 func prMergeableStateConflicting(pr *gh.PullRequest) bool {

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

Intent-alignment delta re-review (read head 3b401b0; delta vs 9404ecf is 9 upstream v5 commits plus the rebase rework β€” PR footprint unchanged apart from automerge_sweep_test.go). The #15278 integration is right: the superseded question still precedes the stale-label bypass (automerge_sweep.go:1739-1756). Two prior findings remain; the api-reference row stays fixed (api-reference.md:288).

1. Still present β€” rebase episode cleared while the PR is still conflicting (src/cmd/hive/merge_eligibility.go:1201-1204)
classifyMergeEligibility returns mergeBucketFailing for a dirty head whose CI is red (:578-595, red is classified before the conflict at :613) and mergeBucketSkip for a held one (:606). Line 1201 keys the ledger reset on the bucket, so for those PRs rebaseAttempts().Clear runs every pass: the RequestedBy written by approve-on-dirty / merge-now / merge-train and the attempt count are wiped, the loop guard restarts from 1, and a requested foreign PR never reaches requested=true at :1224. A conflicting PR with a stale red check is the common shape of #14822.

		if !conflictMergeState(pr) {
			// Not conflicting any more: the rebase episode is over.
			rebaseAttempts().Clear(fullRepo, pr.Number)
		}

2. Still present β€” foreign-head guard accepts a spoofed pane-domain email (src/pkg/github/pr_merge_state.go:113-117, src/pkg/github/pr_signed_reconcile.go:316-335)
The changelog promises "only a head the hive itself committed counts as the rebase" (changelog.d/fixed-rebase-then-merge.md:1). CommitByHive returns true when either author or committer satisfies hiveCommitIdentity, and that helper returns true for any email in the pane domain whenever GitHub resolved no login for it (:321-327). A person pushing to the PR branch with user.email anything@<pane-domain> on an unclaimed address therefore passes, and driveRebaseMerge (rebase_merge_followthrough.go:224-234) merges the new content under the operator's recorded approval. Suggested remediation: identify the pusher, not the commit metadata β€” e.g. read GET /repos/{head_repo}/activity?ref=<head_ref>&activity_type=push,force_push and accept the head only when the newest push's actor.login is the App bot (or GitHub's web-flow for update-branch), falling back to fail-closed; alternatively have the fixer's rebase-resolve kick record the SHA it pushed in the attempts ledger (Observe) and accept only heads so recorded.

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

Security re-review at 3b401b0 (delta since 9404ecf is the v5 rebase + one sweep test fixture; pr_merge_state.go, rebasemerge/*, rebase_merge_followthrough.go, merge_eligibility.go are byte-identical to the previous head).

Still present β€” foreign-head fail-closed guard is bypassable by a spoofed commit email (in-scope, high).
src/pkg/dashboard/rebase_merge_followthrough.go:228-235 sets obs.HeadByHive from CommitByHive, and src/pkg/rebasemerge/rebasemerge.go:255 merges a contributor PR's new head whenever HeadByHive is true. src/pkg/github/pr_merge_state.go:110-113 answers via hiveCommitIdentity (src/pkg/github/pr_signed_reconcile.go:316-335): when GitHub does not resolve the commit's email to an account (login == ""), the email domain alone decides, and signedTrailerDomain() (src/pkg/github/pr_request_signed.go:324-329) is a guessable default/env hostname. A contributor who owns the PR branch can git -c user.email=anything@<pane-domain> commit && git push after the operator clicks Rebase, then merge as maintainer; GitHub leaves the committer login empty, CommitByHive returns true, and the 2-minute ticker merges content the operator never saw with their /lgtm + /approve attached. This is the exact attack the "fail-closed" guard was added for.

Proposed fix β€” on a non-hive-authored PR, do not accept an unresolved identity; require GitHub to have resolved the login to the App bot (or a verified signature):

--- a/src/pkg/github/pr_merge_state.go
+++ b/src/pkg/github/pr_merge_state.go
@@ func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) {
 	if err != nil {
 		return false, fmt.Errorf("reading %s/%s@%s: %w", owner, repoName, shortSHA(sha), err)
 	}
-	if c.hiveCommitIdentity(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) {
-		return true, nil
-	}
-	return c.hiveCommitIdentity(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil
+	// A bare email is contributor-controlled; only a login GitHub itself
+	// resolved to the App bot (or a GitHub-verified signature) proves the
+	// hive produced this head.
+	bot := strings.TrimSpace(c.appBotLogin)
+	if bot != "" && (strings.EqualFold(safeGetLogin(rc.GetCommitter()), bot) || strings.EqualFold(safeGetLogin(rc.GetAuthor()), bot)) {
+		return true, nil
+	}
+	if rc.GetCommit().GetVerification().GetVerified() {
+		return c.hiveCommitIdentity(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) ||
+			c.hiveCommitIdentity(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil
+	}
+	return false, nil
 }

If the fixer's rebase pushes are neither App-attributed nor signed, the alternative that holds regardless of identity is to compare patch-ids of approvedHead vs newHead against the base and merge only when the set is unchanged; either way a bare domain match must not be sufficient.

Previous findings: merge_eligibility.go:1200 (episode cleared while still conflicting) β€” unchanged, still present (correctness, not re-judged here); api-reference.md β€” remains fixed. Merge-train RebaseResolver wiring (src/cmd/hive/main.go:2580) is bounded: members come only from the self-authored / trusted-author prefilters (automerge_sweep.go:1067,1288).

β€” hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Why:

  • the review swarm requested changes

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.

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

Correctness β€” delta re-review (9404ecf β†’ 3b401b0, read at head 3b401b0). The delta is a rebase onto v5 plus one fixture commit; the only PR-content change is the self-lane label-block reorder in src/pkg/github/automerge/automerge_sweep.go:1737-1757, which is a correct resolution against #15278 (superseded question first, stale needs-rebase on behind still reaches updateBranchAndSkip). The api-reference.md:286-288 finding remains fixed. Two previous findings are still present:

1. Operator-requested rebase episode is cleared while the PR is still conflicting β€” src/cmd/hive/merge_eligibility.go:1200-1203. rebaseAttempts().Clear() fires whenever bucket != mergeBucketConflict, but classifyMergeEligibility returns mergeBucketFailing for CIStatus == "failure" (:565-596), mergeBucketSkip for held (:603-605) and for block labels (:551-556) before it reaches conflictMergeState (:612-614). A dirty PR that is also red/held therefore has the Request episode (RequestedBy, written by queueRebaseOnApprove) wiped on the very next sweep, so the requested admission at :1224-1226 never fires and the toast's promise "hive will rebase it next pass" is not kept. Clear on the actual merge state instead of the bucket:

		if !conflictMergeState(pr) {
			// Not conflicting any more: the rebase episode is over.
			rebaseAttempts().Clear(fullRepo, pr.Number)
		}

2. Foreign-head fail-closed guard is bypassable by commit email β€” src/pkg/github/pr_merge_state.go:110-113 β†’ src/pkg/github/pr_signed_reconcile.go:316-335. When GitHub resolves no login for the commit identity (login == ""), hiveCommitIdentity returns true for any address whose domain equals signedTrailerDomain() β€” a repo-visible default (pr_request_signed.go). A contributor can push a new head with user.email=x@<that-domain> after the operator's approval; GitHub resolves no account for it, CommitByHive reports true, and the follow-through merges content the approval never covered β€” the exact case the guard was added for. Email is contributor-controlled; the pusher is not. Decide HeadByHive from who pushed the head (the issue timeline's head_ref_force_pushed/committed events carry the pushing actor, which is the App for the fixer and for update-branch) or from the SHA the hive's own action produced, and keep the email-domain path only for the signed-trailer reconcile it was written for. Minimal fail-closed variant until then:

 func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, error) {
 	...
-	if c.hiveCommitIdentity(safeGetLogin(rc.GetCommitter()), rc.GetCommit().GetCommitter().GetEmail()) {
-		return true, nil
-	}
-	return c.hiveCommitIdentity(safeGetLogin(rc.GetAuthor()), rc.GetCommit().GetAuthor().GetEmail()), nil
+	// Only a GitHub-resolved login is trustworthy here: the commit email is
+	// whatever the pusher wrote, so a pane-domain address with no account
+	// behind it must not release a merge the approval never covered.
+	bot := strings.TrimSpace(c.appBotLogin)
+	if bot == "" {
+		return false, errors.New("commit by hive: app bot login unknown")
+	}
+	return strings.EqualFold(safeGetLogin(rc.GetCommitter()), bot) || strings.EqualFold(safeGetLogin(rc.GetAuthor()), bot), nil
 }

(If the fixer's rebase commits carry a pane identity GitHub does not resolve, that variant fails closed on them too β€” which is the safe direction; the pusher-based check above is the one that distinguishes the two.)

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#151043b401b0` sha256:e4919d79f23883aa657f27dc4fbc6e7038be13fc7efe370e595e7840968d57d5 β€” download from the dashboard or `hivectl review evidence #15104`.

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

@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

author/human A person pushed this PR themselves conflicts-with-open-pr Open PR has a merge conflict with another open PR dco All commits are DCO signed-off 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.

Activity Monitor: hive never rebased its parked PR; "Approve & merge as maintainer" would 405 on a needs-rebase PR

1 participant