diff --git a/changelog.d/fixed-issue-band-label-state.md b/changelog.d/fixed-issue-band-label-state.md new file mode 100644 index 0000000000..460d974c48 --- /dev/null +++ b/changelog.d/fixed-issue-band-label-state.md @@ -0,0 +1 @@ +- Overview issue bands agree with the labels: a held issue is Parked (chip `hold`), not Unclaimed (projectbluefin/utah#551); a parked issue whose only done label is `hive/likely-done` stays Parked instead of Confirm & close (projectbluefin/common#1328); and an issue at `stage/040-covered-by-pr` with no done label says an open PR covers it rather than "already done" (projectbluefin/utah#12, #1075). diff --git a/src/docs/dashboard.md b/src/docs/dashboard.md index 3f77f226c0..6e050289b1 100644 --- a/src/docs/dashboard.md +++ b/src/docs/dashboard.md @@ -617,13 +617,22 @@ in exactly one band, while non-winning states remain as badges on the pill: BLOCKED pill (drawn when `blocked` is a waiting label, not on held rows) shows that server text first on hover, followed by the row's other signals; the pill legend entry points there. + A held issue (any hold label, the server's `held`) is parked too, with the + chip `hold` when no parking label names a better one: the stage engine + leaves it "Open · on hold" and agents do not act on it until the hold goes + (projectbluefin/utah#551 sat in Unclaimed). 5. **Confirm & close** (`close?`) — labels such as `hive/already-done`, `hive/covered-by-pr` (or `stage/040-covered-by-pr` and any later mirrored PR stage), and `hive/likely-done`: an agent believes the work landed; verify and close. An issue also labelled `hive/verified-open` (the agent's verdict that the referenced PR did not finish the work) is not in this band because of `hive/likely-done`; it falls through to its usual band. - Other done labels still apply. + Nor is an issue that is parked and whose only done label is + `hive/likely-done`: the park is the later, stronger word + (projectbluefin/common#1328, an RFC parked on `needs-decision`). Other done + labels still apply. When the only done evidence is `stage/040-covered-by-pr` + (or a later mirrored PR stage), the ✓ signal reads `covered by an open PR + (stage/040) — check it merged before closing`, not `already done`. Precedence is confirm & close → parked → claimed → needs triage → unclaimed, so a label that parks an issue beats an assignment and done beats all other display states. diff --git a/src/pkg/dashboard/bands.go b/src/pkg/dashboard/bands.go index e0d870ab01..014d4c9cf3 100644 --- a/src/pkg/dashboard/bands.go +++ b/src/pkg/dashboard/bands.go @@ -149,8 +149,19 @@ func IssueBand(issue github.Issue, held bool, cfg config.DashboardIssueBandsConf role := issueAgentRole(issue.Labels) acknowledged := issue.HumanAcknowledged || labels["approved-direction"] linked := issueLinkedPRState(issue) - done := issueDoneLabel(labels, norm.DoneLabels) || linked.merged || issueStageCovered(issue.Labels) - waiting := hasAnyLabel(labels, norm.WaitingLabels) + stageCovered := issueStageCovered(issue.Labels) + done := issueDoneLabel(labels, norm.DoneLabels) || linked.merged || stageCovered + // A hold pauses the issue for a person (the stage engine leaves it + // "Open · on hold", hivecommons/hive#13012), so it is parked, not + // unclaimed: projectbluefin/utah#551 wore `hold` in the ready band. + waiting := hasAnyLabel(labels, norm.WaitingLabels) || held + // hive/likely-done is a heuristic (a merged PR referenced the issue); a + // park on a person is the stronger, later word. projectbluefin/common#1328, + // an RFC parked on needs-decision, sat in "Confirm & close" for a month + // on a likely-done from a PR that only referenced it. + if done && waiting && !linked.merged && !stageCovered && onlyLikelyDone(labels, norm.DoneLabels) { + done = false + } inProgress := len(issue.Assignees) > 0 || issueClaimed(issue.Labels) || linked.open selfAuthorizationHeld := true if len(selfAuthorizationHoldActive) > 0 && selfAuthorizationHoldActive[0] != nil { @@ -199,8 +210,13 @@ func IssueBand(issue github.Issue, held bool, cfg config.DashboardIssueBandsConf } if done { label := "already done" - if linked.merged { + switch { + case linked.merged: label = "merged PR references this issue" + case stageCovered && !issueDoneLabel(labels, norm.DoneLabels): + // stage/040 means an open PR covers it, not that it landed + // (projectbluefin/utah#12, #1075 read "already done"). + label = "covered by an open PR (stage/040) — check it merged before closing" } signals = append(signals, Signal{Glyph: "✓", Label: label}) } @@ -221,6 +237,9 @@ func IssueBand(issue github.Issue, held bool, cfg config.DashboardIssueBandsConf chip := "" if band == "waiting" { chip = issueLabelChip(labels) + if chip == "" && held { + chip = "hold" + } } return IssueBandInfo{Band: band, Role: role, Acknowledged: acknowledged, Held: held, HoldReason: heldReason(issue.Labels, false, ""), Stale: stale, Signals: signals, Chip: chip} } @@ -256,6 +275,21 @@ func issueDoneLabel(labels map[string]bool, doneLabels []string) bool { return false } +// onlyLikelyDone reports whether hive/likely-done is the only configured +// done label the issue wears. +func onlyLikelyDone(labels map[string]bool, doneLabels []string) bool { + if !labels[github.LikelyDoneLabel] { + return false + } + for _, label := range doneLabels { + lower := strings.ToLower(label) + if lower != github.LikelyDoneLabel && labels[lower] { + return false + } + } + return true +} + func issueLinkedPRState(github.Issue) linkedPRState { return linkedPRState{} } // prGateLabels are the labels that put a pull request in the waiting @@ -467,9 +501,9 @@ func issueBandSpec(key string, cfg config.DashboardIssueBandsConfig) BandSpec { case "agent-filed": return BandSpec{Key: key, Label: "Needs triage", Short: "triage", Rule: "filed by an agent (agent/ label) with no approved-direction label, no human assignee, and self-authorization hold is on for the repo (ACMM < 6 or github.self_authorization_hold=true) — agents do not pick it up until it is labelled, assigned to a human, or closed. A human comment also acknowledges for #5117 but is not in the snapshot, so a commented-on proposal still shows here"} case "waiting": - return BandSpec{Key: key, Label: "Parked", Short: "parked", Rule: "labelled " + strings.Join(norm.WaitingLabels, ", ") + " — parked: agents do not continue until the label is removed or the question it names is answered"} + return BandSpec{Key: key, Label: "Parked", Short: "parked", Rule: "labelled " + strings.Join(norm.WaitingLabels, ", ") + ", or held — parked: agents do not continue until the label is removed or the question it names is answered"} case "done": - return BandSpec{Key: key, Label: "Confirm & close", Short: "close?", Rule: "an agent applied " + strings.Join(norm.DoneLabels, ", ") + " — the agent reports the work as landed, and the issue is still open"} + return BandSpec{Key: key, Label: "Confirm & close", Short: "close?", Rule: "an agent applied " + strings.Join(norm.DoneLabels, ", ") + " (hive/likely-done not on a parked issue) — the agent reports the work as landed, and the issue is still open"} default: return BandSpec{Key: "ready", Label: "Unclaimed", Short: "unclaimed", Rule: "no other band matched — nobody is assigned, nothing claimed it, and no human gate applies; this does not by itself mean agents will pick it up"} } diff --git a/src/pkg/dashboard/bands_inprogress_test.go b/src/pkg/dashboard/bands_inprogress_test.go index 34ad613fb4..0f85985179 100644 --- a/src/pkg/dashboard/bands_inprogress_test.go +++ b/src/pkg/dashboard/bands_inprogress_test.go @@ -107,12 +107,12 @@ func TestIssueBandParkingStageIsNotDone(t *testing.T) { } ticked := false for _, sig := range info.Signals { - if sig.Label == "already done" { + if sig.Glyph == "✓" { ticked = true } } if ticked != tt.wantTick { - t.Fatalf("already-done signal = %v, want %v (signals=%+v)", ticked, tt.wantTick, info.Signals) + t.Fatalf("done signal = %v, want %v (signals=%+v)", ticked, tt.wantTick, info.Signals) } }) } diff --git a/src/pkg/dashboard/bands_label_state_test.go b/src/pkg/dashboard/bands_label_state_test.go new file mode 100644 index 0000000000..31f70472bd --- /dev/null +++ b/src/pkg/dashboard/bands_label_state_test.go @@ -0,0 +1,63 @@ +package dashboard + +import ( + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// Band rules that agree with the labels the issue wears. +func TestIssueBandAgreesWithLabels(t *testing.T) { + now := time.Date(2026, 11, 5, 22, 0, 0, 0, time.UTC) + tests := []struct { + name string + labels []string + held bool + band string + chip string + signal string // a signal label that must be present ("" = none checked) + }{ + // projectbluefin/utah#551: `hold` sat in ready/Unclaimed. + {name: "held is parked", labels: []string{"kind/bug", "hold", "triage/accepted", "approved-direction"}, held: true, band: "waiting", chip: "hold"}, + {name: "held and claimed is parked", labels: []string{"hold", "hive/claimed-by-scanner"}, held: true, band: "waiting", chip: "hold"}, + {name: "held keeps its park chip", labels: []string{"hold", "needs-human"}, held: true, band: "waiting", chip: "human"}, + {name: "held but done stays done", labels: []string{"hold", "hive/already-done"}, held: true, band: "done"}, + // projectbluefin/common#1328: a parked RFC wearing a month-old likely-done. + {name: "parked outranks likely-done", labels: []string{"needs-human", "needs-decision", "kind/feature", "hive/likely-done", "triage/accepted"}, band: "waiting"}, + {name: "likely-done alone is done", labels: []string{"hive/likely-done"}, band: "done"}, + {name: "parked does not outrank already-done", labels: []string{"needs-decision", "hive/already-done", "hive/likely-done"}, band: "done"}, + {name: "parked does not outrank covered-by-pr", labels: []string{"needs-decision", "hive/covered-by-pr", "hive/likely-done"}, band: "done"}, + // projectbluefin/utah#12, #1075: 040 read "already done" with an open PR. + {name: "040 says an open PR covers it", labels: []string{"triage/accepted", stagelabels.CoveredByPR.Label()}, band: "done", signal: "covered by an open PR (stage/040) — check it merged before closing"}, + {name: "040 with already-done keeps already done", labels: []string{stagelabels.CoveredByPR.Label(), "hive/already-done"}, band: "done", signal: "already done"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + info := IssueBand(github.Issue{Repo: "o/r", Number: 1, Labels: tt.labels}, tt.held, config.DashboardIssueBandsConfig{}, now) + if info.Band != tt.band { + t.Fatalf("band = %q, want %q (info=%+v)", info.Band, tt.band, info) + } + if tt.chip != "" && info.Chip != tt.chip { + t.Fatalf("chip = %q, want %q", info.Chip, tt.chip) + } + if tt.signal != "" { + found := false + for _, sig := range info.Signals { + if sig.Label == tt.signal { + found = true + } + } + if !found { + t.Fatalf("signals %+v lack %q", info.Signals, tt.signal) + } + } + }) + } + if spec := issueBandSpec("waiting", config.DashboardIssueBandsConfig{}); !strings.Contains(spec.Rule, "or held") { + t.Fatalf("waiting rule %q does not name holds", spec.Rule) + } +} diff --git a/src/pkg/dashboard/overview_export_9102_test.go b/src/pkg/dashboard/overview_export_9102_test.go index 0ce66d3299..22f4029f36 100644 --- a/src/pkg/dashboard/overview_export_9102_test.go +++ b/src/pkg/dashboard/overview_export_9102_test.go @@ -85,7 +85,10 @@ process.stdout.write(JSON.stringify({ prBands: prRows.map(r => ({ number: r.number, band: r.band, stale: r.stale, held: r.held, signals: r.signals })), issueCSV: overviewCsv(issueRows, overviewCsvColumns('issues')), prCSV: overviewCsv(prRows, overviewCsvColumns('prs')), - cells: [overviewCsvCell('-5'), overviewCsvCell('-@risk'), overviewCsvCell(['=a', 'b'])] + cells: [overviewCsvCell('-5'), overviewCsvCell('-@risk'), overviewCsvCell(['=a', 'b'])], + // A row with no precomputed info takes overviewIssueCsvRow's fallback, + // which must classify a held issue as held too. + fallbackHeldBand: overviewIssueCsvRow({ issue: { number: 20, title: 'held, no info', labels: ['hold'], assignees: [] }, held: true }).band })); `) out, err := exec.Command(node, "-e", script.String()).CombinedOutput() @@ -98,6 +101,9 @@ process.stdout.write(JSON.stringify({ IssueCSV string `json:"issueCSV"` PRCSV string `json:"prCSV"` Cells []string `json:"cells"` + // FallbackHeldBand is overviewIssueCsvRow's band for a held issue + // passed without precomputed info. + FallbackHeldBand string `json:"fallbackHeldBand"` } if err := json.Unmarshal(out, &js); err != nil { t.Fatalf("decode node output: %v", err) @@ -118,6 +124,9 @@ process.stdout.write(JSON.stringify({ if prCSV != js.PRCSV { t.Fatalf("PR CSV diverged from browser\nGo:\n%s\nJS:\n%s", prCSV, js.PRCSV) } + if want := issueBandSpec("waiting", config.DashboardIssueBandsConfig{}).Label; js.FallbackHeldBand != want { + t.Fatalf("oracle fallback band for a held issue = %q, want %q (Go's IssueBand)", js.FallbackHeldBand, want) + } if got := []string{overviewCSVCell("-5"), overviewCSVCell("-@risk"), overviewCSVCell([]any{"=a", "b"})}; strings.Join(got, "|") != strings.Join(js.Cells, "|") { t.Fatalf("cell encoding = %#v, want %#v", got, js.Cells) } diff --git a/src/pkg/dashboard/overview_ownership_11567_test.go b/src/pkg/dashboard/overview_ownership_11567_test.go index e3092dcf2c..169a9ab714 100644 --- a/src/pkg/dashboard/overview_ownership_11567_test.go +++ b/src/pkg/dashboard/overview_ownership_11567_test.go @@ -458,7 +458,8 @@ func TestOverviewExportSliceFilterMatchesChartSlice11567(t *testing.T) { "?slice=waiting-elsewhere": {5, 6}, "?slice=ready": {1, 7}, "?band=outside": {3, 5, 8}, - "?band=waiting": {4}, + // #6 and #7 wear `hold`: held is parked, not unclaimed. + "?band=waiting": {4, 6, 7}, } { got := numbers(get("/api/overview/issues.json" + query)) if len(got) != len(want) { diff --git a/src/pkg/dashboard/testdata/overview_legacy_9102.js b/src/pkg/dashboard/testdata/overview_legacy_9102.js index b42b813f66..ea06db023d 100644 --- a/src/pkg/dashboard/testdata/overview_legacy_9102.js +++ b/src/pkg/dashboard/testdata/overview_legacy_9102.js @@ -87,7 +87,7 @@ return (Date.now() - t) > repoIssueBandConfig().staleDays * MS_PER_DAY; } - function issueBandInfo(issue) { + function issueBandInfo(issue, held) { const cfg = repoIssueBandConfig(); const labels = issueLabelSet(issue); const linked = issueLinkedPRState(issue) || {}; @@ -95,13 +95,18 @@ const acknowledged = issueAcknowledged(issue); const matches = { done: issueHasAnyLabel(issue, cfg.doneLabels) || !!linked.merged, - waiting: issueHasAnyLabel(issue, cfg.waitingLabels), + waiting: issueHasAnyLabel(issue, cfg.waitingLabels) || !!held, inProgress: ((issue && issue.assignees) || []).length > 0 || issueClaimed(issue) || !!linked.open, // Agent-filed is an operator queue only until a human acknowledges // the proposal (#5117); acknowledged issues fall through to the // claimed/unclaimed bands with the role badge still on the pill. agentFiled: !!role && !acknowledged }; + // hive/likely-done alone does not outrank a park (Go: onlyLikelyDone). + if (matches.done && matches.waiting && !linked.merged && labels.has('hive/likely-done') && + !(cfg.doneLabels || []).some(l => String(l).toLowerCase() !== 'hive/likely-done' && labels.has(String(l).toLowerCase()))) { + matches.done = false; + } let band = 'ready'; if (matches.done) band = 'done'; else if (matches.waiting) band = 'waiting'; @@ -125,8 +130,8 @@ switch (band) { case 'in-progress': return { label: 'Claimed', short: 'claimed', rule: 'assigned or claimed by an agent — nothing needed unless it stalls' }; case 'agent-filed': return { label: 'Needs triage', short: 'triage', rule: 'filed by an agent (agent/ label) with no approved-direction label, no human assignee, and self-authorization hold is on for the repo (ACMM < 6 or github.self_authorization_hold=true) — agents do not pick it up until it is labelled, assigned to a human, or closed. A human comment also acknowledges for #5117 but is not in the snapshot, so a commented-on proposal still shows here' }; - case 'waiting': return { label: 'Parked', short: 'parked', rule: 'labelled ' + (cfg.waitingLabels || []).join(', ') + ' — parked: agents do not continue until the label is removed or the question it names is answered' }; - case 'done': return { label: 'Confirm & close', short: 'close?', rule: 'an agent applied ' + (cfg.doneLabels || []).join(', ') + ' — the agent reports the work as landed, and the issue is still open' }; + case 'waiting': return { label: 'Parked', short: 'parked', rule: 'labelled ' + (cfg.waitingLabels || []).join(', ') + ', or held — parked: agents do not continue until the label is removed or the question it names is answered' }; + case 'done': return { label: 'Confirm & close', short: 'close?', rule: 'an agent applied ' + (cfg.doneLabels || []).join(', ') + ' (hive/likely-done not on a parked issue) — the agent reports the work as landed, and the issue is still open' }; default: return { label: 'Unclaimed', short: 'unclaimed', rule: 'no other band matched — nobody is assigned, nothing claimed it, and no human gate applies; this does not by itself mean agents will pick it up' }; } } @@ -148,10 +153,10 @@ return { ready: 0, 'in-progress': 1, 'agent-filed': 2, waiting: 3, done: 4 }[band] ?? 9; } - function groupedRepoIssues(issues) { + function groupedRepoIssues(issues, heldSet) { const groups = new Map(); (issues || []).forEach(issue => { - const info = issueBandInfo(issue); + const info = issueBandInfo(issue, !!(heldSet && heldSet.has(issue))); const key = info.band; if (!groups.has(key)) groups.set(key, { key, band: info.band, label: issueBandLabel(info.band), tip: issueBandTip(info.band), issues: [] }); groups.get(key).issues.push({ issue, info }); @@ -174,7 +179,7 @@ const actionable = (r.actionableIssues || []).map(issue => ({ issue, held: false })); const held = (r.heldIssues || []).map(issue => ({ issue, held: true })); const meta = new Map(actionable.concat(held).map(entry => [entry.issue, entry])); - groupedRepoIssues(actionable.concat(held).map(entry => entry.issue)).forEach(g => { + groupedRepoIssues(actionable.concat(held).map(entry => entry.issue), new Set(held.map(entry => entry.issue))).forEach(g => { counts.set(g.band, (counts.get(g.band) || 0) + g.issues.length); const next = g.issues.map(entry => { const source = meta.get(entry.issue) || {}; @@ -474,9 +479,9 @@ function overviewIssueCsvRow(item, band) { const issue = (item && (item.item || item.issue)) || item || {}; - const info = (item && item.info) || issueBandInfo(issue); - const key = band || info.band; const held = !!(item && item.held); + const info = (item && item.info) || issueBandInfo(issue, held); + const key = band || info.band; return { band: issueBandLabel(key), band_rule: issueBandRule(key),