Skip to content

πŸ› fix(stage-labels): a merge-guard refusal no longer moves a PR parked at 085 back to 080 - #17012

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/merge-guard-stage-flap
Nov 7, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/merge-guard-stage-flap

Conversation

@Danathar

@Danathar Danathar commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

A PR parked at 085 on a red check flipped to 080 every time a contributor-lane pass was refused the destination-merge lock. The lane reports that refusal (base-refresh:merge-guard) together with its error. The classifier handled errored lanes before it checked for this reason, so an approved head read as "waiting for merge admission" (080). That 080 replaced the standing 085, put the red PR at the front of a merge train, and the next normal pass moved it back. The refusal now has no stage opinion, error or not. Small change: one early return in ClassifyStage, plus a replay test.

What went wrong

projectbluefin/utah-packages#917 is a fork PR with an approve verdict, and its required Canary check is red and fork-guarded (only a maintainer's exact-head run can clear it). The head stayed at 7e52182c0 all day. The label timeline shows 085 β†’ 080 β†’ 085 about 15 times between 12:02Z and 16:11Z on 2026-11-07. Each 080 lasted 1–3 minutes.

Live log for one round trip (hive build 729baa9):

  • 16:09:04 contributor lane: required-check-failing:Canary
  • 16:09:11 contributor lane (the other sweep): base-refresh:merge-guard, error "destination merge already in progress"
  • 16:09:25 / 16:09:47 stage written as 080, reason base-refresh:merge-guard
  • 16:10:40 merge train: front 917, ahead of 921 and 942
  • 16:11:22 / 16:11:36 next evaluated pass puts it back at 085, reason fork-guard:Canary

"Merge guard" here does not mean a base refresh was attempted. The engine ticker and the queued sweep both evaluate PRs. Each takes a per-destination lock (AcquireDestinationMerge, keyed on repo and base) before reading a PR. When the other sweep holds it, the lane gives up straight away and returns base-refresh:merge-guard with ErrDestinationMergeBusy. #16819 made that reason a no-opinion hand-off, but only for an observation recorded without an error. In ClassifyStage the o.Err branch came first, and AuthorSideDone (approved, no CI reason) returned a weak 080. Nothing else had an owned opinion that pass, so the weak 080 was written.

On v6 tip the #16881 reversal guard and the #16980 dampener do not stop this shape. The replay test below fails on tip at the first refusal, and in a scratch run it wrote 080 again on every later refusal pass. #924 shows the same flip on the same passes (080 base-refresh:merge-guard / 085 contributor-lane:workflow-path).

What changes

  • ClassifyStage returns no opinion for base-refresh:merge-guard before the errored-lane branch, so the refusal never outranks the stage the PR already has.
  • The stage-labels doc row for this reason now says the rule holds even when the lane reports an error.
  • Corrected two stale derive_pr_classify.go line citations in the stage-engine docs. They already pointed at the wrong lines on tip.

Files

  • src/pkg/stageengine/derive_pr_classify.go
  • src/pkg/github/automerge/automerge_stage_merge_guard_err_test.go (new)
  • src/docs/labels-and-control-signals/stage-labels.md, src/docs/adr/0025-central-stage-engine.md, src/docs/stage-engine-plan.md
  • changelog.d/fixed-merge-guard-stage-flap.md

Tests

  • TestMergeGuardRefusalKeepsForkGuardedPRAtNeedsDecision replays the fix: contribute page Docker/local mode + HTTP copy fallbackΒ #917 shape: a fork head, an approve verdict and a fork-guarded red required Canary. Evaluated passes alternate with merge-guard passes recorded exactly as the lane records them, error included. The gaps are 70 s to 50 min, so the replay runs both inside and outside the reversal-guard and dampener windows. The PR must stay at 085 with fork-guard:Canary, and 080 must never be added. It fails on v6 tip (3d7e6be) at pass 1 and passes with the fix.
  • TestErroredMergeGuardIsNoStageOpinion is the classifier unit check. It fails on tip (weak 080) and passes with the fix.
  • Full packages pass: ./pkg/stageengine/..., ./pkg/github/automerge/, ./pkg/stagelabels/. go vet is clean. The docs citation and link checks pass.

Not in this PR

Refs projectbluefin/utah-packages#917, Refs #16819

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…85 PR to 080

projectbluefin/utah-packages#917 (fork PR, approve verdict, fork-guarded red
required Canary, head 7e52182c0 unchanged) went 085 -> 080 -> 085 about 15
times on 2026-11-07. Each 080 came from a contributor-lane pass refused the
destination-merge lock ("destination merge already in progress", another
sweep was evaluating a PR into the same base). The lane records that as
base-refresh:merge-guard with the error, so the observation is Err, and
ClassifyStage's errored-lane branch ran before the hand-off check that
hivecommons#16819 added: approve verdict + no CI reason = a weak 080. The 080 seated
the red PR at a merge train's front until the next evaluated pass.

The refusal is now no stage opinion whether or not the lane reports an
error. The reversal guard (hivecommons#16881) and the dampener (hivecommons#16980) on v6 tip do
not stop this shape: the replay test fails on tip at the first refusal.

Also corrects two stale derive_pr_classify.go citations in the stage-engine
docs.

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 Nov 7, 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 clubanderson 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 Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 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.

No conflicting open PRs or same-file overlaps were found.

@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 classifier at src/pkg/stageengine/derive_pr_classify.go on v6 and the four lane sites that emit the reason. The mechanism described here is real and the fix is in the right place.

  • stageHandoffReasons already lists base-refresh:merge-guard (derive_pr_classify.go:260), but that table is consulted at line 375, after the if o.Err branch at line 353.
  • Every lane returns the refusal together with its error β€” automerge_contributor_lane.go:1659, automerge_sweep_queued.go:25, automerge_sweep_trusted.go:26 and :648 β€” and recordStage sets Err: err != nil (automerge_stage_labels.go:562), so the observation always took the errored branch, where AuthorSideDone turns an approved head into a role-rank 080.
  • The new early return sits after the supersession check and before o.Err, so terminal/supersession handling is untouched, and the non-error path for this reason (already "no opinion" via the hand-off table) is unchanged. stage-labels.md already documented this reason as "no opinion"; the code now matches the doc.

TestErroredMergeGuardIsNoStageOpinion is the minimal regression test and TestMergeGuardRefusalKeepsForkGuardedPRAtNeedsDecision replays the #917 cadence through ApplyStageLabels. Looks correct to me.

Note for whoever merges: Sign-off survives the squash shows CANCELLED on this head and coverage has not reported β€” a re-run rather than a code problem as far as I can see.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 2d80e41 into hivecommons:v6 Nov 7, 2026
72 of 75 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Evidence bundle `#17012922376d` sha256:07a7d4f46f04b93013ea82adce1776b80ffb885494ce87fc26c4c303aba41121 β€” download from the dashboard or `hivectl review evidence #17012`.

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