Skip to content

πŸ› fix(automerge): do not merge the base into a PR on a merge-queue-only base - #15038

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/no-base-sync-on-merge-queue-base
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/no-base-sync-on-merge-queue-base

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

On 2026-10-28 the hive merged main into projectbluefin/finpilot#599 (a mergeraptor PR in the self-authored/trusted-bot lane) three times: at 09:15, 11:13 and 15:16Z. Each was an update-branch through currentBaseGate, logged reason=base-moved.

The review verdict is keyed to the exact head, so after each update the PR dropped back to review-gate:no-review-bundle and waited for a fresh review: 16m, 31m and 1h27m.

Each time it reached stage 100, the sweep logged automerge hold reason=merge-queue-required. finpilot's main accepts merges only through GitHub's merge queue, which the hive cannot enqueue into. So the PR could never merge directly, and each refresh only moved it off its review. A merge queue tests base plus PR itself, so a base refresh by the hive buys nothing there.

The hive already remembers such bases (MergeQueueBases, #14068), but:

  • The gate never read the memory. currentBaseGate runs before the merge attempt and did not consult it.
  • The entry expired between refusals. It lasts 30 minutes (mergeQueueBaseRecheck) and only a real 405 re-arms it, while a hold through knownMergeRefusal never did. The 11:13Z update came 1h41m after the 09:31Z refusal.

The rules read is not an alternative signal. finpilot's rules/branches/main lists no merge_queue rule, and GraphQL mergeQueue(branch: "main") is null, so the requirement presumably comes from classic branch protection, which the App cannot read. The remembered 405 is the signal the hive has.

Change

  • MergeQueueBases tracks holds separately. Each entry now keeps two times: refused, the last 405, and held, the last time the base gate skipped an update on that base.
  • New HoldBaseRefresh(repo, base, now). It is true for 24h after the last refusal (mergeQueueBaseRefreshHold) and marks the base held. Required is true within 30 minutes of either time and drops the entry after 24h.
  • currentBaseGate (automerge_current_base.go) returns "proceed, no update" when the head is behind and the base holds refreshes. This check sits before the update-budget check, and all three lanes go through it. The sweep then holds the PR at merge-queue-required after the review gate, as it already does for a current head.
  • Why a hold does not extend the refusal. A removed queue rule must still be noticed:
    • A current head re-probes with a direct merge once no behind head has been held for 30 minutes.
    • With no new 405, the gate goes back to updating after 24h.
    • Marking holds also keeps a behind head from re-probing with a direct merge of a stale head. If the queue rule had been removed, that probe would merge past auto_merge.require_current_base.
  • Unchanged: normal bases, and the strict mergeable_state == behind update paths.
  • Docs: operator-reference.md (the require_current_base row) and labels-and-control-signals.md (the merge-queue-required row).
  • Changelog: changelog.d/fixed-no-base-sync-on-merge-queue-base.md.

Testing

From src/, TZ=UTC, -count=1:

  • go test ./pkg/github/automerge/ passes, as do the MergeQueue / MergeEligib tests in ./cmd/hive/.
  • gofmt and go vet are clean.
  • The changelog, docs-links and docs-citations checks pass.
Test Covers
TestCurrentBaseGateMergeQueueBase A normal base is updated. A merge-queue base 10m and 1h41m after the refusal, with or without update budget, gets no update-branch. After 24h the base is updated again.
TestSelfAuthoredLaneNoBaseRefreshOnMergeQueueBase A finpilot#599 replay: no update at +1h41m or +5h45m, no stale-head probe, a current head re-probes, and the hold re-arms while refusals keep coming.
TestSelfAuthoredLaneMergeQueueRuleRemoved After 24h with no new 405, the base is updated and merged again.
TestMergeQueueBasesHoldBaseRefresh The memory's windows and expiry.

Mutation checks

Seven mutants, each restored from a backup copy, and every one fails a test:

  • the gate skip removed;
  • holds not marked;
  • Required ignoring holds;
  • a 30m window instead of 24h;
  • a hold extending the refusal;
  • the check moved after the budget check;
  • no 24h expiry.

Not verified, or still open

Contributor checklist

  • Changelog: changelog.d/fixed-no-base-sync-on-merge-queue-base.md.
  • Targets v6.
  • The title uses the emoji convention.
  • Commits include DCO sign-off.
  • Docs updated (src/docs/operator-reference.md, src/docs/labels-and-control-signals.md).
  • No secrets, credentials or local runtime state are committed.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…ly base

With auto_merge.require_current_base on, the current-base gate updated a
behind head with update-branch (`base-moved`) before the sweep learned
that the base only accepts merges through GitHub's merge queue, which the
hive cannot use. On projectbluefin/finpilot#599 that happened three times
in a day: each update moved the head off its review verdict, the PR
waited 16m-1h27m for a fresh review, and then held at
merge-queue-required again. The 30-minute merge-queue memory had expired
between refusals, so the gate went back to updating.

The gate now leaves a behind head alone when its base refused a direct
merge as merge-queue-only within the last 24 hours
(MergeQueueBases.HoldBaseRefresh). Each such hold also keeps Required
true for another 30 minutes, so the sweep holds the PR at
merge-queue-required after the review gate instead of probing the base
with a direct merge of a head that does not contain it. A hold never
extends the refusal itself: the direct-merge probe still runs on a head
that is current, a new refusal re-arms the 24 hours, and with none the
gate updates again, so a removed queue rule is picked up.

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 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/L Denotes a PR that changes 100-499 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: 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
#15029 ✨ feat(contribute): record the blocker a relay's blocked verdict names same files src/docs/labels-and-control-signals.md
#14945 πŸ› fix: release label-blocked serialized lane fronts during sweeps same files src/docs/labels-and-control-signals.md
src/pkg/github/automerge/automerge_sweep.go
#14947 πŸ› fix: reject auto-merge queues from untrusted merger identities same files src/pkg/github/automerge/automerge_sweep.go
#15035 πŸ› fix(automerge): hold merges whose closing keywords would close the wrong thing same files src/docs/labels-and-control-signals.md
src/pkg/github/automerge/automerge_sweep.go

@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@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.

Failing checks:

  • check-failure

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.

Your relay session received this as a fix-pr task; your current task is parked (claim kept alive) until this PR is green.

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@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 plus automerge_sweep.go at 191650f. The mechanism holds together and looks correct to me; one low-severity observation on the chosen window.

What I verified

  • Ordering is right for the hold to bite: currentBaseGate runs at automerge_sweep.go:1823 and :2379, and knownMergeRefusal at :1889 / :2407 β€” so HoldBaseRefresh (automerge_merge_queue_bases.go, new) marks held = now before Required is consulted, and the behind head lands at merge-queue-required instead of being re-probed with a stale head. That is the property the long comment on HoldBaseRefresh promises, and TestSelfAuthoredLaneNoBaseRefreshOnMergeQueueBase / TestMergeQueueBasesHoldBaseRefresh pin it.
  • Note now does entry := m.seen[key]; entry.refused = now so a fresh 405 preserves an existing held; Required deletes only on refused β‰₯ 24h, and HoldBaseRefresh never extends refused β€” so a base with no new refusal does return to updating after mergeQueueBaseRefreshHold, as the comment says.
  • Rule-removed path (TestSelfAuthoredLaneMergeQueueRuleRemoved): a current head on a base with no recent held still probes with a direct merge and merges.

Low β€” a behind head that is swept every tick keeps held fresh, so a current head on the same base is never probed for up to 24h. Required returns true when now - max(refused, held) < 30m (automerge_merge_queue_bases.go, Required), and every sweep of any behind PR on that base calls HoldBaseRefresh, which resets held = now. With one long-lived behind PR open, a current head on that base is held at merge-queue-required tick after tick, so a removed queue rule is noticed only when the 24h refused expiry fires β€” not within 30m as the mergeQueueBaseRefreshHold comment ("when no head on that base is current to probe it") implies. Not a defect against the finpilot#599 symptom you are fixing, and strictly better than the old 30m memory for that case; just noting the comment overstates how quickly a current head gets to probe. If you want current heads to keep probing, Required could ignore held when the head being evaluated is not behind β€” but that is a call for you, not a blocker.

Changelog fragment and both docs tables are updated to match.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 2db8805 into hivecommons:v6 Oct 28, 2026
109 of 120 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#15038191650f` sha256:9bd6dcd35d58d3983eadfc63537ed100f10655321000efb4a9b3fec362c362e5 β€” download from the dashboard or `hivectl review evidence #15038`.

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

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@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 v6 with automerge_sweep.go:1800-1850 (self-authored flow) and automerge_merge_refusal.go:118-124. Looks correct to me.

  • The stale-head probe the doc comment worries about cannot happen: a behind head that currentBaseGate lets through (automerge_current_base.go, new mergeQueueBaseHoldsRefresh branch) has just set held = now, so when the merge attempt reaches knownMergeRefusal β†’ mergeQueueBaseKnown β†’ Required, last = held and now.Sub(last) < mergeQueueBaseRecheck is true β†’ merge-queue-required, no direct merge. A current head skips the hold branch (behindBy <= 0 returns first), so held is not refreshed by it and the probe resumes once no behind head has been held for 30m β€” matching the body.
  • Required and HoldBaseRefresh both drop the entry at 24h from refused, and a hold never writes refused, so a removed queue rule is bounded by mergeQueueBaseRefreshHold as stated.
  • Note preserves held on re-refusal (reads the existing entry before writing refused); fine.
  • No time.Sleep( added under pkg/ tests.

One operational note, not a defect: while any behind PR on a merge-queue base is swept every tick, held is pinned, so a current PR on the same base is also held at merge-queue-required and never probes; the 24h cap is then the only re-probe path. That is what the body describes, just worth knowing when reading a merge-queue-required hold on a PR that is up to date.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off 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