Repository navigation
✨ tracker: merge queue position on the chevron, stable wording, stall warning - #15427
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
|
53d3bb0 to
963dc61
Compare
963dc61 to
7a68eac
Compare
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the new one-pr-per-issue delegate rule may close a contributor's PR in favour of an earlier hive PR, since it runs before the existing prefer-contributor rule and has no author-kind guard.
The UI work I read looks fine; the merge-policy half of this PR changes who the hive may close, and that ordering needs an owner's call before it lands.
Read at 7a68eac (I focused on the automerge/delegate change, not the 2k-line UI surface):
-
decideTrainDuplicatepre-emptsprefer-contributor.policy.go:586-588callsdecideTrainDuplicatebefore the!in.DCOMissing && !in.ReporterTrustHoldguard and beforedecideCompeting. The existing rule atpolicy.go:704-707deliberately only recommends when a hive PR competes with a mergeable, current contributor PR ("keep … open until that comparison confirms the contributor's PR is an adequate replacement"). The new rule atpolicy.go:660-676returnsVerdictCloseSuperseded+ActionCloseDuplicatefor whichever PR the queue held, and the queue's pick (automerge_merge_train_duplicate.go:36-55) is green-first then earlier-opened, with noHiveAuthoredcheck. So a green contributor PR opened after a green hive PR for the sameFixes #Nis now held, and "Let hive decide" closes it — the opposite of whatprefer-contributorprotects. If that is intended, say so in the body; if not, the rule needs an author-kind guard or must run afterdecideCompeting. -
Hold is cross-lane blind, by construction.
planDuplicateHolds(automerge_merge_train_duplicate.go:120) sees only theprsslice handed toplanMergeTrainsfor one lane (automerge_merge_train.go:346), so a self-authored and a contributor PR for the same issue are never compared. Open question, not a defect — it just means the rule is narrower than the body's "one PR per issue" reads. -
Overlap with #15400 (
695fded,Refs #15395 — partial): sametracker-words.js/stage_tracker_merge_gate_test.goregion; the body says this builds on it. They conflict rather than duplicate; one should be closed once the other lands. I have not closed anything.
Verified as stated: every prstage.MergeTrainState* incl. the new duplicate-of has a Sentence() mapping (merge_train.go:191-196); the three lane sweeps skip held duplicates symmetrically (automerge_sweep.go:1086,1322, automerge_contributor_lane.go:435).
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the automerge side of this against v5@e0f8bd9 (head 7a68eac). One verified defect in the new one-PR-per-issue hold; the tracker/SPA half I only skimmed, so no claims there.
Finding (medium): the "green beats red" pick never sees GitHub's conflict state, so an earlier-opened conflicting PR holds a clean later one out of every train.
automerge_merge_train_duplicate.go:129computesGreenfrompr.GetMergeableState()on the PRs handed toplanMergeTrains. Those come fromopenPullRequests→listOpenPullRequests, whose own comment atautomerge_sweep.go:1657-1660says the list endpoint "does not populate MergeableState"; the existing train code re-fetches members for exactly that reason atautomerge_merge_train.go:392-404.planDuplicateHoldsruns before that re-fetch (automerge_merge_train.go:346), somergeTrainDirty("")is always false andGreencollapses to!mergeTrainHeadBlocked(...). That map is written only bynoteMergeTrainOutcome(automerge_merge_train.go:696-710) from a prior lane verdict (red required check, terminal hold, permanent refusal) — a PR GitHub reportsdirtyis never in it.- Result: for two PRs closing the same issue where the earlier one is conflicting and the later one is clean (the
15320red /15330green case in the test table),mergeTrainDuplicateBetter(:51) sees both as green and keeps the earlier, conflicting one; the clean PR is skipped in all three lanes (automerge_sweep.go:1086,1322,automerge_contributor_lane.go:435) withduplicate-ofuntil a human picks. That is the inverse of the rule in the PR body ("green beats red"). - The tests pass because the fixtures set
MergeableStatedirectly (automerge_merge_train_duplicate_test.go:80), which the live list path never does.
Suggested fix: in planDuplicateHolds, only for issues with ≥2 candidates, PullRequests.Get each candidate (same pattern and REST caller tag as :392-404) before deciding Green — the extra reads are bounded by the number of actual duplicate pairs. A test that builds candidates from list-shaped PRs (empty MergeableState) would catch the regression.
Also noting: this and #15400 both Fixes #15395 and both rewrite the queued-behind branch of stageTrackerMergeGateWord in tracker-words.js (#15400 at :581-586); the body acknowledges it. Whichever lands second needs a rebase, and — once this PR's own hold rule is live — a pair like that would be held by exactly the mechanism above.
— hive: agent=reviewer 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. |
|
stage 080-awaiting-merge-admission → 071-needs-author: conflicting |
7a68eac to
5ab9efe
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. |
… warning Position chip "In merge queue · 2 of 6 · ~4m" (front: "Next to merge · 1 of 4"), label stable across sweeps (sweep = spinning ⬡ + "Checking now…"), Merge queue popover in the sticky bar, countdown to the member's turn anchored server-side (merge_train.eta_s/eta_at/eta_basis/late), stall warning with governor.merge_train_stall_warn_s (default 3600) and an hourly activity line, and a words table so no merge_train state slug (front, queued-behind, …) can reach a chip again. Fixes #15395 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…et hive decide Two open PRs declaring the same Fixes #N (hive's #15402 and #15407 for per closing issue (green head first, then earlier-opened) and holds the other with stage reason merge-train:duplicate-of#<winner>; the tracker shows merge_gate.state duplicate-of:<n> ("Duplicate of #15402 · needs a pick", needs-decision) and Let hive decide takes the existing supersede path (rule one-pr-per-issue). Also maps every merge_train state slug to plain words (#15406 read bare "front") with a never-leak test. Fixes #15395 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
5ab9efe to
75a613e
Compare
There was a problem hiding this comment.
Delta re-review (correctness) — read 7a68eac…75a613e. The delta is a rebase onto v5 (#15424 / #15426 / #15429); the PR's own hunks are byte-identical to the previous head apart from doc citation line churn, so the prior finding is unchanged.
Still present — duplicate-hold "green" never sees GitHub's conflict state (src/pkg/github/automerge/automerge_merge_train_duplicate.go:129)
planDuplicateHolds is called at automerge_merge_train.go:356, before the live PullRequests.Get refresh at automerge_merge_train.go:397-421 whose own comment says "the list API does not carry it". So pr.GetMergeableState() at line 129 is always "" on sweep input, mergeTrainDirty("") is false, and Green reduces to !mergeTrainHeadBlocked(...). A conflicting earlier PR with green checks therefore beats a clean later PR for the same issue, contradicting the body ("green beats red") and the field comment at line 23-25. TestPlanDuplicateHoldsFiltersCandidates (automerge_merge_train_duplicate_test.go:80) pre-populates MergeableState on fabricated PRs, which list-fetched PRs never have, so it does not catch this.
Smallest fix: refresh the state for candidates that actually collide, before picking a winner (one Get per colliding PR, same caller tag as the train refresh):
--- a/src/pkg/github/automerge/automerge_merge_train_duplicate.go
+++ b/src/pkg/github/automerge/automerge_merge_train_duplicate.go
@@ func (c *Engine) planDuplicateHolds(plan *mergeTrainPlan, owner, repo, displayRepo string, prs []*gh.PullRequest, prefilter func(*gh.PullRequest) string) []*gh.PullRequest {
-func (c *Engine) planDuplicateHolds(plan *mergeTrainPlan, owner, repo, displayRepo string, prs []*gh.PullRequest, prefilter func(*gh.PullRequest) string) []*gh.PullRequest {
- byIssue := map[int][]mergeTrainDuplicateCandidate{}
+func (c *Engine) planDuplicateHolds(ctx context.Context, plan *mergeTrainPlan, owner, repo, displayRepo string, prs []*gh.PullRequest, prefilter func(*gh.PullRequest) string) []*gh.PullRequest {
+ byIssue := map[int][]*gh.PullRequest{}
for _, pr := range prs {
if pr == nil || pr.GetNumber() <= 0 || !mergeTrainCandidate(prefilter(pr)) {
continue
}
issues := mergeTrainClosedIssues(pr, displayRepo)
if len(issues) == 0 {
continue
}
- cand := mergeTrainDuplicateCandidate{
- Number: pr.GetNumber(),
- CreatedAt: pr.GetCreatedAt().Time,
- Green: !mergeTrainDirty(pr.GetMergeableState()) && !c.mergeTrainHeadBlocked(owner, repo, pr.GetNumber(), pr.GetHead().GetSHA()),
- }
for _, issue := range issues {
- byIssue[issue] = append(byIssue[issue], cand)
+ byIssue[issue] = append(byIssue[issue], pr)
}
}
- holds := mergeTrainDuplicateHolds(byIssue)
+ // Only PRs that actually collide need GitHub's live mergeable_state;
+ // the list API leaves it empty.
+ state := map[int]string{}
+ cands := map[int][]mergeTrainDuplicateCandidate{}
+ for issue, list := range byIssue {
+ if len(list) < 2 {
+ continue
+ }
+ for _, pr := range list {
+ n := pr.GetNumber()
+ if _, seen := state[n]; !seen {
+ state[n] = pr.GetMergeableState()
+ if state[n] == "" && c.gh != nil {
+ if live, _, err := c.gh.PullRequests.Get(hgithub.WithRESTCaller(ctx, "hive:automerge_merge_train"), owner, repo, n); err == nil {
+ state[n] = live.GetMergeableState()
+ }
+ }
+ }
+ cands[issue] = append(cands[issue], mergeTrainDuplicateCandidate{
+ Number: n,
+ CreatedAt: pr.GetCreatedAt().Time,
+ Green: !mergeTrainDirty(state[n]) && !c.mergeTrainHeadBlocked(owner, repo, n, pr.GetHead().GetSHA()),
+ })
+ }
+ }
+ holds := mergeTrainDuplicateHolds(cands)and prs = c.planDuplicateHolds(ctx, plan, …) at automerge_merge_train.go:356. Add a test that feeds list-shaped PRs (no MergeableState) through a fake PullRequests.Get returning dirty for the earlier PR and asserts the later clean PR wins.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 75a613e. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
Read the tree at 75a613e. Scope of this review: the sweep-side one-PR-per-issue rule (item 8) and its wiring into the trains and the decision policy. I did not read the dashboard JS, the ETA arithmetic in stage_tracker_merge_train.go, or the docs — someone should still cover those. Two findings, both in the new rule; the rest of what I read holds up.
1. (medium) The duplicate hold ignores the base branch, so a port of the same fix is held — and can be closed — as a duplicate.
planDuplicateHolds keys candidates on issue number only (src/pkg/github/automerge/automerge_merge_train_duplicate.go:117-137) and runs at automerge_merge_train.go:356, before the perBase split at :364-371 that the rest of the train logic uses precisely because PRs on different bases do not contend. Two open PRs that both say Closes #N against different bases (fix on v5, port on v6/v4) therefore become a pair: the loser leaves every train (automerge_sweep.go:1093, :1329, automerge_contributor_lane.go:435), is shown as "Duplicate of #N · needs a pick", and "Let hive decide" resolves it through decideTrainDuplicate → ActionCloseDuplicate (src/pkg/delegatedecision/policy.go:674-679) — closing a PR that must merge. Suggest folding pr.GetBase().GetRef() into the grouping key. automerge_merge_train_duplicate_test.go has no case with two bases.
2. (low) The "green beats red" rule's conflict leg is dead on the production path.
Green reads pr.GetMergeableState() off the listed PR (automerge_merge_train_duplicate.go:131), but the list API does not carry mergeable_state — the plan itself says so at automerge_merge_train.go:398-399 and only fetches live state for grouped members, which happens after the holds are decided. Conflicts are also deliberately kept out of mergeTrainBlocked (:727-729). So !mergeTrainDirty("") is always true and a conflicting earlier PR beats a clean later one; the rule degrades to "red-CI memory from a previous pass, then earlier-opened". The test fixture at automerge_merge_train_duplicate_test.go:80 sets MergeableState on the struct directly, which is why it passes. Either fetch live state for the few PRs that share an issue, or drop the conflict clause from the docstring and PR body so they match what runs.
Verified non-issue: the held PR continues before noteMergeTrainOutcome (automerge_contributor_lane.go:435-437 vs :459-460; same shape at automerge_sweep.go:1093/:1201), so a red loser's blocked mark survives while it is held — the pair does not oscillate pass to pass.
Overlap: this and #15400 (already judged at its head) both edit tracker-words.js and stage_tracker_merge_train_test.go; the body says this one builds on it, so whichever lands second needs a rebase, not a pick between them.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the Go side of head 75a613e — the one-PR-per-issue holdout, the delegate rule, the prstage/config additions and the dashboard server pass. No defects found in what I read; this looks correct to me. I did not read tracker-queue.js / tracker-words.js line by line, so the SPA countdown and popover are covered here only by the node-harness tests, not by this review.
What I verified:
- Holdout only triggers on closing keywords.
automerge_merge_train_duplicate.go:98goes throughParseClaimedIssues, whoseclaimRefPattern(prclaims.go:490) requiresclose|fixes|resolves…; aRefs #Nor bare#Nnever groups two PRs. So #15400 (Refs #15395) and this PR (Fixes #15395) would not hold each other. - Holds are per pass, not persisted.
planDuplicateHolds(:118) rebuildsplan.duplicatesfrom the lane's candidate list on every pass, so a winner turning red re-picks on the next sweep without any state to clear. Wired identically in the three lanes (automerge_sweep.go:1093,:1329,automerge_contributor_lane.go:435) ahead of the sibling check, and only aftermergeTrainCandidate(prefilter(pr))— a PR the lane's prefilter already rejects never counts as a candidate. - Close is never automatic.
decideTrainDuplicate(delegatedecision/policy.go:659) runs after the sentinel rules (:586) and emitsActionCloseDuplicatewithVerdictCloseSuperseded, which is what lets thellm.go:370older-than-target guard pass for the red-earlier/green-later case; a paused repo gets recommend-only. Config.MergeTrainStallWarn()(config.go:4992) is nil-safe and falls back to the default, somergeTrainQueueOptionsFromcannot panic on a nil config.MergeTrainStateDuplicateOfoverloadsPositionto carry the issue number (prstage/merge_train.go);Sentence()andstageTrackerApplyDuplicateHoldboth read it that way, so the overload is consistent, though a dedicated field would read less surprisingly.
Overlap for a maintainer: this PR contains #15400's change to tracker-words.js (same stable "In merge queue · N of M" label, same sweep-cue handling) and #15400 is now DIRTY against v5. If this one lands, #15400 is a no-op and could be closed in its favour. I have not closed anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
v5 already ships the queue-position chip (hivecommons#15427, hivecommons#15449): 'Merge queued · 2nd', sweep-stable label, spinning cue and a tooltip naming the train and PRs ahead. The early return added here shadowed it with different wording and broke TestStageTrackerMergeQueueChipNode, so drop the superseded JS, its test and its changelog fragment. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Fixes #15395
What the operator saw
Rows for #15319 / #15374 wore "⟳ queued-behind · merge sweep running ⬡" for 4h, flipping to "🕓 queued-behind ⬡" every sweep. Live diagnosis in #15395: the head of their train (#15315) was at stage 090 ready-for-human-merge (newcomer author below
require_tiers), so nothing behind it could move — the chip said neither what they were behind nor why the head was stuck, and leaked the slug. Later hive's #15406 chip read the bare slugfront.Changes
sweep_runningtrue/false; the sweep shows as a pulse on the existing ⬡ plus a "Checking now…" tooltip line (node-harness test).governor.merge_train_stall_warn_s(default 3600): chip "Merge queue stalled · head #N waiting on CI 3h", activity-log line once per hour.merge_train {position, length, head_number, head_state, head_since, eta_s, eta_at, eta_basis, late, stalled, stalled_s}per queued item; Go table tests for position/ETA/stall with injected clock.eta_s/eta_basis("2 ahead · next sweep in 40s"): own remaining soak + per-PR-ahead (remaining soak or one sweep interval) + time to next tick; SPA renders a live countdown on the same tick as the soak chip so it does not reset on poll re-render; blocked → no ETA, blocker shown; exceeded >2× → "running late".merge_trainstate has a plain-words mapping;TestStageTrackerMergeTrainStateSlugsNeverLeakenumeratesprstage.MergeTrainState*and renders each through chip/popover.duplicate-of:<n>("Duplicate of 🐛 fix: show adopted PR provenance in the stage tracker #15402 · needs a pick",needs-decision). "Let hive decide" wires to the existing supersede path (ActionCloseDuplicate/ ruleone-pr-per-issue, through the writeback gate). Selection-rule tests.Builds on hive's own #15400 (same function; this version keeps the label constant and adds position/ETA).
Validation
go build,go vet,go test -race ./pkg/dashboard/... ./pkg/config/... ./pkg/github/automerge/... ./pkg/delegatedecision/... ./pkg/stageengine/...go generate ./pkg/dashboard/...committed (TestIndexHTMLIsGenerated)check-api-reference-citations.sh --fixclean; changelog fragment.