Skip to content

πŸ› automerge: name a standing change request in the review-required ask; no merge call on a conflicting head - #16098

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/needs-decision-change-request
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/needs-decision-change-request

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

Two related fixes on the self-authored merge path, both seen on projectbluefin/utah-packages#633 (hive-adopted, hive/adopt-627, build 6f6a5ca).

  • A. The 085 "approving review required" ask names a standing change request. When GitHub refuses the merge for want of an approving review and a person's change request still stands on the PR, the stage/085-needs-decision comment now:

    • names the reviewer, the commit they reviewed, and a compare link to what the hive pushed since;
    • asks them to re-review, or a maintainer to dismiss the review.

    It no longer asks anyone for an Approve over it. PRs without a standing change request get exactly today's text.

  • B. No merge call on a PR GitHub calls conflicting. The self-authored sweep now re-checks mergeable_state on its merge-time re-read and skips a dirty head as conflicting. A 405 "Pull Request has merge conflicts" from any lane is now conflicting, not merge-failed.

The bugs

A: asked to approve over a colleague's change request

  • 10-30 04:12Z. @hanthor submitted CHANGES_REQUESTED at 1760767: the title said seven libraries but only five recipes were added, and the RPM Fusion / negativo17 source policy should be its own PR.
  • 04:22Z–04:58Z. The hive split the policy out (feat: accept pinned RPM Fusion and negativo17 recipe importsΒ projectbluefin/utah-packages#821, merged) and reworked the branch.
  • The review was never dismissed or re-requested, and reviewDecision is still CHANGES_REQUESTED.
  • The 085 comment. The hive posted hive:stage-needs-decision three times (10-30 06:02Z, 10-31 11:31Z, 16:12Z), each saying only: "GitHub refused the merge: branch protection requires an approving review … A GitHub Approve review on this head … lets the hive merge it." None mentions the change request.

Why, at 6f6a5ca:

  • By design, the self lane doesn't block on an old-head change request. latestTrustedHumanChangesRequested (automerge_human_changes_requested.go:19) treats "a changes_requested left on an older commit [as] outdated: the author already pushed past it" (✨ stage 085: route a maintainer decision / changes_requested on a hive-authored PR back to the author agentΒ #13041). So humanChangesRequestedForHead (automerge_sweep.go:2036) passes, and the PR reaches the merge call. I kept that.
  • GitHub doesn't treat it as outdated. It keeps the review standing across pushes until the reviewer re-reviews or it is dismissed; mergeRefusedReviewRE (automerge_merge_refusal.go:44) already matches the ruleset form, "1 review requesting changes by reviewers with write access".
  • The 085 cause is built from the lane reason alone (automerge_stage_human.go:631), and nothing on the stage detail carried the review. noteStageReviews (automerge_stage_labels.go:627) recorded only a count.

B: PUT /merge on a conflicting PR

Hive log, 10-31:

  • From 18:20Z, every ~1m45s: automerge skip … pr 633 reason conflicting.
  • At 18:29:27Z, one pass's first read did not show the conflict (head unchanged at 337fa03). It ran every gate and called merge: WARN self-authored automerge sweep skipped PR … reason merge-failed: PUT …/pulls/633/merge: 405 Pull Request has merge conflicts.
  • The merge-failed reason moved the stage 070 β†’ 080 (18:30:23Z) and back to 070 conflicting at 18:31:56Z.

Why, at 6f6a5ca:

  • trySweepSelfAuthoredPR checks for a conflict only on its first read (automerge_sweep.go:2067).
  • The re-read right before the merge compares the head SHA alone (automerge_sweep.go:2195).
  • refusedMerge (automerge_merge_refusal.go:205) classifies review-required, method-not-allowed and merge-queue 405s, but not the conflict one, so it fell through to merge-failed (automerge_sweep.go:2246).

The fix

A.

  • Record the requests. noteStageReviews now also records StandingChangeRequests on the stage detail: everyone (the hive app and [bot] logins excluded) whose latest opinionated review (APPROVED / CHANGES_REQUESTED / DISMISSED, the same rule hasOutstandingChangesRequested uses) is CHANGES_REQUESTED, on any head, with commit, time and URL. The reviews were already listed on this pass, so this adds no API call. drain() carries the field onto the observation.

  • Use them in the comment. In humanEvidence, a merge-refused-review cause with standing requests becomes mergeRefusedReviewChangeRequestCause, for example:

    GitHub refused the merge: branch protection requires an approving review from someone with write access, and the Hive App cannot give it. A change request still stands on this PR: @hanthor requested changes on 2026-10-30 at 1760767 (review), and the hive has pushed since (changes since that review). GitHub keeps a change request standing across pushes until its reviewer re-reviews or it is dismissed, so settle it before anyone approves: @hanthor, please re-review this head; if the request no longer applies, a maintainer can dismiss the review. The hive retries once GitHub reports the PR unblocked, or within 30 minutes

    A request on the current head says "on this head", with no "pushed since". The comment is posted once per head and cause, as before.

  • Not done: re-requesting the review automatically. It is an unsolicited write that would need its own write-back kind and an owner call on when the hive may ping a person. The comment carries the ask instead. Happy to follow up if wanted.

B.

  • Re-check before the call. After the head re-check, mergeCallConflicting(current) skips with reject("conflicting"), the same as the first-read check. It is true for mergeable_state dirty/conflicting, or for mergeable: false while the state is still unknown/empty. A known state wins over the bool, as in hgithub.MergeableFromState.
  • Classify the 405. refusedMerge returns conflicting for a 405 "Pull Request has merge conflicts". It is not remembered, since the next read shows dirty. This covers the self-authored, trusted-author, queued and contributor lanes.
  • Not changed: a required-review precheck. blocked cannot tell missing reviews from pending checks, and the existing per-head review-refusal memory already stops repeat calls after the first 405 (knownMergeRefusal).

Out of scope, unchanged: branch-protection settings, App bypass, and the trusted-author lane's own conflict path (merge-forward).

Tests

pkg/github/automerge/automerge_merge_change_request_test.go:

  • A, the end-to-end feat: per-agent UID isolation for mandatory proxy enforcementΒ #633 shape. A real self-authored sweep pass runs against a fake whose reviews are:

    • @hanthor CHANGES_REQUESTED on an older commit;
    • a request later approved, a request later dismissed, and a bot's request, none of which stands.

    Merge answers 405 review-required. After drain(), the observation carries only @hanthor's request. humanEvidence and DecisionComment name @hanthor, the date, 1760767, the review link and the compare link, and ask for a re-review or a dismissal, without "A GitHub Approve review on this head". With no standing request, the cause equals decisionCause("merge-refused-review"), today's text.

  • A, text shapes. No requests gives an empty cause; a request on the head doesn't claim a push since; two reviewers read "@hanthor and @castrojo"; no compare link without a URL.

  • B.

    • A first read clean with a re-read dirty / conflicting gives a skip as conflicting with zero merge calls.
    • A clean head still merges once.
    • A 405 merge conflict is one call logged as conflicting, never merge-failed.
    • The classifier accepts only a 405 with that message.
    • mergeCallConflicting reads the bool only while the state is unknown.
  • Fixture. selfAuthoredPR gains reviews and recheckMergeableState.

Results:

  • go test ./pkg/github/... ./pkg/stageengine/... ./pkg/stagelabels/... ./pkg/review/... ./pkg/dashboard/... ./cmd/hive/... passes; go vet is clean.
  • 14/14 mutants killed. They removed the re-check, ignored or always trusted the bool, unclassified the 405, accepted any status, dropped the field in drain() or noteStageReviews, counted bots, let the first review win, ignored dismissals, removed the evidence override, dropped the compare link, claimed a push for an on-head request, and joined names wrong.

Docs and changelog

  • src/docs/labels-and-control-signals/stage-labels.md: the merge-refused:* row.
  • changelog.d/fixed-merge-refused-review-change-request.md.

Related: #13041, #15159, #15419.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…k; no merge call on a conflicting head

A. When GitHub refuses the merge for want of an approving review and a
person's change request still stands (their latest opinionated review is
CHANGES_REQUESTED, on any head), the stage/085-needs-decision comment now
names the reviewer, the commit they reviewed and a compare link to what
the hive pushed since, and asks them to re-review or a maintainer to
dismiss the review, instead of asking anyone to Approve over it.
noteStageReviews records StandingChangeRequests from the review list the
lane already read; drain carries it onto the observation. PRs without a
standing request keep today's text. Seen on projectbluefin/utah-packages
hivecommons#633: three 085 comments asked for an Approve while @hanthor's
CHANGES_REQUESTED stood.

B. The self-authored sweep re-checks mergeable_state on its merge-time
re-read and skips a dirty head as conflicting, and a 405 "Pull Request has
merge conflicts" from any lane is reported as conflicting instead of
merge-failed (hivecommons#633 called PUT /merge on a conflicting PR at 18:29Z and
bounced 070 -> 080 -> 070).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 31, 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

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16096 πŸ› review: a hive-authored ask on a sensitive path stays a person's decision same files src/pkg/stageengine/prstage/types.go

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

Read the diff against the tree at 22d5fb0; both fixes look correct to me.

  • B (conflict skip). refusedMerge returns "conflicting" for the 405 (automerge_merge_refusal.go:224), and that reason is not in the refusal set that parks at 085 (automerge_merge_refusal.go:86), so it takes the ordinary skip path; the self lane already maps it through humanConflictReasons (automerge_stage_human.go:140), same as the contributor lane does at automerge_contributor_lane.go:1393. The pre-merge mergeCallConflicting(current) check in trySweepSelfAuthoredPR sits after the head re-read and before the review gate, so it cannot skip a head that was not re-verified.
  • A (standing change request). standingChangeRequests keys on the login's latest APPROVED/CHANGES_REQUESTED/DISMISSED review, so a later COMMENTED review does not clear it and a dismissal does β€” that matches how GitHub keeps a change request standing across pushes. All three noteStageReviews callers (automerge_sweep.go:3071,3347, automerge_human_changes_requested.go:60) pick up the new field with no signature change, and drain() copies it only under ReviewsKnown, so a cycle that did not read reviews cannot blank it. The override in humanEvidence runs before the adopt-fence prefix at automerge_stage_human.go:464, so that prefix still applies.

go build of pkg/github/automerge and pkg/stageengine/prstage passes at this head, and the new test files type-check.

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

@hivecommons-hive

hivecommons-hive Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Correctness review (head 22d5fb0) β€” the diff does what the body says: standingChangeRequests (automerge_stage_labels.go:647-684) is fed from the same ListReviews walk via noteStageReviews (automerge_human_changes_requested.go:61), carried by drain() (automerge_stage_labels.go:339), and swapped into the 085 cause only for merge-refused-review (automerge_stage_human.go:456-463). mergeCallConflicting (automerge_sweep.go:1453-1463) sits after the head re-verify and before the review gate (automerge_sweep.go:2217-2219), and the 405 conflict classification returns before the remembered-refusal path (automerge_merge_refusal.go:224-230). Tests cover the dismissed / later-approved / bot cases and the plain-text fallback.

One edge case, advisory (not blocking):

A non-collaborator's CHANGES_REQUESTED is reported as the blocker. standingChangeRequests (automerge_stage_labels.go:649-659) excludes only the App and [bot] logins. GitHub's rule only counts "reviews requesting changes by reviewers with write access" (the very text mergeRefusedReviewRE matches, automerge_merge_refusal.go:44), so a drive-by change request from someone without write access does not block the merge β€” but the new 085 text drops the "an Approve on this head lets the hive merge" sentence and tells maintainers to "settle it before anyone approves" (automerge_stage_human.go:689-693). The ask then points at the one review that cannot be what GitHub refused on. The review payload already carries author_association, so this is filterable with no extra call:

		login := strings.ToLower(strings.TrimSpace(hgithub.SafeGetLogin(r.GetUser())))
		if login == "" || strings.HasSuffix(login, "[bot]") || c.isHiveAppReviewAuthor(r) {
			continue
		}
		// GitHub counts only reviewers with write access toward "reviews
		// requesting changes"; a drive-by request is not what it refused on.
		switch strings.ToUpper(strings.TrimSpace(r.GetAuthorAssociation())) {
		case "OWNER", "MEMBER", "COLLABORATOR":
		default:
			continue
		}

(at automerge_stage_labels.go:653-656; MEMBER is a heuristic for org repos, but it is the same cut GitHub's own UI uses for the badge.)

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

Security perspective (read at head 22d5fb0).

Untrusted reviewers can author the hive's 085 ask (medium). standingChangeRequests (src/pkg/github/automerge/automerge_stage_labels.go:649-661) keeps every non-bot, non-App login whose latest opinionated review is CHANGES_REQUESTED, with no trust check. The sibling it borrows its rule from, latestTrustedHumanReview (automerge_human_changes_requested.go:71-74), drops logins unless isTrustedMerger says configured and trusted. On a public repo anyone can submit CHANGES_REQUESTED; GitHub's refusal counts only "reviewers with write access" (mergeRefusedReviewRE, automerge_merge_refusal.go:44), so such a review is not what blocks the merge β€” but humanEvidence (automerge_stage_human.go:457-462) would still replace the Approve ask with mergeRefusedReviewChangeRequestCause (:657-699): it @-mentions the drive-by account as the person to re-review, embeds their review link, and tells maintainers to "settle it before anyone approves". That hands an unprivileged account a way to misdirect the maintainer ask and suppress the merge guidance on any PR the hive sweeps.

Suggested fix β€” apply the same trust filter the self lane already uses:

		if login == "" || strings.HasSuffix(login, "[bot]") || c.isHiveAppReviewAuthor(r) {
			continue
		}
		if trusted, configured := c.isTrustedMerger(login); !configured || !trusted {
			continue
		}

(at automerge_stage_labels.go:656-658; add a test case with an untrusted login's CHANGES_REQUESTED that must not appear in StandingChangeRequests.)

Fix B (mergeCallConflicting, 405-conflict classification) only tightens the merge path; no concerns.

Evidence bundle `#16098731a527` sha256:c5c5049bdf0c500cde03d014dbd1122ceb1e4ca99b5c703874ac167f800202b8 β€” download from the dashboard or `hivectl review evidence #16098`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (2 waiting): fixes are handed out before new work as soon as you have capacity.

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

Read the diff against the tree at 731a527; this looks correct to me.

  • B (conflict skip). automerge_sweep.go:2218 runs mergeCallConflicting(current) on the merge-time re-read, after the head-SHA equality check, so it only ever skips a head that was already verified to be the evaluated one. reject (:1963) closes over the first-read pr, but rejectBeforeLane (:2353) uses it only for pr.GetBase().GetRef(), so passing the stale read there is harmless. mergeConflictMergeError is scoped to a 405 whose message matches "pull request has merge conflicts", and refusedMerge returns conflicting without remembering it, which is right since the next read's dirty state carries the fact.
  • A (085 prose). standingChangeRequests (automerge_stage_labels.go) takes the last APPROVED/CHANGES_REQUESTED/DISMISSED per login in list order and ignores COMMENTED, which matches how GitHub keeps a change request standing; bots and the hive app are excluded via isHiveAppReviewAuthor (automerge_sweep.go:3389). The map iteration is made deterministic by the sort on SubmittedAt, then login. The compare link slices the review URL at /pull/, which yields the repo URL β€” correct for GitHub review HTML URLs.
  • Tests cover both behaviours (merge-time dirty/conflicting, the 405 path, the unknown-state bool fallback, and the prose shapes), and stage-labels.md plus the changelog fragment describe the new behaviour.

No findings.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 26f7c17 into hivecommons:v6 Oct 31, 2026
61 of 62 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at 731a527.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant