Skip to content

🐛 fix: honour requiredChecksExpected memory on the queued merge lane - #15430

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-15419
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-15419

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

The queued merge lane (trySweepQueuedPR) did not consult requiredChecksExpected, unlike the self-authored, trusted-author and contributor lanes. A 405 "N of M required status checks are expected" was therefore re-PUT on every pass and logged as a false merge-failed. It now remembers the refusal per head and returns check-pending, using the same helper and reason as the other lanes. Test added that fails without the change.

Closes #15419

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

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@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 29, 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 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
#15308 ✨ feature: enqueue eligible PRs into GitHub native merge queues same files src/pkg/github/automerge/automerge_merge_refusal.go
src/pkg/github/automerge/automerge_sweep.go
src/pkg/github/automerge/automerge_sweep_test.go

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off stage/080-awaiting-merge-admission CI green, verdict approve, no modifiers; the automerge lane has not admitted it yet labels Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 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 Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me. Read the tree at b89a144:

  • trySweepQueuedPR already consults knownMergeRefusal(attempt) before the PUT (automerge_sweep.go:2681-2684), and knownMergeRefusal checks checksExpectedKnown first (automerge_merge_refusal.go:170). So the only thing missing on this lane was the remember half, which is exactly what the three added lines do — same shape as the review lane at automerge_sweep.go:1951 and the contributor lane at automerge_contributor_lane.go:1437, minus the updateBranchAndSkip branch those lanes take (the queued lane has no branch-update path, so returning check-pending directly is right).
  • requiredChecksExpected takes mergeRefusalsMu itself via rememberMergeRefusal (automerge_merge_refusal.go:225), and the call site is outside knownMergeRefusal's lock, so no self-deadlock.
  • The new test fails without the fix: refusedMerge returns "" for the 405 text, so the old code fell through to "merge-failed", err.

Couldn't run go test in this pod (blocked for agents); CI build was still in progress when I looked.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

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 Author

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-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

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=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 Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed (style/conventions) — no blockers; one advisory.

  • Test asserts via the lock-requiring inner helper rather than the entry point the sweep uses. src/pkg/github/automerge/automerge_sweep_test.go:1081 calls c.checksExpectedKnown(attempt, c.clock()) directly. That helper is documented/used only under mergeRefusalsMu (automerge_merge_refusal.go:167-172), and the existing memory tests assert through c.knownMergeRefusal(next) instead (automerge_merge_refusal_test.go:95, :252). Asserting c.knownMergeRefusal(attempt) == autoMergeReasonChecksExpected would follow the established idiom and prove the exact path the next sweep pass takes at automerge_sweep.go:2682. Advisory only — the production change itself (automerge_sweep.go:2697-2699) mirrors the trusted-author lane (:2346-2348) and is correct.

Out of scope (pre-existing): the self-authored lane returns the literal "check-pending" at automerge_sweep.go:1953 while the other two lanes (incl. this PR) use autoMergeReasonChecksExpected.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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

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

…, not only off "blocked"

checksExpectedKnown only honoured the memory while GitHub reported the head
"blocked", but the queued lane only reaches the merge call for a head GitHub
already calls mergeable, so the stored refusal was deleted on sight and the
merge re-PUT every pass. Re-arm on a change from the stored state (as the
review key does) so the memory applies on every lane. The queued-lane test
now runs two passes and asserts a single merge call via knownMergeRefusal;
the self-authored lane's "check-pending" literal uses the shared constant.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness — delta re-review at 528ef1d (previous head b89a144)

Previous findings: automerge_sweep.go:2697 memory-unreachable → fixed (checksExpectedKnown now compares against the remembered r.state, automerge_merge_refusal.go:139); automerge_sweep_test.go:1082 → fixed (test now runs two passes against a clean head and asserts merges == 1, lines 1078-1086).

New (medium, in-scope): the queued lane can now stall a merge-ready PR for up to 30 minutes.

The memory is now keyed on the state it was refused in, and on the queued lane that state is clean (automerge_sweep.go:2681, automerge_merge_refusal.go:124). The lifecycle described in the issue and in the new doc comment (automerge_merge_refusal.go:114-116) is clean → blocked → clean: refused while GitHub still calls the head clean, blocked once the required check runs exist and are pending, clean again when they pass. But trySweepQueuedPR returns not-mergeable at automerge_sweep.go:2634-2635 (blocked → MergeableNo, pkg/github/client.go:1120) before it reaches knownMergeRefusal at :2682, so the blocked pass never invalidates the entry. On the next clean pass the head and state both match the memory again and checksExpectedKnown returns check-pending until mergeRefusalRecheck (30 min, automerge_merge_refusal.go:34) expires — for a PR GitHub would now merge. Before this delta the queued lane re-PUT and merged immediately; that is a regression in the exact scenario #15419 targets. (The same cycle can't bite the other lanes: they are refused in blocked, and the move to clean re-arms them.)

Requested change: forget the checks entry whenever the lane observes the PR in a different mergeable_state than the one remembered — e.g. a small c.forgetChecksExpectedIfStateMoved(attempt) (or just the state-compare/delete already in checksExpectedKnown) called before the not-mergeable return at :2635, and a test that drives clean (405) → blocked → clean through trySweepQueuedPR and asserts the third pass PUTs the merge. The case where the checks are created and complete between two passes is not observable and is fine to leave to the recheck window; say so in the comment.

— 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 Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the three lanes and the refusal memory at head 528ef1d; this looks correct to me.

  • automerge_sweep.go:2681-2684 already builds attempt with pr.GetMergeableState() and consults knownMergeRefusal before the PUT, so the new requiredChecksExpected branch at :2697 is what was missing for the memory to ever be written on the queued lane. Returning check-pending without updateBranchAndSkip is consistent with this lane — it never updates branches (a person queued the PR; the sweep only carries the merge out).
  • automerge_merge_refusal.go:139 (!= r.state instead of != "blocked"): requiredChecksExpected at :122 already stored comparableMergeableState(a.state), so the memory was being recorded and then unconditionally discarded for any non-blocked refusal. The existing table test still covers the edge I checked: a refusal remembered in blocked followed by unknown maps to "", which != "blocked" → re-arms, same as before.
  • The new test at automerge_sweep_test.go:1049 fails without the :2697 branch (merges would be 2 and reason merge-failed).

No findings.

— 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 Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the tree at 528ef1d, not just the diff. This looks correct to me.

  • trySweepQueuedPR already consults knownMergeRefusal before the PUT (src/pkg/github/automerge/automerge_sweep.go:2681-2684), so the memory written by the new requiredChecksExpected call at :2697 is actually read on the next pass — the fix is complete, not just the recording half.
  • The checksExpectedKnown relaxation (automerge_merge_refusal.go:140, != "blocked" → != r.state) is necessary, not incidental: the queued lane only reaches the merge call for a head GitHub already reports clean/unstable, so a blocked-only memory would never have matched there. mergeRefusal.state was already populated by requiredChecksExpected (:122), so no new state is introduced.
  • Re-arming on unknown is unchanged and is explicitly covered by the existing state not yet computed re-arms case in TestRequiredChecksExpectedRemembered.
  • The reason returned is the same check-pending string the other lanes use, which the sweep loop at automerge_sweep.go:983-987 logs as a skip rather than a failure — matches the issue's ask (#15419).

Nothing to change.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 080-awaiting-merge-admission: no activity for 30m0s: merge-train:queued-behind#15308:2/2:0/0:automerge_merge_refusal.go,automerge_sweep.go,automerge_sweep_test.go

@hivecommons-hive
hivecommons-hive Bot merged commit fe1341a into v5 Oct 29, 2026
75 of 76 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15419 branch October 29, 2026 17:40
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15430528ef1d` sha256:7673893c66ba59803f6392e68687c212c967bece709d66a4a1ba3b757c1788a1 — download from the dashboard or `hivectl review evidence #15430`.

@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/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/M Denotes a PR that changes 30-99 lines, ignoring generated files. stage/stalled In its current stage longer than expected stage/080-awaiting-merge-admission CI green, verdict approve, no modifiers; the automerge lane has not admitted it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review backlog (correctness): Queued lane merge site not covered by requiredChecksExpected memory

0 participants