Repository navigation
π fix(stage-labels): stop PR stages flipping between two sweeps' passes - #16819
Conversation
projectbluefin/utah-packages, 11-05 21:10-21:29Z: hivecommons#878 070<->072, hivecommons#873 080<->090 and hivecommons#869 080<->085 flipped every pass with head, checks and labels unchanged. The engine's ticker and the queued sweep reconcile alternate passes from one stage tracker: - base-refresh:merge-guard (lane skipped the PR: a merge to its destination was in flight) classified as an owned base-refresh stage and overwrote the other sweep's stage. It is now a no-opinion hand-off reason. - the self-authored lane runs only in the ticker, so the queued sweep's contributor lane overwrote its stage for the same head. The tracker now remembers the lane and head that set the stage; a lower lane's different stage waits while that lane is absent, up to 30 minutes, never across a new head or a terminal outcome. 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>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read this against the tree at merge-base plus the callers; it looks correct to me. No defects found.
What I checked:
- Owner timestamp cannot go stale while the owning lane keeps reporting. My first worry was that
noteOwnerruns only after a write (automerge_stage_labels.go:1471-1473), so an unchanged 070 every pass might never refreshAtand the hold would lapse afterstageOwnerAbsenceGrace(30 min). It does not: nothing between the hold check (:1045) andpending = append(...)(:1437) skips an unchanged stage β the onlycontinues are the reporter-trust release and supersession-close paths β so an owned observation reachesReconcileBatchevery pass andAtis refreshed whether or not a label moved. - The hold cannot pin a stage.
stageOwnerHolds(:299-315) returns false on a new head, a terminal verdict, the same stage, a stage another writer moved (current != owner.Stage), an owner that reported this pass (listis this pass's drain,:373), an owner that does not outrank, and past the grace.stageLanePrecedence(:244) has only self/trusted/contributor, so unlisted lanes compare0 <= 0and never hold β covered by the "lanes without precedence never hold" row. base-refresh:merge-guardas a hand-off reason.basePreparationPrefix + "merge-guard"(automerge_base_preparation.go:21, emitted atautomerge_contributor_lane.go:1610,automerge_sweep_queued.go:25,automerge_sweep_trusted.go:26,648) matchesprstage.StageReasonBaseRefreshMergeGuardexactly, andslogfeed.go:254already treats the same string as "not an opinion". Adding it tostageHandoffReasons(derive_pr_classify.go:260) is consistent with how the other no-look reasons are handled.- The
TestStageOwnerHoldstable (11 rows) plusTestMergeGuardPassKeepsTheStage/TestAbsentOwningLaneKeepsTheStagecover the flap shape from utah-packages#878 and the grace expiry.
Not approving (that's a human signature); just confirming the read.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦85 PR to 080 (#17012) 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 #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 (#16881) and the dampener (#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. Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
β¦19381) GitHub reports mergeable_state "unknown" while it recomputes a merge, and the contributor lane then stops before admission, review or CI with reason mergeable-unknown. The stage engine read that as an approved head with nothing left for its author (a weak 080), and another lane's weak opinion could stand in for the silent contributor lane, so an unchanged head dropped for one pass: projectbluefin/utah-packages#1222 went 090 -> 080 -> 090 on a no-linked-issue refusal, and a conflicting PR at 072 could read 090. mergeable-unknown is now "no opinion", like base-refresh:merge-guard (#16819): ClassifyStage abstains, ResolveStage drops other lanes' weak opinions on such a pass (an owned opinion still applies), and the merge train keeps the head's human-merge verdict instead of clearing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Executive summary
After stage labels started being written on contributor PRs (11-05 21:09Z), three projectbluefin/utah-packages fork PRs flipped stage on every pass for about 20 minutes, with head, checks and labels unchanged:
The hive log shows the cause. Two sweeps, the engine's own ticker and the main loop's queued sweep, feed one stage tracker and reconcile alternate passes, and each pass sees a different set of observations. This PR removes both ways that produced a different stage on alternate passes.
What
base-refresh:merge-guardfork-guard:Canary/contributor-lane:no-linked-issueLog evidence (build f0c02da,
stage labels reconciled):base-refresh:merge-guard; security: validate task_id on complete/fail + block reserved usernamesΒ #878 β 070, laneself-authored.fork-guard:Canary), fix: task assignment type assertion for []any itemsΒ #873 β 090 (contributor-lane:no-linked-issue), security: validate task_id on complete/fail + block reserved usernamesΒ #878 β 072 (lanecontributor-lane).Why
base-refresh:merge-guardis what a lane records when it skips a PR because a merge to the same destination is in flight ([selfreport] unclassified_error_repeated: automerge sweep skipped PRΒ #16520), and here that merge belongs to the other sweep.ClassifyStageread it like real base preparation, an owned stage, so the skipped pass overwrote the stage the other sweep had set.How
prstage.StageReasonBaseRefreshMergeGuardis added tostageHandoffReasons, next tofetch-pr, so it reads as "the lane did not look". With no other opinion the pass writes nothing; base preparation proper (base-refresh:preparing,queued-behind) still owns its stage.StageTracker.ownersremembers, per PR, the lane that set the stage just written, the head it was for and when it last reported; unlike the observations, it survivesdrain.stageOwnerHoldsskips the pass for that PR when all of these hold:selfAuthoredSweepMaxInterval).Files
src/pkg/stageengine/prstage/reasons.goStageReasonBaseRefreshMergeGuardsrc/pkg/stageengine/derive_pr_classify.gosrc/pkg/github/automerge/automerge_stage_labels.goStageTracker.owners,stageOwnerHolds, owner noted after the writesrc/pkg/github/automerge/automerge_stage_flap_test.gosrc/docs/labels-and-control-signals/stage-labels.md, changelogTests
TestMergeGuardPassKeepsTheStageTestAbsentOwningLaneKeepsTheStageTestStageOwnerHoldsTestMergeGuardIsNoStageOpinionpreparingstill owns a stagego testautomerge, stageengine, stagelabels, fleetreportcheck-docs-citations.pyNotes
π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1