diff --git a/changelog.d/fixed-fixing-chevron-column.md b/changelog.d/fixed-fixing-chevron-column.md new file mode 100644 index 0000000000..82f84c3c73 --- /dev/null +++ b/changelog.d/fixed-fixing-chevron-column.md @@ -0,0 +1 @@ +- The Hive activity monitor's chevron column now follows a PR's current state, never the highest stage it once reached: a PR under repair (070 fixing, 071 needs-author, 072 returned-to-contributor, 074 adopted-by-hive, or a red required check) lights CI / Review even while a stale `merge-failed` gate or planner-ordered merge train still rides on its record — hive's own #15574 read "Fixing · conflicting" under Merge queue. One predicate decides both the column and train membership (`stageTrackerItemColumn` / `stageTrackerUnderRepair`), `left_train` is mirrored onto `linked_prs[]`, and ratchet tests pin every stage × gate × train state to its column A covered issue's list place now follows the same live work its strip draws — an open covering PR with no stage yet counts as 040 covered-by-PR for sorting too, so a just-filed issue with an open PR no longer sinks to the bottom among the New rows (hive's own #15654) ([#15656](https://github.com/hivecommons/hive/issues/15656)). diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 9ed968f728..622af0a7cb 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -39,7 +39,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/budget-ignore` | Dashboard auth/session | Budget Ignore Get | `pkg/dashboard/api.go:172` | | `POST` | `/api/budget-ignore` | Owner only | Budget Ignore Set | `pkg/dashboard/api.go:173` | | `GET` | `/api/summaries` | Dashboard auth/session | Summaries | `pkg/dashboard/api.go:185` | -| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source: claim-ledger|claim-comment|assignee|kick-history|author}` naming who holds a claimed / in-progress issue or a PR under review or rework (absent when nobody is named; mirrored onto `linked_prs[]`), (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close; a PR in a conflict-aware merge train carries `merge_train` `{id, state, front, position, size, attempt, max_attempts, overlap_files, ahead, length, head_number, head_state, head_reason, head_since, eta_s, eta_at, eta_basis, late, stalled, stalled_s}` — `head_state` one of `needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown` with `head_reason` in plain words; `eta_s` / `eta_at` the estimated wait for this member's own merge attempt (own remaining soak + each PR ahead's remaining soak or one sweep + the next sweep tick; absent while the head waits on a person or CI), `eta_at` anchored to the member's first estimate at its position so a countdown survives polls, `eta_basis` its short reading ("2 ahead · head soaking 12m · next sweep in 40s"), `late` once now has overrun the first estimate twice over, `stalled` / `stalled_s` once the head has sat longer than `governor.merge_train_stall_warn_s` ([#15395](https://github.com/hivecommons/hive/issues/15395)); a PR the queue holds because another open PR declares the same `Fixes #N` carries no `merge_train` and a `merge_gate` of `{state: "duplicate-of:", duplicate_of, duplicate_issue}` plus the `needs-decision` modifier (the queue keeps one PR per issue: green first, then the earlier-opened); a PR GitHub reports conflicting on its own, or one under repair (stage/070, 071, 072, 085, or a red required check), carries no `merge_train` and is not counted in any member's `size` / `length` — a repaired member the view dropped carries `left_train: {why: fixing|needs-author|returned-to-contributor|needs-decision|checks-failing, note}` instead, and a train left with one member reports no `merge_train` at all — the state slugs (`front`, `queued-behind`) are payload values only, the SPA renders ordinal places ("Merge queued · 1st of 2", with the train's tag when more than one train is on the page). Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | +| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source: claim-ledger|claim-comment|assignee|kick-history|author}` naming who holds a claimed / in-progress issue or a PR under review or rework (absent when nobody is named; mirrored onto `linked_prs[]`), (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close; a PR in a conflict-aware merge train carries `merge_train` `{id, state, front, position, size, attempt, max_attempts, overlap_files, ahead, length, head_number, head_state, head_reason, head_since, eta_s, eta_at, eta_basis, late, stalled, stalled_s}` — `head_state` one of `needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown` with `head_reason` in plain words; `eta_s` / `eta_at` the estimated wait for this member's own merge attempt (own remaining soak + each PR ahead's remaining soak or one sweep + the next sweep tick; absent while the head waits on a person or CI), `eta_at` anchored to the member's first estimate at its position so a countdown survives polls, `eta_basis` its short reading ("2 ahead · head soaking 12m · next sweep in 40s"), `late` once now has overrun the first estimate twice over, `stalled` / `stalled_s` once the head has sat longer than `governor.merge_train_stall_warn_s` ([#15395](https://github.com/hivecommons/hive/issues/15395)); a PR the queue holds because another open PR declares the same `Fixes #N` carries no `merge_train` and a `merge_gate` of `{state: "duplicate-of:", duplicate_of, duplicate_issue}` plus the `needs-decision` modifier (the queue keeps one PR per issue: green first, then the earlier-opened); a PR GitHub reports conflicting on its own, or one under repair (stage/070, 071, 072, 074, 085, or a red required check), carries no `merge_train` and is not counted in any member's `size` / `length` — a repaired member the view dropped carries `left_train: {why: fixing|needs-author|returned-to-contributor|adopted-by-hive|needs-decision|checks-failing, note}` instead (mirrored onto the issue's `linked_prs[]` entry), and a train left with one member reports no `merge_train` at all — the state slugs (`front`, `queued-behind`) are payload values only, the SPA renders ordinal places ("Merge queued · 1st of 2", with the train's tag when more than one train is on the page). Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | | `POST` | `/api/prs/{owner}/{repo}/{number}/queue-automerge` | Merger/owner role | Queue PRAuto Merge | `pkg/dashboard/api.go:187` | | `GET` | `/api/inference/models/{backend}` | Dashboard auth/session | Inference Models | `pkg/dashboard/api.go:363` | | `GET` | `/api/hive-id` | Dashboard auth/session | Hive IDGet | `pkg/dashboard/api.go:425` | diff --git a/src/docs/dashboard-copy-inventory.md b/src/docs/dashboard-copy-inventory.md index c06fa10382..b07833ca26 100644 --- a/src/docs/dashboard-copy-inventory.md +++ b/src/docs/dashboard-copy-inventory.md @@ -105,6 +105,7 @@ old name). | `STAGE_TRACKER_TRAIN_STATE_WORD` (`tracker-words.js`) | chevron label, gate pill | `front` → *Next to merge*, `queued-behind` → *In merge queue* | both *Merge queued*; the place tells them apart | `TestStageTrackerMergeTrainStateSlugsNeverLeak` | | `stageTrackerTrainWord` | chevron label | *In merge queue · 2 of 6* / *front* (leaked) | *Merge queued · 1st* / *· 2nd* / *· 3rd* … + *· ~4m* countdown | `TestStageTrackerMergeTrainOrdinalWords` | | `stageTrackerTrainOrdinalOfN` + `stageTrackerTrainTagSuffix` / `stageTrackerTrainTagTip` | chevron label, gate pill, provisional suffix, chevron hover | *Merge queued · 1st* twice over on a page with two trains (owner: "how are there 2 'merge queued 1st'?") | *Merge queued · 1st of 2*; past one train on the page *· train main.go* (overlap basename, else the head `#N`) ends the word and the hover leads *Train of 2 PRs overlapping main.go; merges after #15567.*; one train → no tag | `TestStageTrackerTrainTagOnTwoTrains` | +| `stageTrackerUnderRepair` → `stageTrackerAnchor` (Go: `stageTrackerTrainUnderRepair` → `stageTrackerItemColumn`) | chevron column | *Fixing · @hivecommons-hive[bot]* lit in the **Merge queue** column over the caption *fell back to Fixing — … — conflicting* (hive's own #15574: the refused merge's `merge-failed` gate still promoted the column) | the column follows the current state: under repair → CI / Review, whatever the stale gate or planner train says; the caption keeps the history | `TestStageTrackerItemColumnRatchet`, `TestStageTrackerFixingAfterMergeFailedColumn`, `stage_tracker_fixing_column.test.js` | | `stageTrackerLeftTrainNote` + `STAGE_TRACKER_LEFT_TRAIN_NOTE` (Go: `stageTrackerLeftTrainNote`, `left_train`) | row hover | *merge train · 2 PRs · 1st: #15405* over a row whose chevron read *Fixing* (hive's own #15405, a maintainer requested changes) | the fixing row rides no train (no header, no ordinal, no rail); its hover ends *Merge train: left the merge train while being fixed; rejoins when green*; a train of one is no train | `TestStageTrackerTrainTagOnTwoTrains`, `TestStageTrackerMergeTrainUnderRepairLeaves` | | `stageTrackerOrdinal` | chevron, hover, popover | — | `1st 2nd 3rd 4th … 11th 12th 13th 21st 22nd 23rd` | same | | `stageTrackerTrainStalledWord` + `STAGE_TRACKER_TRAIN_HEAD_STALL_WORD` | chevron label (stalled train), Merge queue popover | *Merge queue stalled · head #15425 waiting for a maintainer (untrusted author) 1h21m* — painted `--yellow` on the amber active chevron, so the row read as an **empty** chevron (#15529, #15530) | rider: *Merge queue · stalled — waiting on #15425 (needs maintainer merge) · 1h21m*; head row: *Merge queue · stalled — needs maintainer merge · 1h21m*; the why comes from `head_state` (`needs-human` → *needs maintainer merge* / *needs a human decision*, `ci` → *waiting for CI*, `soaking` → *soak overran*, `ready` → *waiting for a merge sweep*, `merging` → *merge call in flight*, `fixing` → *being fixed by its author*, `unknown` → *head not in this view*); an unmapped `merge_train.state` falls back to its humanised name + place (*Waiting for front · 3rd*), never `''`; `.ham-seg.active .ham-queue-stalled` inherits the chevron's text colour | `TestStageTrackerMergeTrainStateSlugsNeverLeak` (every state × stalled × head_state × place), `TestStageTrackerMergeTrainPayloadStates` | diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 36875f28c4..d849cd66e7 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -937,9 +937,9 @@ The tooltip lists the PRs ahead and the overlapping files. Waiting siblings are **Who rides.** A PR the lane leaves to a person is not a train member and never its head: an author below the lane's trust (`untrusted-author-role`, `contributor-lane:no-linked-issue`, …), the title/label human-merge rule, a human-merge path, a merge GitHub refused for review, and every other `human_merge_reason` code except the catch-all `policy`. The lane's verdict is remembered per lane and head (`noteMergeTrainOutcome`); a new head starts clean. A head the lane last saw unable to merge on its own (red required check, terminal hold, permanent refusal) stays a member but never fronts. -**PRs under repair leave the train.** A PR somebody is fixing is not a train member either: the planner (`mergeTrainUnderRepair`) skips a PR at 070 fixing, 071 needs-author, 072 returned-to-contributor or 085 needs-decision (label or stage store), and the tracker (`stageTrackerTrainUnderRepair`) drops one whose stage says so or whose `reason` is a red required check (`required-check-failing:` / `check-failing:` / `ci-red`) — hive's own #15405 once led a header as `merge train · 2 PRs · 1st: #15405` while its own chevron read *Fixing* (a maintainer had just requested changes). The dropped row carries `left_train: {why, note}` and no `merge_train`: no ordinal, no rail, and its hover ends with the one muted line *Merge train: left the merge train while being fixed; rejoins when green*. The survivors close ranks — `size`, `position`, `front`, `ahead`, `members` are recomputed, and the next in line fronts when the front itself left — and a train left with one member is no train: no header, no ordinal, the 080 row back to *Green and approved; waiting for the automerge lane to admit it*. 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. Provisional members (050 / 060 with nothing red, [#15580](https://github.com/hivecommons/hive/issues/15580)) keep their slot. +**PRs under repair leave the train.** A PR somebody is fixing is not a train member either: the planner (`mergeTrainUnderRepair`) skips a PR at 070 fixing, 071 needs-author, 072 returned-to-contributor or 085 needs-decision (label or stage store), and the tracker (`stageTrackerTrainUnderRepair`) drops one whose stage says so (074 adopted-by-hive included) or whose `reason` is a red required check (`required-check-failing:` / `check-failing:` / `ci-red`) — hive's own #15405 once led a header as `merge train · 2 PRs · 1st: #15405` while its own chevron read *Fixing* (a maintainer had just requested changes). The dropped row carries `left_train: {why, note}` and no `merge_train`: no ordinal, no rail, and its hover ends with the one muted line *Merge train: left the merge train while being fixed; rejoins when green*. The survivors close ranks — `size`, `position`, `front`, `ahead`, `members` are recomputed, and the next in line fronts when the front itself left — and a train left with one member is no train: no header, no ordinal, the 080 row back to *Green and approved; waiting for the automerge lane to admit it*. 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. Provisional members (050 / 060 with nothing red, [#15580](https://github.com/hivecommons/hive/issues/15580)) keep their slot. -**Queue position, countdown, stall** ([#15395](https://github.com/hivecommons/hive/issues/15395)). The queued chip is its place in the queue and nothing else — **Merge queued · 2nd of 6 · ~4m** — so it reads the same whether or not a merge sweep is evaluating it: the sweep is the spinning ⬡ glyph and a *Checking now…* line in the hover, never a change of words (one label per chevron), and no state slug (`queued-behind`, `front`) ever reaches the page. The hover is the place sentence — *2nd of 6 in the merge queue · behind #15253 (soaking, 12m left) · ETA ~25m (2 ahead · head soaking 12m · next pass in 40s). Hive merges one at a time, in order.*; the head's reads *1st of 6 in the merge queue · merges next · ETA ~13m.* — or, when the head is on a person or on CI, the blocker instead of a clock: *… behind #15253 (waiting for a maintainer (untrusted author)) · no estimate until #15253 moves.* Every train state — the 1st included — lights the **Merge queue** column, whatever numeric stage the lane holds the head at (the train's facts are mirrored onto a head still at 050/070; hive's own #15400 once lit CI / Review beside its 2nd-place sibling). The server adds to each member's `merge_train`: `length`, `head_number`, `head_state` (`needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown`), `head_reason` (plain words), `head_since`, `eta_s`, `eta_at`, `eta_basis`, `late`, `stalled`, `stalled_s`. +**Queue position, countdown, stall** ([#15395](https://github.com/hivecommons/hive/issues/15395)). The queued chip is its place in the queue and nothing else — **Merge queued · 2nd of 6 · ~4m** — so it reads the same whether or not a merge sweep is evaluating it: the sweep is the spinning ⬡ glyph and a *Checking now…* line in the hover, never a change of words (one label per chevron), and no state slug (`queued-behind`, `front`) ever reaches the page. The hover is the place sentence — *2nd of 6 in the merge queue · behind #15253 (soaking, 12m left) · ETA ~25m (2 ahead · head soaking 12m · next pass in 40s). Hive merges one at a time, in order.*; the head's reads *1st of 6 in the merge queue · merges next · ETA ~13m.* — or, when the head is on a person or on CI, the blocker instead of a clock: *… behind #15253 (waiting for a maintainer (untrusted author)) · no estimate until #15253 moves.* Every train state — the 1st included — lights the **Merge queue** column, whatever numeric stage the lane holds the head at (the train's facts are mirrored onto a head still at 050/060; hive's own #15400 once lit CI / Review beside its 2nd-place sibling) — a head under repair is no member (below) and lights CI / Review. The server adds to each member's `merge_train`: `length`, `head_number`, `head_state` (`needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown`), `head_reason` (plain words), `head_since`, `eta_s`, `eta_at`, `eta_basis`, `late`, `stalled`, `stalled_s`. **One PR per issue** ([#15395](https://github.com/hivecommons/hive/issues/15395)). Two open PRs declaring the same `Fixes #N` never both ride the queue (hive's own #15402 and #15407, both for #15396, once sat side by side as "waiting its turn"). Before the trains are grouped the sweep keeps one PR per closing issue — a green head (not conflicting, not blocked on a red required check) beats a red one; among equals the earlier-opened wins — and holds the other out of every train with the stage reason `merge-train:duplicate-of#:/0:0/0:`. The held row's gate reads `duplicate-of:` (`merge_gate.duplicate_of`, `merge_gate.duplicate_issue`), its chip **Duplicate of #15402 · needs a pick** with no clock, it carries no `merge_train`, and it wears `needs-decision` so both PRs sit under their issue with the hold visible. *Let hive decide* on either row takes the existing supersede path (rule `one-pr-per-issue`): on the held PR it closes it as superseded by the kept one with a credit comment, through the same write gate as every delegate close; on the kept PR it releases it and names the duplicate the queue holds (or, if the kept PR has since gone red, only recommends the fix — the queue re-picks on its next pass, so an earlier red PR yields to a later green one). @@ -1231,7 +1231,7 @@ Every PR at the gate now carries `merge_gate: {state, reason, sweep_running, las | any stage after GitHub refused hive's merge call (`merge_gate.state: merge-failed`, `merge_failed`, `merge_failed_kind`, `merge_failed_text`, `merge_failed_at`) | **Merge failed** | the refusal translated to a short phrase — *branch protection*, *needs rebase*, *not allowed*, *review required*, or *retrying* while the sweep is on it; never GitHub's raw text | 🕓 clock — *hive tried to merge this (maintainer merge from the dashboard) 9s ago and GitHub refused — branch protection blocks it. The lane re-evaluates it on its next pass. Details: 405 Pull Request is not mergeable* | | any stage after the merge call drew *N of M required status checks are expected* (`merge_failed_kind: checks-pending`, `merge_failed_checks`) | **Waiting for CI** | *4 checks* | ⟳ while the sweep is on it, else 🕓 — *hive tried to merge this (automerge sweep) 1m ago before its required checks had reported — 4 required checks haven't finished. It merges once they pass.* | -A merge outcome (**Merging**, **Merge failed**, **Waiting for CI**) always lights the **Merge queue** column, whatever numeric stage the lane fell back to (hivecommons/docs#512 drew "Merge failed" in CI / Review because the PR sat at 060). +A merge outcome (**Merging**, **Merge failed**, **Waiting for CI**) lights the **Merge queue** column, whatever numeric stage the lane fell back to (hivecommons/docs#512 drew "Merge failed" in CI / Review because the PR sat at 060) — unless the PR is under repair. The chevron column follows the **current** state, never the highest stage the row once reached: a PR at 070 fixing, 071 needs-author, 072 returned-to-contributor, 074 adopted-by-hive or with a red required check lights **CI / Review** even while a stale `merge_gate` (`merge-failed` from the attempt that found the conflict) or a planner-ordered `merge_train` still rides on the record (hive's own #15574 read *Fixing · conflicting* under Merge queue with the caption *fell back to Fixing — … — conflicting*; the maintainer: "why is this in merge queue if it is being fixed?"). The "fell back to …" caption keeps the history; the column follows the fallback. One predicate decides both — `stageTrackerTrainUnderRepair` (Go, `stageTrackerItemColumn`) and `stageTrackerUnderRepair` (SPA, `stageTrackerAnchor`) — so train membership and column can never disagree; the 085 decision park is the one exception that rides no train yet stays at the gate, where the person decides. A refusal is scoped to the head it failed on. Once the PR head moves (merge-from-base, a new push) or the record falls back below 080 to wait on CI (`required-check-pending:*`) after the refusal, the chevron reads the live stage word (**CI running · build-and-test**, **Review pending**) and the refusal survives only in the hover — *merge attempt on previous head 92d4cef failed: branch protection* (`merge_gate.prior_head_merge_failed`, `prior_head_merge_failed_kind`, `prior_head_merge_failed_text`, `prior_head_merge_failed_at`, `prior_head_merge_failed_head`). The chevron and the caption never disagree about whether a merge is failing now ([#15611](https://github.com/hivecommons/hive/issues/15611); hive#15574 read "Merge failed · branch protection" over a caption waiting on CI for the new head). | 110 | **Merged** (the ✓ cap) | — | — | diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index c90061e1fa..7b3484f1e4 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -636,7 +636,10 @@ type StageTrackerLinkedPR struct { SoakRemainingSeconds int64 `json:"soak_remaining_seconds,omitempty"` MergeGate *StageTrackerMergeGate `json:"merge_gate,omitempty"` MergeTrain *StageTrackerMergeTrain `json:"merge_train,omitempty"` - Soak *StageTrackerSoak `json:"soak,omitempty"` + // LeftTrain mirrors the nested PR's own row field so the sub-row's + // hover can say it left its train while under repair. + LeftTrain *StageTrackerLeftTrain `json:"left_train,omitempty"` + Soak *StageTrackerSoak `json:"soak,omitempty"` // Adoption mirrors the nested PR's own row field (hivecommons/hive#14524). Adoption *StageTrackerAdoption `json:"adoption,omitempty"` // LastOperatorAction / OperatorActionCount mirror the nested PR's own diff --git a/src/pkg/dashboard/stage_tracker_attention_order_test.go b/src/pkg/dashboard/stage_tracker_attention_order_test.go index 5738eae1dc..d305f65c47 100644 --- a/src/pkg/dashboard/stage_tracker_attention_order_test.go +++ b/src/pkg/dashboard/stage_tracker_attention_order_test.go @@ -119,6 +119,9 @@ func TestStageTrackerAttentionOrderJS(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedSupersededGone"), jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), + jsConstLine(t, html, "STAGE_TRACKER_COVERED_BY_PR"), + jsFunc(t, html, "stageTrackerLeadStage"), + jsFunc(t, html, "stageTrackerLead"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "stageTrackerRegressionHandled"), jsFunc(t, html, "stageTrackerNeedsAttention"), diff --git a/src/pkg/dashboard/stage_tracker_fixing_column.test.js b/src/pkg/dashboard/stage_tracker_fixing_column.test.js new file mode 100644 index 0000000000..88e8bff696 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_fixing_column.test.js @@ -0,0 +1,181 @@ +// The chevron column follows the CURRENT state, never the highest stage +// a PR once reached. Hive's own #15574 (its adopted copy of #15526 under +// issue #15511) had been queued, hit a conflict on its merge attempt and +// fell back to 070 Fixing — its caption said "fell back to Fixing — +// conflicting", its chevron said "Fixing", and yet it sat in the Merge +// queue column: the stale merge-failed gate (and, before #15616, the +// planner's merge_train) still promoted the column. The maintainer: "why +// is this in merge queue if it is being fixed?" +// +// stageTrackerUnderRepair is the one predicate (mirroring Go's +// stageTrackerTrainUnderRepair, which seats or drops train members) that +// stageTrackerAnchor consults before any gate / train promotion, so the +// column and train membership can never disagree. The functions are +// lifted out of index.html so this runs against the shipped source. +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8'); + +function pick(re, what) { + const m = html.match(re); + assert.ok(m, what + ' not found in index.html'); + return m[0]; +} + +const src = [ + pick(/const STAGE_TRACKER_PATH = [^\n]*\n/, 'STAGE_TRACKER_PATH'), + pick(/const STAGE_TRACKER_PR_COLUMN = \d+;/, 'STAGE_TRACKER_PR_COLUMN'), + pick(/const STAGE_TRACKER_MERGE_COLUMN = \d+;/, 'STAGE_TRACKER_MERGE_COLUMN'), + pick(/const STAGE_TRACKER_NEEDS_DECISION = \d+;/, 'STAGE_TRACKER_NEEDS_DECISION'), + pick(/const STAGE_TRACKER_ISSUE_NEEDS_DECISION = \d+;/, 'STAGE_TRACKER_ISSUE_NEEDS_DECISION'), + pick(/const STAGE_TRACKER_ISSUE_DECISION_COLUMN = \d+;/, 'STAGE_TRACKER_ISSUE_DECISION_COLUMN'), + pick(/const STAGE_TRACKER_TRIAGE_NEEDED = \d+;/, 'STAGE_TRACKER_TRIAGE_NEEDED'), + pick(/const STAGE_TRACKER_POSSIBLY_EXISTS = \d+;/, 'STAGE_TRACKER_POSSIBLY_EXISTS'), + pick(/const STAGE_TRACKER_PRE_MERGE_SOAK = \d+;/, 'STAGE_TRACKER_PRE_MERGE_SOAK'), + pick(/const STAGE_TRACKER_TERMINAL = \d+;/, 'STAGE_TRACKER_TERMINAL'), + pick(/const STAGE_TRACKER_REPAIR_STAGE_WHY = [^\n]*\n/, 'STAGE_TRACKER_REPAIR_STAGE_WHY'), + pick(/function stageTrackerUnderRepair\(stage, reason\) \{[\s\S]*?\n \}\n/, 'stageTrackerUnderRepair'), + pick(/function stageTrackerAnchor\(stage, stages, kind, item\) \{[\s\S]*?\n \}\n/, 'stageTrackerAnchor'), +].join('\n'); +const lifted = new Function(src + '; return { anchor: stageTrackerAnchor, underRepair: stageTrackerUnderRepair };')(); + +const STAGES = [ + { number: 10 }, { number: 15 }, { number: 17 }, { number: 20 }, { number: 30 }, { number: 40 }, { number: 45 }, + { number: 50 }, { number: 60 }, + { number: 70, branch_from: 50 }, { number: 71, branch_from: 50 }, { number: 72, branch_from: 50 }, { number: 74, branch_from: 50 }, + { number: 80 }, { number: 85, branch_from: 80 }, { number: 90, branch_from: 80 }, { number: 95 }, { number: 100 }, +]; +const COLUMN = { OPEN: 0, ACTIONABLE: 10, CLAIMED: 20, PR: 30, REVIEW: 50, MERGE_GATE: 80, DONE: 110 }; + +// Hive's own #15574 as the roll-9 spoke served it: adopted copy, once +// queued (gate still "merge-failed" from the conflicting attempt, train +// still on the record from the planner), now 070 Fixing · conflicting. +const pr15574 = (extra) => Object.assign({ + repo: 'hivecommons/hive', number: 15574, kind: 'pr', stage: 70, reason: 'conflicting', modifiers: [], + caption: 'fell back to Fixing — Red or changes requested; a hive agent is fixing it — conflicting', + adopted_from: { number: 15526, author: 'odttlnt' }, + merge_gate: { state: 'merge-failed', reason: 'conflicting', merge_failed: 'PUT …/merge: 405 Head branch is out of date' }, + merge_train: { id: 'v5#15574', state: 'queued-behind', front: 15560, position: 2, size: 2 }, +}, extra || {}); + +test('#15574: a Fixing PR with a stale merge-failed gate and a planner train lights CI / Review', () => { + assert.strictEqual(lifted.anchor(70, STAGES, 'pr', pr15574()), COLUMN.REVIEW, 'gate + train'); + assert.strictEqual(lifted.anchor(70, STAGES, 'pr', pr15574({ merge_train: null })), COLUMN.REVIEW, 'merge-failed gate alone'); + assert.strictEqual(lifted.anchor(70, STAGES, 'pr', pr15574({ merge_gate: { state: 'merging' } })), COLUMN.REVIEW, 'merging gate alone'); + assert.strictEqual(lifted.anchor(70, STAGES, 'pr', pr15574({ merge_gate: null })), COLUMN.REVIEW, 'planner train alone (pre-#15616 server)'); + assert.strictEqual(lifted.anchor(70, STAGES, 'pr', pr15574({ merge_gate: null, merge_train: null, left_train: { why: 'fixing' } })), COLUMN.REVIEW, 'post-#15616 server'); +}); + +test('stageTrackerUnderRepair mirrors the Go train rule', () => { + assert.strictEqual(lifted.underRepair(70, ''), 'fixing'); + assert.strictEqual(lifted.underRepair(71, ''), 'needs-author'); + assert.strictEqual(lifted.underRepair(72, ''), 'returned-to-contributor'); + assert.strictEqual(lifted.underRepair(74, ''), 'adopted-by-hive'); + assert.strictEqual(lifted.underRepair(85, ''), 'needs-decision'); + assert.strictEqual(lifted.underRepair(50, 'required-check-failing:build-and-test'), 'checks-failing'); + assert.strictEqual(lifted.underRepair(60, 'check-failing:lint'), 'checks-failing'); + assert.strictEqual(lifted.underRepair(60, 'CI-RED'), 'checks-failing'); + for (const [stage, reason] of [[50, ''], [50, 'required-check-pending:build-and-test'], [60, 'conflicting'], [80, ''], [100, ''], [110, '']]) { + assert.strictEqual(lifted.underRepair(stage, reason), '', 'stage ' + stage + ' reason ' + JSON.stringify(reason)); + } + assert.strictEqual(lifted.underRepair(undefined, undefined), ''); +}); + +// Ratchet: every PR stage × every gate state × every train state → the +// column the current state earns. Under repair → CI / Review always; +// a live merge attempt or a seated train past 030 → Merge queue; merged +// → Merged; otherwise the stage's own column. +const GATE_STATES = [null, 'gate-pending', 'ready', 'soaking', 'merging', 'merge-failed', 'duplicate-of:15560']; +const TRAIN_STATES = [null, 'queued-behind', 'rebasing', 'rebase-exhausted', 'front']; +const STAGE_COLUMN = { + 30: COLUMN.PR, 40: COLUMN.PR, + 50: COLUMN.REVIEW, 60: COLUMN.REVIEW, 70: COLUMN.REVIEW, 71: COLUMN.REVIEW, 72: COLUMN.REVIEW, 74: COLUMN.REVIEW, + 80: COLUMN.MERGE_GATE, 85: COLUMN.MERGE_GATE, 90: COLUMN.MERGE_GATE, 95: COLUMN.MERGE_GATE, 100: COLUMN.MERGE_GATE, + 110: COLUMN.DONE, 120: COLUMN.DONE, +}; +const REPAIR_STAGES = [70, 71, 72, 74]; + +function expectedColumn(stage, gate, train, reason) { + if (stage >= COLUMN.DONE) return COLUMN.DONE; + // 085 is the decision park: it rides no train but the person decides at the gate. + if (stage > COLUMN.PR && stage !== 85 && (REPAIR_STAGES.indexOf(stage) >= 0 || /^(required-)?check-failing:|^ci-red$/.test(reason))) return COLUMN.REVIEW; + if (stage > COLUMN.PR && (gate === 'merging' || gate === 'merge-failed')) return COLUMN.MERGE_GATE; + if (stage > COLUMN.PR && train) return COLUMN.MERGE_GATE; + return STAGE_COLUMN[stage]; +} + +test('ratchet: every state lands in the column its current state earns', () => { + let cases = 0; + for (const stage of Object.keys(STAGE_COLUMN).map(Number)) for (const gate of GATE_STATES) for (const train of TRAIN_STATES) for (const reason of ['', 'conflicting', 'required-check-failing:build-and-test']) { + const item = { repo: 'hivecommons/hive', number: 1, kind: 'pr', stage, reason, modifiers: [], + merge_gate: gate ? { state: gate } : null, + merge_train: train ? { id: 'v5#2', state: train, front: 2, position: 2, size: 2 } : null }; + const want = expectedColumn(stage, gate, train, reason); + const label = 'stage ' + stage + ' gate ' + gate + ' train ' + train + ' reason ' + JSON.stringify(reason); + assert.strictEqual(lifted.anchor(stage, STAGES, 'pr', item), want, label); + // A row under repair never lands past CI / Review, whatever else it carries. + if (lifted.underRepair(stage, reason) && stage > COLUMN.PR && stage !== 85 && stage < COLUMN.DONE) assert.ok(lifted.anchor(stage, STAGES, 'pr', item) <= COLUMN.REVIEW, label + ' promoted while under repair'); + cases++; + } + assert.ok(cases >= 15 * GATE_STATES.length * TRAIN_STATES.length * 3, 'ratchet covered ' + cases + ' cases'); +}); + +test('hivecommons/docs#512 keeps its column: a merge outcome at 050/060 with nothing to repair is a Merge queue matter', () => { + const row = (stage) => ({ repo: 'hivecommons/docs', number: 512, kind: 'pr', stage, reason: 'check-pending', modifiers: [], merge_gate: { state: 'merge-failed', reason: 'check-pending' } }); + assert.strictEqual(lifted.anchor(60, STAGES, 'pr', row(60)), COLUMN.MERGE_GATE); + assert.strictEqual(lifted.anchor(50, STAGES, 'pr', row(50)), COLUMN.MERGE_GATE); + assert.strictEqual(lifted.anchor(30, STAGES, 'pr', row(30)), COLUMN.PR, 'a stale gate never jumps a PR back in progress forward'); +}); + +// hive's own #15654: an issue filed seconds ago (000 New, no label yet) +// whose nested PR #15655 is already open. The strip draws the row via +// the PR ("PR in progress · @clubanderson"), so the list order must ride +// the same live work — not the parent's unlabelled stage, which sank the +// row to the bottom among the New rows. stageTrackerLead is the one rule +// the strip (stageTrackerLeadStage) and the sort key share. +const leadSrc = [ + pick(/const STAGE_TRACKER_COVERED_BY_PR = \d+;/, 'STAGE_TRACKER_COVERED_BY_PR'), + pick(/function stageTrackerLinkedDrawnHere\(lp, item\) \{[\s\S]*?\n \}\n/, 'stageTrackerLinkedDrawnHere'), + // One covering PR per case: the tie-breakers never run, so stubs do. + 'function stageTrackerLinkedSupersededGone(lp) { return String(lp && lp.state || "") === "closed"; }', + 'function stageTrackerAttentionTier() { return 0; }', + pick(/function stageTrackerLinkedSorted\(item, stages\) \{[\s\S]*?\n \}\n/, 'stageTrackerLinkedSorted'), + pick(/function stageTrackerLeadStage\(lp\) \{[\s\S]*?\n \}\n/, 'stageTrackerLeadStage'), + pick(/function stageTrackerLead\(item, stages\) \{[\s\S]*?\n \}\n/, 'stageTrackerLead'), + pick(/function stageTrackerSortKey\(item, stages\) \{[\s\S]*?\n \}\n/, 'stageTrackerSortKey'), +].join('\n'); + +test('#15654: a New issue whose nested PR is open sorts and anchors by the PR, not the unlabelled parent', () => { + let l; + try { + l = new Function(src + '\n' + leadSrc + '; return { lead: stageTrackerLead, leadStage: stageTrackerLeadStage, sortKey: stageTrackerSortKey, anchor: stageTrackerAnchor };')(); + } catch (e) { + assert.fail('lifting the lead helpers: ' + e.message); + } + const issue = { repo: 'hivecommons/hive', number: 15654, kind: 'issue', stage: 0, stage_since: '', created_at: '2026-10-30T23:59:50Z', + caption: 'Covered by PR #15655 — waiting for the stage-label pass', modifiers: [], + linked_prs: [{ number: 15655, title: 'Fix', author: 'clubanderson', author_kind: 'human', stage: 0, stage_since: '' }] }; + const lead = l.lead(issue, STAGES); + assert.strictEqual(lead.kind, 'pr'); + assert.strictEqual(lead.lead.number, 15655); + assert.strictEqual(lead.stage, 40, 'an open PR with no stage yet drives the strip at 040 covered-by-PR'); + assert.strictEqual(l.leadStage(issue.linked_prs[0]), 40); + assert.strictEqual(l.leadStage({ stage: 50 }), 50, 'a staged PR keeps its own stage'); + const key = l.sortKey(issue, STAGES); + assert.strictEqual(key.anchor, COLUMN.PR, 'list place = the PR column, the same the strip lights'); + assert.ok(key.anchor > l.sortKey({ kind: 'issue', stage: 0, linked_prs: [] }, STAGES).anchor, 'sorts above a New issue with no PR'); + // The strip and the sort key never disagree: whatever the nested PR's stage, + // the sort anchor equals the anchor of the stage the strip draws. + for (const stage of [0, 30, 40, 50, 60, 70, 80, 90, 110]) { + const it = Object.assign({}, issue, { linked_prs: [Object.assign({}, issue.linked_prs[0], { stage })] }); + const ld = l.lead(it, STAGES); + assert.strictEqual(l.sortKey(it, STAGES).anchor, l.anchor(ld.stage, STAGES, 'pr', ld.lead), 'nested PR stage ' + stage); + } + // No covering PR: the issue is its own lead. + const bare = l.lead({ kind: 'issue', stage: 10, stage_since: '2026-10-30T00:00:00Z' }, STAGES); + assert.strictEqual(bare.kind, 'issue'); + assert.strictEqual(bare.stage, 10); +}); diff --git a/src/pkg/dashboard/stage_tracker_item_column_test.go b/src/pkg/dashboard/stage_tracker_item_column_test.go new file mode 100644 index 0000000000..5713be02bc --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_item_column_test.go @@ -0,0 +1,141 @@ +package dashboard + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stageengine/prstage" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// TestStageTrackerItemColumnRatchet: the chevron column follows the +// CURRENT state, never the highest stage a PR once reached. Every PR +// stage × gate state × train state × reason → one column, and the same +// predicate (stageTrackerTrainUnderRepair) that seats or drops a train +// member decides it, so membership and column can never disagree. +// Hive's own #15574 sat at 070 "Fixing · conflicting" under Merge queue +// because its stale merge-failed gate still promoted the column. +func TestStageTrackerItemColumnRatchet(t *testing.T) { + gates := []string{"", MergeGateStatePending, MergeGateStateReady, MergeGateStateSoaking, MergeGateStateMerging, MergeGateStateMergeFailed} + trains := []string{"", MergeGateStateQueuedBehind, MergeGateStateRebasing, MergeGateStateRebaseExhausted, MergeGateStateTrainFront} + reasons := []string{"", "conflicting", "required-check-failing:build-and-test", "ci-red", "required-check-pending:build-and-test"} + cases := 0 + for _, d := range stagelabels.Table { + if !d.PR { + continue + } + for _, gate := range gates { + for _, train := range trains { + for _, reason := range reasons { + it := StageTrackerItem{Repo: "hivecommons/hive", Number: 1, Kind: "pr", Stage: d.Number, Reason: reason} + if gate != "" { + it.MergeGate = &StageTrackerMergeGate{State: gate} + } + if train != "" { + it.MergeTrain = &StageTrackerMergeTrain{ID: "v5#2", State: train, Front: 2, Position: 2, Size: 2} + } + want := stageTrackerColumn(d.Stage) + repairing := stageTrackerTrainUnderRepair(d.Number, reason) != "" + switch { + case d.Number <= trackerColumnPR: + // A stale gate never jumps a PR back in progress forward. + case repairing && d.Stage != stagelabels.NeedsDecision: + want = trackerColumnReview + case gate == MergeGateStateMerging || gate == MergeGateStateMergeFailed || train != "": + want = trackerColumnMergeGate + } + got := stageTrackerItemColumn(&it) + label := d.Stage.String() + " gate=" + gate + " train=" + train + " reason=" + reason + if got != want { + t.Errorf("%s: column %d, want %d", label, got, want) + } + if repairing && d.Number > trackerColumnPR && d.Stage != stagelabels.NeedsDecision && got > trackerColumnReview { + t.Errorf("%s: under repair yet promoted to column %d", label, got) + } + cases++ + } + } + } + } + if cases < 11*len(gates)*len(trains)*len(reasons) { + t.Fatalf("ratchet covered only %d cases", cases) + } + merged := StageTrackerItem{Kind: "pr", Stage: stageTrackerMergedStage, MergeGate: &StageTrackerMergeGate{State: MergeGateStateMergeFailed}} + if got := stageTrackerItemColumn(&merged); got != trackerColumnMerged { + t.Fatalf("merged row column %d, want %d", got, trackerColumnMerged) + } + if got := stageTrackerItemColumn(nil); got != trackerColumnOpen { + t.Fatalf("nil column %d", got) + } + // hivecommons/docs#512 keeps its column: a merge outcome at 050/060 + // with nothing to repair is a Merge queue matter. + docs512 := StageTrackerItem{Kind: "pr", Stage: 60, Reason: "check-pending", MergeGate: &StageTrackerMergeGate{State: MergeGateStateMergeFailed}} + if got := stageTrackerItemColumn(&docs512); got != trackerColumnMergeGate { + t.Fatalf("docs#512 column %d, want %d", got, trackerColumnMergeGate) + } +} + +// TestStageTrackerFixingAfterMergeFailedColumn replays hive's own +// #15574 through the payload: an adopted copy that led a train, whose +// merge attempt GitHub refused (conflict), now recorded at 070 fixing +// while a sibling's record still names it as the front. The refusal +// stays on the gate as history, but its column is CI / Review, it rides +// no train (the sub-row under its issue says so too), and the survivor's +// train shrinks to none. +func TestStageTrackerFixingAfterMergeFailedColumn(t *testing.T) { + now := time.Date(2026, 10, 30, 22, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + queued := prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15574, Position: 2, Size: 2, OverlapFiles: []string{"docs/a.md"}}.Reason() + store.Observe(stagelabels.Key("acme/console", 15560), stagelabels.AwaitingMergeAdmission, queued) + store.Observe(stagelabels.Key("acme/console", 15574), stagelabels.AwaitingMergeAdmission, "") + store.Observe(stagelabels.Key("acme/console", 15574), stagelabels.Fixing, "conflicting") + head := "abc123" + attempts := []github.MergeAttempt{{Repo: "acme/console", Number: 15574, Path: github.PRAuditPathSweep, Head: head, + StartedAt: now.Add(-10 * time.Minute), EndedAt: now.Add(-10*time.Minute + time.Second), Error: "PUT /merge: 405 Head branch is out of date"}} + s.mergeAttempts = func() []github.MergeAttempt { return attempts } + s.statusMu.Lock() + s.status.Repos[0].ActionableIssues = append(s.status.Repos[0].ActionableIssues, + github.Issue{Number: 15511, Title: "Tracker column", Author: "pat", AuthorIsHuman: true, Labels: []string{"stage/040-covered-by-pr"}}) + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: 15560, Title: "Sibling", Author: "hive-app[bot]", AppAuthored: true, BaseRef: "v5", Labels: []string{stagelabels.AwaitingMergeAdmission.Label(), "author/hive"}}}, + FrontendPR{PullRequest: github.PullRequest{Number: 15574, Title: "Adopted copy", Author: "hive-app[bot]", AppAuthored: true, BaseRef: "v5", HeadSHA: head, + Labels: []string{stagelabels.Fixing.Label(), "author/hive"}, LinkedIssues: []github.PRLinkedIssue{{Number: 15511}}}}) + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + + pr := trackerItem(t, resp, "pr", 15574) + if pr.Stage != stagelabels.Fixing.Number() { + t.Fatalf("stage %d, want 070", pr.Stage) + } + if pr.MergeGate == nil || pr.MergeGate.State != MergeGateStateMergeFailed { + t.Fatalf("the refusal stays on the gate as history: %+v", pr.MergeGate) + } + if pr.MergeTrain != nil || pr.LeftTrain == nil || pr.LeftTrain.Why != stagelabels.Fixing.Slug() { + t.Fatalf("a PR being fixed rides no train: train %+v left %+v", pr.MergeTrain, pr.LeftTrain) + } + if got := stageTrackerItemColumn(&pr); got != trackerColumnReview { + t.Fatalf("070 fixing after a refused merge lights column %d, want CI / Review %d", got, trackerColumnReview) + } + alone := trackerItem(t, resp, "pr", 15560) + if alone.MergeTrain != nil || stageTrackerItemColumn(&alone) != trackerColumnMergeGate { + t.Fatalf("survivor: train %+v column %d", alone.MergeTrain, stageTrackerItemColumn(&alone)) + } + issue := trackerItem(t, resp, "issue", 15511) + if len(issue.LinkedPRs) != 1 || issue.LinkedPRs[0].Number != 15574 { + t.Fatalf("issue linked_prs = %+v", issue.LinkedPRs) + } + lp := issue.LinkedPRs[0] + if lp.MergeTrain != nil || lp.LeftTrain == nil || lp.LeftTrain.Why != stagelabels.Fixing.Slug() { + t.Fatalf("the sub-row mirrors the row: train %+v left %+v", lp.MergeTrain, lp.LeftTrain) + } + raw, err := json.Marshal(lp) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(raw), `"left_train":{"why":"fixing"`) { + t.Fatalf("linked_prs payload lacks left_train:\n%s", raw) + } +} diff --git a/src/pkg/dashboard/stage_tracker_links.go b/src/pkg/dashboard/stage_tracker_links.go index ed602b1b9d..72ee3642ff 100644 --- a/src/pkg/dashboard/stage_tracker_links.go +++ b/src/pkg/dashboard/stage_tracker_links.go @@ -335,7 +335,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin lp.BaseRef = pr.BaseRef lp.DecisionNeeded = pr.DecisionNeeded lp.SoakRemainingSeconds, lp.MergeGate = pr.SoakRemainingSeconds, pr.MergeGate - lp.MergeTrain = pr.MergeTrain + lp.MergeTrain, lp.LeftTrain = pr.MergeTrain, pr.LeftTrain lp.Soak = pr.Soak lp.LastOperatorAction, lp.OperatorActionCount = pr.LastOperatorAction, pr.OperatorActionCount lp.Decided, lp.AdoptedFrom = pr.Decided, pr.AdoptedFrom diff --git a/src/pkg/dashboard/stage_tracker_merge_train.go b/src/pkg/dashboard/stage_tracker_merge_train.go index aea24e3d07..18eb5e414b 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train.go +++ b/src/pkg/dashboard/stage_tracker_merge_train.go @@ -241,11 +241,17 @@ type StageTrackerLeftTrain struct { // stageTrackerTrainUnderRepair names why a PR at stage, with reason, is // not a train member right now — "" when it may ride. A PR being fixed -// (070), waiting on its author (071) or contributor (072), parked on a -// human decision (085), or whose required checks are red is somebody's -// to repair first; the planner may still have ordered it, but the view -// never seats it (hivecommons/hive#15581 admits 050/060 provisionally -// only while nothing is red). +// (070), waiting on its author (071) or contributor (072), freshly +// adopted (074), parked on a human decision (085), or whose required +// checks are red is somebody's to repair first; the planner may still +// have ordered it, but the view never seats it (hivecommons/hive#15581 +// admits 050/060 provisionally only while nothing is red). +// +// stageTrackerItemColumn reads the same predicate for the chevron +// column, and stageTrackerUnderRepair in the SPA mirrors it: membership +// and column can never disagree (hive's own #15574 sat at 070 "Fixing" +// under Merge queue because its stale merge-failed gate still promoted +// the column after the train rule had already dropped it). func stageTrackerTrainUnderRepair(stage int, reason string) string { switch stage { case stagelabels.Fixing.Number(): @@ -254,6 +260,8 @@ func stageTrackerTrainUnderRepair(stage int, reason string) string { return stagelabels.NeedsAuthor.Slug() case stagelabels.ReturnedToContributor.Number(): return stagelabels.ReturnedToContributor.Slug() + case stagelabels.AdoptedByHive.Number(): + return stagelabels.AdoptedByHive.Slug() case stagelabels.NeedsDecision.Number(): return stagelabels.NeedsDecision.Slug() } diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index de848662f0..8e3d42fcd0 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -594,6 +594,9 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedSorted"), jsFunc(t, html, "stageTrackerNeedsAttention"), stageTrackerTierJS(t, html), + jsConstLine(t, html, "STAGE_TRACKER_COVERED_BY_PR"), + jsFunc(t, html, "stageTrackerLeadStage"), + jsFunc(t, html, "stageTrackerLead"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "stageTrackerHeadline"), jsFunc(t, html, "stageTrackerAnchor"), diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index 9e5fe1a2be..58a99826f9 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -174,6 +174,9 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), + jsConstLine(t, html, "STAGE_TRACKER_COVERED_BY_PR"), + jsFunc(t, html, "stageTrackerLeadStage"), + jsFunc(t, html, "stageTrackerLead"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "esc"), jsFunc(t, html, "agentNowAgo"), diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index a8c7850482..29757545c6 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -207,6 +207,9 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), + jsConstLine(t, html, "STAGE_TRACKER_COVERED_BY_PR"), + jsFunc(t, html, "stageTrackerLeadStage"), + jsFunc(t, html, "stageTrackerLead"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "esc"), jsFunc(t, html, "agentNowAgo"), @@ -959,6 +962,9 @@ func TestStageTrackerFilterSortPage(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), + jsConstLine(t, html, "STAGE_TRACKER_COVERED_BY_PR"), + jsFunc(t, html, "stageTrackerLeadStage"), + jsFunc(t, html, "stageTrackerLead"), jsFunc(t, html, "stageTrackerSortKey"), jsConstLine(t, html, "STAGE_TRACKER_HUMAN_MODS"), jsConstLine(t, html, "STAGE_TRACKER_HANDLED_TEXT"), diff --git a/src/pkg/dashboard/stage_tracker_vocabulary.go b/src/pkg/dashboard/stage_tracker_vocabulary.go index ba4f1d737d..7b174f48ce 100644 --- a/src/pkg/dashboard/stage_tracker_vocabulary.go +++ b/src/pkg/dashboard/stage_tracker_vocabulary.go @@ -50,6 +50,43 @@ func stageTrackerColumn(stage stagelabels.Stage) int { return trackerColumnOpen } +// stageTrackerItemColumn is the chevron a PR row lights given its CURRENT +// state — never the highest stage it once reached. The ladder is: +// +// - merged (≥ 110) → Merged; +// - under repair past 030 (stageTrackerTrainUnderRepair: 070/071/072/ +// 074, or red required checks) → CI / Review, whatever a stale merge +// gate ("merge-failed" from the attempt that found the conflict) or a +// planner-ordered merge train still says — except the 085 decision +// park, which stays at the gate where the person decides; +// - a live merge attempt (merging / merge-failed past 030) or a seated +// train member → Merge queue (hivecommons/docs#512, hive#15395); +// - otherwise the stage's own column (stageTrackerColumn). +// +// The "fell back to …" caption keeps the history; the column follows the +// fallback. The SPA's stageTrackerAnchor applies the same order. +func stageTrackerItemColumn(it *StageTrackerItem) int { + if it == nil { + return trackerColumnOpen + } + if it.Stage >= trackerColumnMerged { + return trackerColumnMerged + } + st := stageByNumber(it.Stage) + if it.Kind == "pr" && it.Stage > trackerColumnPR && st != stagelabels.NeedsDecision && stageTrackerTrainUnderRepair(it.Stage, it.Reason) != "" { + return trackerColumnReview + } + if it.Stage > trackerColumnPR { + if mg := it.MergeGate; mg != nil && (mg.State == MergeGateStateMerging || mg.State == MergeGateStateMergeFailed) { + return trackerColumnMergeGate + } + if mt := it.MergeTrain; mt != nil && mt.State != "" { + return trackerColumnMergeGate + } + } + return stageTrackerColumn(st) +} + // stageTrackerStagePhrase is the stage as a lowercase clause for the // middle of a sentence ("its PR is reviewed · waiting for merge // admission"), from the same words the chevron shows. diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 3f96011df3..b956e1be7e 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -9,9 +9,21 @@ // merge-failed) the outcome is a Merge gate matter whatever numeric // stage the lane fell back to — hivecommons/docs#512 drew "Merge // failed" in CI / Review because the PR sat at 060. + // + // The column follows the CURRENT state, never the highest stage the + // row once reached: a PR under repair (stageTrackerUnderRepair) lights + // CI / Review even when a stale merge_gate ("merge-failed" from the + // attempt that found the conflict) or a planner-ordered merge_train + // still rides on the record — hive's own #15574 read "Fixing" under + // Merge queue after "fell back to Fixing — conflicting". function stageTrackerAnchor(stage, stages, kind, item) { const cur = Number(stage) || 0; if (cur >= STAGE_TRACKER_TERMINAL) return STAGE_TRACKER_TERMINAL; + // Under repair past 030 → CI / Review, before any gate or train + // promotion. The one park the predicate also names, 085 needs + // decision, stays at the gate: the person decides there. + const repairing = typeof stageTrackerUnderRepair === 'function' && !!stageTrackerUnderRepair(cur, item && item.reason); + if (repairing && cur > STAGE_TRACKER_PR_COLUMN && cur !== STAGE_TRACKER_NEEDS_DECISION) return 50; const mg = item && item.merge_gate; if (mg && (mg.state === 'merging' || mg.state === 'merge-failed') && cur > STAGE_TRACKER_PR_COLUMN) return STAGE_TRACKER_MERGE_COLUMN; // A merge-train member is a Merge queue matter too, 1st included: @@ -937,7 +949,7 @@ stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -1138,13 +1150,30 @@ }); } + // The stage a covering PR drives its issue's strip at: its own, or 040 + // covered-by-PR while it has none yet (an open PR filed seconds ago, + // still waiting for the stage-label pass). One rule for the strip and + // the list order — hive's own #15654 (000 New, nested #15655 drawn as + // "PR in progress") sat at the bottom among the New rows because the + // sort key fell back to the parent's unlabelled stage while the strip + // did not. + const STAGE_TRACKER_COVERED_BY_PR = 40; + function stageTrackerLeadStage(lp) { + return Number(lp && lp.stage) || STAGE_TRACKER_COVERED_BY_PR; + } + // Pure: the row whose live work drives an issue's strip and list place + // — its furthest covering PR, else the issue itself. + function stageTrackerLead(item, stages) { + const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; + if (!linked.length) return { lead: item, kind: item.kind, stage: Number(item.stage) || 0, since: item.stage_since || '' }; + const lp = linked[0]; + return { lead: lp, kind: 'pr', stage: stageTrackerLeadStage(lp), since: lp.stage_since || item.stage_since || '' }; + } // List order: furthest along the strip first — a covered issue counts as // far along as its furthest covering PR — then longest-waiting first. function stageTrackerSortKey(item, stages) { - const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; - const lead = linked.length && linked[0].stage ? linked[0] : item; - const kind = lead === item ? item.kind : 'pr'; - return { anchor: stageTrackerAnchor(lead.stage, stages, kind, lead), since: Date.parse(lead.stage_since || '') || Infinity }; + const l = stageTrackerLead(item, stages); + return { anchor: stageTrackerAnchor(l.stage, stages, l.kind, l.lead), since: Date.parse(l.since) || Infinity }; } /* ---- Repo chip and group-by-repo (pure; run under node by @@ -1291,8 +1320,8 @@ const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; - shown = Object.assign({}, item, { via_pr: true, stage: lp.stage || 40, stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || item.decided || null }); + shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/dashboard/static-src/js/tracker-words-core.js b/src/pkg/dashboard/static-src/js/tracker-words-core.js index d9894b43de..cf1b5cbf07 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words-core.js +++ b/src/pkg/dashboard/static-src/js/tracker-words-core.js @@ -185,6 +185,22 @@ const mt = item && item.merge_train; return mt && typeof mt === 'object' && mt.state ? mt : null; } + // Pure: why a PR at stage, with reason, is somebody's to repair right + // now — '' when nothing is. Mirrors stageTrackerTrainUnderRepair in + // Go (the rule that seats a PR in, or drops it from, its merge train) + // so the chevron column and train membership read one predicate: a + // PR being fixed (070), waiting on its author (071) or contributor + // (072), freshly adopted (074), parked on a decision (085), or whose + // required checks are red rides no train; all but the decision park + // light CI / Review whatever the gate or the planner last recorded. + const STAGE_TRACKER_REPAIR_STAGE_WHY = { 70: 'fixing', 71: 'needs-author', 72: 'returned-to-contributor', 74: 'adopted-by-hive', 85: 'needs-decision' }; + function stageTrackerUnderRepair(stage, reason) { + const why = STAGE_TRACKER_REPAIR_STAGE_WHY[Number(stage) || 0]; + if (why) return why; + const lower = String(reason || '').trim().toLowerCase(); + if (lower.indexOf('required-check-failing:') === 0 || lower.indexOf('check-failing:') === 0 || lower === 'ci-red') return 'checks-failing'; + return ''; + } // The first merge-ready stage (080 awaiting merge admission). A train // member below it holds a provisional slot: the planner has ordered // it, but CI / the review verdict / the fixer still stand in front. diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index c74dea3d23..4cfe7e3ae7 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -14625,6 +14625,22 @@

Where to get help

const mt = item && item.merge_train; return mt && typeof mt === 'object' && mt.state ? mt : null; } + // Pure: why a PR at stage, with reason, is somebody's to repair right + // now — '' when nothing is. Mirrors stageTrackerTrainUnderRepair in + // Go (the rule that seats a PR in, or drops it from, its merge train) + // so the chevron column and train membership read one predicate: a + // PR being fixed (070), waiting on its author (071) or contributor + // (072), freshly adopted (074), parked on a decision (085), or whose + // required checks are red rides no train; all but the decision park + // light CI / Review whatever the gate or the planner last recorded. + const STAGE_TRACKER_REPAIR_STAGE_WHY = { 70: 'fixing', 71: 'needs-author', 72: 'returned-to-contributor', 74: 'adopted-by-hive', 85: 'needs-decision' }; + function stageTrackerUnderRepair(stage, reason) { + const why = STAGE_TRACKER_REPAIR_STAGE_WHY[Number(stage) || 0]; + if (why) return why; + const lower = String(reason || '').trim().toLowerCase(); + if (lower.indexOf('required-check-failing:') === 0 || lower.indexOf('check-failing:') === 0 || lower === 'ci-red') return 'checks-failing'; + return ''; + } // The first merge-ready stage (080 awaiting merge admission). A train // member below it holds a provisional slot: the planner has ordered // it, but CI / the review verdict / the fixer still stand in front. @@ -16095,9 +16111,21 @@

Where to get help

// merge-failed) the outcome is a Merge gate matter whatever numeric // stage the lane fell back to — hivecommons/docs#512 drew "Merge // failed" in CI / Review because the PR sat at 060. + // + // The column follows the CURRENT state, never the highest stage the + // row once reached: a PR under repair (stageTrackerUnderRepair) lights + // CI / Review even when a stale merge_gate ("merge-failed" from the + // attempt that found the conflict) or a planner-ordered merge_train + // still rides on the record — hive's own #15574 read "Fixing" under + // Merge queue after "fell back to Fixing — conflicting". function stageTrackerAnchor(stage, stages, kind, item) { const cur = Number(stage) || 0; if (cur >= STAGE_TRACKER_TERMINAL) return STAGE_TRACKER_TERMINAL; + // Under repair past 030 → CI / Review, before any gate or train + // promotion. The one park the predicate also names, 085 needs + // decision, stays at the gate: the person decides there. + const repairing = typeof stageTrackerUnderRepair === 'function' && !!stageTrackerUnderRepair(cur, item && item.reason); + if (repairing && cur > STAGE_TRACKER_PR_COLUMN && cur !== STAGE_TRACKER_NEEDS_DECISION) return 50; const mg = item && item.merge_gate; if (mg && (mg.state === 'merging' || mg.state === 'merge-failed') && cur > STAGE_TRACKER_PR_COLUMN) return STAGE_TRACKER_MERGE_COLUMN; // A merge-train member is a Merge queue matter too, 1st included: @@ -17023,7 +17051,7 @@

Where to get help

stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -17224,13 +17252,30 @@

Where to get help

}); } + // The stage a covering PR drives its issue's strip at: its own, or 040 + // covered-by-PR while it has none yet (an open PR filed seconds ago, + // still waiting for the stage-label pass). One rule for the strip and + // the list order — hive's own #15654 (000 New, nested #15655 drawn as + // "PR in progress") sat at the bottom among the New rows because the + // sort key fell back to the parent's unlabelled stage while the strip + // did not. + const STAGE_TRACKER_COVERED_BY_PR = 40; + function stageTrackerLeadStage(lp) { + return Number(lp && lp.stage) || STAGE_TRACKER_COVERED_BY_PR; + } + // Pure: the row whose live work drives an issue's strip and list place + // — its furthest covering PR, else the issue itself. + function stageTrackerLead(item, stages) { + const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; + if (!linked.length) return { lead: item, kind: item.kind, stage: Number(item.stage) || 0, since: item.stage_since || '' }; + const lp = linked[0]; + return { lead: lp, kind: 'pr', stage: stageTrackerLeadStage(lp), since: lp.stage_since || item.stage_since || '' }; + } // List order: furthest along the strip first — a covered issue counts as // far along as its furthest covering PR — then longest-waiting first. function stageTrackerSortKey(item, stages) { - const linked = item.kind === 'issue' ? stageTrackerLinkedSorted(item, stages) : []; - const lead = linked.length && linked[0].stage ? linked[0] : item; - const kind = lead === item ? item.kind : 'pr'; - return { anchor: stageTrackerAnchor(lead.stage, stages, kind, lead), since: Date.parse(lead.stage_since || '') || Infinity }; + const l = stageTrackerLead(item, stages); + return { anchor: stageTrackerAnchor(l.stage, stages, l.kind, l.lead), since: Date.parse(l.since) || Infinity }; } /* ---- Repo chip and group-by-repo (pure; run under node by @@ -17377,8 +17422,8 @@

Where to get help

const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; - shown = Object.assign({}, item, { via_pr: true, stage: lp.stage || 40, stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || item.decided || null }); + shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron.