From d333c3ebdf8d765d60ade7bae31159101e801cb9 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 12:52:07 -0400 Subject: [PATCH 1/2] dashboard: Needs human chip counts only human-gated rows; Refs-only PRs address, not cover, an issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug 1: the Activity Monitor's Needs human chip was label-based (needs_human_labels), so needs-signal / hold rows — a 040 'PR in progress' issue, held auto-merge PRs — counted. One predicate (stageTrackerNeedsHuman Go, stageTrackerItemNeedsHuman JS) now feeds the chip count, the filter and new needs_human / on_hold payload fields; held rows get an On hold chip. Bug 2: #14976 (shared-CI incident) showed 040 'open PR covers it' because the relay covered the declared issue of #14990 despite its explicit non-closing 'Refs'. Reference-only claims are carried as ClaimFact.Partial, recorded via FactSink.AddressedBy, and read 'addresses part of it'. Bare cross-references (incident deferral comments) never create coverage. Fixes #15008 Signed-off-by: Andrew Anderson --- ...ed-15008-needs-human-chip-partial-cover.md | 1 + src/docs/dashboard-sections.md | 2 + src/docs/labels-and-control-signals.md | 2 +- src/pkg/dashboard/label_presets.go | 10 +- src/pkg/dashboard/stage_tracker.go | 90 ++++++++++++++++- .../stage_tracker_needs_human_test.go | 57 +++++++++++ src/pkg/dashboard/stage_tracker_ui_test.go | 52 ++++++---- src/pkg/dashboard/static/index.html | 97 +++++++++++-------- src/pkg/github/issue_inprogress.go | 67 ++++++++++--- src/pkg/github/issue_stage_facts.go | 2 + src/pkg/github/issue_stage_labels_test.go | 7 ++ src/pkg/github/pr_covered_issues_test.go | 86 ++++++++++++++-- src/pkg/github/pr_request_watcher.go | 4 +- src/pkg/github/stage_facts_sink.go | 32 ++++-- src/pkg/github/stage_ledger_backfill.go | 9 +- src/pkg/github/stage_ledger_backfill_test.go | 6 ++ src/pkg/stageengine/derive_issue.go | 17 ++++ src/pkg/stageengine/derive_issue_test.go | 12 +++ src/pkg/stageengine/facts.go | 6 ++ src/pkg/stageengine/facts_sink.go | 16 +++ src/pkg/stageengine/stageenginetest/fake.go | 3 + 21 files changed, 482 insertions(+), 96 deletions(-) create mode 100644 changelog.d/fixed-15008-needs-human-chip-partial-cover.md create mode 100644 src/pkg/dashboard/stage_tracker_needs_human_test.go diff --git a/changelog.d/fixed-15008-needs-human-chip-partial-cover.md b/changelog.d/fixed-15008-needs-human-chip-partial-cover.md new file mode 100644 index 0000000000..4f8bdf6144 --- /dev/null +++ b/changelog.d/fixed-15008-needs-human-chip-partial-cover.md @@ -0,0 +1 @@ +- The Hive activity monitor's **Needs human** chip now counts and filters only rows a person alone can advance — stages 015/045/085/090, 071/072 with a human author, or a `needs-human` / `needs-decision` / `unauthorized` pill — from one predicate shared by the chip count, the filter, and the new `needs_human` / `on_hold` payload totals; held rows get their own **On hold** chip, and `hold`, `stalled`, `blocked`, handled regressions, covered 040 issues and auto-mergeable PRs no longer appear under Needs human. A hive PR that only references an issue (`Refs #N`, no closing keyword) is recorded as *addressing part of* the issue instead of *covering* it, in the relay, the claim-ledger backfill and the stage reason/caption; a bare cross-reference such as a shared-CI incident deferral never creates a covering relation ([#15008](https://github.com/hivecommons/hive/issues/15008)). diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 7ae4480db8..af284f8cd3 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -646,6 +646,8 @@ A progress strip per open issue and pull request showing which step of the pipel 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). +**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. + **Repo chip.** Each row carries a small monospace chip before the number naming the repository it belongs to (`dibs #456`, `hive #13524`); the chip is tinted per repository from a fixed palette so one repo always looks the same, the configured primary repo is shown muted, and the full `owner/repo` is in the tooltip. Linked PR sub-rows carry the same chip. Clicking a chip sets the **Repo** filter to that repository (click it again, or pick "All repos", to clear). By default the chip appears only when the list spans more than one repository; the ⚙ settings modal's **Repositories** section offers **Show repo chip: always / only when multiple repos / never** (stored under `hive.tracker.repochip`). **Group.** The **Group** control next to **Sort** switches between **None** (one flat list, the default) and **Repo**. Grouped by repo, rows sit under a sticky header per repository showing the `owner/repo`, its row count, how many of those rows need attention, and a mini distribution of rows across the pipeline columns; the primary repo's group comes first, then groups by row count. The chosen **Sort** still orders rows within each group. A header's chevron collapses that group to its header alone; collapsed repos are remembered across reloads (`hive.tracker.group.collapsed`), as is the Group choice itself (`hive.tracker.group`), which is also available in the settings modal. Group headers are keyed by repo so a refresh keeps them in place while rows move, and a header leaves only after the last row in its group has played its exit animation. diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index 6587b89ab7..1e4251d0de 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -218,7 +218,7 @@ referenced it) a lone `stage/050-review-pending` | `stage/017-possible-existing` | issue | **Possibly exists · needs author.** The prior-art gate found something that looks like the request already (knowledge bead, setting, merged PR, closed issue, doc or code) and parked the issue with the findings; the author confirms the gap (`/hive decision proceed — `) or closes it (`/hive decision exists`, label `already-exists`). The label itself is the park signal and an issue-level hard suppress, so no agent claims it; clanker-filed parks auto-close after `runs.triage.prior_art.bot_close_ttl`; hive-filed issues never wear it ([#13575](https://github.com/hivecommons/hive/issues/13575)) | none | | `stage/020-claimed` | issue | a live claim by anyone — a human, a relay contributor or a hive agent's `hive-open-issue claim` / start mark — with no PR evidence yet (replaces `claimed`, `hive/in-progress`) | 2h | | `stage/030-pr-in-progress` | issue | the claimant has a PR under way: its `hive-open-pr --issues` request named the issue or its start marker named a branch / PR (`pr_started=true` on the `hive:claim` marker). A claim or start mark without that evidence — the scanner's bare `hive-open-issue claim` included — stays at 020 ([#13069](https://github.com/hivecommons/hive/issues/13069)). If the in-progress evidence includes an open Hive-authored PR, the issue-stage lane applies the same PR-link safeguard described for 040: default-branch PRs that fully address the issue get a `Fixes #N` trailer when missing, while partial or non-default-branch PRs get an issue stage-entry comment linking the PR and explaining GitHub's icon limitation. If the claiming PR has already merged, the issue leaves 030: full-fix claims close it with one `` comment (checked before posting, so a close that fails after the comment is retried without a duplicate), while `Refs` / `Part of` claims move back to 010 with a partial-landed note. | 90m | -| `stage/040-covered-by-pr` | issue | an open PR covers it (replaces `🐝 covered by PR`); the issue stays here while the PR is open — the PR's own stage is named in the issue's stage reason, never written as its label ([#12451](https://github.com/hivecommons/hive/issues/12451)). For Hive-authored PRs on the repository default branch, the stage and claim-label sweeps append `Fixes #N` to the PR body when the PR appears to fully address the issue but lacks a closing keyword, so GitHub can show the Development sidebar link and issue-list PR icon. They also retrofit older Hive-authored default-branch PRs whose only claim line is `Refs #N` by rewriting that one keyword to `Fixes #N` once and stamping ``; human-authored PR bodies are never edited. `Part of` / leave-open partial work and non-default-branch PRs get one issue stage-entry comment with the PR link and GitHub limitation instead. Merged full-fix claims close the issue; merged reference claims remove stale 040/030 and return the issue to 010 with a partial-landed note. | n/a (the PR carries health) | +| `stage/040-covered-by-pr` | issue | an open PR covers it (replaces `🐝 covered by PR`), or — when the hive's PR only *references* the issue without a closing keyword (`Refs #N`) — "an open PR addresses part of it": the issue is still parked here but its stage reason and tracker caption say the remainder stays open when the PR merges ([#15008](https://github.com/hivecommons/hive/issues/15008)). Coverage is derived only from a closing reference in the PR body or commits, a hive claim-ledger entry, or an explicit hive marker — a bare cross-reference (an incident deferral comment, `see also`, a backlog link) never puts an issue here; the issue stays here while the PR is open — the PR's own stage is named in the issue's stage reason, never written as its label ([#12451](https://github.com/hivecommons/hive/issues/12451)). For Hive-authored PRs on the repository default branch, the stage and claim-label sweeps append `Fixes #N` to the PR body when the PR appears to fully address the issue but lacks a closing keyword, so GitHub can show the Development sidebar link and issue-list PR icon. They also retrofit older Hive-authored default-branch PRs whose only claim line is `Refs #N` by rewriting that one keyword to `Fixes #N` once and stamping ``; human-authored PR bodies are never edited. `Part of` / leave-open partial work and non-default-branch PRs get one issue stage-entry comment with the PR link and GitHub limitation instead. Merged full-fix claims close the issue; merged reference claims remove stale 040/030 and return the issue to 010 with a partial-landed note. | n/a (the PR carries health) | | `stage/045-needs-decision` | issue | **the** issue-side park-for-a-person signal (owner decision, 2026-10-17: issues never wear `stage/085-needs-decision`; that stage is PR-only). Derived whenever the issue carries `needs-human` or a hard-suppress park label (`needs-spec`, the retired `needs-direction` / `needs-decision`, a pre-045 `stage/085-needs-decision`) **and no hold-class label** — a held issue (`hold`, `do-not-merge*`, the hive's `hive-pause/`) is paused, not parked: it carries no stage label and the activity monitor shows it as "Open · on hold", the reconciler removing a 045 the hold caught it with ([#13012](https://github.com/hivecommons/hive/issues/13012)) — and written by the relay (`hive-open-issue --needs-decision`, or `label … stage/045-needs-decision`, the one issue stage label an agent may add) and by the dedupe/selfreport relays; the issue is outside the agent work queue (and off the good-first-issue list) until a maintainer replies `/hive approve` / `/hive decision `, which removes it and adds `approved-direction` (a Hive-added `needs-human` lifts too, so the issue reaches 010, [#13075](https://github.com/hivecommons/hive/issues/13075); a person's `needs-human` is left and keeps deriving 045 — the issue stays visibly a person's); with `project.agent_issue_decision_policy: resolve` (default), Hive-authored non-risk engineering questions are not allowed to self-park here — the relay records `Decision taken by hive: …`, downgrades to `stage/010-actionable`, and audits the downgrade, while true parks include a `Risk: ` line naming security posture, data loss, irreversible/public-facing behaviour, governance/policy/licensing, spend, owner-only credentials/secrets/infra, or uninferable human intent; once `approved-direction` is on the issue the relay refuses an agent's re-park while the recorded decision is unchanged — the agent adds `needs-human` and `/unclaim`s instead; a lapsed claim on a parked issue never shows 030. A contributor verdict that parks here citing only the target repository's own confirmation gate ("AGENTS.md says offer a spec and wait", "confirm scope first") or a registered sibling checkout that is merely not cloned yet (`repo_location_missing`) is not a decision: the hub reclassifies it as idle, removes the label with a `` comment, and re-offers the issue once; the second such park on the same issue stays (`src/pkg/dashboard/contribute_gate_park.go`, `src/pkg/decisionpolicy`). Leaving 045 is never a regression. An issue still wearing 085 is re-staged to 045 by the reconciler in one write, and a one-shot startup sweep (`/data/issue-needs-decision-stage-v1.done`) catches issues the enumeration never sees (`src/pkg/github/issue_needs_decision_migration.go`) | none | | `stage/050-review-pending` | PR | review swarm requested/dispatched; awaiting a verdict for the current head (or CI still pending with no verdict) | 1h | | `stage/060-reviewed` | PR | swarm verdict approve but a gate is still pending (CI running, or the soak clock on a head the lane has not admitted — the trust-blocked 090 path) | 30m | diff --git a/src/pkg/dashboard/label_presets.go b/src/pkg/dashboard/label_presets.go index 6813d4821b..3b58faee56 100644 --- a/src/pkg/dashboard/label_presets.go +++ b/src/pkg/dashboard/label_presets.go @@ -51,11 +51,11 @@ const ( // - the reporter-trust awaiting label (default needs-triage): the issue // waits for a maintainer to triage it before the hive may pick it up. // -// The Hive activity monitor's synthetic "Needs human" facet reads the same -// list (StageTrackerResponse.NeedsHumanLabels); a label matches when it -// equals an entry or sits under it as `entry/...` (needs-human/agent-ready), -// or matches the needs-human*, *needs-decision or *needs-author patterns -// (stageTrackerLabelNeedsHuman). +// The list still rides the stage-tracker payload +// (StageTrackerResponse.NeedsHumanLabels) for the Projects preset, but the +// Hive activity monitor's own "Needs human" chip no longer reads it — +// labels such as needs-signal or hold put rows nobody waits on under the +// chip (hivecommons/hive#15008); it uses stageTrackerNeedsHuman instead. // // "blocked" is deliberately absent: the codebase treats it as a contributor // skip marker and a PR mergeability state, not as a parked-on-a-person label. diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 4ab3ccea0a..23ce89618a 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -64,9 +64,17 @@ type StageTrackerResponse struct { // inferred from the PR's hive markers. AuthorKindLabels bool `json:"author_kind_labels"` // NeedsHumanLabels is the "a person must act" label set - // (needsHumanPresetLabels) behind the tracker's synthetic Needs human - // facet, so the page and the Projects preset cannot disagree. + // (needsHumanPresetLabels) the Projects preset filters by. The + // tracker's own "Needs human" chip no longer reads it: it counts + // StageTrackerItem.NeedsHuman (hivecommons/hive#15008). NeedsHumanLabels []string `json:"needs_human_labels,omitempty"` + // NeedsHuman counts Items whose NeedsHuman flag is set — the number the + // SPA's "Needs human" chip shows; OnHold likewise for the "On hold" + // chip. Both come from the same predicates the per-item flags do + // (stageTrackerNeedsHuman / stageTrackerOnHold), so chip, count and + // filter cannot disagree. + NeedsHuman int `json:"needs_human"` + OnHold int `json:"on_hold"` // Engine is the ADR-0025 central stage engine's mode and counters for // the tracker's status strip; absent when the hive has no engine. Engine *stageengine.Status `json:"engine,omitempty"` @@ -276,6 +284,18 @@ type StageTrackerItem struct { // does not count them until the PR reaches stage/080 or later. The // labels themselves are untouched; this is presentation only. DeferredModifiers []string `json:"deferred_modifiers,omitempty"` + // NeedsHuman is true when a person's decision or action is the ONLY + // thing that advances the item (stageTrackerNeedsHuman): stages 015 + // triage-needed, 045/085 needs-decision, 071/072 needs-author / + // returned-to-contributor with a human author, 090 ready-for-human- + // merge, or a needs-human / needs-decision / unauthorized pill. A + // hold is NOT this (OnHold): the owner chose to pause it. Neither are + // stalled, a handled regression, blocked-on-pr, 040 covered or a PR + // ready for auto-merge — the hive advances those (hivecommons/hive#15008). + NeedsHuman bool `json:"needs_human,omitempty"` + // OnHold is true when the item wears a hold pill: paused on purpose, + // waiting on nobody. + OnHold bool `json:"on_hold,omitempty"` // RegressedFrom / RegressedTo / RegressedAt / RegressedReason narrate // the unresolved regression behind the `regressed` modifier: the // high-water stage the item fell from, the stage that fall landed on @@ -1026,6 +1046,11 @@ func humanizeStageReason(reason string) string { switch lower { case "actionable", "live agent claim", "live issue claim", "open pr covers it": return "" + } + if stageengine.ReasonIsPartialCover(r) { + return "the PR references it without closing it (partial)" + } + switch lower { case "held": return "held by a hold label" case "label:needs-rebase": @@ -1282,6 +1307,9 @@ func stageTrackerCaption(stage stagelabels.Stage, reason, author string, kind st case stagelabels.PRInProgress: return joinClause("An agent has a PR under way; not yet opened", clause), "hive" case stagelabels.CoveredByPR: + if stageengine.ReasonIsPartialCover(reason) { + return "An open PR" + prRef + " addresses part of this issue — it references it without a closing keyword, so the remainder stays open when it merges", "its PR" + } return joinClause("An open PR"+prRef+" covers this issue", clause), "its PR" case stagelabels.ReviewPending: return joinClause("Review swarm requested; waiting for a verdict on the current head", clause), "review swarm" @@ -1660,6 +1688,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } } resp.OpenIssues, resp.OpenPRs = stageTrackerOpenCounts(resp.Items) + resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items) stageTrackerResolveLinkedPRs(resp.Items) sort.SliceStable(resp.Items, stageTrackerLess(resp.Items)) return resp @@ -1683,6 +1712,63 @@ var stageTrackerAttentionStages = []int{stagelabels.IssueNeedsDecision.Number(), // (dashboard STAGE_TRACKER_HUMAN_MODS). var stageTrackerHumanMods = []string{modHold, modUnauthorized, modNeedsHuman, modNeedsDecision, modNeedsRebase, modBlocked, modStalled} +// stageTrackerNeedsHumanStages are the stages where only a person can +// advance the item (dashboard STAGE_TRACKER_NEEDS_HUMAN_STAGES): 015 +// triage-needed, 045 issue needs-decision, 085 PR needs-decision, 090 +// ready-for-human-merge; 071 needs-author and 072 returned-to-contributor +// count only when the author is a human (stageTrackerNeedsHumanAuthorStages). +var stageTrackerNeedsHumanStages = []int{stagelabels.TriageNeeded.Number(), stagelabels.IssueNeedsDecision.Number(), stagelabels.NeedsDecision.Number(), stagelabels.ReadyForHumanMerge.Number()} + +// stageTrackerNeedsHumanAuthorStages park the PR on its author; a human +// author must act, a clanker's or hive's PR is re-kicked by the hive. +var stageTrackerNeedsHumanAuthorStages = []int{stagelabels.NeedsAuthor.Number(), stagelabels.ReturnedToContributor.Number()} + +// stageTrackerNeedsHumanMods are the pills that mean "a person must decide +// or act" (dashboard STAGE_TRACKER_NEEDS_HUMAN_MODS). hold is deliberately +// absent (On hold is its own chip); stalled, regressed, blocked, +// needs-rebase and draft are the hive's or nobody's to move. +var stageTrackerNeedsHumanMods = []string{modNeedsHuman, modNeedsDecision, modUnauthorized} + +// stageTrackerNeedsHuman is the ONE definition of "Needs human" behind the +// payload's per-item flag, its count and the SPA's chip + filter +// (dashboard stageTrackerItemNeedsHuman mirrors it): a human decision or +// action is the only thing that advances the item. A hold wins: a held +// item is paused, not waiting on a person (hivecommons/hive#15008). +func stageTrackerNeedsHuman(it StageTrackerItem) bool { + if stageTrackerOnHold(it) { + return false + } + if slices.ContainsFunc(it.Modifiers, func(m string) bool { return slices.Contains(stageTrackerNeedsHumanMods, m) }) { + return true + } + if slices.Contains(stageTrackerNeedsHumanStages, it.Stage) { + return true + } + return slices.Contains(stageTrackerNeedsHumanAuthorStages, it.Stage) && it.AuthorKind == authorKindHuman +} + +// stageTrackerOnHold mirrors the dashboard's stageTrackerItemOnHold: the +// row wears the hold pill. +func stageTrackerOnHold(it StageTrackerItem) bool { + return slices.Contains(it.Modifiers, modHold) +} + +// stageTrackerHumanCounts sets every item's NeedsHuman / OnHold flag and +// returns the two totals for the payload header. +func stageTrackerHumanCounts(items []StageTrackerItem) (needsHuman, onHold int) { + for i := range items { + items[i].NeedsHuman = stageTrackerNeedsHuman(items[i]) + items[i].OnHold = stageTrackerOnHold(items[i]) + if items[i].NeedsHuman { + needsHuman++ + } + if items[i].OnHold { + onHold++ + } + } + return needsHuman, onHold +} + // stageTrackerSunkMods are the modifiers that sink a row to the bottom of // its stage (dashboard STAGE_TRACKER_SUNK_MODS): a person parked it, or it // is a draft nobody should act on yet. diff --git a/src/pkg/dashboard/stage_tracker_needs_human_test.go b/src/pkg/dashboard/stage_tracker_needs_human_test.go new file mode 100644 index 0000000000..88cf3a91e1 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_needs_human_test.go @@ -0,0 +1,57 @@ +package dashboard + +import "testing" + +// hivecommons/hive#15008: the "Needs human" chip count and the filter share +// stageTrackerNeedsHuman — only rows a person alone can advance qualify; +// hold is "On hold", and 040 "PR in progress" / stalled / blocked / +// ready-for-automerge rows never count. +func TestStageTrackerNeedsHuman(t *testing.T) { + cases := []struct { + name string + it StageTrackerItem + needsHuman, hold bool + }{ + {"040 covered, no mods (#14976)", StageTrackerItem{Stage: 40, Modifiers: []string{}}, false, false}, + {"015 triage", StageTrackerItem{Stage: 15}, true, false}, + {"045 needs decision", StageTrackerItem{Stage: 45}, true, false}, + {"085 needs decision", StageTrackerItem{Stage: 85}, true, false}, + {"090 human merge", StageTrackerItem{Stage: 90}, true, false}, + {"071 human author", StageTrackerItem{Stage: 71, AuthorKind: authorKindHuman}, true, false}, + {"071 clanker author", StageTrackerItem{Stage: 71, AuthorKind: "clanker"}, false, false}, + {"072 human author", StageTrackerItem{Stage: 72, AuthorKind: authorKindHuman}, true, false}, + {"needs-human pill", StageTrackerItem{Stage: 20, Modifiers: []string{modNeedsHuman}}, true, false}, + {"needs-decision pill", StageTrackerItem{Stage: 50, Modifiers: []string{modNeedsDecision}}, true, false}, + {"unauthorized pill", StageTrackerItem{Stage: 50, Modifiers: []string{modUnauthorized}}, true, false}, + {"hold on 045 wins", StageTrackerItem{Stage: 45, Modifiers: []string{modHold}}, false, true}, + {"ready for auto merge + hold (#7563)", StageTrackerItem{Stage: 80, Modifiers: []string{modHold}}, false, true}, + {"stalled", StageTrackerItem{Stage: 60, Modifiers: []string{modStalled}}, false, false}, + {"blocked on pr", StageTrackerItem{Stage: 60, Modifiers: []string{"blocked-on-pr"}}, false, false}, + {"regressed handled", StageTrackerItem{Stage: 30, Modifiers: []string{"regressed"}}, false, false}, + {"merge queue", StageTrackerItem{Stage: 100}, false, false}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + if got := stageTrackerNeedsHuman(c.it); got != c.needsHuman { + t.Fatalf("needsHuman = %v, want %v", got, c.needsHuman) + } + if got := stageTrackerOnHold(c.it); got != c.hold { + t.Fatalf("onHold = %v, want %v", got, c.hold) + } + }) + } + + items := make([]StageTrackerItem, 0, len(cases)) + for _, c := range cases { + items = append(items, c.it) + } + nh, oh := stageTrackerHumanCounts(items) + if nh != 9 || oh != 2 { + t.Fatalf("counts = (%d, %d), want (9, 2)", nh, oh) + } + for i, c := range cases { + if items[i].NeedsHuman != c.needsHuman || items[i].OnHold != c.hold { + t.Fatalf("%s: flags (%v,%v) want (%v,%v)", c.name, items[i].NeedsHuman, items[i].OnHold, c.needsHuman, c.hold) + } + } +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 333b3105ad..9c94535427 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -122,8 +122,10 @@ func TestStageTrackerRows(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerWaitSince"), jsFunc(t, html, "stageTrackerLabelFamily"), - jsFunc(t, html, "stageTrackerNeedsHumanLabels"), - jsFunc(t, html, "stageTrackerLabelNeedsHuman"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_MODS"), + jsFunc(t, html, "stageTrackerItemOnHold"), jsFunc(t, html, "stageTrackerItemNeedsHuman"), jsFunc(t, html, "stageTrackerLabelCompare"), jsFunc(t, html, "stageTrackerLabelDialogData"), @@ -832,8 +834,10 @@ func TestStageTrackerFilterSortPage(t *testing.T) { jsFunc(t, html, "stageTrackerNeedsAttention"), jsFunc(t, html, "stageTrackerWaitSince"), jsFunc(t, html, "stageTrackerLabelFamily"), - jsFunc(t, html, "stageTrackerNeedsHumanLabels"), - jsFunc(t, html, "stageTrackerLabelNeedsHuman"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES"), + jsConstLine(t, html, "STAGE_TRACKER_NEEDS_HUMAN_MODS"), + jsFunc(t, html, "stageTrackerItemOnHold"), jsFunc(t, html, "stageTrackerItemNeedsHuman"), jsFunc(t, html, "stageTrackerLabelCompare"), jsFunc(t, html, "stageTrackerLabelDialogData"), @@ -977,7 +981,7 @@ assert.deepStrictEqual(fac.chips.map(x => x.label), ['stage/010-actionable', 'st assert.deepStrictEqual(fac.chips.find(x => x.label === 'author/clanker').count, 2); assert.deepStrictEqual(fac.all.map(x => x.label), fac.chips.map(x => x.label), 'under the limit the dialog list equals the row'); assert.strictEqual(fac.hidden, 0); -assert.strictEqual(fac.needsHuman, null, 'no needs-human set in the payload, no synthetic chip'); +assert.deepStrictEqual([fac.needsHuman.count, fac.needsHuman.on, fac.onHold.count, fac.onHold.on], [0, false, 0, false], 'synthetic chips always exist; nothing here is human-gated or held'); assert.ok(stageTrackerLabelFacets(items.concat([{ kind: 'issue', repo: 'a/b', number: 7, labels: ['solo'] }]), F()).chips.some(x => x.label === 'solo'), 'single-item labels are offered too (no hidden labels)'); // Over the limit: the row shows the first N in order plus any selected label; all keeps every label and hidden the overflow. const wide = items.concat(Array.from({ length: 30 }, (_, i) => ({ kind: 'issue', repo: 'a/b', number: 100 + i, labels: ['zz-' + String(i).padStart(2, '0')] }))); @@ -991,24 +995,34 @@ let dlg = stageTrackerLabelDialogData(fac, 'ZZ-1'); assert.deepStrictEqual(dlg.rows.map(x => x.label), ['zz-10', 'zz-11', 'zz-12', 'zz-13', 'zz-14', 'zz-15', 'zz-16', 'zz-17', 'zz-18', 'zz-19', 'zz-29'], 'query is a case-insensitive substring; selected labels stay listed'); assert.deepStrictEqual([dlg.total, dlg.selected, dlg.query], [40, 1, 'zz-1']); -// Needs human: one synthetic facet over the payload's set; count = distinct items, prefix children match, filter is OR across the set. -const nh = stageTrackerNeedsHumanLabels({ needs_human_labels: ['stage/045-needs-decision', 'Needs-Human', 'hold', ' stage/071-needs-author '] }); -assert.deepStrictEqual(nh, ['stage/045-needs-decision', 'needs-human', 'hold', 'stage/071-needs-author']); +// Needs human (hivecommons/hive#15008): stage/modifier predicate shared with the count — labels alone never qualify. const parked = items.concat([ - { kind: 'issue', repo: 'a/b', number: 20, labels: ['stage/045-needs-decision', 'needs-human', 'hold'] }, - { kind: 'issue', repo: 'a/b', number: 21, labels: ['needs-human/agent-ready'] }, - { kind: 'pr', repo: 'a/b', number: 22, labels: ['stage/071-needs-author', 'author/human'] }, - { kind: 'issue', repo: 'a/b', number: 23, labels: ['holder'] }, + { kind: 'issue', repo: 'a/b', number: 20, stage: 45, modifiers: [], labels: ['stage/045-needs-decision'] }, + { kind: 'issue', repo: 'a/b', number: 21, stage: 20, modifiers: ['needs-human'], labels: ['needs-human/agent-ready'] }, + { kind: 'pr', repo: 'a/b', number: 22, stage: 71, author_kind: 'human', modifiers: [], labels: ['stage/071-needs-author', 'author/human'] }, + { kind: 'pr', repo: 'a/b', number: 23, stage: 71, author_kind: 'clanker', modifiers: [], labels: ['stage/071-needs-author'] }, + { kind: 'issue', repo: 'a/b', number: 24, stage: 40, modifiers: [], labels: ['needs-signal'] }, + { kind: 'issue', repo: 'a/b', number: 25, stage: 45, modifiers: ['hold'], labels: ['stage/045-needs-decision', 'hold'] }, + { kind: 'pr', repo: 'a/b', number: 26, stage: 80, modifiers: ['hold'], labels: ['hold'] }, + { kind: 'pr', repo: 'a/b', number: 27, stage: 60, modifiers: ['stalled', 'blocked-on-pr'], labels: [] }, + { kind: 'issue', repo: 'a/b', number: 28, stage: 15, modifiers: [], labels: [] }, + { kind: 'pr', repo: 'a/b', number: 29, stage: 90, modifiers: [], labels: [] }, + { kind: 'pr', repo: 'a/b', number: 30, stage: 50, modifiers: ['unauthorized'], labels: [] }, ]); -assert.strictEqual(stageTrackerLabelNeedsHuman('needs-human/agent-ready', nh), true); -assert.strictEqual(stageTrackerLabelNeedsHuman('holder', nh), false, 'prefix match needs the / separator'); -fac = stageTrackerLabelFacets(parked, F(), { needsHumanLabels: nh }); -assert.deepStrictEqual([fac.needsHuman.count, fac.needsHuman.on], [3, false], 'three distinct items, not five label hits'); -assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ needsHuman: true }), Object.assign({ needsHumanLabels: nh }, ctx))), [20, 21, 22]); -assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ needsHuman: true, labels: ['author/human'] }), Object.assign({ needsHumanLabels: nh }, ctx))), [22], 'needs-human ANDs with label chips'); +assert.strictEqual(stageTrackerItemNeedsHuman(parked.find(x => x.number === 24)), false, '040 "PR in progress" needs no human (#14976)'); +assert.strictEqual(stageTrackerItemNeedsHuman(parked.find(x => x.number === 23)), false, '071 with a clanker author is the bot\'s turn'); +assert.strictEqual(stageTrackerItemNeedsHuman(parked.find(x => x.number === 25)), false, 'hold wins: a held row is paused, not waiting'); +assert.strictEqual(stageTrackerItemOnHold(parked.find(x => x.number === 25)), true); +fac = stageTrackerLabelFacets(parked, F()); +assert.deepStrictEqual([fac.needsHuman.count, fac.needsHuman.on, fac.onHold.count, fac.onHold.on], [6, false, 2, false]); +assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ needsHuman: true }), ctx)), [20, 21, 22, 28, 29, 30], 'filter and chip count agree'); +assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ onHold: true }), ctx)), [25, 26]); +assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ needsHuman: true, labels: ['author/human'] }), ctx)), [22], 'needs-human ANDs with label chips'); assert.strictEqual(stageTrackerFilterActive(F({ needsHuman: true })), true); +assert.strictEqual(stageTrackerFilterActive(F({ onHold: true })), true); assert.strictEqual(stageTrackerNormalizeFilter({ needsHuman: 'yes' }).needsHuman, true); -assert.deepStrictEqual(nums(stageTrackerVisible(parked, F({ needsHuman: true }), ctx)), [], 'without a set nothing can need a human'); +assert.strictEqual(stageTrackerNormalizeFilter({ onHold: 1 }).onHold, true); +assert.strictEqual(stageTrackerLabelDialogData(stageTrackerLabelFacets(parked, F({ needsHuman: true, onHold: true }))).selected, 2); ` cmd := exec.Command(node, "-e", script) if out, err := cmd.CombinedOutput(); err != nil { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 2e9e9bda96..3a3dd11b2c 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1366,6 +1366,8 @@ /* Synthetic "Needs human" facet: first in the row, attention-coloured so it reads as a verdict, not a label. */ .ham-needs-human-chip { color: var(--status-attention); border-color: var(--status-attention); font-weight: 600; } .ham-needs-human-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--status-attention) 16%, transparent); color: var(--text); border-color: var(--status-attention); } + .ham-on-hold-chip { color: var(--text-muted); font-weight: 600; } + .ham-on-hold-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text); } .ham-label-dialog-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); } .ham-label-dialog-tools .ham-input { flex: 1 1 14rem; } .ham-label-dialog .ham-labels { margin-bottom: var(--sp-2); } @@ -13910,6 +13912,17 @@

Where to get help

const STAGE_TRACKER_CLOCK_MS = 10000; const STAGE_TRACKER_AGE_MS = { '1h': 3600000, '1d': 86400000, '1w': 604800000 }; const STAGE_TRACKER_ATTENTION_STAGES = [45, 71, 72, 85, 90]; + // "Needs human" (one definition with Go stageTrackerNeedsHuman; the + // payload's needs_human flag/count come from it too): a person's + // decision or action is the ONLY thing that advances the row — 015 + // triage, 045/085 needs-decision, 090 human merge; 071/072 only when + // the author is a human; or a needs-human / needs-decision / + // unauthorized pill. hold is "On hold" (its own chip), never this. + const STAGE_TRACKER_NEEDS_HUMAN_STAGES = [15, 45, 85, 90]; + const STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES = [71, 72]; + const STAGE_TRACKER_NEEDS_HUMAN_MODS = ['needs-human', 'needs-decision', 'unauthorized']; + const STAGE_TRACKER_NEEDS_HUMAN_TIP = 'Only a person can move these: triage needed, needs decision, human author must act, human merge, or a needs-human / unauthorized pill'; + const STAGE_TRACKER_ON_HOLD_TIP = 'Paused on purpose with a hold label — waiting on nobody; remove the hold to resume'; // Label families a chip row is built from, in display order; other // labels follow when at least two items carry them. const STAGE_TRACKER_LABEL_FAMILIES = ['stage/', 'needs-', 'author/', 'role/', 'hold', 'on-hold', 'do-not-merge', 'hive-pause/']; @@ -13946,7 +13959,7 @@

Where to get help

var _stageTrackerGroup = STAGE_TRACKER_GROUP_DEFAULT; var _stageTrackerCollapsed = {}; function stageTrackerDefaultFilter() { - return { kind: 'all', repo: '', q: '', labels: [], needsHuman: false, age: 'any', author: 'any', attention: false, sort: 'furthest', dir: 'desc', size: STAGE_TRACKER_DEFAULT_PAGE_SIZE, page: 1 }; + return { kind: 'all', repo: '', q: '', labels: [], needsHuman: false, onHold: false, age: 'any', author: 'any', attention: false, sort: 'furthest', dir: 'desc', size: STAGE_TRACKER_DEFAULT_PAGE_SIZE, page: 1 }; } var _stageTrackerFilter = stageTrackerDefaultFilter(); // Type-to-filter text of the "all labels" dialog (not persisted). @@ -15169,22 +15182,22 @@

Where to get help

} // label facet helpers begin - // The "a person must act" label set comes from the payload - // (needs_human_labels, one Go definition shared with the Projects - // preset). A label matches an entry exactly or as `entry/...`. - function stageTrackerNeedsHumanLabels(d) { - return (d && Array.isArray(d.needs_human_labels) ? d.needs_human_labels : []).map(l => String(l || '').trim().toLowerCase()).filter(Boolean); - } - // Patterns catch new stages/labels the explicit set does not list yet: - // needs-human*, *needs-decision, *needs-author. - function stageTrackerLabelNeedsHuman(label, set) { - const l = String(label || '').toLowerCase(); - if (l.startsWith('needs-human') || l.endsWith('needs-decision') || l.endsWith('needs-author')) return true; - return (set || []).some(s => l === s || l.startsWith(s + '/')); - } - function stageTrackerItemNeedsHuman(item, set) { - if (!set || !set.length) return false; - return (item && Array.isArray(item.labels) ? item.labels : []).some(l => stageTrackerLabelNeedsHuman(l, set)); + // "On hold": the row wears the hold pill (Go stageTrackerOnHold). + function stageTrackerItemOnHold(item) { + const mods = item && Array.isArray(item.modifiers) ? item.modifiers : []; + return mods.indexOf('hold') >= 0; + } + // "Needs human" — mirrors Go stageTrackerNeedsHuman (see the constants + // above); the chip's count and the filter both call this, so they + // cannot disagree. Stage/modifier based: labels alone (needs-signal, + // hold, …) never qualify a row. A held row is paused, not waiting. + function stageTrackerItemNeedsHuman(item) { + if (!item || stageTrackerItemOnHold(item)) return false; + const mods = Array.isArray(item.modifiers) ? item.modifiers : []; + if (mods.some(m => STAGE_TRACKER_NEEDS_HUMAN_MODS.indexOf(m) >= 0)) return true; + const n = Number(item.stage) || 0; + if (STAGE_TRACKER_NEEDS_HUMAN_STAGES.indexOf(n) >= 0) return true; + return STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES.indexOf(n) >= 0 && (item.author_kind || '') === 'human'; } // Chip order: every stage/NNN-* label first by NNN, then everything @@ -15208,6 +15221,7 @@

Where to get help

f.q = typeof f.q === 'string' ? f.q : ''; f.labels = Array.isArray(f.labels) ? f.labels.filter(l => typeof l === 'string' && l).map(l => l.toLowerCase()) : []; f.needsHuman = !!f.needsHuman; + f.onHold = !!f.onHold; if (!(f.age in STAGE_TRACKER_AGE_MS) && f.age !== 'stale') f.age = 'any'; if (['human', 'clanker', 'hive'].indexOf(f.author) < 0) f.author = 'any'; f.attention = !!f.attention; @@ -15220,7 +15234,7 @@

Where to get help

// True when any narrowing filter (not sort / paging) is set. function stageTrackerFilterActive(f) { - return f.kind !== 'all' || !!f.repo || !!f.q || f.labels.length > 0 || f.needsHuman || f.age !== 'any' || f.author !== 'any' || f.attention; + return f.kind !== 'all' || !!f.repo || !!f.q || f.labels.length > 0 || f.needsHuman || f.onHold || f.age !== 'any' || f.author !== 'any' || f.attention; } // Does one item pass the narrowing filters? ctx.nowMs anchors the age @@ -15244,7 +15258,8 @@

Where to get help

f.labels.forEach(l => { const fam = stageTrackerLabelFamily(l) || l; (byFamily[fam] = byFamily[fam] || []).push(l); }); for (const fam in byFamily) if (!byFamily[fam].some(l => have.has(l))) return false; } - if (f.needsHuman && !stageTrackerItemNeedsHuman(item, ctx.needsHumanLabels)) return false; + if (f.needsHuman && !stageTrackerItemNeedsHuman(item)) return false; + if (f.onHold && !stageTrackerItemOnHold(item)) return false; if (f.author !== 'any' && (item.author_kind || '') !== f.author) return false; if (f.attention && !stageTrackerNeedsAttention(item)) return false; if (f.age !== 'any') { @@ -15317,11 +15332,11 @@

Where to get help

// the rest alphabetically (stageTrackerLabelCompare). The row shows the // first STAGE_TRACKER_LABEL_CHIP_LIMIT plus every selected label; `all` // is the complete list the "+N more" dialog offers, so no label is ever - // out of reach. `needsHuman` is the synthetic facet: its count is the - // number of distinct items carrying any label of the needs-human set. + // out of reach. `needsHuman` and `onHold` are the synthetic facets: + // their counts are the items stageTrackerItemNeedsHuman / + // stageTrackerItemOnHold accept — the same predicates the filter uses. function stageTrackerLabelFacets(items, f, opts) { f = stageTrackerNormalizeFilter(f); - opts = opts || {}; const counts = {}; (items || []).forEach(it => (Array.isArray(it.labels) ? it.labels : []).forEach(l => { const k = String(l).toLowerCase(); counts[k] = (counts[k] || 0) + 1; })); const all = Object.keys(counts).sort(stageTrackerLabelCompare); @@ -15329,9 +15344,9 @@

Where to get help

f.labels.forEach(l => { if (counts[l] && shown.indexOf(l) < 0) shown.push(l); }); shown.sort(stageTrackerLabelCompare); const chip = l => ({ label: l, count: counts[l], on: f.labels.indexOf(l) >= 0 }); - const set = Array.isArray(opts.needsHumanLabels) ? opts.needsHumanLabels : []; - const needsHuman = set.length ? { count: (items || []).filter(it => stageTrackerItemNeedsHuman(it, set)).length, on: f.needsHuman, labels: set.slice(), covered: all.filter(l => stageTrackerLabelNeedsHuman(l, set)).map(chip) } : null; - return { chips: shown.map(chip), all: all.map(chip), hidden: Math.max(0, all.length - shown.length), needsHuman }; + const needsHuman = { count: (items || []).filter(stageTrackerItemNeedsHuman).length, on: f.needsHuman }; + const onHold = { count: (items || []).filter(stageTrackerItemOnHold).length, on: f.onHold }; + return { chips: shown.map(chip), all: all.map(chip), hidden: Math.max(0, all.length - shown.length), needsHuman, onHold }; } // Rows of the "all labels" dialog: `facets.all` narrowed by a @@ -15341,8 +15356,8 @@

Where to get help

const q = String(query || '').trim().toLowerCase(); const all = facets && Array.isArray(facets.all) ? facets.all : []; const rows = q ? all.filter(c => c.on || c.label.indexOf(q) >= 0) : all; - const selected = all.filter(c => c.on).length + (facets && facets.needsHuman && facets.needsHuman.on ? 1 : 0); - return { rows, total: all.length, selected, query: q, needsHuman: facets ? facets.needsHuman : null }; + const selected = all.filter(c => c.on).length + (facets && facets.needsHuman && facets.needsHuman.on ? 1 : 0) + (facets && facets.onHold && facets.onHold.on ? 1 : 0); + return { rows, total: all.length, selected, query: q, needsHuman: facets ? facets.needsHuman : null, onHold: facets ? facets.onHold : null }; } // label facet model end @@ -15467,7 +15482,8 @@

Where to get help

case 'size': f.size = Number(value) || STAGE_TRACKER_DEFAULT_PAGE_SIZE; break; case 'label': { const l = String(value || '').toLowerCase(); const i = f.labels.indexOf(l); if (i >= 0) f.labels.splice(i, 1); else if (l) f.labels.push(l); break; } case 'needsHuman': f.needsHuman = value === 'toggle' ? !f.needsHuman : !!value; break; - case 'labelsClear': f.labels = []; f.needsHuman = false; break; + case 'onHold': f.onHold = value === 'toggle' ? !f.onHold : !!value; break; + case 'labelsClear': f.labels = []; f.needsHuman = false; f.onHold = false; break; case 'page': f.page = value === 'prev' ? f.page - 1 : value === 'next' ? f.page + 1 : Number(value) || 1; break; case 'reset': { const keep = { sort: f.sort, dir: f.dir, size: f.size }; _stageTrackerFilter = Object.assign(stageTrackerDefaultFilter(), keep); break; } } @@ -15501,12 +15517,18 @@

Where to get help

} function stageTrackerNeedsHumanChipHtml(nh) { if (!nh) return ''; - const tip = (nh.on ? 'Remove the Needs human filter' : 'Show only items a person must act on') + ' — any of: ' + nh.labels.join(', '); + const tip = (nh.on ? 'Remove the Needs human filter. ' : '') + STAGE_TRACKER_NEEDS_HUMAN_TIP; return ``; } + function stageTrackerOnHoldChipHtml(oh) { + if (!oh) return ''; + const tip = (oh.on ? 'Remove the On hold filter. ' : '') + STAGE_TRACKER_ON_HOLD_TIP; + return ``; + } function stageTrackerLabelsHtml(facets) { - if (!facets.chips.length && !facets.needsHuman) return ''; + if (!facets.chips.length && !facets.needsHuman && !facets.onHold) return ''; return stageTrackerNeedsHumanChipHtml(facets.needsHuman) + + stageTrackerOnHoldChipHtml(facets.onHold) + facets.chips.map(stageTrackerLabelChipHtml).join('') + (facets.hidden ? `` : ''); } @@ -15516,15 +15538,9 @@

Where to get help

// In-app modal (config-overlay recipe), never a native prompt. function stageTrackerLabelDialogHtml(data) { return `
${esc(stageTrackerLabelDialogCountText(data))}
` - + (data.needsHuman ? `
${stageTrackerNeedsHumanChipHtml(data.needsHuman)}
` + stageTrackerNeedsHumanGroupHtml(data.needsHuman) : '') + + (data.needsHuman || data.onHold ? `
${stageTrackerNeedsHumanChipHtml(data.needsHuman)}${stageTrackerOnHoldChipHtml(data.onHold)}
` : '') + `
${stageTrackerLabelDialogListHtml(data)}
`; } - // Group header listing the labels the Needs human facet covers. - function stageTrackerNeedsHumanGroupHtml(nh) { - const covered = nh && Array.isArray(nh.covered) ? nh.covered : []; - if (!covered.length) return ''; - return `
Needs human covers ${covered.length} ${covered.length === 1 ? 'label' : 'labels'}
${covered.map(stageTrackerLabelChipHtml).join('')}
`; - } function stageTrackerLabelDialogListHtml(data) { return data.rows.length ? data.rows.map(stageTrackerLabelChipHtml).join('') : `
No label matches “${esc(data.query)}”
`; } @@ -15537,7 +15553,7 @@

Where to get help

function stageTrackerRenderLabelDialog() { const body = document.getElementById('activity-monitor-labels-body'); if (!body || !_stageTracker || !Array.isArray(_stageTracker.items)) return; - const facets = stageTrackerLabelFacets(_stageTracker.items, _stageTrackerFilter, { needsHumanLabels: stageTrackerNeedsHumanLabels(_stageTracker) }); + const facets = stageTrackerLabelFacets(_stageTracker.items, _stageTrackerFilter); const data = stageTrackerLabelDialogData(facets, _stageTrackerLabelQuery); const q = document.getElementById('activity-monitor-labels-q'); if (!q || document.activeElement !== q) { setIfChanged(body, stageTrackerLabelDialogHtml(data)); return; } @@ -15548,7 +15564,7 @@

Where to get help

const clear = body.querySelector('.ham-label-dialog-tools .hv-btn'); if (clear) clear.disabled = !data.selected; const nh = body.querySelector('.ham-label-dialog-needs-human'); - if (nh) setIfChanged(nh, stageTrackerNeedsHumanChipHtml(data.needsHuman)); + if (nh) setIfChanged(nh, stageTrackerNeedsHumanChipHtml(data.needsHuman) + stageTrackerOnHoldChipHtml(data.onHold)); } var _stageTrackerLabelDialogReturnFocus = null; function openStageTrackerLabelDialog() { @@ -15657,7 +15673,6 @@

All labels

} stageTrackerSyncToolbar(f); const ctx = { nowMs, stages, moves: _stageTrackerMoves }; - ctx.needsHumanLabels = stageTrackerNeedsHumanLabels(d); ctx.sharedPRs = stageTrackerSharedPRs(d.items); // Repo chips ride the setting against how many repos the payload spans. if (stageTrackerRepoChipOn(stageTrackerRepoChipSetting(), repos.length)) ctx.repoChips = { primary: stageTrackerPrimaryRepo(), active: f.repo }; @@ -15688,7 +15703,7 @@

All labels

const badge = document.getElementById('activity-monitor-sidebar-badge'); if (badge) { badge.textContent = String(counts.badge); badge.title = counts.badgeTitle; if (counts.badge) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); } const labelsEl = document.getElementById('activity-monitor-labels'); - if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f, { needsHumanLabels: ctx.needsHumanLabels }))); + if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f))); stageTrackerRenderLabelDialog(); const meta = document.getElementById('activity-monitor-meta'); if (meta) setIfChanged(meta, `${esc(counts.showing)}${stageTrackerEngineHtml(d)}${stageTrackerUpdatedHtml(d, nowMs, _stageTrackerPollError, _stageTrackerPollErrorSince)}${stageTrackerPagerHtml(page)}`); diff --git a/src/pkg/github/issue_inprogress.go b/src/pkg/github/issue_inprogress.go index f94b0991f8..97a754af77 100644 --- a/src/pkg/github/issue_inprogress.go +++ b/src/pkg/github/issue_inprogress.go @@ -183,6 +183,15 @@ func (c *Client) clearInProgressForPR(ctx context.Context, repo string, prNumber c.coverIssuesByPR(ctx, repo, prNumber, issues) } +// addressInProgressForPR is clearInProgressForPR for the declared issues +// the PR's body references without closing (prCoveredIssues' partial set). +func (c *Client) addressInProgressForPR(ctx context.Context, repo string, prNumber int, issues []int) { + if !c.inProgressSetting().Enabled || len(issues) == 0 { + return + } + c.addressIssuesByPR(ctx, repo, prNumber, issues) +} + // prCoveredIssues is every same-repo issue a freshly opened PR covers: the // issues the request declared (hive-open-pr --issue) plus the ones its body // closes with a GitHub closing keyword. The request names the issue the @@ -192,31 +201,61 @@ func (c *Client) clearInProgressForPR(ctx context.Context, repo string, prNumber // with the scanner as their actor while the PR was in CI // (hivecommons/hive#14910, #14911 under #14921). Ascending, deduplicated, // non-positive numbers dropped. -func (c *Client) prCoveredIssues(repo, body string, declared []int) []int { +// +// partial is the declared issues the body references WITHOUT closing +// ("Refs #N (needs-human: …)"): the agent chose not to claim it finishes +// the issue — the same rule claimsFromPR applies to a branch-name claim +// (hivecommons/hive#12144) — so those get an AddressedBy fact (040, reason +// "addresses part of it"), never a "covers it". hivecommons/hive#14976 was +// staged "open PR covers it" under its own partial fix #14990 this way +// (hivecommons/hive#15008). A bare mention ("see #N", a hive deferral +// comment) is neither: it is not in the body's claims at all. +func (c *Client) prCoveredIssues(repo, body string, declared []int) (covered, partial []int) { owner, name := c.splitRepo(repo) seen := map[int]bool{} - var out []int - add := func(n int) { + add := func(dst *[]int, n int) { if n <= 0 || seen[n] { return } seen[n] = true - out = append(out, n) + *dst = append(*dst, n) + } + closing := closingIssueRefs(body, owner, name) + referenced := map[int]bool{} + for _, ref := range ParseReferencedIssues(body, repo) { + if ref.Repo == repo || strings.EqualFold(ref.Repo, repo) { + referenced[ref.Issue] = true + } } for _, n := range declared { - add(n) + if referenced[n] && !closing[n] { + add(&partial, n) + continue + } + add(&covered, n) } - for n := range closingIssueRefs(body, owner, name) { - add(n) + for n := range closing { + add(&covered, n) } - sort.Ints(out) - return out + sort.Ints(covered) + sort.Ints(partial) + return covered, partial } // coverIssuesByPR submits one CoveredBy fact per issue naming the open PR, // after making sure the repo defines the covered-by-pr label. Best-effort: // a failure is logged and the stage sweep converges the labels later. func (c *Client) coverIssuesByPR(ctx context.Context, repo string, prNumber int, issues []int) { + c.stageIssuesUnderPR(ctx, repo, prNumber, issues, false) +} + +// addressIssuesByPR is coverIssuesByPR for the issues the PR references +// without closing (AddressedBy: 040, reason "addresses part of it"). +func (c *Client) addressIssuesByPR(ctx context.Context, repo string, prNumber int, issues []int) { + c.stageIssuesUnderPR(ctx, repo, prNumber, issues, true) +} + +func (c *Client) stageIssuesUnderPR(ctx context.Context, repo string, prNumber int, issues []int, partial bool) { if len(issues) == 0 { return } @@ -231,8 +270,14 @@ func (c *Client) coverIssuesByPR(ctx context.Context, repo string, prNumber int, } continue } - if err := c.StageFacts().CoveredBy(ctx, c.IssueStageRef(repo, n), pr); err != nil && c.logger != nil { - c.logger.Warn("in-progress: moving issue to covered-by-pr after PR open failed", "repo", repo, "issue", n, "error", err) + var err error + if partial { + err = c.StageFacts().AddressedBy(ctx, c.IssueStageRef(repo, n), pr) + } else { + err = c.StageFacts().CoveredBy(ctx, c.IssueStageRef(repo, n), pr) + } + if err != nil && c.logger != nil { + c.logger.Warn("in-progress: moving issue to covered-by-pr after PR open failed", "repo", repo, "issue", n, "partial", partial, "error", err) } } } diff --git a/src/pkg/github/issue_stage_facts.go b/src/pkg/github/issue_stage_facts.go index 564a87d0a2..f15fde4613 100644 --- a/src/pkg/github/issue_stage_facts.go +++ b/src/pkg/github/issue_stage_facts.go @@ -43,6 +43,8 @@ func issueFactsFrom(in IssueStageInput, prStage func(repo string, number int) st c := &stageengine.ClaimFact{Holder: in.ClaimedBy, Kind: claims.Kind(in.ClaimKind), PRStarted: in.PRStarted} if in.Claim != nil { c.PRRepo, c.PRNumber = in.Claim.PRRepo, in.Claim.PRNumber + // A non-closing "Refs #N" claim stages 040 but never "covers". + c.Partial = in.Claim.Reference && !in.Claim.Closing } f.Issue.Claim = c } diff --git a/src/pkg/github/issue_stage_labels_test.go b/src/pkg/github/issue_stage_labels_test.go index 41c0a0d33a..e0d163ec5a 100644 --- a/src/pkg/github/issue_stage_labels_test.go +++ b/src/pkg/github/issue_stage_labels_test.go @@ -18,6 +18,7 @@ import ( "github.com/hivecommons/hive/pkg/authorkind" "github.com/hivecommons/hive/pkg/claims" + "github.com/hivecommons/hive/pkg/stageengine" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -324,6 +325,9 @@ func TestIssueStageFor(t *testing.T) { // as the issue's label — 050+ are PR-only stages. {"covered, PR staged: stays 040", IssueStageInput{Repo: "acme/widgets", Bucket: workBucketClaimedByPR, Claim: &IssueClaimContext{PRNumber: 99}}, stagelabels.CoveredByPR, true}, {"covered, cross-repo PR staged: stays 040", IssueStageInput{Repo: "acme/other", Bucket: workBucketClaimedByPR, Claim: &IssueClaimContext{PRNumber: 99, PRRepo: "acme/widgets"}}, stagelabels.CoveredByPR, true}, + // hivecommons/hive#15008: a live "Refs #N" claim (#13747) is 040 as + // "addresses part of it", never "covers it". + {"partial: Refs claim is 040 but not a cover", IssueStageInput{Bucket: workBucketClaimedByPR, Claim: &IssueClaimContext{PRNumber: 5, Reference: true, Decision: ClaimDecisionCoveredByOpenPR}}, stagelabels.CoveredByPR, false}, {"likely-done is no stage", IssueStageInput{Labels: []string{LikelyDoneLabel}}, stagelabels.None, false}, {"filtered out", IssueStageInput{Bucket: "filtered"}, stagelabels.None, false}, // Owner decision: an issue parked on a person wears 045, never 085 @@ -357,6 +361,9 @@ func TestIssueStageFor(t *testing.T) { if strings.HasPrefix(tc.name, "held:") && !strings.HasPrefix(reason, "held: ") { t.Fatalf("reason %q must name the hold label", reason) } + if partial := strings.HasPrefix(tc.name, "partial:"); partial != stageengine.ReasonIsPartialCover(reason) || (!partial && strings.HasPrefix(tc.name, "covered") && reason != "open PR covers it" && !strings.Contains(reason, " covers it (PR at ")) { + t.Fatalf("reason %q: partial-cover wording must follow the claim's Reference flag", reason) + } if got != tc.want || covered != tc.covered { t.Fatalf("IssueStageFor = %s/%v, want %s/%v", got, covered, tc.want, tc.covered) } diff --git a/src/pkg/github/pr_covered_issues_test.go b/src/pkg/github/pr_covered_issues_test.go index 0999043986..d6ad5bce28 100644 --- a/src/pkg/github/pr_covered_issues_test.go +++ b/src/pkg/github/pr_covered_issues_test.go @@ -24,15 +24,87 @@ import ( func TestPRCoveredIssues_UnionOfDeclaredAndBodyCloses(t *testing.T) { c := testClient(t, "http://127.0.0.1:0") body := "Builds on #14912.\n\nCloses #14906\nCloses #14910\nCloses #14911\nRefs #14909\nFixes other/repo#5" - got := c.prCoveredIssues("o/r", body, []int{14906, 0, 14906}) - if want := []int{14906, 14910, 14911}; !reflect.DeepEqual(got, want) { - t.Fatalf("prCoveredIssues = %v, want %v", got, want) + got, partial := c.prCoveredIssues("o/r", body, []int{14906, 0, 14906}) + if want := []int{14906, 14910, 14911}; !reflect.DeepEqual(got, want) || partial != nil { + t.Fatalf("prCoveredIssues = %v (partial %v), want %v", got, partial, want) } - if got := c.prCoveredIssues("o/r", "no closing keyword here, see #3", nil); got != nil { - t.Fatalf("prCoveredIssues with no closes = %v, want nil", got) + if got, partial := c.prCoveredIssues("o/r", "no closing keyword here, see #3", nil); got != nil || partial != nil { + t.Fatalf("prCoveredIssues with no closes = %v / %v, want nil", got, partial) } - if got := c.prCoveredIssues("o/r", "", []int{7}); !reflect.DeepEqual(got, []int{7}) { - t.Fatalf("declared-only = %v, want [7]", got) + if got, partial := c.prCoveredIssues("o/r", "", []int{7}); !reflect.DeepEqual(got, []int{7}) || partial != nil { + t.Fatalf("declared-only = %v / %v, want [7]", got, partial) + } +} + +// hivecommons/hive#15008: the scanner's partial fix #14990 for the shared-CI +// incident #14976 declared the issue but its body read "Refs #14976 +// (needs-human: …)" — the agent deliberately not claiming to finish it. The +// relay still staged the incident "open PR covers it". A declared issue the +// body references without a closing keyword is partial, never covered; a +// closing keyword on the same issue wins; a bare mention is nothing. +func TestPRCoveredIssues_DeclaredRefsIsPartialNotCovered(t *testing.T) { + c := testClient(t, "http://127.0.0.1:0") + body := "Retry go mod download in the Docker builder stages.\n\nRefs #14976 (needs-human: the workflow steps need the same retry; the App token cannot edit workflows)" + covered, partial := c.prCoveredIssues("o/r", body, []int{14976}) + if covered != nil || !reflect.DeepEqual(partial, []int{14976}) { + t.Fatalf("declared + Refs: covered %v partial %v, want nil / [14976]", covered, partial) + } + covered, partial = c.prCoveredIssues("o/r", "Refs #14976\nFixes #14976", []int{14976}) + if !reflect.DeepEqual(covered, []int{14976}) || partial != nil { + t.Fatalf("Refs + Fixes: covered %v partial %v, want [14976] / nil", covered, partial) + } + // The hive's own deferral comment text names the incident, but it is + // neither a closing nor a reference keyword: no claim of any tier. + deferral := "\nDeferred to shared-CI incident #14976 (Go module proxy stream resets); the failing checks are not this PR's fault." + if got := ParseClaimedIssues(deferral, "o/r"); got != nil { + t.Fatalf("deferral comment parsed as closing claims: %v", got) + } + if got := ParseReferencedIssues(deferral, "o/r"); got != nil { + t.Fatalf("deferral comment parsed as reference claims: %v", got) + } + covered, partial = c.prCoveredIssues("o/r", deferral, nil) + if covered != nil || partial != nil { + t.Fatalf("deferral text covers %v / %v, want nothing", covered, partial) + } +} + +// Through the relay: the declared-but-only-referenced issue is an +// AddressedBy fact (040, "addresses part of it"), not CoveredBy. +func TestPRRequestWatcher_DeclaredRefsIssueIsAddressedNotCovered(t *testing.T) { + created := 0 + srv := newPRMockServer(t, "", &created) + defer srv.Close() + c := testClient(t, srv.URL) + enableInProgress(c, "hive-a", time.Hour) + sink := &stageenginetest.Recorder{} + c.SetStageFactSink(sink) + c.coveredByPRLabel.mark("o/r") + + dir := t.TempDir() + old := prRequestDirForTest + prRequestDirForTest = dir + defer func() { prRequestDirForTest = old }() + + body := "Retry go mod download.\n\nRefs #14976 (needs-human: workflow files need the same retry)" + if _, err := WritePRRequest(dir, PRRequest{Repo: "o/r", Head: "scanner/fix-14976", Title: "🐛 fix(ci): retry", Body: body, Agent: "scanner", IssueN: []int{14976}}); err != nil { + t.Fatal(err) + } + c.ProcessPRRequestsOnce(context.Background()) + if created != 1 { + t.Fatalf("expected 1 PR created, got %d", created) + } + var methods []string + for _, f := range sink.All() { + if f.Method != "CoveredBy" && f.Method != "AddressedBy" { + continue + } + if f.Ref.Number != 14976 || f.PR == nil || f.PR.Number != 42 { + t.Errorf("fact = %+v, want (issue #14976, PR #42)", f) + } + methods = append(methods, f.Method) + } + if !reflect.DeepEqual(methods, []string{"AddressedBy"}) { + t.Fatalf("facts = %v, want exactly one AddressedBy (no CoveredBy for a Refs-only declared issue)", methods) } } diff --git a/src/pkg/github/pr_request_watcher.go b/src/pkg/github/pr_request_watcher.go index 8483fa3069..c88e2e680e 100644 --- a/src/pkg/github/pr_request_watcher.go +++ b/src/pkg/github/pr_request_watcher.go @@ -677,7 +677,9 @@ func (c *Client) handleOnePRRequest(ctx context.Context, path string, nowFn func // body closes: they move to stage/040-covered-by-pr, where the stage // reconciler keeps them while the PR is open (the PR's own stage is // narrated in the issue's stage reason, never written as its label). - c.clearInProgressForPR(ctx, req.Repo, res.Number, c.prCoveredIssues(req.Repo, body, req.IssueN)) + covered, partial := c.prCoveredIssues(req.Repo, body, req.IssueN) + c.clearInProgressForPR(ctx, req.Repo, res.Number, covered) + c.addressInProgressForPR(ctx, req.Repo, res.Number, partial) c.recordWriteAudit(AuditActionAgentPRCreated, meta, WriteTarget{Repo: req.Repo, Number: res.Number}, "author", res.Author, diff --git a/src/pkg/github/stage_facts_sink.go b/src/pkg/github/stage_facts_sink.go index c21ac9e3f2..defba7a28e 100644 --- a/src/pkg/github/stage_facts_sink.go +++ b/src/pkg/github/stage_facts_sink.go @@ -191,8 +191,15 @@ func (c *Client) enrichCoveringPR(ctx context.Context, store *stagelabels.Store, return f, nil } pr, ok := c.rememberedCoveringPR(store, f.Ref) - if !ok { - pr, ok = c.ledgerCoveringPR(f.Ref) + partial := false + if ok { + // The store remembers the PR, not whether it closes the issue; the + // ledger does (a "Refs #N" claim is Reference, hivecommons/hive#15008). + if claim, found := c.ledgerClaim(f.Ref); found && claim.PRNumber == pr.Number { + partial = claim.Reference && !claim.Closing + } + } else { + pr, partial, ok = c.ledgerCoveringPR(f.Ref) } if !ok || (f.Issue.ClosedPR != nil && f.Issue.ClosedPR.Key() == pr.Key()) { return f, nil @@ -213,6 +220,7 @@ func (c *Client) enrichCoveringPR(ctx context.Context, store *stagelabels.Store, f.Issue.Claim = &stageengine.ClaimFact{} } f.Issue.Claim.PRRepo, f.Issue.Claim.PRNumber = pr.FullRepo(), pr.Number + f.Issue.Claim.Partial = partial return f, nil } @@ -238,18 +246,26 @@ func (c *Client) rememberedCoveringPR(store *stagelabels.Store, issue stageengin // suppress the issue for counts (IssueClaim.CoversOpenIssue); the ledger is // keyed by the configured repo spelling, so both the bare and the // owner-qualified name are tried. -func (c *Client) ledgerCoveringPR(issue stageengine.Ref) (stageengine.Ref, bool) { +func (c *Client) ledgerCoveringPR(issue stageengine.Ref) (pr stageengine.Ref, partial bool, ok bool) { + claim, found := c.ledgerClaim(issue) + if !found || !claim.CoversOpenIssue() { + return stageengine.Ref{}, false, false + } + pr, ok = c.claimPRRef(claim, issue) + return pr, claim.Reference && !claim.Closing, ok +} + +// ledgerClaim is the duplicate-PR claim ledger's live claim on issue, tried +// under both the bare and the owner-qualified repo spelling. +func (c *Client) ledgerClaim(issue stageengine.Ref) (IssueClaim, bool) { if c == nil || c.prClaimLookup == nil || !issue.IsDefaultSource() { - return stageengine.Ref{}, false + return IssueClaim{}, false } claim, ok := c.prClaimLookup(issue.Repo, issue.Number) if !ok && issue.Owner != "" { claim, ok = c.prClaimLookup(issue.Owner+"/"+issue.Repo, issue.Number) } - if !ok || !claim.CoversOpenIssue() { - return stageengine.Ref{}, false - } - return c.claimPRRef(claim, issue) + return claim, ok } // SetPRClaimLookup installs the duplicate-PR claim ledger read the fact sink diff --git a/src/pkg/github/stage_ledger_backfill.go b/src/pkg/github/stage_ledger_backfill.go index 8213e4b82b..1707b1107b 100644 --- a/src/pkg/github/stage_ledger_backfill.go +++ b/src/pkg/github/stage_ledger_backfill.go @@ -88,7 +88,14 @@ func (c *Client) BackfillCoveredByLedger(ctx context.Context, ledger *ClaimLedge c.warnLedgerBackfill("ensuring covered-by-pr label failed", issue, pr, err) continue } - if err := c.StageFacts().CoveredBy(ctx, issue, pr); err != nil { + // A non-closing "Refs #N" claim stages 040 as "addresses part of + // it", never "covers it" (hivecommons/hive#15008). + if claim.Reference && !claim.Closing { + err = c.StageFacts().AddressedBy(ctx, issue, pr) + } else { + err = c.StageFacts().CoveredBy(ctx, issue, pr) + } + if err != nil { res.Errors++ c.warnLedgerBackfill("moving issue to covered-by-pr failed", issue, pr, err) continue diff --git a/src/pkg/github/stage_ledger_backfill_test.go b/src/pkg/github/stage_ledger_backfill_test.go index 1bed80e6a2..70d182408a 100644 --- a/src/pkg/github/stage_ledger_backfill_test.go +++ b/src/pkg/github/stage_ledger_backfill_test.go @@ -76,6 +76,12 @@ func TestStageFacts_ClaimReleaseUnderExternalLedgerClaimDerives040(t *testing.T) if labels, _, _ := srv.snapshot(); stagelabels.Current(labels) != stagelabels.CoveredByPR { t.Fatalf("labels = %v, want 040", labels) } + // A "Refs #N" claim is 040 as "addresses part of it", never "covers it" + // (hivecommons/hive#15008). + rec, _ := stagelabels.Shared().Get(issue.Key()) + if !stageengine.ReasonIsPartialCover(rec.Reason) { + t.Fatalf("record reason = %q, want the partial-cover reason for a non-closing reference claim", rec.Reason) + } } // Ledger claims the guard does not suppress for are no cover: a hive diff --git a/src/pkg/stageengine/derive_issue.go b/src/pkg/stageengine/derive_issue.go index 5f9b9075fb..84bc57ec23 100644 --- a/src/pkg/stageengine/derive_issue.go +++ b/src/pkg/stageengine/derive_issue.go @@ -23,8 +23,18 @@ const ( reasonIssueLikelyDone = "merged PR awaiting confirmation" reasonIssueActionable = "actionable" reasonIssueOpenPR = "open PR covers it" + // reasonIssueOpenPRPartial is 040 under a PR that references the issue + // without closing it (ClaimFact.Partial); ReasonIsPartialCover reads it. + reasonIssueOpenPRPartial = "open PR addresses part of it (references it without a closing keyword)" ) +// ReasonIsPartialCover reports whether a 040 reason describes a PR that +// references the issue without closing it, so presentation layers can say +// "addresses part of" rather than "covers". +func ReasonIsPartialCover(reason string) bool { + return strings.HasPrefix(strings.TrimSpace(reason), "open PR addresses part of it") +} + // deriveIssue maps issue Facts to a Decision. Pure: same Facts → same // Decision. An issue never goes past 040-covered-by-pr: 050+ are PR stages // (stagelabels.Table, PR: true) and mirroring them onto the issue is what @@ -141,11 +151,18 @@ func issueStage(f Facts) (stage stagelabels.Stage, covered bool, reason string) } return stagelabels.Claimed, false, "in-progress start mark (no PR yet)" case BucketCoveredByPR: + partial := claim != nil && claim.Partial if pr := is.CoveringPR; pr != nil && pr.Number > 0 { if s := is.CoveringPRStage; s != stagelabels.None && !s.Before(stagelabels.CoveredByPR) { + if partial { + return stagelabels.CoveredByPR, true, "open PR #" + strconv.Itoa(pr.Number) + " addresses part of it (references it without a closing keyword; PR at " + s.String() + ")" + } return stagelabels.CoveredByPR, true, "open PR #" + strconv.Itoa(pr.Number) + " covers it (PR at " + s.String() + ")" } } + if partial { + return stagelabels.CoveredByPR, false, reasonIssueOpenPRPartial + } return stagelabels.CoveredByPR, false, reasonIssueOpenPR } return stagelabels.None, false, "outside the pipeline: " + string(is.Bucket) diff --git a/src/pkg/stageengine/derive_issue_test.go b/src/pkg/stageengine/derive_issue_test.go index 6c4d28303f..c5a41724a4 100644 --- a/src/pkg/stageengine/derive_issue_test.go +++ b/src/pkg/stageengine/derive_issue_test.go @@ -59,6 +59,18 @@ func TestDeriveIssueTable(t *testing.T) { f.Issue.CoveringPR = pr99 f.Issue.CoveringPRStage = stagelabels.MergeQueue }, stagelabels.CoveredByPR, true, "open PR #99 covers it (PR at 100-merge-queue)"}, + // hivecommons/hive#15008: a "Refs #N" PR stages 040 but never "covers". + {"partial (Refs), PR not staged", func(f *Facts) { + f.Issue.Bucket = BucketCoveredByPR + f.Issue.CoveringPR = pr99 + f.Issue.Claim = &ClaimFact{PRNumber: 99, Partial: true} + }, stagelabels.CoveredByPR, false, "open PR addresses part of it (references it without a closing keyword)"}, + {"partial (Refs), PR staged", func(f *Facts) { + f.Issue.Bucket = BucketCoveredByPR + f.Issue.CoveringPR = pr99 + f.Issue.CoveringPRStage = stagelabels.MergeQueue + f.Issue.Claim = &ClaimFact{PRNumber: 99, Partial: true} + }, stagelabels.CoveredByPR, true, "open PR #99 addresses part of it (references it without a closing keyword; PR at 100-merge-queue)"}, {"likely done", func(f *Facts) { f.Issue.LikelyDone = true }, stagelabels.None, false, "merged PR awaiting confirmation"}, {"filtered", func(f *Facts) { f.Issue.Bucket = BucketFiltered; f.Issue.FilteredReason = "Exempt label" }, stagelabels.None, false, "outside the pipeline: filtered"}, {"needs-human", func(f *Facts) { f.Issue.Bucket = BucketFiltered; f.Park.NeedsHuman = true }, stagelabels.IssueNeedsDecision, false, "held for a person: needs-human"}, diff --git a/src/pkg/stageengine/facts.go b/src/pkg/stageengine/facts.go index 061f14d715..7afa13e93a 100644 --- a/src/pkg/stageengine/facts.go +++ b/src/pkg/stageengine/facts.go @@ -176,6 +176,12 @@ type ClaimFact struct { PRStarted bool PRRepo string PRNumber int + // Partial says the covering PR references the issue without a closing + // keyword ("Refs #N", "Part of #N") — it works the issue but does not + // claim to finish it (hivecommons/hive#15008). The deriver still stages + // 040 (the hive is on it; dispatch is withheld, #13747) but the reason + // and the activity monitor say "addresses part of", never "covers". + Partial bool } // PRFacts is the pull-request-side evidence. diff --git a/src/pkg/stageengine/facts_sink.go b/src/pkg/stageengine/facts_sink.go index 53aba0de3d..d9143c74f5 100644 --- a/src/pkg/stageengine/facts_sink.go +++ b/src/pkg/stageengine/facts_sink.go @@ -18,6 +18,11 @@ type FactSink interface { ClaimReleased(ctx context.Context, ref Ref, holder string) error InProgress(ctx context.Context, ref Ref, agent string, until time.Time) error CoveredBy(ctx context.Context, issue Ref, pr Ref) error + // AddressedBy is CoveredBy for a PR that references the issue without + // a closing keyword ("Refs #N"): still 040 — the hive is working it — + // but the reason says "addresses part of", never "covers" + // (ClaimFact.Partial; hivecommons/hive#15008). + AddressedBy(ctx context.Context, issue Ref, pr Ref) error Uncovered(ctx context.Context, issue Ref, pr Ref) error Parked(ctx context.Context, ref Ref, label string) error // agent escalation (045/085/needs-human) Unparked(ctx context.Context, ref Ref, by string) error // /hive approve|decision @@ -164,6 +169,17 @@ func (s *factSink) CoveredBy(ctx context.Context, issue Ref, pr Ref) error { })) } +// AddressedBy implements FactSink: an open PR references the issue +// without closing it → 040 with the partial reason. +func (s *factSink) AddressedBy(ctx context.Context, issue Ref, pr Ref) error { + pr.Kind = stagelabels.PRItem + return s.submit(ctx, issueFacts(issue, IssueFacts{ + Bucket: BucketCoveredByPR, + CoveringPR: &pr, + Claim: &ClaimFact{PRRepo: pr.FullRepo(), PRNumber: pr.Number, Partial: true}, + })) +} + // Uncovered implements FactSink: the covering PR closed unmerged → 010. // The closed PR rides along so enrichment does not read the store's // memory of that same PR as a cover that still stands. diff --git a/src/pkg/stageengine/stageenginetest/fake.go b/src/pkg/stageengine/stageenginetest/fake.go index 8d42d2f651..819a17a0e3 100644 --- a/src/pkg/stageengine/stageenginetest/fake.go +++ b/src/pkg/stageengine/stageenginetest/fake.go @@ -207,6 +207,9 @@ func (r *Recorder) InProgress(_ context.Context, ref stageengine.Ref, agent stri func (r *Recorder) CoveredBy(_ context.Context, issue, pr stageengine.Ref) error { return r.record(Recorded{Method: "CoveredBy", Ref: issue, PR: &pr}) } +func (r *Recorder) AddressedBy(_ context.Context, issue, pr stageengine.Ref) error { + return r.record(Recorded{Method: "AddressedBy", Ref: issue, PR: &pr}) +} func (r *Recorder) Uncovered(_ context.Context, issue, pr stageengine.Ref) error { return r.record(Recorded{Method: "Uncovered", Ref: issue, PR: &pr}) } From 65262a2cb42ab817871ca448dbe05cd54b376c37 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 13:06:03 -0400 Subject: [PATCH 2/2] dashboard: port label_facets.test.js to the stage/modifier Needs human predicate Refs #15008 Signed-off-by: Andrew Anderson --- src/pkg/dashboard/label_facets.test.js | 55 +++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/pkg/dashboard/label_facets.test.js b/src/pkg/dashboard/label_facets.test.js index 8cc527d678..efb405d033 100644 --- a/src/pkg/dashboard/label_facets.test.js +++ b/src/pkg/dashboard/label_facets.test.js @@ -1,7 +1,7 @@ // Hive activity monitor label facets (hivecommons/hive): stage/NNN chips // first by number then every other label alphabetically, the "+N more" -// dialog data, and the synthetic Needs human facet over the payload's -// needs_human_labels set. Run: node --test src/pkg/dashboard/*.test.js +// dialog data, and the synthetic Needs human / On hold facets (stage and +// modifier predicates, hivecommons/hive#15008). Run: node --test src/pkg/dashboard/*.test.js const test = require('node:test'); const assert = require('node:assert'); const fs = require('node:fs'); @@ -31,11 +31,12 @@ const fnSrc = name => { const src = [ constLine('STAGE_TRACKER_PAGE_SIZES'), constLine('STAGE_TRACKER_DEFAULT_PAGE_SIZE'), constLine('STAGE_TRACKER_LABEL_CHIP_LIMIT'), constLine('STAGE_TRACKER_AGE_MS'), constLine('STAGE_TRACKER_LABEL_FAMILIES'), constLine('STAGE_TRACKER_SORTS'), + constLine('STAGE_TRACKER_NEEDS_HUMAN_STAGES'), constLine('STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES'), constLine('STAGE_TRACKER_NEEDS_HUMAN_MODS'), fnSrc('stageTrackerDefaultFilter'), fnSrc('stageTrackerNormalizeFilter'), fnSrc('stageTrackerLabelFamily'), pick('label facet helpers begin', 'label facet helpers end'), pick('label facet model begin', 'label facet model end'), ].join('\n'); -const h = new Function(src + '; return { STAGE_TRACKER_LABEL_CHIP_LIMIT, stageTrackerDefaultFilter, stageTrackerNeedsHumanLabels, stageTrackerLabelNeedsHuman, stageTrackerItemNeedsHuman, stageTrackerLabelCompare, stageTrackerLabelFacets, stageTrackerLabelDialogData };')(); +const h = new Function(src + '; return { STAGE_TRACKER_LABEL_CHIP_LIMIT, stageTrackerDefaultFilter, stageTrackerItemOnHold, stageTrackerItemNeedsHuman, stageTrackerLabelCompare, stageTrackerLabelFacets, stageTrackerLabelDialogData };')(); const F = over => Object.assign(h.stageTrackerDefaultFilter(), over); const item = (n, labels) => ({ kind: 'issue', repo: 'a/b', number: n, labels }); @@ -71,30 +72,30 @@ test('dialog data filters by case-insensitive substring and keeps selected label assert.strictEqual(h.stageTrackerLabelDialogData(fac, '').rows.length, 4); }); -test('needs-human patterns match new labels and the dialog lists covered ones', () => { - const set = h.stageTrackerNeedsHumanLabels({ needs_human_labels: ['sentinel-alert'] }); - for (const l of ['needs-human-review', 'stage/099-needs-decision', 'ci-needs-author', 'sentinel-alert']) assert.strictEqual(h.stageTrackerLabelNeedsHuman(l, set), true, l); - for (const l of ['stage/010-actionable', 'unneeds-humans']) assert.strictEqual(h.stageTrackerLabelNeedsHuman(l, set), false, l); - const fac = h.stageTrackerLabelFacets([item(1, ['needs-human-review', 'stage/010-actionable']), item(2, ['sentinel-alert'])], F(), { needsHumanLabels: set }); - assert.deepStrictEqual(fac.needsHuman.covered.map(c => c.label), ['needs-human-review', 'sentinel-alert']); +test('needs-human: stage/modifier predicate, labels alone never qualify (hivecommons/hive#15008)', () => { + const it = (n, stage, mods, extra) => Object.assign({ kind: 'issue', repo: 'a/b', number: n, stage, modifiers: mods, labels: [] }, extra || {}); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(1, 40, [], { labels: ['needs-signal'] })), false, '040 PR in progress (#14976)'); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(2, 80, ['hold'])), false, 'ready for auto merge + hold (#7563)'); + assert.strictEqual(h.stageTrackerItemOnHold(it(2, 80, ['hold'])), true); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(3, 45, ['hold'])), false, 'hold wins over a needs-decision stage'); + for (const st of [15, 45, 85, 90]) assert.strictEqual(h.stageTrackerItemNeedsHuman(it(4, st, [])), true, 'stage ' + st); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(5, 71, [], { author_kind: 'human' })), true); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(6, 71, [], { author_kind: 'clanker' })), false); + assert.strictEqual(h.stageTrackerItemNeedsHuman(it(7, 72, [], { author_kind: 'human' })), true); + for (const m of ['needs-human', 'needs-decision', 'unauthorized']) assert.strictEqual(h.stageTrackerItemNeedsHuman(it(8, 50, [m])), true, m); + for (const m of ['stalled', 'blocked-on-pr', 'regressed', 'draft']) assert.strictEqual(h.stageTrackerItemNeedsHuman(it(9, 60, [m])), false, m); + assert.strictEqual(h.stageTrackerItemNeedsHuman({ kind: 'pr', number: 10, labels: ['needs-human'] }), false, 'a label without the modifier is not enough'); + assert.strictEqual(h.stageTrackerItemNeedsHuman(null), false); }); -test('needs-human set: normalised from the payload, prefix children match, count is distinct items', () => { - const set = h.stageTrackerNeedsHumanLabels({ needs_human_labels: ['stage/045-needs-decision', 'stage/085-needs-decision', 'needs-decision', 'needs-direction', 'needs-spec', 'needs-signal', 'Needs-Human', 'hold', 'on-hold', 'hold/review', 'stage/071-needs-author', 'needs-triage', ''] }); - assert.strictEqual(set.length, 12); - assert.ok(set.includes('needs-human') && set.includes('stage/071-needs-author') && set.includes('needs-triage')); - assert.strictEqual(h.stageTrackerLabelNeedsHuman('needs-human/agent-ready', set), true); - assert.strictEqual(h.stageTrackerLabelNeedsHuman('stage/010-actionable', set), false); - assert.strictEqual(h.stageTrackerLabelNeedsHuman('holdover', set), false); - const items = [ - item(1, ['stage/045-needs-decision', 'needs-human', 'hold']), - item(2, ['needs-human/agent-ready']), - item(3, ['stage/071-needs-author']), - item(4, ['stage/010-actionable']), - ]; - const fac = h.stageTrackerLabelFacets(items, F(), { needsHumanLabels: set }); - assert.deepStrictEqual([fac.needsHuman.count, fac.needsHuman.on], [3, false], 'distinct items, not the sum of label counts (5)'); - assert.deepStrictEqual(h.stageTrackerLabelFacets(items, F({ needsHuman: true }), { needsHumanLabels: set }).needsHuman.on, true); - assert.strictEqual(h.stageTrackerLabelFacets(items, F()).needsHuman, null, 'no set, no chip'); - assert.strictEqual(h.stageTrackerItemNeedsHuman(items[3], set), false); +test('needs-human / on-hold facets: count equals what the filter predicate accepts', () => { + const it = (n, stage, mods, extra) => Object.assign({ kind: 'issue', repo: 'a/b', number: n, stage, modifiers: mods, labels: [] }, extra || {}); + const items = [it(1, 45, []), it(2, 20, ['needs-human']), it(3, 71, [], { author_kind: 'human' }), it(4, 10, []), it(5, 80, ['hold']), it(6, 45, ['hold'])]; + const fac = h.stageTrackerLabelFacets(items, F()); + assert.deepStrictEqual([fac.needsHuman.count, fac.needsHuman.on, fac.onHold.count, fac.onHold.on], [3, false, 2, false]); + assert.strictEqual(fac.needsHuman.count, items.filter(h.stageTrackerItemNeedsHuman).length); + assert.deepStrictEqual(h.stageTrackerLabelFacets(items, F({ needsHuman: true })).needsHuman.on, true); + assert.deepStrictEqual(h.stageTrackerLabelFacets(items, F({ onHold: true })).onHold.on, true); + assert.deepStrictEqual([h.stageTrackerLabelFacets([], F()).needsHuman.count, h.stageTrackerLabelFacets([], F()).onHold.count], [0, 0], 'chips always exist'); + assert.strictEqual(h.stageTrackerLabelDialogData(h.stageTrackerLabelFacets(items, F({ needsHuman: true, onHold: true })), '').selected, 2); });