From 7623e4f17f67f4092b2e49b8d72c28f07e033733 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 09:07:19 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20merge=20train:=20ready=20PRs?= =?UTF-8?q?=20lead;=20CI/Review=20members=20join=20behind=20the=20ready=20?= =?UTF-8?q?front?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lane's train planner ordered members by GitHub mergeable state, age and number, never by hive's own readiness, so a PR still at 050 CI/Review could front a train and hold fully green 080 members behind it (owner: "if 15471 is in ci/review, how can it be first in a train?"). - automerge: members carry a readiness tier (ready / unknown / unready) learned from the lane's last verdict or the stage store; the sort puts ready members first, then unknown, then unready, before the existing mergeable-state / age / number tiebreaks. Re-sorted every pass. - dashboard: a below-queue member's overlap hint points at the riding (ready) front; the chip reads 'train · joins behind #N when green' in the member's real column, never a Merge-queue chip. An all-unready train says it is provisional. - docs: hive-merge.md 'Merge train: ready PRs lead'; operator-reference. - tests: ordering table cases, readiness memory, column placement, chip wording under node. Signed-off-by: Andrew Anderson --- src/docs/hive-merge.md | 32 +++++ src/docs/operator-reference.md | 2 +- .../stage_tracker_merge_train_overlap.go | 48 ++++++-- .../stage_tracker_merge_train_overlap_test.go | 100 +++++++++++++++- .../stage_tracker_merge_train_postpass.go | 13 ++ .../static-src/js/tracker-words-core.js | 30 +++-- src/pkg/dashboard/static/index.html | 30 +++-- .../github/automerge/automerge_merge_train.go | 112 ++++++++++++++++-- .../automerge/automerge_merge_train_test.go | 112 ++++++++++++++++++ src/pkg/stageengine/derive_pr_classify.go | 9 +- 10 files changed, 440 insertions(+), 48 deletions(-) diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 64017a3d19..437196f78b 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -356,6 +356,38 @@ gate, saying it will wait for a human. The rule exists because a ⚠️-titled PR was auto-merged by the trusted-author lane while its owner was still deciding whether to ship it. +### Merge train: ready PRs lead + +Every lane groups its candidates on one base whose changed files overlap +into a **merge train** (`auto_merge.merge_train.*`, [#15117](https://github.com/hivecommons/hive/issues/15117)) +and merges one front at a time; the siblings park at stage/080 with lane +reason `merge-train:queued-behind#:/:…` and, the moment +the front merges, are update-branched (`behind`) or handed to the rebase +resolver (`dirty`) so the next front is evaluated on a current base. Hive's +own repo also runs the current-base gate (`require_current_base`), which +holds a behind head until the update lands; the two cooperate — the train +refreshes, the gate waits for the refresh. + +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". + +This replaced the age-first order after hive's own #15741, still at CI / +Review, led #15748 and #15755 — both green and queued at 080 — and nothing +merged until its checks finished. In the Activity Monitor only members at +080 and beyond ride a train chip in the *Merge queue* column; a member still +at CI / Review keeps its chevron in its own column with a muted +"train · joins behind #N when green" note. + ### Trusted-author auto-merge `auto_merge.trusted_authors` is a third, default-off sweep tier for diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index c5a4c1d3f6..03cad9a1e0 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -439,7 +439,7 @@ advanced into the merge path. | `auto_merge.require_current_base_default` | `false` | Hive-wide default of the current-base gate for repos in neither `require_current_base` nor `skip_current_base` (Settings → Features → Auto-merge → "Merge only on current base"). **Off** by default: the merge train already update-branches overlapping siblings, so the gate is being soaked per repo (hive's own hive first, via `require_current_base`) before any hive turns it on everywhere. When `true`, a behind head the App cannot update merges as it was tested, with one WARN per PR (`automerge current-base gate: … merging as tested`), so fork-heavy repos are not parked wholesale. | | `auto_merge.skip_current_base` | unset | Repo list (`owner/repo`) with an explicit **off** override for the current-base gate (Settings → Repos → "Merge only on current base" unchecked): a green head there merges even if the base has moved, whatever `require_current_base_default` says. An explicit `require_current_base` entry wins over this list. | | `auto_merge.merge_forward_trusted_human` | unset (off) | Repo list (`owner/repo`) where a `role/trusted` + `author/human` PR on a same-repo branch that GitHub reports as conflicting (`dirty`) gets the base merged into its head as one App-authored, signed-off merge commit via the GitHub merges API (no human commit is rewritten), then merges once CI is green on the new head. A real conflict pushes nothing and posts one `` note naming the files both sides changed. Fork heads are never written. Attempted once per head (#13636). | -| `auto_merge.merge_train.enabled` | `true` | Conflict-aware merge train in every automerge lane (hive, trusted-author, contributor) ([#15117](https://github.com/hivecommons/hive/issues/15117)). Each sweep groups the open approved / mergeable-pending PRs of one repo+base by overlapping changed files (`GET /pulls/{n}/files`, cached per head SHA) and lets ONE front per group merge — the clean-mergeable PR approved earliest — while the others wait at stage/080 with lane reason `merge-train:queued-behind#:/:…` (tracker pill "In merge queue · 3 of 4 · ~4m", never a human stage, never `needs-rebase` as a human flag). The moment the front merges, every sibling whose branch is merely `behind` gets `PUT /pulls/{n}/update-branch`; a `dirty` one is handed to the fixer's rebase-resolve episode (`requested_by: merge-train`, the shared two-attempt guard of [#15104](https://github.com/hivecommons/hive/pull/15104); the fixer router still requires a head the hive can push to, so a fork without maintainer edits stays on the plain `conflicting` path for a person). A head the lane last saw blocked on its own (red required check, terminal hold, permanent merge refusal) never fronts, and a group whose best member is blocked imposes no ordering (fail-open) — nobody waits behind a PR that is not moving. One INFO line `merge train` per order change, not per cycle. The queue carries one PR per issue: when two open PRs declare the same `Fixes #N`, the sweep keeps one (green first, then the earlier-opened) and holds the other with lane reason `merge-train:duplicate-of#:/0:0/0:` (tracker pill "Duplicate of #15402 · needs a pick"; *Let hive decide* supersedes, [#15395](https://github.com/hivecommons/hive/issues/15395)). `false` restores independent per-PR evaluation. A PR GitHub reports conflicting on its own, or one at stage/072 returned-to-contributor (label or stage record), is never a member nor counted in the train's size and draws no train idle comment; a conflicting PR rides only while the train itself is repairing it (its rebase requested behind a merged front, loop guard not spent) ([#15395](https://github.com/hivecommons/hive/issues/15395)). | +| `auto_merge.merge_train.enabled` | `true` | Conflict-aware merge train in every automerge lane (hive, trusted-author, contributor) ([#15117](https://github.com/hivecommons/hive/issues/15117)). Each sweep groups the open approved / mergeable-pending PRs of one repo+base by overlapping changed files (`GET /pulls/{n}/files`, cached per head SHA) and lets ONE front per group merge — ordered readiness first: a head the lane last saw at the merge gate (green, approved, soaking or waiting on a sweep) leads, one it has not evaluated since its push comes next, one still at CI / Review trails, then clean-mergeable before behind, then oldest; recomputed every pass, so a member that turns green moves up and one that turns red moves back — while the others wait at stage/080 with lane reason `merge-train:queued-behind#:/:…` (tracker pill "In merge queue · 3 of 4 · ~4m", never a human stage, never `needs-rebase` as a human flag). The moment the front merges, every sibling whose branch is merely `behind` gets `PUT /pulls/{n}/update-branch`; a `dirty` one is handed to the fixer's rebase-resolve episode (`requested_by: merge-train`, the shared two-attempt guard of [#15104](https://github.com/hivecommons/hive/pull/15104); the fixer router still requires a head the hive can push to, so a fork without maintainer edits stays on the plain `conflicting` path for a person). A head the lane last saw blocked on its own (red required check, terminal hold, permanent merge refusal) never fronts, and a group whose best member is blocked imposes no ordering (fail-open) — nobody waits behind a PR that is not moving. One INFO line `merge train` per order change, not per cycle. The queue carries one PR per issue: when two open PRs declare the same `Fixes #N`, the sweep keeps one (green first, then the earlier-opened) and holds the other with lane reason `merge-train:duplicate-of#:/0:0/0:` (tracker pill "Duplicate of #15402 · needs a pick"; *Let hive decide* supersedes, [#15395](https://github.com/hivecommons/hive/issues/15395)). `false` restores independent per-PR evaluation. A PR GitHub reports conflicting on its own, or one at stage/072 returned-to-contributor (label or stage record), is never a member nor counted in the train's size and draws no train idle comment; a conflicting PR rides only while the train itself is repairing it (its rebase requested behind a merged front, loop guard not spent) ([#15395](https://github.com/hivecommons/hive/issues/15395)). | | `auto_merge.merge_train.max_rebase_attempts` | `2` | Loop guard: how many rebase-resolve requests the train makes for one PR behind one front. Past it the PR moves to stage/085 with the pill "Needs human decision · rebase failed twice" and the decision option "Rebase, then merge as maintainer". | | `auto_merge.native_merge_queue.enabled` | `false` | Opt-in: once the lane's gates pass, enqueue the PR into GitHub's native merge queue (App auth only) instead of merging directly, and withdraw only Hive's own entries when the PR loses eligibility ([#15198](https://github.com/hivecommons/hive/issues/15198)). Off keeps the pre-queue behaviour everywhere, including the `merge-queue-required` park. See [native-merge-queue.md](native-merge-queue.md). | | `auto_merge.native_merge_queue.repos` | unset (every watched repo once enabled) | `owner/repo` allow-list for the hand-off, matched case-insensitively. | diff --git a/src/pkg/dashboard/stage_tracker_merge_train_overlap.go b/src/pkg/dashboard/stage_tracker_merge_train_overlap.go index f2a0bfe36d..6037fe178f 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_overlap.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_overlap.go @@ -2,6 +2,7 @@ package dashboard import ( "reflect" + "sort" "strconv" "strings" @@ -27,8 +28,12 @@ type StageTrackerOverlap struct { } // stageTrackerOverlapHint builds the hint for a PR at number, out of a -// train whose planner's front is front and whose other members are -// others (number excluded by the caller). +// train whose front is front and whose other members are others (number +// excluded by the caller). front is the PR this one joins behind when it +// is green — the ready member the lane merges first — or number itself +// when no member is ready yet: the lane orders a train readiness first +// (automerge_merge_train.go), so a PR at CI / Review never merges ahead +// of a green one; it is "1st" only provisionally, while nobody is ready. func stageTrackerOverlapHint(number, front int, others []int, files []string) *StageTrackerOverlap { o := &StageTrackerOverlap{With: append([]int(nil), others...), Files: append([]string(nil), files...)} paren := "" @@ -37,7 +42,7 @@ func stageTrackerOverlapHint(number, front int, others []int, files []string) *S } if number != front && front > 0 { o.Behind = front - o.Note = "overlaps #" + strconv.Itoa(front) + paren + " — will queue behind it" + o.Note = "overlaps #" + strconv.Itoa(front) + paren + " — " + stageTrackerOverlapJoinsNote return o } names := make([]string, 0, len(others)) @@ -48,13 +53,42 @@ func stageTrackerOverlapHint(number, front int, others []int, files []string) *S if len(others) > 1 { them = "them" } - o.Note = "overlaps " + strings.Join(names, ", ") + paren + " — merges ahead of " + them + " once both are ready" - if len(others) > 1 { - o.Note = strings.Replace(o.Note, "once both are ready", "once all are ready", 1) - } + o.Note = "overlaps " + strings.Join(names, ", ") + paren + " — " + stageTrackerOverlapProvisionalNote + " merges ahead of " + them + " if it is green first" return o } +// stageTrackerOverlapProvisionalNote leads the hint on a PR the planner +// ordered first while no member of its train is merge-ready. +const stageTrackerOverlapProvisionalNote = "no member of the train is merge-ready yet; provisionally 1st," + +// stageTrackerOverlapJoinsNote is the hint's tail on a PR that joins a +// train behind its ready front once green. +const stageTrackerOverlapJoinsNote = "joins the merge train behind it when green" + +// stageTrackerOverlapJoinBehind re-points a below-queue PR's hint at the +// front that actually rides: the planner may have seated this PR first +// while it was still at CI / Review, but the lane merges the ready member +// first and this one joins behind it when green (hive's own #15741 at CI / +// Review was drawn "1st" over #15748 and #15755, both green at 080). +func stageTrackerOverlapJoinBehind(it *StageTrackerItem, front int) { + if it == nil || it.Overlap == nil || front <= 0 || front == it.Number { + return + } + o := it.Overlap + others := make([]int, 0, len(o.With)+1) + seen := map[int]bool{it.Number: true} + for _, n := range append([]int{front}, o.With...) { + if !seen[n] { + seen[n] = true + others = append(others, n) + } + } + sort.Ints(others) + trainID, pos := o.trainID, o.position + it.Overlap = stageTrackerOverlapHint(it.Number, front, others, o.Files) + it.Overlap.trainID, it.Overlap.position = trainID, pos +} + // stageTrackerLeaveMergeTrainBelowQueue takes a PR short of the merge // queue out of its train and leaves the overlap hint in its place. func stageTrackerLeaveMergeTrainBelowQueue(it *StageTrackerItem, front int, others []int) { diff --git a/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go b/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go index 831e219b4d..ce18e2eae2 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go @@ -51,13 +51,13 @@ func TestStageTrackerMergeTrainCIReviewPairRidesNoTrain(t *testing.T) { if rider.Overlap == nil || rider.Overlap.Behind != 15637 || strings.Join(rider.Overlap.Files, ",") != "sidebar.html,index.html" { t.Fatalf("rider overlap = %+v", rider.Overlap) } - if want := "overlaps #15637 (sidebar.html, index.html) — will queue behind it"; rider.Overlap.Note != want { + if want := "overlaps #15637 (sidebar.html, index.html) — joins the merge train behind it when green"; rider.Overlap.Note != want { t.Errorf("rider note = %q, want %q", rider.Overlap.Note, want) } if front.Overlap == nil || front.Overlap.Behind != 0 || len(front.Overlap.With) != 1 || front.Overlap.With[0] != 15633 { t.Fatalf("front overlap = %+v", front.Overlap) } - if want := "overlaps #15633 (sidebar.html, index.html) — merges ahead of it once both are ready"; front.Overlap.Note != want { + if want := "overlaps #15633 (sidebar.html, index.html) — no member of the train is merge-ready yet; provisionally 1st, merges ahead of it if it is green first"; front.Overlap.Note != want { t.Errorf("front note = %q, want %q", front.Overlap.Note, want) } raw, err := json.Marshal(rider) @@ -112,7 +112,8 @@ func TestStageTrackerMergeTrainCountsOnlyMergeQueueMembers(t *testing.T) { // Two overlapping PRs, the planner's front still at 050 and the sibling // at 080: no train (one merge-queue member is no train), the 080 row -// back to its own caption, the 050 row with the hint. +// back to its own caption, the 050 row with the hint — naming the 080 +// row as the PR it joins behind: the lane merges the ready one first. func TestStageTrackerMergeTrainPendingFrontLeavesLoneRider(t *testing.T) { now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) s, store := stageTrackerFixture(t, now) @@ -131,9 +132,12 @@ func TestStageTrackerMergeTrainPendingFrontLeavesLoneRider(t *testing.T) { if front.MergeTrain != nil || rider.MergeTrain != nil { t.Fatalf("no train of one: front=%+v rider=%+v", front.MergeTrain, rider.MergeTrain) } - if front.Overlap == nil || front.Overlap.Behind != 0 || len(front.Overlap.With) != 1 || front.Overlap.With[0] != 15578 { + if front.Overlap == nil || front.Overlap.Behind != 15578 || len(front.Overlap.With) != 1 || front.Overlap.With[0] != 15578 { t.Errorf("front overlap = %+v", front.Overlap) } + if want := "overlaps #15578 (tracker-words.js) — joins the merge train behind it when green"; front.Overlap.Note != want { + t.Errorf("front note = %q, want %q", front.Overlap.Note, want) + } if rider.Overlap != nil || rider.Caption != stageTrackerAwaitingAdmissionCaption { t.Errorf("080 rider: overlap=%+v caption=%q", rider.Overlap, rider.Caption) } @@ -177,3 +181,91 @@ func TestStageTrackerMergeTrainSizeCountsRidersInPayload(t *testing.T) { t.Errorf("front gate = %+v", front.MergeGate) } } + +// Owner, hive's own page, 2026-10-30: "if 15741 is in ci/review, how can +// it be first in a train? isn't that clogging up the train? and why is +// ci/review in the merge queue column?" The planner had seated #15741 +// (CI / Review) first and #15748 / #15755 (both green at 080) behind it. +// The lane now orders readiness first, and the view agrees with it: the +// train is the two ready rows with #15748 at its head, in the Merge queue +// column; #15741 keeps its chevron in the CI / Review column with a train +// hint that names #15748 as the PR it joins behind when green — never +// "1st", never a Merge-queue chip. +func TestStageTrackerMergeTrainReadyMembersLeadPendingPlannerFront(t *testing.T) { + now := time.Date(2026, 10, 30, 12, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + overlap := []string{"hive-merge.md"} + queued := func(pos int) string { + return prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15741, Position: pos, Size: 3, OverlapFiles: overlap}.Reason() + } + store.Observe(stagelabels.Key("acme/console", 15741), stagelabels.ReviewPending, "required-check-pending:build-and-test") + store.Observe(stagelabels.Key("acme/console", 15748), stagelabels.AwaitingMergeAdmission, queued(2)) + store.Observe(stagelabels.Key("acme/console", 15755), stagelabels.AwaitingMergeAdmission, queued(3)) + s.statusMu.Lock() + for n, stage := range map[int]stagelabels.Stage{15741: stagelabels.ReviewPending, 15748: stagelabels.AwaitingMergeAdmission, 15755: stagelabels.AwaitingMergeAdmission} { + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Merge docs", Author: "someone", BaseRef: "v5", Labels: []string{stage.Label()}}}) + } + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + + pending := trackerItem(t, resp, "pr", 15741) + head := trackerItem(t, resp, "pr", 15748) + tail := trackerItem(t, resp, "pr", 15755) + if head.MergeTrain == nil || tail.MergeTrain == nil { + t.Fatalf("the ready rows ride: head=%+v tail=%+v", head.MergeTrain, tail.MergeTrain) + } + if head.MergeTrain.State != MergeGateStateTrainFront || head.MergeTrain.Position != 1 || head.MergeTrain.Front != 15748 || tail.MergeTrain.Front != 15748 || tail.MergeTrain.Position != 2 || head.MergeTrain.Size != 2 { + t.Errorf("the ready member leads: head=%+v tail=%+v", head.MergeTrain, tail.MergeTrain) + } + if head.MergeGate == nil || !strings.Contains(head.MergeGate.Reason, "1st of 2") || strings.Contains(head.MergeGate.Reason, "once it is ready") { + t.Errorf("head gate = %+v", head.MergeGate) + } + for _, it := range []StageTrackerItem{head, tail} { + if col := stageTrackerItemColumn(&it); col != trackerColumnMergeGate { + t.Errorf("#%d column = %d, want merge queue (%d)", it.Number, col, trackerColumnMergeGate) + } + } + if pending.MergeTrain != nil || pending.LeftTrain != nil { + t.Fatalf("the CI / Review row rides no train: train=%+v left=%+v", pending.MergeTrain, pending.LeftTrain) + } + if col := stageTrackerItemColumn(&pending); col != trackerColumnReview { + t.Errorf("#15741 column = %d, want CI / Review (%d)", col, trackerColumnReview) + } + if pending.Overlap == nil || pending.Overlap.Behind != 15748 || len(pending.Overlap.With) != 2 { + t.Fatalf("#15741 joins behind the ready front: %+v", pending.Overlap) + } + if want := "overlaps #15748 (hive-merge.md) — joins the merge train behind it when green"; pending.Overlap.Note != want { + t.Errorf("#15741 note = %q, want %q", pending.Overlap.Note, want) + } + if pending.MergeGate != nil && (pending.MergeGate.State == MergeGateStateTrainFront || pending.MergeGate.State == MergeGateStateQueuedBehind) { + t.Errorf("#15741 keeps a train gate: %+v", pending.MergeGate) + } +} + +// The SPA's secondary train chip on a CI / Review row: "train · joins +// behind #15748 when green" with the server's note as hover, "train · +// 1st once green" when no member is ready; nothing on a row that rides +// a train or overlaps nothing. +func TestStageTrackerOverlapChipWording(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, "function esc(s) { return String(s).replace(/&/g, '&').replace(/ 0) && !withPRs.length) return null; return o; } - // Pure: the badge word — "overlaps #15637" (the PR it queues behind, - // else the first PR it overlaps, "+1" for the rest). + // Pure: the chip's words — "train · joins behind #15748 when green" + // (the ready front it joins behind), else "train · 1st once green" + // (nobody in the train is ready; this one is provisionally first). function stageTrackerOverlapBadgeText(item) { const o = stageTrackerOverlap(item); if (!o) return ''; - const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); - const lead = Number(o.behind) > 0 ? Number(o.behind) : withPRs[0]; - const rest = withPRs.filter(n => n !== lead).length; - return 'overlaps #' + lead + (Number(o.behind) > 0 ? '' : (rest > 0 ? ' +' + rest : '')); + if (Number(o.behind) > 0) return STAGE_TRACKER_OVERLAP_CHIP_LEAD + 'joins behind #' + Number(o.behind) + ' when green'; + return STAGE_TRACKER_OVERLAP_CHIP_LEAD + '1st once green'; } // Pure: the hover sentence — the server's note, else built from the // parts the same way. @@ -464,9 +470,9 @@ if (o.note) return String(o.note); const files = (Array.isArray(o.files) ? o.files : []).filter(Boolean); const paren = files.length ? ' (' + files.join(', ') + ')' : ''; - if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — will queue behind it'; + if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — joins the merge train behind it when green'; const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); - return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — merges ahead of ' + (withPRs.length > 1 ? 'them once all are ready' : 'it once both are ready'); + return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — no member of the train is merge-ready yet; provisionally 1st, merges ahead of ' + (withPRs.length > 1 ? 'them' : 'it') + ' if it is green first'; } // Pure: the muted badge beside the row's chips; '' without a hint. function stageTrackerOverlapBadgeHtml(item) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index bc2b8b0576..50b4d22da1 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -14881,10 +14881,17 @@

Where to get help

beyond ride one. A PR still at CI / Review whose files overlap another open PR's carries `overlap: {behind, with, files, note}` instead of `merge_train` — hive's own page once drew "merge train · - 2 PRs · 1st: #15637" under two rows that both read CI / Review. The - row shows one muted badge, "overlaps #15637", whose hover is the - note: "overlaps #15637 (sidebar.html, index.html) — will queue - behind it". No rail, no ordinal, no header. */ + 2 PRs · 1st: #15637" under two rows that both read CI / Review, and + later "1st: #15741" over a CI / Review row while #15748 and #15755 + sat green at 080 behind it. The lane merges ready members first, + so the row's lead chip stays in its own column and a small + secondary train chip says where it joins: "train · joins behind + #15748 when green" (hover: "overlaps #15748 (hive-merge.md) — + joins the merge train behind it when green"), or, when no member + of the train is ready, "train · 1st once green". No rail, no + ordinal, no header. */ + // The secondary chip's lead word. + const STAGE_TRACKER_OVERLAP_CHIP_LEAD = 'train · '; // Pure: the row's overlap hint, or null when it rides a train or // overlaps nothing. function stageTrackerOverlap(item) { @@ -14894,15 +14901,14 @@

Where to get help

if (!(Number(o.behind) > 0) && !withPRs.length) return null; return o; } - // Pure: the badge word — "overlaps #15637" (the PR it queues behind, - // else the first PR it overlaps, "+1" for the rest). + // Pure: the chip's words — "train · joins behind #15748 when green" + // (the ready front it joins behind), else "train · 1st once green" + // (nobody in the train is ready; this one is provisionally first). function stageTrackerOverlapBadgeText(item) { const o = stageTrackerOverlap(item); if (!o) return ''; - const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); - const lead = Number(o.behind) > 0 ? Number(o.behind) : withPRs[0]; - const rest = withPRs.filter(n => n !== lead).length; - return 'overlaps #' + lead + (Number(o.behind) > 0 ? '' : (rest > 0 ? ' +' + rest : '')); + if (Number(o.behind) > 0) return STAGE_TRACKER_OVERLAP_CHIP_LEAD + 'joins behind #' + Number(o.behind) + ' when green'; + return STAGE_TRACKER_OVERLAP_CHIP_LEAD + '1st once green'; } // Pure: the hover sentence — the server's note, else built from the // parts the same way. @@ -14912,9 +14918,9 @@

Where to get help

if (o.note) return String(o.note); const files = (Array.isArray(o.files) ? o.files : []).filter(Boolean); const paren = files.length ? ' (' + files.join(', ') + ')' : ''; - if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — will queue behind it'; + if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — joins the merge train behind it when green'; const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); - return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — merges ahead of ' + (withPRs.length > 1 ? 'them once all are ready' : 'it once both are ready'); + return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — no member of the train is merge-ready yet; provisionally 1st, merges ahead of ' + (withPRs.length > 1 ? 'them' : 'it') + ' if it is green first'; } // Pure: the muted badge beside the row's chips; '' without a hint. function stageTrackerOverlapBadgeHtml(item) { diff --git a/src/pkg/github/automerge/automerge_merge_train.go b/src/pkg/github/automerge/automerge_merge_train.go index b0f40066f5..20eaf711ea 100644 --- a/src/pkg/github/automerge/automerge_merge_train.go +++ b/src/pkg/github/automerge/automerge_merge_train.go @@ -14,6 +14,7 @@ import ( gh "github.com/google/go-github/v72/github" hgithub "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stageengine" "github.com/hivecommons/hive/pkg/stageengine/prstage" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -141,6 +142,42 @@ type mergeTrainMember struct { // that is not moving. A head the lane leaves to a person's merge // (mergeTrainHumanMergeReason) is not even a member. Blocked bool + // Readiness is the member's merge-gate readiness as the lane last saw + // it (mergeTrainReadiness*): a ready head (green, approved, soaking or + // waiting for a sweep) leads over one the lane has not evaluated at + // this head, which leads over one still at CI / Review. The front of a + // train is always a ready member when the train has one + // (hivecommons/hive#15741 at CI / Review led #15748 and #15755, both + // queued at 080, and nothing merged). + Readiness int +} + +// Readiness tiers. The zero value is unknown; mergeTrainReadinessRank +// puts them in merge order (ready, unknown, unready). +const ( + // mergeTrainReadinessUnknown: the lane has not evaluated this head on + // its normal path (a new PR, or one parked behind a front since it + // was pushed). + mergeTrainReadinessUnknown = 0 + // mergeTrainReadinessReady: the lane last saw this head at the merge + // gate — green and approved, soaking or waiting on a sweep. + mergeTrainReadinessReady = 1 + // mergeTrainReadinessUnready: the lane last saw this head short of the + // merge gate — CI running, review pending. + mergeTrainReadinessUnready = 2 +) + +// mergeTrainReadinessRank is a tier's place in merge order: a ready head +// leads, one the lane has not evaluated comes next (so it gets evaluated +// and sorted), one seen short of the gate trails. +func mergeTrainReadinessRank(tier int) int { + switch tier { + case mergeTrainReadinessReady: + return 0 + case mergeTrainReadinessUnready: + return 2 + } + return 1 } // mergeTrainGroup is one train: the ordered members (front first) and the @@ -274,6 +311,9 @@ func groupMergeTrains(members []mergeTrainMember) []mergeTrainGroup { if ms[a].Blocked != ms[b].Blocked { return !ms[a].Blocked } + if ra, rb := mergeTrainReadinessRank(ms[a].Readiness), mergeTrainReadinessRank(ms[b].Readiness); ra != rb { + return ra < rb + } ra, rb := mergeTrainStateRank(ms[a].MergeableState), mergeTrainStateRank(ms[b].MergeableState) if ra != rb { return ra < rb @@ -418,6 +458,7 @@ func (c *Engine) planMergeTrains(ctx context.Context, lane, displayRepo, owner, MergeableState: pr.GetMergeableState(), Fork: c.isForkPR(pr), Blocked: c.mergeTrainHeadBlocked(lane, owner, repo, pr.GetNumber(), pr.GetHead().GetSHA()), + Readiness: c.mergeTrainHeadReadiness(lane, owner, repo, pr.GetNumber(), pr.GetHead().GetSHA()), }) } } @@ -820,10 +861,13 @@ type mergeTrainState struct { } // mergeTrainVerdict is the remembered lane verdict for one head: Blocked -// heads never front; HumanMerge heads are not train members at all. +// heads never front; HumanMerge heads are not train members at all; +// Readiness orders the members that do ride (mergeTrainReadiness*). type mergeTrainVerdict struct { sha string + blocked bool humanMerge bool + readiness int } // mergeTrainBlockingReason reports whether a lane's verdict means the head @@ -837,6 +881,24 @@ func mergeTrainBlockingReason(reason string) bool { return isTerminalRequiredCheckHold(reason) || isPermanentMergeRefusal(reason) || classifyCIReason(reason) == ciReasonRed } +// mergeTrainReadinessOf reads a lane verdict as a readiness tier: a merge +// (""), a soak, a merge-queue wait or a release hold is ready — the head +// would merge but for its turn; CI pending, no reviewer verdict yet or a +// review gate still waiting is unready; any other reason says nothing +// about readiness (unknown). +func mergeTrainReadinessOf(reason string) int { + switch { + case reason == "", strings.HasPrefix(reason, prstage.ContributorLaneReasonSoaking), + stageengine.MergeQueueReason(reason): + return mergeTrainReadinessReady + case classifyCIReason(reason) == ciReasonPending, reason == prstage.ContributorLaneReasonNoVerdict, + reason == prstage.AutoMergeReasonReviewGatePrefix+prstage.ReviewGateOutcomeAwaiting, + reason == prstage.AutoMergeReasonReviewGatePrefix+prstage.ReviewGateOutcomeNoBundle: + return mergeTrainReadinessUnready + } + return mergeTrainReadinessUnknown +} + // mergeTrainHumanMergeReason reports whether a lane's verdict means a // person, not the hive, merges this PR: the author is below the trust the // lane needs (untrusted-author-role, contributor-lane:no-linked-issue, …), @@ -856,27 +918,28 @@ func mergeTrainVerdictKey(lane, owner, repo string, number int) string { return lane + "|" + owner + "/" + repo + "#" + strconv.Itoa(number) } -// noteMergeTrainOutcome remembers, per lane and head, whether the lane's -// verdict blocks it from fronting a train or excludes it altogether; any -// other verdict clears the mark. Keyed by lane so the trusted-author lane's -// "untrusted-author-role" for a PR the contributor lane admits never -// touches the contributor lane's train. +// noteMergeTrainOutcome remembers, per lane and head, the lane's verdict +// on the head: whether it blocks it from fronting a train or excludes it +// altogether, and its readiness tier. A verdict that says none of those +// (a handoff, an error) clears the mark. Keyed by lane so the +// trusted-author lane's "untrusted-author-role" for a PR the contributor +// lane admits never touches the contributor lane's train. func (c *Engine) noteMergeTrainOutcome(lane, owner, repo string, number int, sha, reason string) { if c == nil || number <= 0 { return } key := mergeTrainVerdictKey(lane, owner, repo, number) - human := mergeTrainHumanMergeReason(reason) + v := mergeTrainVerdict{sha: sha, blocked: mergeTrainBlockingReason(reason), humanMerge: mergeTrainHumanMergeReason(reason), readiness: mergeTrainReadinessOf(reason)} c.mergeTrainMu.Lock() defer c.mergeTrainMu.Unlock() - if (!human && !mergeTrainBlockingReason(reason)) || strings.TrimSpace(sha) == "" { + if (!v.humanMerge && !v.blocked && v.readiness == mergeTrainReadinessUnknown) || strings.TrimSpace(sha) == "" { delete(c.mergeTrainVerdicts, key) return } if c.mergeTrainVerdicts == nil { c.mergeTrainVerdicts = map[string]mergeTrainVerdict{} } - c.mergeTrainVerdicts[key] = mergeTrainVerdict{sha: sha, humanMerge: human} + c.mergeTrainVerdicts[key] = v } func (c *Engine) mergeTrainVerdictFor(lane, owner, repo string, number int, sha string) (mergeTrainVerdict, bool) { @@ -892,8 +955,35 @@ func (c *Engine) mergeTrainVerdictFor(lane, owner, repo string, number int, sha // mergeTrainHeadBlocked reports whether this exact head was last seen by // the lane unable to merge on its own: it does not front a train. func (c *Engine) mergeTrainHeadBlocked(lane, owner, repo string, number int, sha string) bool { - _, ok := c.mergeTrainVerdictFor(lane, owner, repo, number, sha) - return ok + v, ok := c.mergeTrainVerdictFor(lane, owner, repo, number, sha) + return ok && (v.blocked || v.humanMerge) +} + +// mergeTrainHeadReadiness is the readiness tier the lane last saw this +// exact head at (mergeTrainReadiness*): the lane's own verdict on the +// head first; else the stage store's resolved stage for the PR when a +// lane evaluated it on its normal path (a stage at or past the merge gate +// is ready, one short of it unready); unknown when the PR has only ever +// been parked behind a front, or never seen. +func (c *Engine) mergeTrainHeadReadiness(lane, owner, repo string, number int, sha string) int { + if v, ok := c.mergeTrainVerdictFor(lane, owner, repo, number, sha); ok { + return v.readiness + } + store := c.stageStoreOrShared() + if store == nil { + return mergeTrainReadinessUnknown + } + rec, ok := store.Get(stagelabels.Key(owner+"/"+repo, number)) + if !ok || rec.Stage == stagelabels.None { + return mergeTrainReadinessUnknown + } + if _, parked := prstage.ParseMergeTrain(rec.Reason); parked { + return mergeTrainReadinessUnknown + } + if rec.Stage.Number() >= stagelabels.AwaitingMergeAdmission.Number() { + return mergeTrainReadinessReady + } + return mergeTrainReadinessUnready } // mergeTrainHeadHumanMerge reports whether this exact head was last seen diff --git a/src/pkg/github/automerge/automerge_merge_train_test.go b/src/pkg/github/automerge/automerge_merge_train_test.go index b5cc356b67..ce05815aca 100644 --- a/src/pkg/github/automerge/automerge_merge_train_test.go +++ b/src/pkg/github/automerge/automerge_merge_train_test.go @@ -103,6 +103,46 @@ func TestGroupMergeTrains(t *testing.T) { blocked(mtMember(2, "clean", t0.Add(time.Minute), "x.go")), }, }, + { + // hivecommons/hive#15741 at CI / Review led #15748 and #15755, + // both green at 080, and nothing merged. + name: "ready members lead an older one still at CI / Review", + members: []mergeTrainMember{ + readiness(mtMember(15741, "clean", t0, "x.go"), mergeTrainReadinessUnready), + readiness(mtMember(15748, "clean", t0.Add(time.Minute), "x.go"), mergeTrainReadinessReady), + readiness(mtMember(15755, "clean", t0.Add(2*time.Minute), "x.go"), mergeTrainReadinessReady), + }, + want: [][]int{{15748, 15755, 15741}}, + overlap: []string{"x.go"}, + }, + { + name: "an unevaluated head leads an unready one, ready beats both; readiness outranks mergeable state", + members: []mergeTrainMember{ + readiness(mtMember(1, "clean", t0, "x.go"), mergeTrainReadinessUnready), + readiness(mtMember(2, "behind", t0.Add(time.Minute), "x.go"), mergeTrainReadinessReady), + mtMember(3, "clean", t0.Add(2*time.Minute), "x.go"), + }, + want: [][]int{{2, 3, 1}}, + overlap: []string{"x.go"}, + }, + { + name: "all unready keeps the age tiebreak (a provisional front)", + members: []mergeTrainMember{ + readiness(mtMember(2, "clean", t0.Add(time.Minute), "x.go"), mergeTrainReadinessUnready), + readiness(mtMember(1, "clean", t0, "x.go"), mergeTrainReadinessUnready), + }, + want: [][]int{{1, 2}}, + overlap: []string{"x.go"}, + }, + { + name: "a blocked head trails even a ready-tier sort", + members: []mergeTrainMember{ + blocked(readiness(mtMember(1, "clean", t0, "x.go"), mergeTrainReadinessReady)), + readiness(mtMember(2, "clean", t0.Add(time.Minute), "x.go"), mergeTrainReadinessUnready), + }, + want: [][]int{{2, 1}}, + overlap: []string{"x.go"}, + }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -530,6 +570,78 @@ func blocked(m mergeTrainMember) mergeTrainMember { return m } +func readiness(m mergeTrainMember, tier int) mergeTrainMember { + m.Readiness = tier + return m +} + +// TestMergeTrainReadinessMemory: the lane's verdict on a head sets its +// readiness tier for the next plan — a soak or merge-queue wait is ready, +// CI pending or a review wait is unready, a new head forgets — and a PR +// the lane never evaluated on its normal path reads its tier from the +// stage store's resolved stage (parked-behind records say nothing). +func TestMergeTrainReadinessMemory(t *testing.T) { + for reason, want := range map[string]int{ + "": mergeTrainReadinessReady, + prstage.ContributorLaneReasonSoaking: mergeTrainReadinessReady, + "behind": mergeTrainReadinessReady, + "release-hold:v5": mergeTrainReadinessReady, + "check-pending": mergeTrainReadinessUnready, + "required-check-pending:build": mergeTrainReadinessUnready, + prstage.ContributorLaneReasonNoVerdict: mergeTrainReadinessUnready, + prstage.AutoMergeReasonReviewGatePrefix + prstage.ReviewGateOutcomeAwaiting: mergeTrainReadinessUnready, + "not-mergeable": mergeTrainReadinessUnknown, + "untrusted-author-role": mergeTrainReadinessUnknown, + } { + if got := mergeTrainReadinessOf(reason); got != want { + t.Fatalf("mergeTrainReadinessOf(%q) = %d, want %d", reason, got, want) + } + } + t0 := time.Date(2026, 10, 30, 9, 0, 0, 0, time.UTC) + c := &Engine{} + c.stageStore = stagelabels.NewStore("", func() time.Time { return t0 }) + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 7, "sha1"); got != mergeTrainReadinessUnknown { + t.Fatalf("never seen = %d, want unknown", got) + } + c.noteMergeTrainOutcome("self", "acme", "widget", 7, "sha1", "check-pending") + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 7, "sha1"); got != mergeTrainReadinessUnready { + t.Fatalf("CI pending = %d, want unready", got) + } + if c.mergeTrainHeadBlocked("self", "acme", "widget", 7, "sha1") { + t.Fatal("CI pending is unready, not blocked") + } + // The member turns ready: it moves to the front of the next plan. + c.noteMergeTrainOutcome("self", "acme", "widget", 7, "sha1", prstage.ContributorLaneReasonSoaking) + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 7, "sha1"); got != mergeTrainReadinessReady { + t.Fatalf("soaking = %d, want ready", got) + } + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 7, "sha2"); got != mergeTrainReadinessUnknown { + t.Fatalf("new head = %d, want unknown", got) + } + if got := c.mergeTrainHeadReadiness("trusted", "acme", "widget", 7, "sha1"); got != mergeTrainReadinessUnknown { + t.Fatalf("another lane = %d, want unknown", got) + } + // It goes red: blocked, and no longer a ready front. + c.noteMergeTrainOutcome("self", "acme", "widget", 7, "sha1", "required-check-failing:build") + if !c.mergeTrainHeadBlocked("self", "acme", "widget", 7, "sha1") { + t.Fatal("red check blocks the head") + } + // No verdict at this head: the stage store's resolved stage decides. + c.stageStore.Observe(stagelabels.Key("acme/widget", 8), stagelabels.ReviewPending, "check-pending") + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 8, "sha8"); got != mergeTrainReadinessUnready { + t.Fatalf("050 in the store = %d, want unready", got) + } + c.stageStore.Observe(stagelabels.Key("acme/widget", 8), stagelabels.AwaitingMergeAdmission, "") + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 8, "sha8"); got != mergeTrainReadinessReady { + t.Fatalf("080 in the store = %d, want ready", got) + } + parked := prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 7, Position: 2, Size: 2}.Reason() + c.stageStore.Observe(stagelabels.Key("acme/widget", 8), stagelabels.AwaitingMergeAdmission, parked) + if got := c.mergeTrainHeadReadiness("self", "acme", "widget", 8, "sha8"); got != mergeTrainReadinessUnknown { + t.Fatalf("parked behind a front = %d, want unknown", got) + } +} + // TestMergeTrainBlockedHeadMemory: the lane's verdict per head decides // whether it may front; a red/terminal verdict marks the exact head, any // other verdict clears it, and a new head starts clean. A conflict is not diff --git a/src/pkg/stageengine/derive_pr_classify.go b/src/pkg/stageengine/derive_pr_classify.go index 5ed7ed1a6c..abca3bc989 100644 --- a/src/pkg/stageengine/derive_pr_classify.go +++ b/src/pkg/stageengine/derive_pr_classify.go @@ -306,6 +306,13 @@ var stageMergeQueueReasons = map[string]bool{ autoMergeReasonBehindBudgetExhausted: true, autoMergeReasonMergeQueueRequired: true, } +// MergeQueueReason reports whether a lane reason means the head is at the +// merge queue (100): the merge was attempted or is waiting on the queue, a +// branch update, or a release hold — the head itself is ready. +func MergeQueueReason(reason string) bool { + return stageMergeQueueReasons[reason] || strings.HasPrefix(reason, prstage.AutoMergeReasonNativeQueuePrefix) || strings.HasPrefix(reason, "release-hold") +} + // stageFixingReasons are reasons an agent (or the author) must fix the head. var stageFixingReasons = map[string]bool{ "changes-requested": true, autoMergeReasonHumanChangesRequested: true, StageReasonDecisionAnswered: true, contributorLaneReasonChangesRequested: true, "conflicting": true, "not-mergeable": true, @@ -495,7 +502,7 @@ func ClassifyStage(o stageObservation) stageVerdict { // 095, not 100 — the merge has not been attempted yet. return WithHumanApprovalReason(stageVerdict{Stage: stagelabels.PreMergeSoak, Rank: stageRankOwned}, humanApprovalReason) } - if stageMergeQueueReasons[reason] || strings.HasPrefix(reason, prstage.AutoMergeReasonNativeQueuePrefix) || strings.HasPrefix(reason, "release-hold") { + if MergeQueueReason(reason) { return WithHumanApprovalReason(stageVerdict{Stage: stagelabels.MergeQueue, Rank: stageRankOwned}, humanApprovalReason) } if reason == contributorLaneReasonNoVerdict { From f8d4d0cc81eaeb892250d3790855867bed3b55d3 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 09:08:09 -0400 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9D=20changelog:=20merge=20train?= =?UTF-8?q?=20readiness=20order=20(#15761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson --- changelog.d/fixed-merge-train-readiness-order.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/fixed-merge-train-readiness-order.md diff --git a/changelog.d/fixed-merge-train-readiness-order.md b/changelog.d/fixed-merge-train-readiness-order.md new file mode 100644 index 0000000000..1c099fc2da --- /dev/null +++ b/changelog.d/fixed-merge-train-readiness-order.md @@ -0,0 +1 @@ +- Merge trains now order their members by readiness first: PRs the lane knows are merge-ready (080 admitted, soaking, merge queue) lead, members it has not evaluated follow, and members still in CI/Review trail — re-sorted every pass, so a PR going green moves up and one going red moves back. A PR still in CI/Review renders in its real column with a "train · joins behind #N when green" chip instead of a Merge-queue chip, and a train with no ready member says its front is provisional ([#15761](https://github.com/hivecommons/hive/issues/15761)). From a631185fceb7014b2ac1cab18056a7c020a908f0 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 09:08:09 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20dashboard:=20Merged=20odomet?= =?UTF-8?q?er=20rolls=20only=20after=20the=20bee=20lands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merge-gate hold (#15245) masks a landed merge as still 'Merging' for the banner's lifetime, and the bee only launches when the hold ends. The Merged chip, though, held its number back only for merges with a glyph pending or in flight — so the poll that brought the merge (and the server's raised all_time) rolled the drum at once, thirty seconds before the bee flew, and the landing found nothing left to roll. Masked merges are now tracked (_stageTrackerMergedHeld) and treated as flights to come: the holdback subtracts them from the shown count and the drum (and day/week line) stays still while any is held. The number rolls once, on the landing; successive merges each wait for their own bee; the final displayed value equals the server's; a reload shows the server's number immediately. Node test runs the real hold functions, which the other celebration tests stub off — the path was uncovered. Fixes #15762 Signed-off-by: Andrew Anderson --- .../fixed-odometer-rolls-after-bee-lands.md | 1 + src/pkg/dashboard/stage_tracker_cues_test.go | 113 +++++++++++++++++- .../dashboard/static-src/js/tracker-merged.js | 36 ++++-- src/pkg/dashboard/static/index.html | 36 ++++-- 4 files changed, 165 insertions(+), 21 deletions(-) create mode 100644 changelog.d/fixed-odometer-rolls-after-bee-lands.md diff --git a/changelog.d/fixed-odometer-rolls-after-bee-lands.md b/changelog.d/fixed-odometer-rolls-after-bee-lands.md new file mode 100644 index 0000000000..08cebf2656 --- /dev/null +++ b/changelog.d/fixed-odometer-rolls-after-bee-lands.md @@ -0,0 +1 @@ +- The Activity Monitor's Merged odometer no longer rolls before the bee lands: a merge the merge-gate hold still masks as "Merging" is held back from the count like a flight to come, so the number waits through the hold and the flight and rolls once when the glyph reaches the chip. Successive merges queue their rolls and the display ends on the server's value; a reload still shows the server's number at once ([#15762](https://github.com/hivecommons/hive/issues/15762)). diff --git a/src/pkg/dashboard/stage_tracker_cues_test.go b/src/pkg/dashboard/stage_tracker_cues_test.go index a4f3893daa..c6cb02f00f 100644 --- a/src/pkg/dashboard/stage_tracker_cues_test.go +++ b/src/pkg/dashboard/stage_tracker_cues_test.go @@ -431,7 +431,7 @@ let renders = 0; function renderStageTracker() { renders++; } const srcs = new Map(); function stageTrackerRowSrcOf(node) { return srcs.get(node); } let _stageTrackerEvents = {}; const STAGE_TRACKER_TERMINAL = 110; -var _stageTrackerPRHost = {}; var _stageTrackerPRTitle = {}; var _stageTrackerMergeState = null, _stageTrackerZapped = {}, _stageTrackerMerged = { server: null, local: {} }, _stageTrackerMergedShown = 0, _stageTrackerCelebrating = {}, _stageTrackerCelebratePending = {}, _stageTrackerFlights = 0, _stageTrackerReleaseTimer = 0; +var _stageTrackerPRHost = {}; var _stageTrackerPRTitle = {}; var _stageTrackerMergeState = null, _stageTrackerZapped = {}, _stageTrackerMerged = { server: null, local: {} }, _stageTrackerMergedShown = 0, _stageTrackerCelebrating = {}, _stageTrackerCelebratePending = {}, _stageTrackerMergedHeld = {}, _stageTrackerFlights = 0, _stageTrackerReleaseTimer = 0; let settingsClosed = 0; function closeStageTrackerSettings() { settingsClosed++; } const odoText = e => e.getAttribute('data-odo-value'); const flights = () => body.children.filter(c => c.classList.contains('cue-flight')); @@ -855,6 +855,117 @@ console.log('ok'); `) } +// TestStageTrackerOdometerWaitsForMergingHoldNode (owner: "the odometer +// still updates before the bee animation lands on it"): the merge gate's +// hold (#15245) masks a landed merge as still open for the banner's +// lifetime, and the poll that brought it also brings the server's raised +// ledger total. The drum used to roll on that poll — the hold kept the +// bee grounded while nothing kept the number — so the landing, a full +// hold later, found nothing left to roll. The chip now holds the masked +// merges back like flights to come: the number waits through the hold, +// through the flight, and rolls once on the landing. Runs the real hold +// functions (the other celebration tests stub them off). +func TestStageTrackerOdometerWaitsForMergingHoldNode(t *testing.T) { + html := indexHTML(t) + for _, want := range []string{ + "_stageTrackerMergedHeld = {};", + "masked.held.forEach(k => { _stageTrackerMergedHeld[k] = true; });", + "stageTrackerMergedHoldback(_stageTrackerMerged, _stageTrackerCelebratePending, _stageTrackerMergedHeld)", + } { + if !strings.Contains(html, want) { + t.Errorf("index.html missing %q", want) + } + } + holdOn := strings.Join([]string{ + jsConstLine(t, html, "STAGE_TRACKER_MERGING_HOLD_MS"), + jsConstLine(t, html, "STAGE_TRACKER_MERGE_QUEUE"), + "var _stageTrackerMergingHold = {}; var _stageTrackerPRItems = {}; var _stageTrackerMergingHoldTimer = 0; var _stageTracker = null;", + jsFunc(t, html, "stageTrackerPRItemsOf"), + jsFunc(t, html, "stageTrackerMergingHoldLive"), + jsFunc(t, html, "stageTrackerMergingHoldNext"), + jsFunc(t, html, "stageTrackerMergingHoldMask"), + jsFunc(t, html, "stageTrackerMergingHoldSchedule"), + jsFunc(t, html, "stageTrackerMergingHoldRelease"), + }, "\n") + js := strings.Replace(stageTrackerCelebrateJS(t, html), stageTrackerMergingHoldOffJS, holdOn, 1) + if js == stageTrackerCelebrateJS(t, html) { + t.Fatal("the hold stub was not swapped for the real functions") + } + runStageTrackerRowActionsScript(t, js+stageTrackerCelebrateFixture+` +const rolling = e => e.children[0].children.filter(c => c.classList.contains('ham-odo-roll')); +const iso = ms => new Date(ms).toISOString(); +const rec = (...nums) => nums.map(x => ({ repo: 'o/r', number: x, title: 'fix ' + x, merged_at: iso(clock), merged_by: 'hive', lane: 'hive' })); +const srv = (all, today, recent) => ({ all_time: all, today, total_7d: today, total_30d: today, recent, tz: 'UTC', day_start: iso(stageTrackerLocalMidnight(clock)) }); +const pr = (num, stage, mg) => Object.assign({ repo: 'o/r', kind: 'pr', number: num, stage, title: 'fix ' + num }, mg ? { merge_gate: mg } : {}); +// The poll handler: remember the payload (the hold's release re-reads it) and note it. +const poll = d => { _stageTracker = d; stageTrackerNoteMerges(d); }; +panel.appendChild(row('o/r/pr#1')); +poll({ items: [pr(1, 90)], merged: srv(40, 2, rec(31, 30)) }); +assert.strictEqual(odoText(n), '40', 'hydrated'); assert.strictEqual(odoText(sub), '2 today · 2 this week'); +// The sweep is merging #1: the gate says so. +tick(5000); +const T = clock; +poll({ items: [pr(1, 95, { state: 'merging', merging_since: iso(T) })], merged: srv(40, 2, rec(31, 30)) }); +assert.strictEqual(odoText(n), '40'); +// Next poll: #1 landed — the items dropped it, the ledger counts it (41), +// recently_merged settles it. The hold masks the merge for the banner's +// lifetime, so no bee launches yet; the number must wait with it. +tick(5000); +poll({ items: [], recently_merged: [{ repo: 'o/r', number: 1, merged_at: iso(clock) }], merged: srv(41, 3, rec(1, 31, 30)) }); +tick(0); +assert.strictEqual(flights().length, 0, 'the hold keeps the bee grounded'); +assert.strictEqual(odoText(n), '40', 'the total waits for the bee (it used to roll here, a full hold early)'); assert.strictEqual(rolling(n).length, 0); +assert.strictEqual(odoText(sub), '2 today · 2 this week', 'so does the day line'); +assert.ok(!chip.classList.contains('cue-tick'), 'no pop'); +assert.deepStrictEqual(zaps, []); +// A further poll inside the hold with the same numbers: still waiting. +tick(10000); +poll({ items: [], recently_merged: [{ repo: 'o/r', number: 1, merged_at: iso(T) }], merged: srv(41, 3, rec(1, 31, 30)) }); +assert.strictEqual(odoText(n), '40', 'a repeat poll does not leak the number either'); +// The hold ends: the merge is re-read as fresh, the bee launches, the number still waits. +tick(T + STAGE_TRACKER_MERGING_HOLD_MS - clock + 60); +tick(0); +assert.strictEqual(flights().length, 1, 'the bee launches when the hold ends'); +assert.strictEqual(odoText(n), '40', 'held under the flight'); assert.strictEqual(rolling(n).length, 0); +// The bee lands: one roll, to the server's number. +flights()[0]._ev.animationend(); +assert.strictEqual(flights().length, 0); +assert.strictEqual(odoText(n), '41', 'the landing rolls it'); assert.strictEqual(rolling(n).length, 1, 'rolled, not set'); +assert.strictEqual(odoText(sub), '3 today · 3 this week'); +assert.ok(chip.classList.contains('cue-tick'), 'pop with the roll'); assert.deepStrictEqual(zaps, [1], 'zap with the roll'); +assert.ok(chip.title.startsWith('Merged: 41 all time'), chip.title); +tick(STAGE_TRACKER_ODOMETER_MS + 100); +// Steady afterwards: the same ledger does not move it again. +poll({ items: [], merged: srv(41, 3, rec(1, 31, 30)) }); +assert.strictEqual(odoText(n), '41'); assert.strictEqual(rolling(n).length, 0); +// Two merges in quick succession, each through its own hold: nothing is lost — the display ends on the server's value. +zaps.length = 0; chip.classList.remove('cue-tick'); +panel.appendChild(row('o/r/pr#2')); panel.appendChild(row('o/r/pr#3')); +poll({ items: [pr(2, 90), pr(3, 90)], merged: srv(41, 3, rec(1, 31, 30)) }); +tick(1000); const T2 = clock; +poll({ items: [pr(2, 95, { state: 'merging', merging_since: iso(T2) }), pr(3, 90)], merged: srv(41, 3, rec(1, 31, 30)) }); +tick(3000); const T3 = clock; +poll({ items: [pr(3, 95, { state: 'merging', merging_since: iso(T3) })], recently_merged: [{ repo: 'o/r', number: 2 }], merged: srv(42, 4, rec(2, 1, 31, 30)) }); +assert.strictEqual(odoText(n), '41', '#2 held'); +tick(3000); +poll({ items: [], recently_merged: [{ repo: 'o/r', number: 2 }, { repo: 'o/r', number: 3 }], merged: srv(43, 5, rec(3, 2, 1, 31, 30)) }); +assert.strictEqual(odoText(n), '41', '#2 and #3 held'); +// #2's hold ends first: its bee flies and lands; the number still waits for #3, whose hold is live. +tick(T2 + STAGE_TRACKER_MERGING_HOLD_MS - clock + 60); tick(0); +assert.strictEqual(flights().length, 1, '#2 flies'); +flights()[0]._ev.animationend(); +assert.strictEqual(odoText(n), '41', 'still held: #3 is masked (its bee is to come), and a landing never leaves a merge uncounted'); +// #3's hold ends: its bee flies and lands; the display reaches the server's value. +tick(T3 + STAGE_TRACKER_MERGING_HOLD_MS - clock + 60); tick(0); +assert.strictEqual(flights().length, 1, '#3 flies'); +assert.strictEqual(odoText(n), '41', 'held under its flight'); +flights()[0]._ev.animationend(); +assert.strictEqual(odoText(n), '43', 'final displayed value == server value'); +assert.strictEqual(odoText(sub), '5 today · 5 this week'); +console.log('ok'); +`) +} + // TestStageTrackerFlightTargetNode: the operator's spec for the flight — // from the ✓ cell to the Merged chip when the chip is inside the viewport, // otherwise up and out through the top edge; the glyph is configurable; diff --git a/src/pkg/dashboard/static-src/js/tracker-merged.js b/src/pkg/dashboard/static-src/js/tracker-merged.js index bca14d786d..b7b6c30ae0 100644 --- a/src/pkg/dashboard/static-src/js/tracker-merged.js +++ b/src/pkg/dashboard/static-src/js/tracker-merged.js @@ -57,6 +57,10 @@ _stageTrackerMergingHold = stageTrackerMergingHoldNext(_stageTrackerMergingHold, d, _stageTrackerMergeState, raw, _stageTrackerPRItems, nowMs); const masked = stageTrackerMergingHoldMask(raw, _stageTrackerMergingHold, nowMs); if (masked.until) stageTrackerMergingHoldSchedule(masked.until - nowMs); + // The Merged chip holds the masked merges back too: the server + // already counts them, their glyph has not even launched yet. + _stageTrackerMergedHeld = {}; + masked.held.forEach(k => { _stageTrackerMergedHeld[k] = true; }); _stageTrackerPRItems = stageTrackerPRItemsOf(d); const next = masked.state; const fresh = stageTrackerNewlyMerged(_stageTrackerMergeState, next).filter(k => !_stageTrackerZapped[k]); @@ -390,6 +394,12 @@ // Merges whose glyph is still on its way: the count holds them back // until stageTrackerCelebrateTick lands them. var _stageTrackerCelebratePending = {}; + // Merges the merge-gate hold (#15245) still masks as open: the server + // counts them already, the SPA has not read them as fresh yet, so no + // glyph is pending for them. Without this the drum rolled on the poll + // that brought the merge — a full banner-lifetime before the bee + // launched — and the landing found nothing left to roll. + var _stageTrackerMergedHeld = {}; // Stateful: fold one payload into the state and redraw the chip. The // count only bumps (pop + zap) through stageTrackerCelebrateTick; a // plain reload draws the server's number without a flourish. @@ -407,13 +417,16 @@ stageTrackerMergedChip.node = document.getElementById('activity-monitor-merged') || have || null; return stageTrackerMergedChip.node; } - // Pure: how many in-flight merges the server already counts — the - // chip holds those back so the landing is when it bumps. - function stageTrackerMergedHoldback(state, pending) { + // Pure: how many merges the server already counts whose bump the chip + // still owes the bee — a glyph pending or in the air, or a merge the + // merge-gate hold masks until its flight can launch — so the landing + // is when it bumps. + function stageTrackerMergedHoldback(state, pending, held) { const known = {}; for (const e of ((state && state.server && state.server.recent) || [])) known[stageTrackerMergedIdent(e.repo, e.number)] = true; + const keys = Object.assign({}, held || {}, pending || {}); let n = 0; - for (const key of Object.keys(pending || {})) { const i = key.indexOf('/pr#'); if (i > 0 && known[stageTrackerMergedIdent(key.slice(0, i), key.slice(i + 4))]) n++; } + for (const key of Object.keys(keys)) { const i = key.indexOf('/pr#'); if (i > 0 && known[stageTrackerMergedIdent(key.slice(0, i), key.slice(i + 4))]) n++; } return n; } // Pure: the odometer columns for a change of text from `from` to `to`, @@ -567,15 +580,18 @@ } // Stateful: whether a celebration glyph is in the air or about to be // (stageTrackerCelebrateMerges staggers the launches; a merge is - // pending from the payload that brought it). The drum and the zap - // wait on this; the flight's own end — its animationend, or - // stageTrackerAfter's timer at STAGE_TRACKER_CELEBRATE_FLY_MS when the - // event never fires — is what clears it. - function stageTrackerMergedInFlight() { return _stageTrackerFlights > 0 || Object.keys(_stageTrackerCelebratePending).length > 0; } + // pending from the payload that brought it, or masked by the merge + // gate's hold until then). The drum and the zap wait on this; the + // flight's own end — its animationend, or stageTrackerAfter's timer + // at STAGE_TRACKER_CELEBRATE_FLY_MS when the event never fires — is + // what clears it. + // A merge the merge-gate hold still masks counts as a flight to come: + // its glyph launches when the hold ends and re-reads it as fresh. + function stageTrackerMergedInFlight() { return _stageTrackerFlights > 0 || Object.keys(_stageTrackerCelebratePending).length > 0 || Object.keys(_stageTrackerMergedHeld).length > 0; } function stageTrackerMergedCountDraw(tick) { const chip = stageTrackerMergedChip(); const now = Date.now(); - const txt = stageTrackerMergedText(_stageTrackerMerged, now, stageTrackerMergedHoldback(_stageTrackerMerged, _stageTrackerCelebratePending)); + const txt = stageTrackerMergedText(_stageTrackerMerged, now, stageTrackerMergedHoldback(_stageTrackerMerged, _stageTrackerCelebratePending, _stageTrackerMergedHeld)); // Never backwards within a tab: a server that has not caught up yet // (or lost a merge) does not make the number drop. if (txt.count > _stageTrackerMergedShown || tick) _stageTrackerMergedShown = Math.max(_stageTrackerMergedShown, txt.count); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 50b4d22da1..17721f11ef 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -21608,6 +21608,10 @@

All labels

_stageTrackerMergingHold = stageTrackerMergingHoldNext(_stageTrackerMergingHold, d, _stageTrackerMergeState, raw, _stageTrackerPRItems, nowMs); const masked = stageTrackerMergingHoldMask(raw, _stageTrackerMergingHold, nowMs); if (masked.until) stageTrackerMergingHoldSchedule(masked.until - nowMs); + // The Merged chip holds the masked merges back too: the server + // already counts them, their glyph has not even launched yet. + _stageTrackerMergedHeld = {}; + masked.held.forEach(k => { _stageTrackerMergedHeld[k] = true; }); _stageTrackerPRItems = stageTrackerPRItemsOf(d); const next = masked.state; const fresh = stageTrackerNewlyMerged(_stageTrackerMergeState, next).filter(k => !_stageTrackerZapped[k]); @@ -21941,6 +21945,12 @@

All labels

// Merges whose glyph is still on its way: the count holds them back // until stageTrackerCelebrateTick lands them. var _stageTrackerCelebratePending = {}; + // Merges the merge-gate hold (#15245) still masks as open: the server + // counts them already, the SPA has not read them as fresh yet, so no + // glyph is pending for them. Without this the drum rolled on the poll + // that brought the merge — a full banner-lifetime before the bee + // launched — and the landing found nothing left to roll. + var _stageTrackerMergedHeld = {}; // Stateful: fold one payload into the state and redraw the chip. The // count only bumps (pop + zap) through stageTrackerCelebrateTick; a // plain reload draws the server's number without a flourish. @@ -21958,13 +21968,16 @@

All labels

stageTrackerMergedChip.node = document.getElementById('activity-monitor-merged') || have || null; return stageTrackerMergedChip.node; } - // Pure: how many in-flight merges the server already counts — the - // chip holds those back so the landing is when it bumps. - function stageTrackerMergedHoldback(state, pending) { + // Pure: how many merges the server already counts whose bump the chip + // still owes the bee — a glyph pending or in the air, or a merge the + // merge-gate hold masks until its flight can launch — so the landing + // is when it bumps. + function stageTrackerMergedHoldback(state, pending, held) { const known = {}; for (const e of ((state && state.server && state.server.recent) || [])) known[stageTrackerMergedIdent(e.repo, e.number)] = true; + const keys = Object.assign({}, held || {}, pending || {}); let n = 0; - for (const key of Object.keys(pending || {})) { const i = key.indexOf('/pr#'); if (i > 0 && known[stageTrackerMergedIdent(key.slice(0, i), key.slice(i + 4))]) n++; } + for (const key of Object.keys(keys)) { const i = key.indexOf('/pr#'); if (i > 0 && known[stageTrackerMergedIdent(key.slice(0, i), key.slice(i + 4))]) n++; } return n; } // Pure: the odometer columns for a change of text from `from` to `to`, @@ -22118,15 +22131,18 @@

All labels

} // Stateful: whether a celebration glyph is in the air or about to be // (stageTrackerCelebrateMerges staggers the launches; a merge is - // pending from the payload that brought it). The drum and the zap - // wait on this; the flight's own end — its animationend, or - // stageTrackerAfter's timer at STAGE_TRACKER_CELEBRATE_FLY_MS when the - // event never fires — is what clears it. - function stageTrackerMergedInFlight() { return _stageTrackerFlights > 0 || Object.keys(_stageTrackerCelebratePending).length > 0; } + // pending from the payload that brought it, or masked by the merge + // gate's hold until then). The drum and the zap wait on this; the + // flight's own end — its animationend, or stageTrackerAfter's timer + // at STAGE_TRACKER_CELEBRATE_FLY_MS when the event never fires — is + // what clears it. + // A merge the merge-gate hold still masks counts as a flight to come: + // its glyph launches when the hold ends and re-reads it as fresh. + function stageTrackerMergedInFlight() { return _stageTrackerFlights > 0 || Object.keys(_stageTrackerCelebratePending).length > 0 || Object.keys(_stageTrackerMergedHeld).length > 0; } function stageTrackerMergedCountDraw(tick) { const chip = stageTrackerMergedChip(); const now = Date.now(); - const txt = stageTrackerMergedText(_stageTrackerMerged, now, stageTrackerMergedHoldback(_stageTrackerMerged, _stageTrackerCelebratePending)); + const txt = stageTrackerMergedText(_stageTrackerMerged, now, stageTrackerMergedHoldback(_stageTrackerMerged, _stageTrackerCelebratePending, _stageTrackerMergedHeld)); // Never backwards within a tab: a server that has not caught up yet // (or lost a merge) does not make the number drop. if (txt.count > _stageTrackerMergedShown || tick) _stageTrackerMergedShown = Math.max(_stageTrackerMergedShown, txt.count); From 939172d40729f89eb1fce28c7f2cdae5913e0ae7 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 09:32:18 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8C=B1=20test:=20overlap-hint=20node?= =?UTF-8?q?=20test=20follows=20the=20train=20chip=20wording=20(#15761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson --- .../stage_tracker_overlap_hint.test.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/pkg/dashboard/stage_tracker_overlap_hint.test.js b/src/pkg/dashboard/stage_tracker_overlap_hint.test.js index 4e4400ac65..a61c1d29a1 100644 --- a/src/pkg/dashboard/stage_tracker_overlap_hint.test.js +++ b/src/pkg/dashboard/stage_tracker_overlap_hint.test.js @@ -24,6 +24,7 @@ const src = [ "const STAGE_TRACKER_LEFT_TRAIN_NOTE = 'left the merge train while being fixed; rejoins when green';", "const STAGE_TRACKER_TRAIN_STATE_FRONT = 'front', STAGE_TRACKER_TRAIN_STATE_REBASING = 'rebasing', STAGE_TRACKER_TRAIN_STATE_EXHAUSTED = 'rebase-exhausted';", "const STAGE_TRACKER_TERMINAL = 110;", + pick(/const STAGE_TRACKER_OVERLAP_CHIP_LEAD = '[^']*';/, 'STAGE_TRACKER_OVERLAP_CHIP_LEAD'), "function stageTrackerOrdinal(n) { return String(n); }", fn('stageTrackerTrain'), fn('stageTrackerLeftTrainNote'), @@ -38,7 +39,10 @@ const src = [ const api = new Function(src + '; return { badgeText: stageTrackerOverlapBadgeText, tip: stageTrackerOverlapTip, badgeHtml: stageTrackerOverlapBadgeHtml, lines: stageTrackerTrainLines, trainKey: stageTrackerTrainKey };')(); -// The two records as /api/stage-tracker now emits them. +// The two records as /api/stage-tracker now emits them. The chip names the +// train and the condition (#15761: a CI / Review member joins behind the +// ready front when it goes green; a pair with no ready member has a +// provisional front) but never a Merge-queue ordinal or rail. const files = ['sidebar.html', 'index.html']; const rider15633 = { repo: 'hivecommons/hive', number: 15633, kind: 'pr', stage: 50, modifiers: [], caption: 'Review swarm requested; waiting for a verdict on the current head', overlap: { behind: 15637, with: [15637], files, note: 'overlaps #15637 (sidebar.html, index.html) — will queue behind it' } }; @@ -49,14 +53,14 @@ test('a CI / Review pair with overlapping files draws no train, only the hint', for (const it of [rider15633, front15637]) { assert.strictEqual(api.trainKey(it), '', '#' + it.number + ' must group into no train'); } - assert.strictEqual(api.badgeText(rider15633), 'overlaps #15637'); - assert.strictEqual(api.badgeText(front15637), 'overlaps #15633'); + assert.strictEqual(api.badgeText(rider15633), 'train · joins behind #15637 when green'); + assert.strictEqual(api.badgeText(front15637), 'train · 1st once green'); assert.strictEqual(api.tip(rider15633), 'overlaps #15637 (sidebar.html, index.html) — will queue behind it'); const badge = api.badgeHtml(rider15633); assert.match(badge, /class="ham-badge ham-badge-overlap"/); - assert.match(badge, />overlaps #15637train · joins behind #15637 when green { assert.deepStrictEqual(api.lines({ kind: 'pr', number: 1, stage: 50 }), []); // An older payload without the note still reads the same sentence. const bare = { kind: 'pr', number: 2, stage: 50, overlap: { behind: 7, with: [7], files: ['a.go'] } }; - assert.strictEqual(api.tip(bare), 'overlaps #7 (a.go) — will queue behind it'); + assert.strictEqual(api.tip(bare), 'overlaps #7 (a.go) — joins the merge train behind it when green'); const bareFront = { kind: 'pr', number: 7, stage: 50, overlap: { with: [2, 3], files: ['a.go'] } }; - assert.strictEqual(api.badgeText(bareFront), 'overlaps #2 +1'); - assert.strictEqual(api.tip(bareFront), 'overlaps #2, #3 (a.go) — merges ahead of them once all are ready'); + assert.strictEqual(api.badgeText(bareFront), 'train · 1st once green'); + assert.strictEqual(api.tip(bareFront), 'overlaps #2, #3 (a.go) — no member of the train is merge-ready yet; provisionally 1st, merges ahead of them if it is green first'); });