Skip to content

🐛 tracker: PRs under repair leave the merge train - #15616

Merged
clubanderson merged 3 commits into
v5from
fix/train-membership-repair
Oct 30, 2026
Merged

clubanderson merged 3 commits into
v5from
fix/train-membership-repair

Conversation

@clubanderson

@clubanderson clubanderson commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #15615

Owner screenshot: header merge train · 2 PRs · 1st: #15405 · overlapping: operator-reference.md while #15405's chevron read Fixing (a maintainer had just requested changes).

Root cause

stageTrackerMergeTrainPostPass attached the front from its siblings' train reasons on stage < merged alone, so a front that regressed to 070 still led the header; regressed members kept the merge_train the lane's reason encoded. The planner only excluded 072.

Fix

  • Planner (pkg/github/automerge): mergeTrainReturnedToContributor → mergeTrainUnderRepair, skipping 070 fixing / 071 needs-author / 072 returned / 085 needs-decision by label or stage store (why=<slug> skip log).
  • Tracker (pkg/dashboard/stage_tracker_merge_train.go): stageTrackerTrainUnderRepair(stage, reason) names those stages or a red required check (required-check-failing: / check-failing: / ci-red). Such a member — the front included — leaves the train (stageTrackerLeaveMergeTrain): merge_train gone, train gate words gone, left_train: {why, note} set. Survivors close ranks (size, position, front, ahead, members; the next in line fronts and takes the front's gate words), and a train left with one member is no train (no header, no ordinal; the 080 caption goes back to "Green and approved; waiting for the automerge lane to admit it"). The rebase-exhausted 085 tail stays — the train put it there. Provisional 050/060 members (🐛 tracker: chevron and caption agree — queue slot is a suffix until the PR is ready #15581) keep their slot.
  • SPA (tracker-words.js): stageTrackerLeftTrainNote / STAGE_TRACKER_LEFT_TRAIN_NOTE; the row hover ends with the muted line Merge train: left the merge train while being fixed; rejoins when green.

Tests

  • Go: TestStageTrackerMergeTrainUnderRepairLeaves (train of 2, front at 070 → both rows trainless, note on the dropped one; train of 3 with the middle at 072 → 2 of 2; front at 071 → next in line promoted), TestPlanMergeTrainsExcludesUnderRepair.
  • Node: TestStageTrackerTrainTagOnTwoTrains extended — dropped row + lone survivor: no header, no ordinal, no rail, hover note; lift helpers updated.

Docs: dashboard-sections.md ("PRs under repair leave the train"), dashboard-copy-inventory.md, api-reference/dashboard-misc.md; changelog fragment.

Screenshots

Before — #15405 at 070 Fixing still leads the header and #15410 reads "Merge queued · 2nd of 2":

before: fixing PR leads the merge train header

After — no header, no ordinal; #15405 rides no train (hover: Merge train: left the merge train while being fixed; rejoins when green), #15410 is simply ready:

after: the fixing PR left the train, the survivor is a plain ready row

A PR being fixed (070), waiting on its author (071) or contributor
(072), parked on a human decision (085), or with a red required check
is not a merge-train member. The planner (mergeTrainUnderRepair) skips
it; the tracker (stageTrackerTrainUnderRepair) drops it — the front
included — with left_train {why, note} and a muted hover line, the
survivors close ranks (size, position, front, ahead, members), and a
train left with one member renders no header and no ordinal. The
rebase-exhausted 085 tail stays: the train put it there.

Hive's own #15405 led a header as "1st: #15405" while its chevron
read "Fixing".

Fixes #15615

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15566 🌱 refactor: split stage tracker UI tests same files src/pkg/dashboard/static/index.html
#15574 🌱 dashboard: split stage_tracker.go into 4 files CONFLICT src/pkg/dashboard/stage_tracker.go
#15565 🌱 refactor: split tracker words source same files src/pkg/dashboard/static-src/js/tracker-words.js
#15530 🐛 fix(dashboard): issue-row linked PR passes null when the lineage chip is empty same files src/pkg/dashboard/static/index.html
#15526 🌱 dashboard: split stage_tracker.go into 4 files same files src/docs/dashboard-sections.md
src/pkg/dashboard/stage_tracker.go
#15620 ✨ dashboard: running-cost tile rotates hour / today / week / month same files src/docs/dashboard-sections.md
src/pkg/dashboard/static/index.html

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
The lone survivor of a train that shrank to one member reads the 080
row's own gate (ready), not an empty state.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission → 050-review-pending: required-check-missing:build-and-test

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism is right and matches the screenshot in the body; one low aliasing issue in the close-ranks loop is worth a one-line fix.

Verified at the head (stage_tracker_merge_train.go):

  • Under-repair members leave in the first pass (:347-352) before members is built, so they never contribute to idx; the front — which carries no MergeTrain of its own — is checked separately (:360-364) and recorded as LeftTrain{position: 1} so it lands in dropped. A train shrinking below two members strips everyone with why == "" (:392-396), so no header survives for a train of one. stageTrackerLeaveMergeTrain restores the stage's own gate state (ready at 080, pending at 060) and the 080 caption, so a row that left does not keep "waiting its turn … behind #N".
  • Rebase-exhausted 085 tails are exempted (:346) — correct, since that stage is the train's own doing, not a repair.
  • Planner side: mergeTrainUnderRepair (automerge_merge_train.go:484) widens the 072-only check to 070/071/072/085 by label then store record, same precedence as before.
  • JS: stageTrackerLeftTrainNote returns '' whenever stageTrackerTrain(item) is truthy, so a stale left_train can never show alongside a live ordinal.

Low — sample is mutated mid-loop (stage_tracker_merge_train.go:398-406). sample := items[idx[0]].MergeTrain is a pointer, and idx[0] is the first member the size loop visits, so after that iteration sample.Size already holds the reduced size. Every later member then computes sample.Size - len(dropped) against the already reduced value — subtracting dropped twice. The max(…, len(idx)) floor hides this whenever every surviving member is present in items, but when the view has fewer members than the planner counted (a member whose stage record has not yet picked up the merge_train reason this sweep, for instance), survivors report different sizes: with Size=4, one dropped and idx=[#2, front], #2 says "2 of 3" and the front says "1st of 2". Fix: read size := sample.Size - len(dropped) once before the for _, i := range idx loop and assign mt.Size = max(size, len(idx)). Cosmetic in effect (header vs. chip disagree), no behavioural impact on the planner.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracker side reads correct to me (traced the post-pass and type-checked go build ./pkg/dashboard/ ./pkg/github/automerge/ at 7e93f0f). One verified mismatch between the stated exception and the planner, which I think needs a decision before this lands.

Planner drops the rebase-exhausted 085 tail that the body and docs say stays — medium

  • src/pkg/github/automerge/automerge_merge_train.go:476 lists stagelabels.NeedsDecision in mergeTrainUnderRepairStages with no reason check, and :386 / :498 skip any PR wearing that label or stage-store record. A front the train itself parked at 085 via mergeTrainFrontReason(…, MergeTrainStateRebaseExhausted, …) (:693) is therefore excluded from the next plan, and the survivors re-form the train without it.
  • The tracker makes the opposite choice: src/pkg/dashboard/stage_tracker_merge_train.go:347 keeps a member whose MergeTrain.State == MergeGateStateRebaseExhausted, and docs/dashboard-sections.md:923 says "The exception is the rebase-exhausted tail at 085: the train put it there, and it stays so the person who rebases it sees where it merges."
  • TestPlanMergeTrainsExcludesUnderRepair (automerge_merge_train_test.go:642-653) pins the planner behaviour: it observes #15407 at NeedsDecision with reason rebase-failed-twice and asserts it is out of every train.

Consequence: the dashboard row keeps showing the exhausted PR as "1st of N" from its stale stage-record reason while the planner has already promoted the next member and will merge around it, so the ordinal the person sees is no longer the order the lane will merge in. It is also a merge-policy change rather than a display fix — before this PR an exhausted front held its train until someone rebased; after it the train proceeds. That may well be the better behaviour, but the body says the opposite, so one of the two should change: either exempt a record whose reason parses as a rebase-exhausted train from mergeTrainUnderRepair (and flip the test expectation for #15407), or drop the exception from stageTrackerMergeTrainPostPass:347 and the docs so both halves agree.

Everything else I checked holds: stageTrackerLeaveMergeTrain (:272-308) only resets a gate state the train wrote; the dropped slot recompute (:384-411) shifts positions only for slots below each survivor and collapses a one-member remainder with why "" so no stray note appears; the promoted front re-words via stageTrackerMergeTrainFrontGate(…, promoted=true); stageTrackerLeftTrainNote in the SPA returns '' whenever a merge_train is present, so a row can never show both.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm requested changes

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.

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traced stageTrackerMergeTrainPostPass on this head rather than only the diff. The flow holds together: an under-repair member leaves in the first loop with its slot remembered in LeftTrain.position; a front under repair is caught on the sample.Front lookup and sets frontLeft; dropped slots shift survivors' Position, the slot-1 survivor is promoted through stageTrackerMergeTrainFrontGate(..., promoted=true) and Front is rewritten for every member; a train that shrinks below two members collapses with no note. Rebase-exhausted tails are explicitly kept, which matches the comment.

Engine side: mergeTrainUnderRepair returns st.Slug(), and ReturnedToContributor.Slug() is "returned-to-contributor" (stagelabels.go:273), so the skip-log reason for the existing case is unchanged; the new reasons are fixing, needs-author, needs-decision.

Looks correct to me. No findings.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@clubanderson
clubanderson merged commit 11ec258 into v5 Oct 30, 2026
78 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/train-membership-repair branch October 30, 2026 02:43
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the branch conflicts with the base and needs a rebase

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.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read stage_tracker_merge_train.go, automerge_merge_train.go, derive_pr_classify.go and the new tests at 8405aaf. The view-side mechanism (drop under-repair members, close ranks, promote the next front) is right and the three Go cases pin it. Two things I could verify, one defect and one body/code mismatch:

1. Close-ranks Size is computed through a pointer it mutates (stage_tracker_merge_train.go:410-421) — medium.
sample := items[idx[0]].MergeTrain is a *StageTrackerMergeTrain. The loop does mt.Size = max(sample.Size-len(dropped), len(idx)) for every i in idx; on the first iteration mt == sample, so sample.Size becomes S-d, and every later member gets max(S-2d, len(idx)). The len(idx) floor hides it whenever all surviving members are in the view — which is every case in TestStageTrackerMergeTrainUnderRepairLeaves (3 members, 1 dropped, 2 visible → floor 2 == correct 2). With a member off-view (planner size 4, one dropped, two visible) the first row says "of 3" and the others "of 2". Fix: size := sample.Size before the loop and use size-len(dropped).

2. The planner now drops the rebase-exhausted 085 front the body says "stays" — medium, needs the author's call.
The body: "The rebase-exhausted 085 tail stays — the train put it there." That exemption exists only in the tracker (stage_tracker_merge_train.go:348, State != MergeGateStateRebaseExhausted). The engine's new mergeTrainUnderRepair (automerge_merge_train.go:485-504) matches stagelabels.NeedsDecision by label or store record with no such exemption, and derive_pr_classify.go:367-368 is what puts a rebase-exhausted front at 085. So on the next planMergeTrains tick the exhausted front is no longer a candidate, the train re-plans without it, and the member behind it fronts and merges — whereas before this PR the train parked behind it until a person rebased (mergeTrainFront, automerge_merge_train.go:682). TestPlanMergeTrainsExcludesUnderRepair does not cover a rebase-exhausted 085. That may well be the behaviour you want (a train should not stall indefinitely behind a human rebase), but it is a merge-order change, not a display fix, and the view will then show the exhausted PR as a member of a train the engine no longer counts it in. Either exempt 085 whose stage reason parses as MergeTrainStateRebaseExhausted in mergeTrainUnderRepair, or say in the body/changelog that exhausted fronts now yield the train.

Not a defect, just noting: when a 2-member train loses its front, the survivor is made trainless via stageTrackerLeaveMergeTrain(it, "") but the departed front keeps left_train.note = "rejoins when green" for a train that no longer exists — cosmetic.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tracker: a PR being fixed still leads its merge train header

1 participant