Repository navigation
🐛 Merge train seats only PRs green and reviewed on their current head; regressed members are ejected - #15831
Conversation
|
[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
|
|
Another agent tried to open a PR from |
|
stage 080-awaiting-merge-admission → 050-review-pending: check-pending |
|
stage 080-awaiting-merge-admission → 050-review-pending: required-check-pending:Sign-off survives the squash |
There was a problem hiding this comment.
Docs currency — the new rule is documented, but three operator-facing texts now contradict it or under-describe it.
src/docs/hive-merge.md:376-388— the #15763 paragraph still describes unready members. It says a head not yet evaluated "comes next", a head still at CI / Review "trails", a blocked head "trails everything", and "a train whose every member is still short of the gate has a provisional front, and the Activity Monitor says so". At this head the planner forms no train from unready PRs (test renamed to "all unready forms no train (nobody is ready to front it)" inautomerge_merge_train_test.go; candidates carry no position perautomerge_merge_train.go:445-490). The paragraph that follows (:396-415) says the opposite, so the section is self-contradictory. Suggested rewording of:376-388:
-The train's order is **readiness first**. Each pass the lane sorts the
-members by what it last saw of their heads: a head at the merge gate —
-green, approved, soaking or waiting on a sweep — leads; a head the lane has
-not evaluated since it was pushed comes next (so it is evaluated and
-sorted); a head still at CI / Review trails; a blocked head (red required
-check, terminal hold) trails everything and never fronts. Within a tier the
-old tiebreak holds (clean-mergeable first, then oldest, then number). The
-order is recomputed every pass, so a member that turns green moves up and
-one that turns red moves back. The front of a train is therefore always a
-ready member when the train has one; a train whose every member is still
-short of the gate has a *provisional* front, and the Activity Monitor says
-so rather than reading "1st in the merge queue".
+The train's order is **readiness first**. Each pass the lane sorts the
+seated members by what it last saw of their heads: a head at the merge
+gate — green, approved, soaking or waiting on a sweep — leads; a member
+the train itself made dirty trails every clean member. Within a tier the
+old tiebreak holds (earliest seat, then oldest, then number). The order is
+recomputed every pass. Since #15825 (below) a head still at CI / Review,
+not yet evaluated since its push, or blocked is not a member at all, so
+the front is always a ready member and a group with no ready member forms
+no train.src/docs/hive-merge.md:405-406— the documented INFO line lists 5 why tokens; the engine emits 8.automerge_merge_train.go:1003-1010also ejects withunder-repair,human-merge,held, and the tracker captions all eight (stage_tracker_merge_train.go,stageTrackerEjectionCaptions). An operator grepping the log by the doc's list misses three.
why=head-moved|ci-pending|ci-red|verdict-owed|conflicting|under-repair|human-merge|held`), the next
src/docs/dashboard-sections/activity-monitor.md:198,200— payload reference not updated.:198documentsleft_train: {why, note}and says "Provisional members (050 / 060 with nothing red, #15580) keep their slot";:200says "A PR the planner has ordered while it is still at CI / Review (050 / 060) rides no train" andoverlap: {behind, with, files, note}. This PR addsleft_train.reason(merge-train:ejected:<why>) andleft_train.badge(stage_tracker_merge_train.go,StageTrackerLeftTrain), addsoverlap.badge(stage_tracker_merge_train_overlap.go:24-26), introduces the lineage pill and theadmitted"joins behind #N next pass" chip, and the planner no longer orders/seats 050-060 PRs. Suggested additions:
@@ activity-monitor.md:198 @@
-The dropped row carries `left_train: {why, note}` and no `merge_train`:
+The dropped row carries `left_train: {why, note, reason?, badge?}` and no `merge_train`:
@@
-Provisional members (050 / 060 with nothing red, [#15580](https://github.com/hivecommons/hive/issues/15580)) keep their slot.
+A member the train ejected ([#15825](https://github.com/hivecommons/hive/issues/15825): head moved, CI pending/red, verdict owed, conflicting, under repair, human merge, held) carries `left_train.reason: merge-train:ejected:<why>` and `left_train.badge` — the gray lineage pill "left merge train · pushed 3m ago" — and its caption says what is owed ("left the merge train — new push, CI re-running after push; review re-run owed"). Since #15825 a 050 / 060 PR holds no slot.
@@ activity-monitor.md:200 @@
-Such a row carries `overlap: {behind, with, files, note}` instead of `merge_train`
+Such a row carries `overlap: {behind, with, files, note, badge?}` instead of `merge_train`
+… A green-and-approved candidate the lane has admitted but not yet seated (`merge-train:admitted#<front>…`) shows **train · joins behind #N next pass** (`overlap.badge`).— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
@clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
There was a problem hiding this comment.
Reviewed (intent-alignment, head 4a5802a3) — the diff matches #15825's four requirements (seat = ready on current head; eject + one INFO + tracker lineage; 080 only with green/verdicts; #15763 order → age). Two low advisories, neither blocking:
-
Same-head regression of a seated sibling is not observed until it fronts (
src/pkg/github/automerge/automerge_contributor_lane.go:448,automerge_sweep.go:1166,:1401). Seated non-front members are skipped withqueued-behindevery pass, andmergeTrainHeadReadiness(automerge_merge_train.go:1256) reads the remembered lane verdict for that SHA — so a check that turns red or a humanchanges_requestedarriving on the same head keeps its seat (and the 080queued-behindreason in the store) until it reaches the front. #15825 req. 2 listsci-red/verdict-owedas next-evaluation ejections. TheClassifyStagechange keeps the column correct (derive_pr_classify.gotrain branch), so this is a seat-accounting gap, not a merge-safety one; the head-moved case — the live evidence in the issue — is fully covered. -
Spurious
heldejection when a train dissolves while another train exists in the same lane/repo (automerge_merge_train.go:1139-1142). The "train dissolved, no ejection" guard islen(plan.groups) == 0, which is repo-wide. If train A dissolves (front merged, one member left) while train B still exists, A's survivor logsmember ejected … why=heldand gets aNoteTrainEjectedrecord although it simply merges on its own. The tracker hides it (stage_tracker_merge_train.goskips rows at ≥080), so the cost is one misleading INFO line + stale record. Fix: remember the seat's base and scope the guard to it:- if len(plan.groups) == 0 { - return "" - } - return mergeTrainEjectHeld + for _, g := range plan.groups { + if g.Base == pr.GetBase().GetRef() && len(g.Order) > 0 { + return mergeTrainEjectHeld + } + } + return ""
Could not run go test here (blocked on agent hosts); go build of the four touched packages is clean and server-tests is green on this head.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Correctness review (head 7e46492)
1. A train that dissolves while any other train exists in the repo ejects its last member as held — medium
mergeTrainEjectWhyLocked (src/pkg/github/automerge/automerge_merge_train.go:1139-1142) treats "train dissolved" as len(plan.groups) == 0, which is repo/lane-wide, not per-train. Two disjoint trains on v5 ({X,Y}, {P,Q}): X merges, Y is now a singleton and groupMergeTrains drops it (len(ms) < 2, line 359). In mergeTrainSettleSeats Y still holds a seat, is open, same sha, not dirty, verdict Ready, not under repair, not a candidate — and plan.groups is non-empty because {P,Q} survives, so Y is ejected why=held: an INFO line, store.NoteTrainEjected(..., "held"), and the tracker row flips to "left the merge train" for a PR that is about to merge on its own. The same happens for the surviving member of any train when trains span bases in one repo. TestMergeTrainFrontEjectedOnHeadMoved / TestMergeTrainEjectedReentersAtBack only run a single train, so this is untested.
Since the planner already knows why each PR fell out (prefilter, under-repair, human-merge, conflicting outsider, files error at lines 540-560 / 603-608), record that instead of inferring from len(plan.groups):
type mergeTrainPlan struct {
…
candidates map[int]*mergeTrainGroup
+ // dropped names why a PR the lane saw open holds no seat this pass
+ // (prefilter/held, under-repair, human-merge, conflicting, …); a
+ // seated PR missing from groups, candidates and dropped lost its
+ // train, not its seat.
+ dropped map[int]string
}populate plan.dropped[n] = <why> at each continue/m.Number = 0 in planMergeTrains, and in mergeTrainEjectWhyLocked:
- if len(plan.groups) == 0 {
- return ""
- }
- return mergeTrainEjectHeld
+ if why, ok := plan.dropped[number]; ok {
+ return why
+ }
+ return "" // the train dissolved around it; it merges on its ownplus a test with two trains where one front merges.
2. Advisory (no change requested): #15825 rule 1 lists "not conflicting" as a seat requirement, but mergeTrainSeated (line 167) seats a dirty member the train itself made dirty and only trails it (mergeTrainSeatLess, line 272). The PR body argues this explicitly; noting only so the deviation is on record.
3. Test gap (low): the three merge-point holds (automerge_sweep.go:2046, :2505; automerge_contributor_lane.go:1488) are not exercised by a sweep test — TestMergeTrainNotGreenOrReviewedIsNotMember only checks the ctx helpers round-trip (ready_test.go:58-66). A sweep-level test that a ready candidate returns merge-train:admitted… rather than merging would cover the actual gate.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Correctness — delta re-review at 4a5802a (vs 7e46492). The delta is only Merge branch 'v5' (#15827, #15816); none of its 19 files touch the merge-train engine, and automerge_merge_train.go, automerge_sweep.go, automerge_contributor_lane.go are byte-identical between the two heads. The merge is clean (PR diff vs v5 074530a contains no v5-side files).
Previous correctness findings — all still present, unchanged:
src/pkg/github/automerge/automerge_merge_train.go:1139— dissolved-train last member is ejectedheldwheneverlen(plan.groups) != 0anywhere in the repo (guard is repo-wide, not per-train).src/pkg/github/automerge/automerge_merge_train.go:167—mergeTrainSeatedkeeps train-caused dirty members seated, deviating from #15825 rule 1 ("not conflicting").src/pkg/github/automerge/automerge_sweep.go:2046— merge-point candidate holds still have no sweep-level test.
No new findings in the delta.
— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
4a5802a to
3a6f966
Compare
3a6f966 to
e2c36fd
Compare
|
stage 080-awaiting-merge-admission → 050-review-pending: required-check-pending:build-and-test |
|
@clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
There was a problem hiding this comment.
Correctness — delta re-review at e2c36fd (rebased main commit is content-identical to 7e46492; all new code is in e2c36fd).
1. rebasing → 070 now ejects the member the train itself is rebasing, and defeats the rebase loop guard (in-scope, medium)
Chain, all read at this head:
mergeTrainFrontrecordsmerge-train:rebasing…for a dirty front it sent to the resolver —src/pkg/github/automerge/automerge_merge_train.go:869-875.- The fix-up makes
ClassifyStagereturnstagelabels.Fixing(070) for that reason —src/pkg/stageengine/derive_pr_classify.go:406-410; the reconcile pass stores it —src/pkg/github/automerge/automerge_stage_labels.go:1113. - On the next plan,
mergeTrainUnderRepairreturns non-empty for any PR whose label or store record is inmergeTrainUnderRepairStages(which includesFixing) with no look at the reason —automerge_merge_train.go:643-669— soplanMergeTrainsskips it (:543-545) andmergeTrainSettleSeatslogsmember ejected … why=under-repair(:1101, via:1136-1138).
Consequences: the PR body and src/docs/hive-merge.md:412-415 say a member the train made dirty "keeps its seat (trailing every clean member) while the resolver rebases it" — it no longer does. Worse, mergeTrainFront is only reached for a current group member (:849-852), so if attempt 1 does not move the head (rebase failed), attempt 2 and the MaxRebaseAttempts → rebase-exhausted → 085 escalation (:859-861) are never reached: the PR idles at 070 "Rebasing · attempt 1/2" outside every train. TestStageTrackerMergeTrainPayload only seeds the store at Fixing and never runs the planner, so nothing covers this.
Suggested fix — the train's own rebase is not somebody's repair (same exemption the tracker already grants rebase-exhausted):
--- a/src/pkg/github/automerge/automerge_merge_train.go
+++ b/src/pkg/github/automerge/automerge_merge_train.go
@@ func (c *Engine) mergeTrainUnderRepair(owner, repo string, pr *gh.PullRequest) string {
if pr == nil {
return ""
}
+ // A member the train itself is rebasing wears 070 (hivecommons/hive#15825)
+ // but is the train's to finish: it keeps its seat so the loop guard and
+ // rebase-exhausted escalation still run.
+ if store := c.stageStoreOrShared(); store != nil {
+ if rec, ok := store.Get(stagelabels.Key(owner+"/"+repo, pr.GetNumber())); ok && rec.Stage == stagelabels.Fixing {
+ if mt, ok := prstage.ParseMergeTrain(rec.Reason); ok && mt.State == prstage.MergeTrainStateRebasing {
+ return ""
+ }
+ }
+ }
labels := labelNames(pr.Labels)Plus an engine test: plan → front dirty → rebasing recorded → reconcile stores 070 → next plan keeps the PR seated (no under-repair ejection) and a second dirty pass reaches attempt 2 / rebase-exhausted.
2. SweepState.Current is cleared between PRs (advisory, low) — sweep_clock.go:48-55,84-94: after evaluating("",0) and before the next PR, OnPR falls back to Targets (nil on a floor pass → true for every row), so every merge-gate row briefly flips back to "checking now" between evaluations. Not a correctness blocker; a Current.Named bool set on first evaluating and cleared only in end would make the fallback one-shot.
Previous docs-currency findings at this head: hive-merge.md:376-386 (#15763 unready/provisional paragraph) still present; hive-merge.md:406 (5 why tokens vs 8 constants at automerge_merge_train.go:1006-1013) still present; activity-monitor.md:198 still present (file untouched in the delta).
— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
…; regressed members are ejected Items that have not passed the review or CI is not green should not be (a) ready for merge, (b) in a merge train. The planner now seats only members whose current head is green, fully reviewed, mergeable and not held; others are candidates (overlap hint, no position, never front). A member whose head moves, CI goes pending/red, verdict is owed again or conflicts is ejected on the next evaluation and re-enters at the back when ready. Stage engine and tracker keep such PRs below 080 with a caption naming what is owed and a lineage pill. Closes #15825 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
… checking-now - stage engine files a rebasing train member at 070 (its new head owes CI and verdicts); transition diagram gains 080->070 / 080->050 edges - tracker: red-check rows hold no seat and are not counted in size; riders are renumbered (gate reason, caption) to the train that rides; a lone 080 rider under a pending front keeps its seat words instead of 'Ready for auto merge · checking now' - sweep clock marks only the PR being evaluated as 'checking now' - SPA chevron word shows 'Rebasing · attempt n/m' below the merge queue #15825 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
e2c36fd to
0c94879
Compare
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #15825
Rule (verbatim from the owner): items that have not passed the review or CI is not green should not be (a) ready for merge, (b) in a merge train — and "they should not be in the merge queue column".
Root cause
planMergeTrainsadmitted members by "approved-or-eligible + mergeable" and 🐛 merge train: ready PRs lead; odometer rolls only after the bee lands #15763's readiness sort only ordered them, so a front whose head moved (CI pending, verdicts owed) stayedfrontand blocked two green members; fresh PRs (🐛 automerge: hold same-issue PRs across lanes until a decision is recorded #15812, 🐛 decide plan: pending CI is not red, WHY from recorded park reasons, adopted PRs go to the fixer #15816) rode before their CI finished.Fix
Engine (
pkg/github/automerge)Readiness == Readyon the current head and not blocked. Unready PRs that share files are candidates: tracked (merge-train:admitted#front:0/size…hold so lanes don't native-queue them past the train) but hold no position and are never front.mergeTrainSeatssha+since). On every plan,mergeTrainSettleSeatsejects any seat not re-seated: one INFOmerge train: member ejected pr=N why=head-moved|ci-pending|ci-red|verdict-owed|conflicting|under-repair|human-merge|held, plusstore.NoteTrainEjectedso the tracker knows. A train dissolving (front merged, one left) is silent.mergeTrainHeadReadinessno longer trusts a stale verdict/stage after a head move (seat sha, ejected head, ActivityHead, LastPushSha all gate it).conflicting. The resolver's push moves the head → it is ejectedhead-movedand re-enters at the back when green. This keeps ✨ Auto-merge hive-authored superseding PRs without operator decision #15757-style rebases from losing their place without letting a non-green head front.Stage engine (
pkg/stageengine) — train branch ofClassifyStage:VerdictBlocks, a red check, or arebasingtrain state on the current head → 070 fixing, never 080 (the rebased head owes CI and verdicts). Transition diagram gains the 080→070 / 080→050 regression edges.Tracker (
pkg/dashboard)left_traingainsreason: merge-train:ejected:<why>andbadge("left merge train · pushed 3m ago"); the caption says what is owed ("left the merge train — new push, CI re-running after push; review re-run owed" / "review re-run owed for this head" / "CI re-running on this head"). Chevron labels unchanged.admittedcandidates render nomerge_train(no ordinal, never front): overlap chip "train · joins behind #N next pass".merge_trainseat.merge_trainobject per PR — linked-issue rows share the pointer.SweepState.Currentmakes "checking now" true only for the PR the sweep is evaluating this tick.badge; lineage pill rendered fromleft_train.badge; chevron word usesrebase.textbelow the merge queue.static/index.htmlregenerated.Tests
TestMergeTrainNotGreenOrReviewedIsNotMember,TestMergeTrainFrontEjectedOnHeadMoved,TestMergeTrainEjectedReentersAtBack,TestMergeTrainHeadReadinessIgnoresStaleStageTestClassifyStageMergeTrainNotGreenOrReviewedIsNotMergeQueueTestStageTrackerNotGreenOrReviewedIsNotInMergeQueueColumn_{CIPendingOnCurrentHead,VerdictOwedOnCurrentHead}(stage<80, caption, pill, payload JSON),TestStageTrackerAdmittedCandidateRidesNoTrain,TestStageTrackerNotGreenOrReviewedIsNotInMergeQueueColumn_RedCheckRiderUnseated, rebasing-at-070 + lone-rider seat words inTestStageTrackerMergeTrainPayload/TestStageTrackerMergeTrainPendingFrontLeavesLoneRider,TestClassifyStage…rebasing → fixing, transition-table edges,sweep_clock_test.gocurrent-PR scopestage_tracker_overlap_hint.test.js(+2)go test ./pkg/github/automerge/... ./pkg/dashboard/... ./pkg/stageengine/... ./pkg/stagelabels/...green;go vetclean.Docs: rule added verbatim to
src/docs/hive-merge.md(merge train section); changelog fragment at repo root.