From 39a8e50c83314a3bcb74a6ce5f0559fdc7646e56 Mon Sep 17 00:00:00 2001 From: thatguywob Date: Wed, 28 Oct 2026 19:47:17 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20explain=20Activity=20?= =?UTF-8?q?Monitor=20merge=20gates=20and=20sweep=20timing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Distinguish reviewed, ready, soaking and merging rows, expose merge-sweep clocks and preserve gate context on nested PRs. Label the gate glyph and agent activity separately. Hive-Run: hivecommons/hive#15073 Hive-Plan: merge-gate-observability Hive-Spec: issue-15073#fix Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> Signed-off-by: thatguywob --- changelog.d/fixed-15073-merge-gate.md | 1 + src/cmd/hive/automerge_sweep_wiring_test.go | 5 + src/cmd/hive/main.go | 2 + src/docs/dashboard-sections.md | 5 +- src/pkg/dashboard/stage_tracker.go | 28 +++-- src/pkg/dashboard/stage_tracker_merge_gate.go | 53 +++++++++ .../stage_tracker_merge_gate_test.go | 44 ++++++++ src/pkg/dashboard/stage_tracker_ui_test.go | 59 ++++++++-- src/pkg/dashboard/static/index.html | 37 +++++-- .../automerge/automerge_contributor_lane.go | 1 + .../github/automerge/automerge_forgestate.go | 5 +- src/pkg/github/automerge/automerge_sweep.go | 16 ++- src/pkg/github/automerge/sweep_clock.go | 34 ++++++ src/pkg/github/automerge/sweep_clock_test.go | 45 ++++++++ src/pkg/github/client.go | 5 +- src/pkg/github/merge_sweep_clock.go | 102 ++++++++++++++++++ src/pkg/github/merge_sweep_clock_test.go | 44 ++++++++ 17 files changed, 453 insertions(+), 33 deletions(-) create mode 100644 changelog.d/fixed-15073-merge-gate.md create mode 100644 src/pkg/dashboard/stage_tracker_merge_gate.go create mode 100644 src/pkg/dashboard/stage_tracker_merge_gate_test.go create mode 100644 src/pkg/github/automerge/sweep_clock.go create mode 100644 src/pkg/github/automerge/sweep_clock_test.go create mode 100644 src/pkg/github/merge_sweep_clock.go create mode 100644 src/pkg/github/merge_sweep_clock_test.go diff --git a/changelog.d/fixed-15073-merge-gate.md b/changelog.d/fixed-15073-merge-gate.md new file mode 100644 index 0000000000..fae7636caf --- /dev/null +++ b/changelog.d/fixed-15073-merge-gate.md @@ -0,0 +1 @@ +- Activity Monitor distinguishes awaiting the merge gate, ready, soaking and merging, labels merge-sweep and agent glyphs separately, and shows sweep timing and nested PR soak countdowns ([#15073](https://github.com/hivecommons/hive/issues/15073)). diff --git a/src/cmd/hive/automerge_sweep_wiring_test.go b/src/cmd/hive/automerge_sweep_wiring_test.go index 8adca47929..05309db2dc 100644 --- a/src/cmd/hive/automerge_sweep_wiring_test.go +++ b/src/cmd/hive/automerge_sweep_wiring_test.go @@ -103,6 +103,11 @@ func TestRunAutoMergeSweepIfDue_DueSweepStampsLastRunAndCallsAPI(t *testing.T) { if lastRun.Before(start) { t.Fatalf("due sweep must stamp lastRun, got %v", lastRun) } + clock := ghClient.MergeSweepClock().Snapshot("testorg/widget", 1) + if clock.LastSweepAt == nil || clock.LastSweepAt.Before(start) || clock.NextSweepAt == nil || !clock.NextSweepAt.Equal(lastRun.Add(autoMergeSweepInterval)) { + t.Fatalf("sweep clock did not publish actual pass timing: %+v", clock) + } + } func TestRunAutoMergeSweepIfDue_NilLastRunStillSweeps(t *testing.T) { diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index d80b44cd0a..c2a2bcfafc 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -9314,6 +9314,8 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c if lastRun != nil { *lastRun = now } + ghClient.MergeSweepClock().Schedule("queued", now.Add(autoMergeSweepInterval)) + defer ghClient.MergeSweepClock().Begin("queued")() ctx = github.WithPacingClass(ctx, github.PacingLow) // governor.automerge covers the queued, trusted-author and contributor- // lane sweeps plus the stage-label pass that follows them. The sweep runs diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 85b8788e5f..1ca0b528d7 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -646,7 +646,10 @@ More about the line: A progress strip per open issue and pull request showing which step of the pipeline it is on and who must act next. -Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same pipeline, named once in the column header above the list: `Open → Actionable (010) → Claimed (020) → PR in progress (030/040) → CI / Review (050/060) → Merge gate (080/100) → ✓ merged`. Each entry is a title line over a thin chevron strip. Only the current step is coloured: it is filled amber and carries the step name in words; once the PR is merged the final ✓ chevron is the lit one, in green. Motion is reserved for what is running or needs a hand — the lit chevron falls into one of three buckets (`stageTrackerMotion()` in `index.html`): **static** (steady): Open, Open · on hold (any hold label wins over every other signal), Actionable (010), Claimed (020), PR in progress / Covered by PR (030/040) by a human author, Merged, and any unrecognised stage; **active** (gentle pulse): the hive is acting — 030/040 by a hive or clanker author, 050 review pending, 060 reviewed, 070 fixing, 074 adopted by hive, 080 merge gate, 095 pre-merge soak, 100 merge queue; **needs-human** (slower amber→red breathe): a person must move — 015 triage needed, 045/085 needs decision, 071 needs author, 072 returned to contributor, 090 ready for a human merge, or a `stalled` / `blocked` / `needs-human` / `needs-decision` / `needs-triage` modifier on any stage. Under `prefers-reduced-motion` nothing animates; a needs-human step keeps a steady red tint so it still stands out. Every other step is a low-contrast shape with a small grey glyph (circle, bolt, lock, branch, eye, shield, check) — passed steps a subtle neutral fill, steps ahead a faint outline. Side stages are not extra steps: `070 Fixing` (the author's move; the `needs-rebase` chip next to it says what is being fixed — the stage labeller always parks a needs-rebase PR at 070/071/072, never at CI / Review), `071 Needs author` (human-authored), `072 Returned to contributor` (clanker-authored) and `074 Adopted by hive` light *CI / Review* with their own name (an adopted PR stays on 074 through the hive's pushes going pending, green or red again, and moves on only when *Merge gate* takes it); `085 Needs human decision` (PR-only) and `090 Ready for human merge` light *Merge gate* with their own name (the 085 tooltip says what must be decided); an issue parked on a person wears `045 Needs human decision` and lights *Actionable* (the issue side) with that name — a pre-045 issue still wearing 085 is drawn the same way until the reconciler re-stages it; an actionable issue no maintainer has looked at yet wears `015 Triage needed` (carrying `needs-triage`, or held in the reporter-trust gate's `reporter_triage` bucket — never derived from who filed it) and lights *Actionable* as "Triage needed" (a human's move) — so the Actionable column reads "Actionable", "Triage needed" or "Needs human decision", and the Open column is untouched. An issue carrying a hold-class label (`hold`, `do-not-merge*`, `hive-pause/`) is never parked: it sits at *Open* as "Open · on hold" even beside `needs-human`, and the reconciler removes any 045 the hold caught it with ([#13012](https://github.com/hivecommons/hive/issues/13012)). The lit chevron ends with an ink-coloured icon of whose move it is — person (human), robot (clanker) or hexagon (hive): the claim holder on Claimed, the PR author on PR in progress and Returned to contributor, hive on CI / Review, Adopted by hive and Ready for auto merge, a human on Needs human decision and Ready for human merge. A row at `090 Ready for human merge` always says *why* a person and not the hive merges it (#14658): the lit word ends `· workflow files`, `· tests removed`, `· manual-merge policy`, `· branch protection`, `· merge method`, `· auto-merge off`, `· untrusted author`, `· unauthorized`, `· reviewer deferred` or `· policy` (payload `human_merge_reason`, a `prstage.HumanMergeReason*` code derived from the stage record's lane reason — no second store), the chevron tooltip leads with the one-sentence `human_merge_reason_text` ("Changes .github/workflows/** — the hive never merges workflow changes …; click Merge on GitHub"), the manual-merge word reads `Awaiting human merge · workflow files · approved by @login`, the search / needs-attention headline carries the same tail, and a PR nested under its issue mirrors `human_approver`, `manual_merge`, `human_merge_reason` and `human_merge_reason_text` onto its `linked_prs` entry so the sub-row says the same. `040 Covered by PR` shares the *PR in progress* column with 030; `060 Reviewed`, `080 Awaiting merge admission` and `100 Merge queue` all light *Merge gate* as "Ready for auto merge" (the chevron tooltip says "not yet admitted — " for 060/080 and "admitted, merging" for 100); `095 Pre-merge soak` lights the same column as "Soaking" (hive's move; tooltip "admitted, soaking — Xm left", headline "Pre-merge soak — Xm left" from the payload's `soak_remaining_seconds`, aged from the lane's last sweep), so an admitted PR inside its soak window is no longer drawn as merging; the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `↳ [author icon] #PR title` under the *PR in progress* header on the same title line (the ↳ marks a PR drawn on its issue's row; the PR link's tooltip says so — "linked PR, shown on its issue's row" — and, when two open issues list the same PR, every row but the lowest-numbered issue adds "also under #N"), and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. A PR whose only linked issue is already closed — a superseded PR whose body still says `Fixes #N` after an earlier PR fixed it — keeps its own row with the closed issue in the issue slot: `#N title` as a link, muted and struck through, followed by a small `closed` chip, so the pairing reads at a glance; when the title cannot be resolved the slot says `#N (closed issue)` rather than a bare number (the title comes from the snapshot, or from one cached issue read the cycle makes once per issue — see [Linked issues](dashboard.md#pr-review-and-link-signals)). The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). A plain *Open* step — no stage label yet and not on hold — also carries that age in its own words, "Open · since 3d" ("since 14h" under two days), taken from the same `stage_since` instant the column draws (falling back to the time the item was opened, which the chevron tooltip then marks "(opened)"); past `STAGE_TRACKER_OPEN_STALE_DAYS` (2) the chevron takes a subtle red tint. *Open · hold* never shows the age. An Open item carrying the `blocked` label is drawn the same way as a hold — "Open · blocked" with a ⛔ glyph in the hold's yellow — but keeps the age ("Open · blocked · since 7h"; a stale blocked item is exactly what should stand out, [#14194](https://github.com/hivecommons/hive/issues/14194)) and its chevron tooltip says why: "blocked on owner/repo#N" when the payload names the blocker (`blocked_on`), else "carries the blocked label"; when an item is both held and blocked, hold wins — it is a human instruction. A draft PR — the forge's draft bit, or prow's `do-not-merge/work-in-progress` label — reads "Draft · since 18h" in the Open cell with a ✎ glyph in the muted draft tint, never turns stale (the hive's review and merge lanes skip drafts, so the wait is the author's, not a stuck pipeline), and wears a muted `draft` chip whose tooltip says the lanes skip it until the author marks it ready; a hold or blocked label still wins the cell, with `draft` folded into the chip's `+N` ([#14572](https://github.com/hivecommons/hive/issues/14572)). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-triage` — shown as "triage needed" (amber) on an issue still carrying the `needs-triage` label before the claim (010, 017, 045; at 015 the lit chevron already says so); a `needs-triage` left on a claimed or later issue (020+) is stale, never shown as a chip or stage text, and reported instead as `stale_labels` in the payload with a muted *Stale label* line in the hover tooltip until the stage sweep removes it (hivecommons/hive#14586) —, `needs-rebase`, `blocked`, `draft` — set by the PR's draft bit or prow's `do-not-merge/work-in-progress` label, which the tracker reads as a draft rather than a hold) with a `+N` for the rest. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a drawn health modifier or on 071 / 072 / 085 / 090 — merge-gate pills held back before the gate do not count), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header count "N rows · M need attention" is for the filtered set, the **sidebar badge is the row count of the default view** (owner: the tracker counts rows, not items — a covering PR drawn on its issue's row is not a row of its own, and an issue with several PRs already has several), and both come from the same `stageTrackerCountsText()` call so they cannot disagree. When rows sit below the payload's open issues + PRs, the "showing" line's tooltip and the badge's footnote say why — "2 PRs shown on their issue's row" — rather than printing a second total.the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `[author icon] #PR title` under the *PR in progress* header on the same title line, and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-rebase`, `blocked`, `draft` — the PR's draft bit or prow's `do-not-merge/work-in-progress` label) with a `+N` for the rest. A `regressed` chip is red only when the row is parked on a person (a human-gate modifier or stage 045 / 071 / 072 / 085 / 090); on a hive-driven stage with nothing waiting on a human it draws as a muted dashed `stage ↓` pill, yields the lead slot to any other modifier, keeps the row out of **Needs attention**, and its tooltip ends "the hive is handling it — no action needed; clears on the next forward step". The marker is set by a genuine backward hop (a lapsed claim 020 → 010, a 030 ↔ 020 flicker and a 040 → 010 after a partially-addressing merge are not regressions) and clears on the first forward hop; see "The regressed marker" in `labels-and-control-signals.md`. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a drawn health modifier or on 071 / 072 / 085 / 090 — merge-gate pills held back before the gate do not count), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header reads "N items (I issues / P PRs) · M need attention" — N, I and P are the whole list, the same `openItems` set the Overview tile and its left-menu counter print, so N always equals the tile's **Total open issues + Total open PRs**; a "· X match filters" note follows while a filter is on. The sidebar counter beside **Hive activity monitor** is that same N — total open items, written in the same render pass as the header, so the two cannot drift apart; how many need attention is the warn-coloured header suffix and the counter's hover tooltip (counted over every item, filters or not). When covering pull requests are nested under their issue the "showing X–Y of R" line counts rows and adds "(P nested under their issues)" so R never reads as a different total. The small monospace strip beside the count — `engine enforce · N anomalies` — is the central stage engine ([ADR-0025](adr/0025-central-stage-engine.md)): `engine` names the current `governor.labels.stage.engine.mode` (green `enforce`, neutral `shadow` = paused, nothing written; hover for what the mode does and the derivation count), `anomalies` counts stage moves the engine's admission table did not expect (red when non-zero). The same numbers are `/api/status.stageEngine`; the mode is changed under **Settings → Labels → Central stage engine mode** and the operator notes are in [operator-reference.md](operator-reference.md#central-stage-engine-rollout). "updated Ns ago · cache" says how old the server-built payload is: the spoke rebuilds it at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from its existing snapshot and serves it with an `ETag`, so the browser's 30-second poll is a 304 and no request ever reaches GitHub (`/api/gh-rate-limits` lists the caller `dashboard:stage-tracker` with nothing charged). See [Stage labels](labels-and-control-signals.md#stage-labels-stagennn--the-pipeline-state-machine). +Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same pipeline, named once in the column header above the list: `Open → Actionable (010) → Claimed (020) → PR in progress (030/040) → CI / Review (050/060) → Merge gate (080/100) → ✓ merged`. Each entry is a title line over a thin chevron strip. Only the current step is coloured: it is filled amber and carries the step name in words; once the PR is merged the final ✓ chevron is the lit one, in green. Motion is reserved for what is running or needs a hand — the lit chevron falls into one of three buckets (`stageTrackerMotion()` in `index.html`): **static** (steady): Open, Open · on hold (any hold label wins over every other signal), Actionable (010), Claimed (020), PR in progress / Covered by PR (030/040) by a human author, Merged, and any unrecognised stage; **active** (gentle pulse): the hive is acting — 030/040 by a hive or clanker author, 050 review pending, 060 reviewed, 070 fixing, 074 adopted by hive, 080 merge gate, 095 pre-merge soak, 100 merge queue; **needs-human** (slower amber→red breathe): a person must move — 015 triage needed, 045/085 needs decision, 071 needs author, 072 returned to contributor, 090 ready for a human merge, or a `stalled` / `blocked` / `needs-human` / `needs-decision` / `needs-triage` modifier on any stage. Under `prefers-reduced-motion` nothing animates; a needs-human step keeps a steady red tint so it still stands out. Every other step is a low-contrast shape with a small grey glyph (circle, bolt, lock, branch, eye, shield, check) — passed steps a subtle neutral fill, steps ahead a faint outline. Side stages are not extra steps: `070 Fixing` (the author's move; the `needs-rebase` chip next to it says what is being fixed — the stage labeller always parks a needs-rebase PR at 070/071/072, never at CI / Review), `071 Needs author` (human-authored), `072 Returned to contributor` (clanker-authored) and `074 Adopted by hive` light *CI / Review* with their own name (an adopted PR stays on 074 through the hive's pushes going pending, green or red again, and moves on only when *Merge gate* takes it); `085 Needs human decision` (PR-only) and `090 Ready for human merge` light *Merge gate* with their own name (the 085 tooltip says what must be decided); an issue parked on a person wears `045 Needs human decision` and lights *Actionable* (the issue side) with that name — a pre-045 issue still wearing 085 is drawn the same way until the reconciler re-stages it; an actionable issue no maintainer has looked at yet wears `015 Triage needed` (carrying `needs-triage`, or held in the reporter-trust gate's `reporter_triage` bucket — never derived from who filed it) and lights *Actionable* as "Triage needed" (a human's move) — so the Actionable column reads "Actionable", "Triage needed" or "Needs human decision", and the Open column is untouched. An issue carrying a hold-class label (`hold`, `do-not-merge*`, `hive-pause/`) is never parked: it sits at *Open* as "Open · on hold" even beside `needs-human`, and the reconciler removes any 045 the hold caught it with ([#13012](https://github.com/hivecommons/hive/issues/13012)). The lit chevron ends with an ink-coloured icon of whose move it is — person (human), robot (clanker) or hexagon (hive): the claim holder on Claimed, the PR author on PR in progress and Returned to contributor, hive on CI / Review, Adopted by hive and Ready for auto merge, a human on Needs human decision and Ready for human merge. A row at `090 Ready for human merge` always says *why* a person and not the hive merges it (#14658): the lit word ends `· workflow files`, `· tests removed`, `· manual-merge policy`, `· branch protection`, `· merge method`, `· auto-merge off`, `· untrusted author`, `· unauthorized`, `· reviewer deferred` or `· policy` (payload `human_merge_reason`, a `prstage.HumanMergeReason*` code derived from the stage record's lane reason — no second store), the chevron tooltip leads with the one-sentence `human_merge_reason_text` ("Changes .github/workflows/** — the hive never merges workflow changes …; click Merge on GitHub"), the manual-merge word reads `Awaiting human merge · workflow files · approved by @login`, the search / needs-attention headline carries the same tail, and a PR nested under its issue mirrors `human_approver`, `manual_merge`, `human_merge_reason` and `human_merge_reason_text` onto its `linked_prs` entry so the sub-row says the same. `040 Covered by PR` shares the *PR in progress* column with 030; `060 Reviewed` lights *Merge gate* as "Awaiting merge gate" with the gate reason in its tooltip; `080 Awaiting merge admission` reads "Ready for auto merge"; `100 Merge queue` reads "Merging"; `095 Pre-merge soak` lights the same column as "Soaking" (hive's move; tooltip "admitted, soaking — Xm left", headline "Pre-merge soak — Xm left" from the payload's `soak_remaining_seconds`, aged from the lane's last sweep), so an admitted PR inside its soak window is no longer drawn as merging; the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `↳ [author icon] #PR title` under the *PR in progress* header on the same title line (the ↳ marks a PR drawn on its issue's row; the PR link's tooltip says so — "linked PR, shown on its issue's row" — and, when two open issues list the same PR, every row but the lowest-numbered issue adds "also under #N"), and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. A PR whose only linked issue is already closed — a superseded PR whose body still says `Fixes #N` after an earlier PR fixed it — keeps its own row with the closed issue in the issue slot: `#N title` as a link, muted and struck through, followed by a small `closed` chip, so the pairing reads at a glance; when the title cannot be resolved the slot says `#N (closed issue)` rather than a bare number (the title comes from the snapshot, or from one cached issue read the cycle makes once per issue — see [Linked issues](dashboard.md#pr-review-and-link-signals)). The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). A plain *Open* step — no stage label yet and not on hold — also carries that age in its own words, "Open · since 3d" ("since 14h" under two days), taken from the same `stage_since` instant the column draws (falling back to the time the item was opened, which the chevron tooltip then marks "(opened)"); past `STAGE_TRACKER_OPEN_STALE_DAYS` (2) the chevron takes a subtle red tint. *Open · hold* never shows the age. An Open item carrying the `blocked` label is drawn the same way as a hold — "Open · blocked" with a ⛔ glyph in the hold's yellow — but keeps the age ("Open · blocked · since 7h"; a stale blocked item is exactly what should stand out, [#14194](https://github.com/hivecommons/hive/issues/14194)) and its chevron tooltip says why: "blocked on owner/repo#N" when the payload names the blocker (`blocked_on`), else "carries the blocked label"; when an item is both held and blocked, hold wins — it is a human instruction. A draft PR — the forge's draft bit, or prow's `do-not-merge/work-in-progress` label — reads "Draft · since 18h" in the Open cell with a ✎ glyph in the muted draft tint, never turns stale (the hive's review and merge lanes skip drafts, so the wait is the author's, not a stuck pipeline), and wears a muted `draft` chip whose tooltip says the lanes skip it until the author marks it ready; a hold or blocked label still wins the cell, with `draft` folded into the chip's `+N` ([#14572](https://github.com/hivecommons/hive/issues/14572)). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-triage` — shown as "triage needed" (amber) on an issue still carrying the `needs-triage` label before the claim (010, 017, 045; at 015 the lit chevron already says so); a `needs-triage` left on a claimed or later issue (020+) is stale, never shown as a chip or stage text, and reported instead as `stale_labels` in the payload with a muted *Stale label* line in the hover tooltip until the stage sweep removes it (hivecommons/hive#14586) —, `needs-rebase`, `blocked`, `draft` — set by the PR's draft bit or prow's `do-not-merge/work-in-progress` label, which the tracker reads as a draft rather than a hold) with a `+N` for the rest. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a drawn health modifier or on 071 / 072 / 085 / 090 — merge-gate pills held back before the gate do not count), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header count "N rows · M need attention" is for the filtered set, the **sidebar badge is the row count of the default view** (owner: the tracker counts rows, not items — a covering PR drawn on its issue's row is not a row of its own, and an issue with several PRs already has several), and both come from the same `stageTrackerCountsText()` call so they cannot disagree. When rows sit below the payload's open issues + PRs, the "showing" line's tooltip and the badge's footnote say why — "2 PRs shown on their issue's row" — rather than printing a second total.the chevron's own tooltip names the exact stage. Covering pull requests nest under their issue. An issue with no PR yet draws the whole strip like any other row, lit at Open, Actionable or Claimed with the steps ahead faint. Once exactly one PR covers it, issue and PR are a single entry: the issue's `#N title` on the left, `[author icon] #PR title` under the *PR in progress* header on the same title line, and one continuous strip — Open, Actionable and Claimed passed, the PR's stage lighting the chevron from PR in progress through CI / Review, Merge gate and ✓; the chip, tooltip and `since` are the PR's. With two or more covering PRs the issue's own strip stops at Claimed — all passed, nothing on the issue line lit. Directly beneath, tighter than the gap between entries, sits one indented sub-row per open covering PR, furthest along first: `[author icon] #N title` at the *PR in progress* column, then that PR's own strip from there on — `PR in progress → CI / Review → Merge gate → ✓` — with its own lit chevron, chip, tooltip and `since`. So an issue with two PRs, one at 030, shows "PR in progress" lit on that sub-row, not on the issue. A PR linked to an open issue in the list has no top-level row of its own; a PR with no linked issue keeps a full-width row and shows the first steps as passed. The *Pull requests* filter flattens the list — every PR as a top-level row; *Issues* and *All* show the nested view. Each row is named once on the left; a covering PR appears under the *PR in progress* header as `[author icon] #N title`. A pull request with no linked issue is named once: `[PR icon] [author icon] #N title` on the left over one continuous strip (first steps passed, its own step lit) and nothing in the *PR in progress* column, which is reserved for covering PRs — so a title never appears twice in a row. Pull requests are never issues here: when a number arrives through both the issues feed and the pulls feed the PR record wins and the issue copy is dropped on the server (pairing is keyed by repository, kind and number), and the *Issues* filter never lists a PR. The author icon is the one coloured legend: hive hexagon in blue, clanker robot in purple, human silhouette in teal (the `author/*` kind, inferred from the snapshot when the label is absent; the login is in the `#N` link's tooltip). The right-hand `since` column, in line with the chevron strip, is how long the item has been on its step (red when `stalled`). At most one muted chip sits at the right end of the title line, directly over the strip's ✓ cap (on the last line when the title wraps; a hairline above each entry and a hover tint over the whole entry keep chip and `since` unambiguously with their own row — [#14640](https://github.com/hivecommons/hive/issues/14640)): the most important health modifier (`stalled`, `regressed`, `hold`, `needs-human`, `needs-decision` — shown as "needs human decision" —, `needs-rebase`, `blocked`, `draft` — the PR's draft bit or prow's `do-not-merge/work-in-progress` label) with a `+N` for the rest. A `regressed` chip is red only when the row is parked on a person (a human-gate modifier or stage 045 / 071 / 072 / 085 / 090); on a hive-driven stage with nothing waiting on a human it draws as a muted dashed `stage ↓` pill, yields the lead slot to any other modifier, keeps the row out of **Needs attention**, and its tooltip ends "the hive is handling it — no action needed; clears on the next forward step". The marker is set by a genuine backward hop (a lapsed claim 020 → 010, a 030 ↔ 020 flicker and a 040 → 010 after a partially-addressing merge are not regressions) and clears on the first forward hop; see "The regressed marker" in `labels-and-control-signals.md`. Everything else — the reason sentence, who must act, nudges sent, the repository, all flags and the last stage hops — is in the hover tooltip on the item's `#N` link (on a nested sub-row, on its `#N` PR link). Hover text in a row lives only on the `#N` link, the covering-PR link, the title and the lit chevron (its stage, and whose move it is); passed and upcoming chevrons, the kind and author icons, chips and the `since` column have none. Title lines wrap rather than push the strip out of alignment: the issue title stays before the *PR in progress* column (a clear gap always separates it from the PR entry, which starts at the column edge) and the PR title before the chip; hovering a title shows the full text. Rows are sorted furthest-along first by default — a covered issue ranks by its furthest-along PR — then, within a column, attention-first: rows a person must act on now (any shown pill — `stalled`, `unauthorized`, `needs rebase`, `needs human`, … — or a human-gated stage: 045, 071, 072, 085, 090) come first, plain rows next, and rows nobody should act on — `hold` (incl. `do-not-merge/*`), `draft`, and a PR standing in for a closed issue — sink to the bottom of the column; within a tier the longest on the step comes first, then repo and number. Pills the server holds back until the merge gate (`deferred_modifiers`) never promote a row. The same tiering orders the PR sub-rows under an issue, and the server pre-sorts `GET /api/stage-tracker` the same way (stage, tier, wait, repo, number) so chat `/prs` and the hub read the same order. *Sort* also offers longest waiting (tier first, then wait), newest and number (no tiering); the arrow beside it flips the column / age / repo / number keys but never the tier — attention stays on top in both directions, as its tooltip says ("Attention-first within each column; arrow flips age order"). Every open issue and pull request of the watched repositories is listed — actionable, held, claimed, in progress, covered by a PR, filtered by a `needs-*` label, reporter-triage, draft and exempt-labelled alike; an item without a stage label or journal entry sits at *Open*, and one in a scanner bucket with no label yet is placed from the bucket (claimed → 020, in progress → 030, covered → 040). Filters work on the cached payload in the browser and persist across reloads (the page number does not): kind chips, *Repo*, a search box (`#number` / number / title substring, also matching a covering PR), *Since* (any, over 1 hour / 1 day / 1 week on the current step, or past the stage's configured dwell — stalled items always qualify), *Author* kind, *Needs attention* (anything with a drawn health modifier or on 071 / 072 / 085 / 090 — merge-gate pills held back before the gate do not count), and label chips built from every label present, each with its count: a **🙋 Needs human** facet first (attention-coloured; it matches any item carrying a label of the needs-human set — the server's `needs_human_labels`, the same list as the Projects *Needs human* preset: `stage/045-needs-decision`, `stage/085-needs-decision`, `needs-decision`, `needs-direction`, `needs-spec`, `needs-signal`, `needs-human` and `needs-human/*`, the hold labels, `stage/071-needs-author`, `sentinel-alert`, `needs-triage`; its count is the number of distinct items, not the sum of label counts), then every `stage/NNN-*` label in numerical order, then all other labels alphabetically (case-insensitive). When the row would overflow, the **+N more** button opens an in-app *All labels* dialog listing every label in the same order with counts, a type-to-filter box, the same toggles the chips use and a *Clear* button; a label selected there is promoted into the visible row. Chips of one family OR, families AND; *Needs human* ANDs with the label chips. *Clear filters* shows while anything is narrowed. The list is paged — 25 / 50 / 100 rows, default 50 — with Prev / Next and "showing X–Y of N (M filtered out)" above and below; the header reads "N items (I issues / P PRs) · M need attention" — N, I and P are the whole list, the same `openItems` set the Overview tile and its left-menu counter print, so N always equals the tile's **Total open issues + Total open PRs**; a "· X match filters" note follows while a filter is on. The sidebar counter beside **Hive activity monitor** is that same N — total open items, written in the same render pass as the header, so the two cannot drift apart; how many need attention is the warn-coloured header suffix and the counter's hover tooltip (counted over every item, filters or not). When covering pull requests are nested under their issue the "showing X–Y of R" line counts rows and adds "(P nested under their issues)" so R never reads as a different total. The small monospace strip beside the count — `engine enforce · N anomalies` — is the central stage engine ([ADR-0025](adr/0025-central-stage-engine.md)): `engine` names the current `governor.labels.stage.engine.mode` (green `enforce`, neutral `shadow` = paused, nothing written; hover for what the mode does and the derivation count), `anomalies` counts stage moves the engine's admission table did not expect (red when non-zero). The same numbers are `/api/status.stageEngine`; the mode is changed under **Settings → Labels → Central stage engine mode** and the operator notes are in [operator-reference.md](operator-reference.md#central-stage-engine-rollout). "updated Ns ago · cache" says how old the server-built payload is: the spoke rebuilds it at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from its existing snapshot and serves it with an `ETag`, so the browser's 30-second poll is a 304 and no request ever reaches GitHub (`/api/gh-rate-limits` lists the caller `dashboard:stage-tracker` with nothing charged). See [Stage labels](labels-and-control-signals.md#stage-labels-stagennn--the-pipeline-state-machine). + +**Merge-gate glyphs and timing.** Every merge-gate row has a steady leading status glyph with a plain-language title and accessible label. It says whether the merge sweep is evaluating this PR now, waiting for its next scheduled floor pass (events may run sooner), or soaking with time left. A separate labelled spinning glyph means an agent is working on the PR; it does not mean merge progress. The vocabulary is **Awaiting merge gate (060) → Ready for auto merge (080) → Soaking (095) → Merging (100) → Merged**. Soak pills show the time left on nested PRs too. PR items and `linked_prs` carry `merge_gate: {state, reason, sweep_running, last_sweep_at, next_sweep_at, soak_until, soak_remaining_seconds}`; unknown timestamps are null, and an overdue floor pass is shown as due rather than a negative countdown. The clocks observe the lanes and never change merge admission. + **Filter chips (Needs human / On hold / labels).** The label row under the toolbar starts with two synthetic chips, then one chip per label the listed items carry. **🙋 Needs human** means a person's decision or action is the *only* thing that advances the row: an issue at `015` triage-needed, `045` or `085` needs-decision, a PR at `090` ready-for-human-merge, a PR at `071`/`072` whose author is a human, or any row wearing a `needs human` / `needs human decision` / `unauthorized` pill. It is **not** `hold`, `stalled`, `blocked`, a handled regression, a `040` issue an open PR covers, or a PR the hive will merge itself — those are the hive's (or nobody's) to move. **⏸ On hold** is the separate chip for rows a maintainer paused on purpose with a hold label; a held row never counts as Needs human. The chip label, its count, the filter it toggles and the payload's `needs_human` / `on_hold` totals (and per-item flags) all come from one predicate (`stageTrackerNeedsHuman` in Go, `stageTrackerItemNeedsHuman` in the page), so what the chip counts is exactly what the filter shows ([#15008](https://github.com/hivecommons/hive/issues/15008)). Hover a chip for a one-line explanation. Label chips AND with the synthetic chips. diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 0f5d2473ad..f3bd51201d 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -324,7 +324,8 @@ type StageTrackerItem struct { // soak window was left as of the last sweep (the lane's // `soaking(remaining=…)` reason aged by the time since it was recorded); // 0 when unknown or not soaking. - SoakRemainingSeconds int64 `json:"soak_remaining_seconds,omitempty"` + SoakRemainingSeconds int64 `json:"soak_remaining_seconds,omitempty"` + MergeGate *StageTrackerMergeGate `json:"merge_gate,omitempty"` // SentinelAlert is true on a PR the suspicious-activity sentinel flagged: // it wears the configured alert label (sentinel.label, default // sentinel-alert) or the review evidence bundle for its current head @@ -458,16 +459,19 @@ type StageTrackerLinkedIssue struct { // StageTrackerLinkedPR is one covering PR nested under an issue row. type StageTrackerLinkedPR struct { - BaseRef string `json:"base_ref,omitempty"` - Number int `json:"number"` - Title string `json:"title,omitempty"` - URL string `json:"url,omitempty"` - Author string `json:"author,omitempty"` - AuthorKind string `json:"author_kind,omitempty"` - Stage int `json:"stage,omitempty"` - StageSince *time.Time `json:"stage_since,omitempty"` - Caption string `json:"caption,omitempty"` - Modifiers []string `json:"modifiers,omitempty"` + MergeGate *StageTrackerMergeGate `json:"merge_gate,omitempty"` + SoakRemainingSeconds int64 `json:"soak_remaining_seconds,omitempty"` + Reason string `json:"reason,omitempty"` + BaseRef string `json:"base_ref,omitempty"` + Number int `json:"number"` + Title string `json:"title,omitempty"` + URL string `json:"url,omitempty"` + Author string `json:"author,omitempty"` + AuthorKind string `json:"author_kind,omitempty"` + Stage int `json:"stage,omitempty"` + StageSince *time.Time `json:"stage_since,omitempty"` + Caption string `json:"caption,omitempty"` + Modifiers []string `json:"modifiers,omitempty"` // DeferredModifiers mirrors the nested PR's own row field: the // merge-gate pills it is not yet drawing. DeferredModifiers []string `json:"deferred_modifiers,omitempty"` @@ -1777,6 +1781,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto resp.OpenIssues, resp.OpenPRs = stageTrackerOpenCounts(resp.Items) s.applyOperatorActions(resp.Items, now) resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items) + s.applyMergeGates(resp.Items, now) stageTrackerResolveLinkedPRs(resp.Items) sort.SliceStable(resp.Items, stageTrackerLess(resp.Items)) return resp @@ -2500,6 +2505,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem) { if pr := prs[it.Repo+"#"+strconv.Itoa(lp.Number)]; pr != nil { lp.Title, lp.Author, lp.AuthorKind, lp.Stage = pr.Title, pr.Author, pr.AuthorKind, pr.Stage lp.StageSince, lp.Caption = pr.StageSince, pr.Caption + lp.MergeGate, lp.SoakRemainingSeconds, lp.Reason = pr.MergeGate, pr.SoakRemainingSeconds, pr.Reason lp.SentinelAlert, lp.SentinelReason, lp.Head = pr.SentinelAlert, pr.SentinelReason, pr.Head lp.Adoption = pr.Adoption lp.HumanApprover, lp.ManualMerge = pr.HumanApprover, pr.ManualMerge diff --git a/src/pkg/dashboard/stage_tracker_merge_gate.go b/src/pkg/dashboard/stage_tracker_merge_gate.go new file mode 100644 index 0000000000..4e863a71fa --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_merge_gate.go @@ -0,0 +1,53 @@ +package dashboard + +import ( + "time" + + "github.com/hivecommons/hive/pkg/github" +) + +// StageTrackerMergeGate distinguishes admission, soak and merge execution. +// Clock fields are null until a lane has actually scheduled/completed a pass. +type StageTrackerMergeGate struct { + State string `json:"state"` + Reason string `json:"reason"` + github.MergeSweepTimes + SoakUntil *time.Time `json:"soak_until"` + SoakRemainingSeconds int64 `json:"soak_remaining_seconds"` +} + +func stageTrackerMergeGate(it StageTrackerItem, clock github.MergeSweepTimes, now time.Time) *StageTrackerMergeGate { + state := "gate-pending" + switch it.Stage { + case 60: + state = "gate-pending" + case 80: + state = "ready" + case 95: + state = "soaking" + case 100: + state = "merging" + case 110: + state = "merged" + } + gate := &StageTrackerMergeGate{State: state, Reason: it.Reason, MergeSweepTimes: clock, SoakRemainingSeconds: it.SoakRemainingSeconds} + if it.Stage == 95 && it.SoakRemainingSeconds > 0 { + until := now.Add(time.Duration(it.SoakRemainingSeconds) * time.Second) + gate.SoakUntil = &until + } + return gate +} + +func (s *Server) applyMergeGates(items []StageTrackerItem, now time.Time) { + for i := range items { + it := &items[i] + if it.Kind != "pr" { + continue + } + clock := github.MergeSweepTimes{} + if s.deps != nil && s.deps.GHClient != nil { + clock = s.deps.GHClient.MergeSweepClock().Snapshot(it.Repo, it.Number) + } + it.MergeGate = stageTrackerMergeGate(*it, clock, now) + } +} diff --git a/src/pkg/dashboard/stage_tracker_merge_gate_test.go b/src/pkg/dashboard/stage_tracker_merge_gate_test.go new file mode 100644 index 0000000000..c9ee542f89 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_merge_gate_test.go @@ -0,0 +1,44 @@ +package dashboard + +import ( + "encoding/json" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" +) + +func TestStageTrackerMergeGateStatesAndNestedSoak(t *testing.T) { + now := time.Date(2026, 10, 28, 19, 0, 0, 0, time.UTC) + for stage, state := range map[int]string{50: "gate-pending", 60: "gate-pending", 80: "ready", 95: "soaking", 100: "merging", 110: "merged"} { + got := stageTrackerMergeGate(StageTrackerItem{Stage: stage, Reason: "check-pending", SoakRemainingSeconds: 420}, github.MergeSweepTimes{}, now) + if got == nil || got.State != state || got.Reason != "check-pending" { + t.Fatalf("stage %d: %+v", stage, got) + } + if stage == 95 && (got.SoakUntil == nil || !got.SoakUntil.Equal(now.Add(7*time.Minute))) { + t.Fatalf("soak deadline: %+v", got) + } + } + pr := StageTrackerItem{Repo: "org/repo", Kind: "pr", Number: 2, Stage: 95, SoakRemainingSeconds: 420, Reason: "soaking(remaining=7m)"} + pr.MergeGate = stageTrackerMergeGate(pr, github.MergeSweepTimes{SweepRunning: true, NextSweepAt: &now}, now) + items := []StageTrackerItem{{Repo: "org/repo", Kind: "issue", Number: 1, LinkedPR: 2}, pr} + stageTrackerResolveLinkedPRs(items) + nested := items[0].LinkedPRs[0] + if nested.MergeGate != pr.MergeGate || nested.SoakRemainingSeconds != 420 || nested.Reason != pr.Reason { + t.Fatalf("nested PR lost gate context: %+v", nested) + } + data, err := json.Marshal(nested) + if err != nil { + t.Fatal(err) + } + var wire map[string]any + if err := json.Unmarshal(data, &wire); err != nil { + t.Fatal(err) + } + gate := wire["merge_gate"].(map[string]any) + for _, key := range []string{"state", "reason", "sweep_running", "last_sweep_at", "next_sweep_at", "soak_until", "soak_remaining_seconds"} { + if _, ok := gate[key]; !ok { + t.Fatalf("missing wire field %s: %s", key, data) + } + } +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 1566b01be4..783549ac7f 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -233,7 +233,7 @@ const segStates = (html) => Array.from(strip(html).matchAll(/
  • ]*>(.*?)<\/a>/g)).map(m => m[1]); const B = 'blank'; -const text = (h) => h.replace(/<[^>]+>/g, '').replace(/'/g, "'").replace(/\s+/g, ' ').trim(); +const text = (h) => h.replace(//g, '').replace(/<[^>]+>/g, '').replace(/'/g, "'").replace(/\s+/g, ' ').trim(); // The row tooltip rides the issue's #N link on an issue row and the PR link // (after "PR title · ") on a PR row; the issue slot of a PR row carries none. const tooltip = (row) => (/]*title="([^"]*)"/.exec(row) || /]*title="([^"]*)"/.exec(row))[1]; @@ -422,7 +422,7 @@ assert.ok(!stageTrackerRowHtml({ repo: 'acme/console', number: 30, kind: 'pr', t // With the PR's stage known the issue strip rides it (merge queue → Merge gate lit, hive move). row = stageTrackerRowHtml({ repo: 'acme/console', number: 8, kind: 'issue', stage: 40, linked_prs: [{ number: 102, title: 'Fix it', author_kind: 'human', author: 'bob', stage: 100, stage_since: new Date(now - 7200000).toISOString(), modifiers: ['stalled'], caption: 'Admitted, merging' }] }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, D, D, 'active', 'todo cap']); -assert.ok(row.includes('Ready for auto mergeMergingstalled') && row.includes('2h'), 'chips + since come from the covering PR: ' + row); assert.ok(tooltip(row).includes('Admitted, merging') && tooltip(row).includes('Covering PR: #102'), tooltip(row)); assert.ok(prCol(row)[0].includes('ham-author-human') && prCol(row)[0].includes('Fix it'), prCol(row)[0]); @@ -431,17 +431,18 @@ assert.strictEqual(subs(row).length, 0); row = stageTrackerRowHtml({ repo: 'acme/console', number: 8, kind: 'issue', stage: 40, linked_prs: [{ number: 102, stage: 100 }, { number: 104 }] }, stages, ctx); assert.ok(subs(row)[1].includes('#104') && segStates(subs(row)[1]).every(st => st.startsWith('blank') || st === 'todo' || st === 'todo cap'), 'unknown PR stage: blank lead-in, nothing lit'); assert.ok(tooltip(row).includes('acme/console'), 'repo lives in the tooltip'); -// Full PR row for 100: Merge gate lit as Ready for auto merge with the hive actor icon. +// Full PR row for 100: Merge gate lit as Merging with the hive actor icon. row = stageTrackerRowHtml({ repo: 'acme/console', number: 102, kind: 'pr', stage: 100, author: 'hive-bot', author_kind: 'hive' }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, D, D, 'active', 'todo cap']); assert.ok(strip(row).includes('title="Merge queue — admitted, merging · Next move: hive"'), 'chevron tooltip carries 100: ' + row); -assert.ok(text(row).includes('#102 Ready for auto merge'), text(row)); +assert.ok(text(row).includes('#102 Merging'), text(row)); // Full PR row for 095: Merge gate lit as Soaking (not a detour), hive actor, // chevron tooltip names the real stage and the time left; headline carries it too. row = stageTrackerRowHtml({ repo: 'acme/console', number: 13020, kind: 'pr', stage: 95, author: 'hive-bot', author_kind: 'hive', soak_remaining_seconds: 17 * 60 + 1 }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, D, D, 'active', 'todo cap'], '095 lights the Merge gate column, no detour'); assert.ok(strip(row).includes('title="Pre-merge soak — admitted, soaking — 18m left · Next move: hive"'), 'chevron tooltip carries 095 + time left: ' + row); assert.ok(tooltip(row).startsWith('Pre-merge soak — 18m left'), 'headline: ' + tooltip(row)); +assert.ok(row.includes('>Soaking — 18m left'), 'soak time is visible in the pill'); assert.strictEqual(stageTrackerHeadline({ stage: 95 }), 'Pre-merge soak', 'no remaining known → plain headline'); assert.strictEqual(stageTrackerHeadline({ stage: 95, soak_remaining_seconds: 5400 }), 'Pre-merge soak — 1h30m left'); assert.strictEqual(stageTrackerHeadline({ stage: 95, kind: 'issue', soak_remaining_seconds: 60 }), 'Pre-merge soak — 1m left (its PR)'); @@ -689,7 +690,7 @@ assert.deepStrictEqual(segStates(row), ['active', T, T, T, T, T, 'todo cap']); // is what the chevron says, the actor is whose move it is. The active // chevron now leads with its stage icon, so the regex skips that svg. const prWords = {}; -for (const [st, word, actor] of [[50, 'CI / Review', 'hive'], [60, 'Ready for auto merge', 'hive'], [70, 'Fixing', 'author'], [71, 'Needs author', 'author'], [72, 'Returned to contributor', 'author'], [74, 'Adopted by hive', 'hive'], [80, 'Ready for auto merge', 'hive'], [85, 'Needs human decision', 'human'], [90, 'Ready for human merge', 'human'], [100, 'Ready for auto merge', 'hive']]) { +for (const [st, word, actor] of [[50, 'CI / Review', 'hive'], [60, 'Awaiting merge gate', 'hive'], [70, 'Fixing', 'author'], [71, 'Needs author', 'author'], [72, 'Returned to contributor', 'author'], [74, 'Adopted by hive', 'hive'], [80, 'Ready for auto merge', 'hive'], [85, 'Needs human decision', 'human'], [90, 'Ready for human merge', 'human'], [100, 'Merging', 'hive']]) { const r = stageTrackerRowHtml({ repo: 'acme/console', number: 500 + st, kind: 'pr', stage: st, author_kind: 'clanker' }, stages, ctx); const m = /aria-current="step">]*>[\s\S]*?<\/svg>([^<]*)<\/span>]*aria-label="Next move: ([a-z]+)"[^>]*>/.exec(r); assert.ok(m, 'stage ' + st + ' has no active word + actor: ' + r); @@ -700,7 +701,7 @@ for (const [st, word, actor] of [[50, 'CI / Review', 'hive'], [60, 'Ready for au // and the next mover for the strip's active segment; it stays empty when no // active segment is in range. assert.strictEqual(stageTrackerCurrentStageHtml({ repo: 'acme/console', number: 570, kind: 'pr', stage: 70, author_kind: 'clanker' }, stages), '

    CI / Review · Fixing · Next move: clanker

    '); -assert.strictEqual(stageTrackerCurrentStageHtml({ repo: 'acme/console', number: 560, kind: 'pr', stage: 60 }, stages), '

    Ready for auto merge · Next move: hive

    ', 'no detour → column word only'); +assert.strictEqual(stageTrackerCurrentStageHtml({ repo: 'acme/console', number: 560, kind: 'pr', stage: 60 }, stages), '

    Awaiting merge gate · Next move: hive

    ', 'no detour → column word only'); assert.strictEqual(stageTrackerCurrentStageHtml({ repo: 'acme/console', number: 570, kind: 'pr', stage: 70, author_kind: 'clanker' }, stages, { from: 500 }), '', 'no caption when the active segment is out of range'); assert.strictEqual(STAGE_TRACKER_ACTOR[70], 'author', '070 fixing is the author\'s move'); // Filters. @@ -744,11 +745,11 @@ assert.deepStrictEqual(stageTrackerVisible(g, { kind: 'pr', repo: '' }).map(it = // Hover text budget per row (owner request): only the #N link, the PR link, // the item title and the active chevron carry title="…". The row container, // sub-row container, kind / author / actor icons, chips, since cells and -// every non-active chevron carry none; icons expose their label via aria-label. +// every non-active chevron carry none. Active glyphs have their own title and aria-label, checked below. const tags = (html) => Array.from(html.matchAll(/<(\w+)\b([^>]*)>/g)).map(m => ({ tag: m[1], attrs: m[2] })); -const titled = (html) => tags(html).filter(t => / title="/.test(t.attrs)); +const titled = (html) => tags(html).filter(t => / title="/.test(t.attrs) && !/ham-active-ico|cue-spin/.test(t.attrs)); const expectTitles = (html, want, what) => assert.deepStrictEqual(titled(html).map(t => t.tag + '.' + ((/class="([^" ]+)/.exec(t.attrs) || [])[1] || '')), want, what + ': ' + html); -assert.ok(!/]*>\s*/.test(golden), 'no svg <title> tooltips anywhere in the tracker'); +for (const m of golden.matchAll(/<svg([^>]*)>\s*<title>/g)) assert.ok(/ham-active-ico|cue-spin/.test(m[1]), 'only status and agent activity glyphs have SVG titles'); assert.ok(!/<(div|span)[^>]*class="ham-(row|sub|since|badge|kind-ico)[^>]*title="/.test(golden), 'containers, since cells, chips and kind icons carry no title'); for (const r of golden.split('<div class="ham-row"').slice(1)) { const seg = Array.from(r.matchAll(/<li class="ham-seg ([^"]*)"([^>]*)>/g)); @@ -784,12 +785,27 @@ assert.ok(/<a class="ham-pr-ref"[^>]*title="First PR · Back with the contributo row = stageTrackerRowHtml(g[6], stages, ctx); expectTitles(row, ['a.ham-pr-ref', 'li.ham-seg'], 'standalone PR'); assert.ok(/<a class="ham-pr-ref"[^>]*title="Standalone PR · Not yet admitted to auto merge[^"]*@cy \(author\/human\)/.test(row), 'PR link: title, then the row tooltip: ' + row); -assert.ok(row.includes('aria-label="human · @cy"') && !row.includes('<title>'), 'author icon label is aria-only: ' + row); +assert.ok(row.includes('aria-label="human · @cy"') && !/<svg[^>]*ham-author-ico[^>]*>\s*<title>/.test(row), 'author icon label is aria-only: ' + row); // Since cells are untouched: plain text, no title. assert.ok(/<span class="ham-since( ham-stalled)?">[^<]*<\/span>/.test(row) && !/ham-since[^>]*title=/.test(golden), 'since cells unchanged'); // Merged: the lit cap is the only chevron with hover text. row = stageTrackerRowHtml({ repo: 'acme/console', number: 106, kind: 'pr', stage: 110 }, stages, ctx); assert.ok(/<li class="ham-seg active cap merged" title="Merged — [^"]*" aria-current="step">/.test(row) && titled(strip(row)).length === 1, row); +` + "\n globalThis.stageTrackerMergeGateTip = " + jsFunc(t, html, "stageTrackerMergeGateTip") + `; +for (const stage of [60, 80, 95, 100]) { + const it = {repo: 'acme/console', kind: 'pr', number: 900, stage, soak_remaining_seconds: 420, reason: 'check-pending', merge_gate: {next_sweep_at: new Date(now + 42000).toISOString()}}; + const idle = stageTrackerRowHtml(it, stages, ctx); + assert.ok(/<svg class="ham-ico ham-active-ico"[^>]*title="[^"]+"[^>]*data-merge-gate="true"[^>]*aria-label="[^"]+"/.test(idle), 'every gate has a labelled glyph without a worker: ' + idle); + const busy = stageTrackerRowHtml(it, stages, Object.assign({}, ctx, {workers: {'acme/console#900': {agent: 'scout', action: 'agent_comment_created', at: new Date(now).toISOString()}}})); + assert.ok(busy.includes('title="An agent is working on this PR now"') && busy.includes('aria-label="An agent is working on this PR now"'), 'agent activity is independently labelled: ' + busy); +} +const soakingPR = {number: 901, stage: 95, soak_remaining_seconds: 420, merge_gate: {state: 'soaking'}}; +const issue = {repo: 'acme/console', kind: 'issue', number: 800, stage: 40, linked_prs: [soakingPR, {number: 902, stage: 60}]}; +const nestedSoak = stageTrackerRowHtml(issue, stages, ctx); +assert.ok(subs(nestedSoak).some(sub => sub.includes('Soaking — 7m left')), 'nested PR retains visible soak countdown: ' + nestedSoak); +const nestedItem = stageTrackerLinkedPRItem(issue, soakingPR); +assert.strictEqual(nestedItem.merge_gate.state, 'soaking'); +assert.strictEqual(nestedItem.soak_remaining_seconds, 420); ` // Over stdin: the lifted fixture exceeds Linux's per-argument limit. cmd := exec.Command(node, "-") @@ -1042,3 +1058,26 @@ assert.strictEqual(stageTrackerLabelDialogData(stageTrackerLabelFacets(parked, F t.Fatalf("node Hive activity monitor fixture failed: %v\n%s", err, out) } } + +func TestStageTrackerMergeGateTips(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node not on PATH") + } + html := indexHTML(t) + script := jsFunc(t, html, "stageTrackerSoakLeft") + "\n" + jsFunc(t, html, "stageTrackerMergeGateTip") + ` +const assert = require('assert'); +const now = Date.parse('2026-10-28T19:00:00Z'); +assert.strictEqual(stageTrackerMergeGateTip({stage: 60, reason: 'required-check-pending:build'}, now), 'awaiting merge gate — required-check-pending:build'); +assert.strictEqual(stageTrackerMergeGateTip({stage: 80, merge_gate: {next_sweep_at: new Date(now + 42000).toISOString()}}, now), "waiting for hive's merge sweep — next pass in 42s (events may run sooner)"); +assert.ok(stageTrackerMergeGateTip({stage: 80}, now).includes('not scheduled yet')); +assert.ok(stageTrackerMergeGateTip({stage: 80, merge_gate: {next_sweep_at: new Date(now - 1).toISOString()}}, now).includes('next pass due')); +assert.strictEqual(stageTrackerMergeGateTip({stage: 80, merge_gate: {sweep_running: true}}, now), "hive's merge sweep is running on this PR now"); +assert.strictEqual(stageTrackerMergeGateTip({stage: 95, soak_remaining_seconds: 420}, now), 'soaking — 7m left'); +assert.strictEqual(stageTrackerMergeGateTip({stage: 100}, now), 'merging — admitted to the merge queue'); +assert.strictEqual(stageTrackerMergeGateTip({stage: 110}, now), 'merged'); +` + if out, err := exec.Command(node, "-e", script).CombinedOutput(); err != nil { + t.Fatalf("merge gate tips: %v\n%s", err, out) + } +} diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 483ad40908..06373386c3 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1556,6 +1556,7 @@ .ham-current-stage { display: none; margin: 0; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; } .ham-active-ico { display: none; } .cue-working .ham-seg.active:not(.cap) .ham-active-ico { display: inline-block; margin-right: var(--sp-1); } + .ham-seg.active .ham-active-ico[data-merge-gate] { display: inline-block; margin-right: var(--sp-1); animation: none; } @keyframes ham-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.3; } } /* ---- tracker-cues: the Activity Monitor's shared cue vocabulary ------ Owner request: a viewer must always read where an item stands, @@ -1610,6 +1611,7 @@ @keyframes cue-count-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } } @media (prefers-reduced-motion: reduce) { .cue-token { display: none; } .ham-merged-count.cue-tick { animation: none; } .cue-merged .ham-seg.cap { animation-duration: 0.01ms; } } .ham-rm-preview .cue-token { display: none; } + .cue-working .ham-seg.active:not(.cap) .ham-active-ico[data-merge-gate] { animation: none; } @media (prefers-reduced-motion: reduce) { .cue-working .ham-seg.active .ham-active-ico, .cue-spin, .cue-acting .ham-seg.active, .cue-event { animation: none; } } @keyframes ham-breathe-human { 0%, 100% { opacity: 0; } 50% { opacity: 0.55; } } .ham-empty { color: var(--muted); font-size: var(--fs-sm); padding: var(--sp-4) 0; } @@ -8438,7 +8440,7 @@ <h3 class="faq-group-title">Where to get help</h3> 'logs-section': { heading: 'Agent Logs', help: 'The raw text output of each worker, for following what it is doing line by line.' }, 'agents-section': { heading: 'Agents', help: 'Each worker Hive runs, what it is doing now, and buttons to pause, restart or configure it.' }, 'agent-activity-section': { heading: 'Agent activity', help: 'One line per worker showing what it is doing now, how long since it last acted, and which issues it has reserved.' }, - 'activity-monitor-section': { heading: 'Hive activity monitor', help: 'A progress strip per open issue and pull request showing which step of the pipeline it is on and who must act next.' }, + 'activity-monitor-section': { heading: 'Hive activity monitor', help: 'A progress strip per open issue and pull request showing which step of the pipeline it is on and who must act next. Merge gate: Awaiting merge gate → Ready for auto merge → Soaking → Merging → Merged. Every gate has a labelled status glyph; hover for the gate reason, soak time left or next scheduled floor sweep (events may run sooner). A separate spinning agent glyph means an agent is working on the PR.' }, 'faq-section': { heading: 'FAQ', help: 'Short answers to the questions people ask once a hive is running, each linking to the guide that explains it fully.' }, }); // The one place that decides where dashboard help lives: every help mark and @@ -13961,7 +13963,7 @@ <h3 class="faq-group-title">Where to get help</h3> const STAGE_TRACKER_POSSIBLY_EXISTS = 17; // Stages that share a column (or a detour word) and what the lit chevron says. const STAGE_TRACKER_PRE_MERGE_SOAK = 95; - const STAGE_TRACKER_ACTIVE_WORD = { 15: 'Triage needed', 17: 'Possibly exists', 60: 'Ready for auto merge', 80: 'Ready for auto merge', 95: 'Soaking', 100: 'Ready for auto merge', 45: 'Needs human decision', 85: 'Needs human decision' }; + const STAGE_TRACKER_ACTIVE_WORD = { 15: 'Triage needed', 17: 'Possibly exists', 60: 'Awaiting merge gate', 80: 'Ready for auto merge', 95: 'Soaking', 100: 'Merging', 45: 'Needs human decision', 85: 'Needs human decision' }; // Whose move it is on each lit chevron: 'author' = the PR's author kind, // 'claimant' = the live claim holder's kind; Open and Actionable carry none. const STAGE_TRACKER_ACTOR = { 15: 'human', 17: 'human', 20: 'claimant', 30: 'author', 40: 'author', 45: 'human', 50: 'hive', 60: 'hive', 70: 'author', 71: 'author', 72: 'author', 74: 'hive', 80: 'hive', 85: 'human', 90: 'human', 95: 'hive', 100: 'hive' }; @@ -14148,6 +14150,19 @@ <h3 class="faq-group-title">Where to get help</h3> return ' — ' + (min >= 60 ? Math.floor(min / 60) + 'h' + (min % 60 ? (min % 60) + 'm' : '') : min + 'm') + ' left'; } + // The sweep glyph describes the merge lane; agent activity is independent. + function stageTrackerMergeGateTip(item, nowMs) { + const gate = item.merge_gate || {}; + const stage = Number(item.stage) || 0; + if (stage === 110) return 'merged'; + if (stage === 95) return 'soaking' + stageTrackerSoakLeft(item); + if (gate.sweep_running) return "hive's merge sweep is running on this PR now"; + if (stage === 100) return 'merging — admitted to the merge queue'; + if (stage === 60) return 'awaiting merge gate — ' + (item.caption || gate.reason || item.reason || 'waiting for merge gate evaluation'); + const next = Date.parse(gate.next_sweep_at || ''); + return "waiting for hive's merge sweep" + (Number.isFinite(next) ? (next > nowMs ? ' — next pass in ' + Math.ceil((next - nowMs) / 1000) + 's (events may run sooner)' : ' — next pass due; waiting for the scheduler') : ' — next pass not scheduled yet'); + } + function stageTrackerHoldLabels(item) { const labels = Array.isArray(item.labels) ? item.labels : []; return labels.filter(label => { @@ -14423,7 +14438,7 @@ <h3 class="faq-group-title">Where to get help</h3> if (sg.blocked) tip += ' — ' + stageTrackerBlockedTip(item); if (sg.draft) tip += ' — ' + STAGE_TRACKER_DRAFT_TIP; if (sg.openSince) tip += ' — open since ' + new Date(sg.openSince.ms).toISOString() + (sg.openSince.fromCreated ? ' (opened)' : ''); - // The shared Merge gate word hides 080 vs 095 vs 100; the chevron tooltip carries it. + // The tooltip includes admission details in addition to the distinct pill words. if (!sg.detour && (curStage === 60 || curStage === 80)) tip = sg.label + ' — not yet admitted' + (item.caption || item.reason ? ' — ' + (item.caption || item.reason) : ''); else if (curStage === STAGE_TRACKER_PRE_MERGE_SOAK) tip = sg.label + ' — admitted, soaking' + stageTrackerSoakLeft(item); else if (curStage === 100) tip = sg.label + ' — admitted, merging'; @@ -14436,15 +14451,23 @@ <h3 class="faq-group-title">Where to get help</h3> // Working or waiting leads: what happens now, or what it waits on. if (!sg.cap && typeof stageTrackerCueLead === 'function') tip = stageTrackerCueLead(item, worker, nowMs) + tip; } + const gateRow = active && !sg.cap && sg.number === STAGE_TRACKER_MERGE_COLUMN; + const gateTip = gateRow && !sg.detour && typeof stageTrackerMergeGateTip === 'function' ? stageTrackerMergeGateTip(item, nowMs || Date.now()) : ''; + if (gateTip) tip = gateTip + ' — ' + tip; let inner; // A lit chevron on a row parked on a person ("Needs human decision", // "Triage needed") is the trigger of the decision popover: the word // becomes a button and the chevron drops its native title so the // popover (which repeats the stage line) is its one hover text. const decision = active && !sg.cap && typeof stageTrackerDecisionOf === 'function' ? stageTrackerDecisionOf(item) : null; - const word = sg.detour ? `<span class="ham-detour">${esc(sg.detour.text)}</span>` : `<span class="ham-seg-t">${esc(sg.short)}</span>`; + const word = sg.detour ? `<span class="ham-detour">${esc(sg.detour.text)}</span>` : `<span class="ham-seg-t">${esc(sg.short + (curStage === 95 && active ? stageTrackerSoakLeft(item) : ''))}</span>`; if (sg.cap) inner = stageTrackerIcon(sg.number, 'ham-ico'); - else if (active) inner = stageTrackerIcon(sg.number, 'ham-ico ham-active-ico') + (decision ? stageTrackerDecisionTriggerHtml(decision, word, tip) : word) + actorIco; + else if (active) { + const iconLabel = gateRow ? (gateTip || tip) : 'An agent is working on this item now'; + const icon = stageTrackerIcon(sg.number, 'ham-ico ham-active-ico', iconLabel).replace(' viewBox=', ` title="${esc(iconLabel)}"${gateRow ? ' data-merge-gate="true"' : ''} viewBox=`).replace('><', `><title>${esc(iconLabel)}<`); + const agentIcon = gateRow && worker ? stageTrackerIcon(50, 'ham-ico cue-spin', 'An agent is working on this PR now').replace(' viewBox=', ' title="An agent is working on this PR now" viewBox=').replace('><', '>An agent is working on this PR now<') : ''; + inner = icon + (decision ? stageTrackerDecisionTriggerHtml(decision, word, tip) : word) + actorIco + agentIcon; + } else inner = stageTrackerIcon(sg.number, 'ham-ico'); return `
  • ${inner}
  • `; }).join(''); @@ -14852,7 +14875,7 @@

    Where to get help

    function stageTrackerLinkedPRItem(issue, lp) { const open = Array.isArray(issue.linked_prs) ? issue.linked_prs.filter(x => x && x.number !== lp.number && stageTrackerLinkedPROpen(x)) : []; return { repo: issue.repo, number: lp.number, kind: 'pr', title: lp.title || '', url: lp.url || '', author: lp.author || '', author_kind: lp.author_kind || '', - 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 || '', + merge_gate: lp.merge_gate || null, soak_remaining_seconds: lp.soak_remaining_seconds || 0, 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 || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, superseded: !!lp.superseded, 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 }; @@ -15047,7 +15070,7 @@

    Where to get help

    const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + 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.base_ref ? ` ${esc(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, + shown = Object.assign({}, item, { via_pr: true, merge_gate: lp.merge_gate || null, soak_remaining_seconds: lp.soak_remaining_seconds || 0, 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, adoption: lp.adoption || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed diff --git a/src/pkg/github/automerge/automerge_contributor_lane.go b/src/pkg/github/automerge/automerge_contributor_lane.go index 3ef3443014..50248f4ba8 100644 --- a/src/pkg/github/automerge/automerge_contributor_lane.go +++ b/src/pkg/github/automerge/automerge_contributor_lane.go @@ -1351,6 +1351,7 @@ func (c *Engine) evaluateContributorLanePR(ctx context.Context, displayRepo, own } func (c *Engine) trySweepContributorLanePR(ctx context.Context, displayRepo, owner, repo string, number int, policy ContributorLanePolicy) (AutoMergeSweepEvent, string, error) { + defer c.workingPR(displayRepo, number)() eval, reason, err := c.evaluateContributorLanePR(ctx, displayRepo, owner, repo, number, policy, false) if err != nil || reason != "" { return AutoMergeSweepEvent{}, reason, err diff --git a/src/pkg/github/automerge/automerge_forgestate.go b/src/pkg/github/automerge/automerge_forgestate.go index 78c0cb40e5..26c36e663e 100644 --- a/src/pkg/github/automerge/automerge_forgestate.go +++ b/src/pkg/github/automerge/automerge_forgestate.go @@ -352,6 +352,8 @@ func (c *Engine) runEventDrivenSweep(ctx context.Context, maxMerges int, acmmAll return } } + c.scheduleSweep(time.Now().Add(c.floorInterval())) + defer c.scheduleSweep(time.Time{}) floor := time.NewTicker(c.floorInterval()) defer floor.Stop() c.sweepPass(ctx, maxMerges, acmmAllowed, nil, "startup") @@ -359,7 +361,8 @@ func (c *Engine) runEventDrivenSweep(ctx context.Context, maxMerges int, acmmAll select { case <-ctx.Done(): return - case <-floor.C: + case tick := <-floor.C: + c.scheduleSweep(tick.Add(c.floorInterval())) // The floor pass is low-priority work like the legacy tick: under // rate-limit caution it yields to the queue (#13382); event passes // are targeted and still run. diff --git a/src/pkg/github/automerge/automerge_sweep.go b/src/pkg/github/automerge/automerge_sweep.go index eeef03493a..8a9d0c41d5 100644 --- a/src/pkg/github/automerge/automerge_sweep.go +++ b/src/pkg/github/automerge/automerge_sweep.go @@ -1437,6 +1437,8 @@ func (c *Engine) StartSelfAuthoredAutoMergeSweep(ctx context.Context, maxMerges ctx = lowPriority(ctx) go func() { defer close(done) + c.scheduleSweep(time.Now().Add(interval)) + defer c.scheduleSweep(time.Time{}) t := time.NewTicker(interval) defer t.Stop() // cautionTick is non-zero while the ticker is running at the caution @@ -1446,10 +1448,16 @@ func (c *Engine) StartSelfAuthoredAutoMergeSweep(ctx context.Context, maxMerges select { case <-ctx.Done(): return - case <-t.C: + case tick := <-t.C: + tickInterval := interval + if cautionTick != 0 { + tickInterval = cautionTick + } + c.scheduleSweep(tick.Add(tickInterval)) gate := c.sweepTickGate(interval, cautionTick, hgithub.ShedLowPriorityTick) if gate.reset { t.Reset(gate.tick) + c.scheduleSweep(time.Now().Add(gate.tick)) } cautionTick = gate.cautionTick if gate.skip { @@ -1461,6 +1469,7 @@ func (c *Engine) StartSelfAuthoredAutoMergeSweep(ctx context.Context, maxMerges } if next, changed := nextSelfAuthoredSweepInterval(repos, interval, result); changed { t.Reset(next) + c.scheduleSweep(time.Now().Add(next)) c.info("self-authored automerge sweep interval adjusted", "previous_interval", interval, "next_interval", next, @@ -1471,6 +1480,7 @@ func (c *Engine) StartSelfAuthoredAutoMergeSweep(ctx context.Context, maxMerges if cautionTick != 0 { cautionTick = cautionSweepInterval(interval) t.Reset(cautionTick) + c.scheduleSweep(time.Now().Add(cautionTick)) } } } @@ -1486,6 +1496,7 @@ func (c *Engine) StartSelfAuthoredAutoMergeSweep(ctx context.Context, maxMerges // for the log. It returns nil when the self-authored lane failed outright // (its callers then keep the current cadence). func (c *Engine) sweepPass(ctx context.Context, maxMerges int, acmmAllowed bool, targets SweepTargets, cause string) *AutoMergeSweepResult { + defer c.beginSweep()() result := &AutoMergeSweepResult{} if acmmAllowed { var err error @@ -1615,6 +1626,7 @@ func (c *Engine) releaseHoldActive(ctx context.Context, owner, repo, branch stri } func (c *Engine) trySweepSelfAuthoredPR(ctx context.Context, displayRepo, owner, repo string, number int, branchUpdateAllowed bool) (AutoMergeSweepEvent, string, error) { + defer c.workingPR(displayRepo, number)() pr, _, err := c.gh.PullRequests.Get(hgithub.WithRESTCaller(ctx, "hive:automerge_sweep"), owner, repo, number) if err != nil { if isGitHubStatus(err, http.StatusNotFound) { @@ -2085,6 +2097,7 @@ func (c *Engine) listQueuedPullRequestIssues(ctx context.Context, owner, repo, l } func (c *Engine) trySweepTrustedAuthorPR(ctx context.Context, displayRepo, owner, repo string, number int, policy TrustedAuthorPolicy) (AutoMergeSweepEvent, string, error) { + defer c.workingPR(displayRepo, number)() pr, _, err := c.gh.PullRequests.Get(hgithub.WithRESTCaller(ctx, "hive:trusted_author_automerge_sweep"), owner, repo, number) if err != nil { if isGitHubStatus(err, http.StatusNotFound) { @@ -2430,6 +2443,7 @@ func (c *Engine) commentTrustedAuthorMerge(ctx context.Context, owner, repo stri } func (c *Engine) trySweepQueuedPR(ctx context.Context, displayRepo, owner, repo string, number int, label string) (AutoMergeSweepEvent, string, error) { + defer c.workingPR(displayRepo, number)() pr, _, err := c.gh.PullRequests.Get(hgithub.WithRESTCaller(ctx, "hive:automerge_sweep"), owner, repo, number) if err != nil { if isGitHubStatus(err, http.StatusNotFound) { diff --git a/src/pkg/github/automerge/sweep_clock.go b/src/pkg/github/automerge/sweep_clock.go new file mode 100644 index 0000000000..429253fc38 --- /dev/null +++ b/src/pkg/github/automerge/sweep_clock.go @@ -0,0 +1,34 @@ +package automerge + +import ( + hgithub "time" + + "github.com/hivecommons/hive/pkg/github" +) + +// Optional transport capability keeps test transports and other forges usable. +func (c *Engine) sweepClock() *hgithub.MergeSweepClock { + if t, ok := c.transport.(interface { + MergeSweepClock() *hgithub.MergeSweepClock + }); ok { + return t.MergeSweepClock() + } + return nil +} +func (c *Engine) scheduleSweep(next time.Time) { + if clock := c.sweepClock(); clock != nil { + clock.Schedule("lanes", next) + } +} +func (c *Engine) beginSweep() func() { + if clock := c.sweepClock(); clock != nil { + return clock.Begin("lanes") + } + return func() {} +} +func (c *Engine) workingPR(repo string, number int) func() { + if clock := c.sweepClock(); clock != nil { + return clock.Working(repo, number) + } + return func() {} +} diff --git a/src/pkg/github/automerge/sweep_clock_test.go b/src/pkg/github/automerge/sweep_clock_test.go new file mode 100644 index 0000000000..6e0b0b19a7 --- /dev/null +++ b/src/pkg/github/automerge/sweep_clock_test.go @@ -0,0 +1,45 @@ +package automerge + +import ( + "context" + "log/slog" + "net/http" + "net/http/httptest" + "testing" + + hgithub "github.com/hivecommons/hive/pkg/github" +) + +func TestMergeSweepClockMarksOnlyEvaluatedPRInEveryLane(t *testing.T) { + var client *hgithub.Client + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if !client.MergeSweepClock().Snapshot("acme/widget", 1).SweepRunning { + t.Error("PR evaluation did not publish running state") + } + if client.MergeSweepClock().Snapshot("acme/widget", 2).SweepRunning { + t.Error("unrelated PR appears to be running") + } + http.Error(w, "gone", http.StatusNotFound) + })) + defer srv.Close() + client = hgithub.NewClientForTest(srv.URL, "acme", []string{"widget"}, slog.Default()) + c := New(client, Options{}) + ctx := context.Background() + for name, run := range map[string]func(){ + "queued": func() { _, _, _ = c.trySweepQueuedPR(ctx, "acme/widget", "acme", "widget", 1, "automerge") }, + "self-authored": func() { _, _, _ = c.trySweepSelfAuthoredPR(ctx, "acme/widget", "acme", "widget", 1, false) }, + "trusted": func() { + _, _, _ = c.trySweepTrustedAuthorPR(ctx, "acme/widget", "acme", "widget", 1, TrustedAuthorPolicy{}) + }, + "contributor": func() { + _, _, _ = c.trySweepContributorLanePR(ctx, "acme/widget", "acme", "widget", 1, ContributorLanePolicy{}) + }, + } { + t.Run(name, func(t *testing.T) { + run() + if client.MergeSweepClock().Snapshot("acme/widget", 1).SweepRunning { + t.Fatal("early return left the PR marked running") + } + }) + } +} diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index 9c90f1e21b..4c8e3cf20a 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -38,8 +38,9 @@ import ( var ErrNoGitHubClient = errors.New("no github client configured (hive is running without GitHub credentials)") type Client struct { - client *gh.Client - linearTeams map[string][]string + mergeSweepClock MergeSweepClock + client *gh.Client + linearTeams map[string][]string // foldedTrackers records issues that finding folds landed on (#11587). foldedTrackers foldedTrackerSet // commentBudget caps automated comments per issue per day (#12733). diff --git a/src/pkg/github/merge_sweep_clock.go b/src/pkg/github/merge_sweep_clock.go new file mode 100644 index 0000000000..315052a948 --- /dev/null +++ b/src/pkg/github/merge_sweep_clock.go @@ -0,0 +1,102 @@ +package github + +import ( + "strings" + "sync" + "time" +) + +// MergeSweepTimes is an observational clock, never an input to merge admission. +// NextSweepAt is the scheduled floor pass; events can cause an earlier pass. +type MergeSweepTimes struct { + SweepRunning bool `json:"sweep_running"` + LastSweepAt *time.Time `json:"last_sweep_at"` + NextSweepAt *time.Time `json:"next_sweep_at"` +} + +type mergeSweepLane struct { + last, next time.Time + running int +} + +// MergeSweepClock belongs to a client so separate hives cannot share clocks. +// All lanes may update it concurrently with dashboard reads. +type MergeSweepClock struct { + mu sync.Mutex + lanes map[string]mergeSweepLane + active map[string]map[int]int +} + +func (c *Client) MergeSweepClock() *MergeSweepClock { return &c.mergeSweepClock } + +func (c *MergeSweepClock) Schedule(lane string, next time.Time) { + c.mu.Lock() + defer c.mu.Unlock() + if c.lanes == nil { + c.lanes = make(map[string]mergeSweepLane) + } + l := c.lanes[lane] + l.next = next + c.lanes[lane] = l +} + +// Begin records a whole pass; the returned function records completion even +// when the pass exits early or fails. Overlapping lanes retain their clocks. +func (c *MergeSweepClock) Begin(lane string) func() { + c.mu.Lock() + if c.lanes == nil { + c.lanes = make(map[string]mergeSweepLane) + } + l := c.lanes[lane] + l.running++ + c.lanes[lane] = l + c.mu.Unlock() + return func() { + c.mu.Lock() + defer c.mu.Unlock() + l := c.lanes[lane] + l.running-- + l.last = time.Now().UTC() + c.lanes[lane] = l + } +} + +// Working marks only the PR currently being evaluated, rather than every PR +// in a running sweep. A counter handles concurrent evaluations of the same PR. +func (c *MergeSweepClock) Working(repo string, number int) func() { + repo = strings.ToLower(repo) + c.mu.Lock() + if c.active == nil { + c.active = make(map[string]map[int]int) + } + if c.active[repo] == nil { + c.active[repo] = make(map[int]int) + } + c.active[repo][number]++ + c.mu.Unlock() + return func() { + c.mu.Lock() + defer c.mu.Unlock() + c.active[repo][number]-- + if c.active[repo][number] == 0 { + delete(c.active[repo], number) + } + } +} + +func (c *MergeSweepClock) Snapshot(repo string, number int) MergeSweepTimes { + c.mu.Lock() + defer c.mu.Unlock() + out := MergeSweepTimes{SweepRunning: c.active[strings.ToLower(repo)][number] > 0} + for _, l := range c.lanes { + if !l.last.IsZero() && (out.LastSweepAt == nil || l.last.After(*out.LastSweepAt)) { + t := l.last + out.LastSweepAt = &t + } + if !l.next.IsZero() && (out.NextSweepAt == nil || l.next.Before(*out.NextSweepAt)) { + t := l.next + out.NextSweepAt = &t + } + } + return out +} diff --git a/src/pkg/github/merge_sweep_clock_test.go b/src/pkg/github/merge_sweep_clock_test.go new file mode 100644 index 0000000000..f5730608bb --- /dev/null +++ b/src/pkg/github/merge_sweep_clock_test.go @@ -0,0 +1,44 @@ +package github + +import ( + "testing" + "time" +) + +func TestMergeSweepClockConcurrentLanes(t *testing.T) { + var c MergeSweepClock + if got := c.Snapshot("org/repo", 1); got.SweepRunning || got.LastSweepAt != nil || got.NextSweepAt != nil { + t.Fatalf("unstarted: %+v", got) + } + later := time.Now().Add(5 * time.Minute) + earlier := later.Add(-time.Minute) + c.Schedule("lanes", later) + c.Schedule("queued", earlier) + endPass := c.Begin("lanes") + endOne := c.Working("Org/Repo", 1) + endTwo := c.Working("org/repo", 1) + if c.Snapshot("org/repo", 2).SweepRunning { + t.Fatal("unrelated PR appears active") + } + if c.Snapshot("other/repo", 1).SweepRunning { + t.Fatal("unrelated repo appears active") + } + endOne() + if !c.Snapshot("org/repo", 1).SweepRunning { + t.Fatal("concurrent evaluation lost") + } + endTwo() + endPass() + got := c.Snapshot("org/repo", 1) + if got.SweepRunning || got.LastSweepAt == nil || got.NextSweepAt == nil || !got.NextSweepAt.Equal(earlier) { + t.Fatalf("completed: %+v", got) + } + c.Schedule("queued", time.Time{}) + if got := c.Snapshot("org/repo", 1); !got.NextSweepAt.Equal(later) { + t.Fatalf("remaining lane: %+v", got) + } + var other MergeSweepClock + if other.Snapshot("org/repo", 1).LastSweepAt != nil { + t.Fatal("clock leaked between hives") + } +} From a62090a3e88542f2a0726ee9f09a5f82d57aa3cb Mon Sep 17 00:00:00 2001 From: thatguywob Date: Wed, 28 Oct 2026 19:53:07 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20correct=20merge=20swe?= =?UTF-8?q?ep=20clock=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: thatguywob --- src/pkg/github/automerge/sweep_clock.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/github/automerge/sweep_clock.go b/src/pkg/github/automerge/sweep_clock.go index 429253fc38..38cff56087 100644 --- a/src/pkg/github/automerge/sweep_clock.go +++ b/src/pkg/github/automerge/sweep_clock.go @@ -1,9 +1,9 @@ package automerge import ( - hgithub "time" + "time" - "github.com/hivecommons/hive/pkg/github" + hgithub "github.com/hivecommons/hive/pkg/github" ) // Optional transport capability keeps test transports and other forges usable.