diff --git a/changelog.d/fixed-advisory-issue-noise.md b/changelog.d/fixed-advisory-issue-noise.md new file mode 100644 index 0000000000..7d77285812 --- /dev/null +++ b/changelog.d/fixed-advisory-issue-noise.md @@ -0,0 +1 @@ +- Dedupe advisories with nothing to act on are no longer filed as issues, and advisory issues no longer look like stalled work ([#15381](https://github.com/hivecommons/hive/issues/15381)): the dedupe lane's prompt files a new checklist only for an action-required row, and the issue-request relay refuses an `issue-create` whose dedupe-checklist body has zero near-duplicate pairs, zero resolved candidates, zero missing PR↔issue links and no task lines (audited as `agent_issue_empty_advisory_refused`, summarised in a knowledge bead). In the Activity Monitor an issue wearing `triage/advisory`, carrying the dedupe-checklist marker or a `Decision required: no` line is an advisory: the Open chevron reads **Advisory · read & close** (or **Advisory · nothing found · safe to close** when its own counts are all zero) with no "· since Nh" or stale tint, the caption is *Advisory for maintainers · read, then close*, it is excluded from Needs human / Needs attention, and the row menu leads with **Close (read)**, which closes the issue as completed through the existing decision path (`close-read`). diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 3e2e9b0d1e..88b10eee73 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -1013,6 +1013,12 @@ The *since* time is the item's `created_at`; "next pass" is the governor's next A row that already wears a hold, `blocked`, a draft marker or any stage record is never *New*; neither is an issue at `015` once the stage-label pass has written it. +#### Advisory row (`triage/advisory`, dedupe checklists) + +An issue that is a note for maintainers rather than work — one wearing `triage/advisory`, a dedupe-agent checklist (body opens with ``) or any body whose verdict line reads `Decision required: no` — is an **advisory** ([#15381](https://github.com/hivecommons/hive/issues/15381) sat for hours as a plain *Open · since 3h*, indistinguishable from stalled work). Its row keeps `kind: issue` and carries `advisory{kind: "advisory", source (label|dedupe-checklist|decision-no), empty, chip, caption}`; the Open chevron reads the chip — **Advisory · read & close**, or **Advisory · nothing found · safe to close** when the checklist's own counts are all zero — muted (`ham-open-advisory`, ⓘ), with no *· since Nh* suffix and never the stale tint. The caption is *Advisory for maintainers · read, then close* (or *… · nothing found · safe to close*), the actor is a human with nothing waiting on them, the row is never *New*, never *stalled* or *sent back*, and it is excluded from **Needs human** and **Needs attention**. The row menu leads with **Close (read)**, which posts the existing `POST /api/repos/{owner}/{repo}/items/{number}/decision` with `decision: close-read`: a "Closed as read (advisory acknowledged) by @you from the Hive dashboard" comment, then the issue closes as *completed* (operator action `close-read` in the row's history). + +The enumeration computes the body-derived part (`RepoWorkIssue.advisory`) because sidelined `hive_advisory` rows do not carry the body. Upstream, the issue-request relay refuses an agent's `issue-create` whose body is a dedupe checklist with no actionable finding (verdict `no`, zero near-duplicate pairs, zero resolved candidates, zero missing PR↔issue links, no `- [ ]` task lines): the agent's result file says why, the write audit records `agent_issue_empty_advisory_refused`, and a knowledge bead keeps the summary in the hive's own log — merge-order reminders and cross-links are notes, not issues. + #### Hive's own unblock is live When the blocked sweep or the review-backlog block reconciler lifts `blocked` itself (the tracked PR merged or closed; the `` note), it takes the same path as an inbound label webhook: the tracker cache is dropped and the issue is queued for the targeted re-read (`ItemPatches` delivery `self:edit`), which patches the status row and the governor's cached snapshot at once. A reconcile enumeration that was already listing when the unblock happened used to overwrite that patch with its pre-unblock copy, and the rows reverted to `blocked` until the next pass (~an hour on the hive's hive); the governor now replays re-reads newer than the listing's start onto the pass's result before publishing it, so a row never moves backwards behind a read it has already made. diff --git a/src/docs/scale-envelope.md b/src/docs/scale-envelope.md index e8f8ff1e50..b1bfe44a51 100644 --- a/src/docs/scale-envelope.md +++ b/src/docs/scale-envelope.md @@ -34,7 +34,7 @@ ones to: 2. **Truncation must preserve the prioritization signal, not cut an arbitrary slice.** This holds today and is easy to assume backwards: - Issues are sorted by actionable rank tier, then **oldest first** within each tier before any cap is applied - (`RankActionableIssues`, `src/pkg/github/client.go:4794-4804`, descending `AgeMinutes` within each tier). + (`RankActionableIssues`, `src/pkg/github/client.go:4804-4814`, descending `AgeMinutes` within each tier). - PRs are sorted by **review class then oldest-first within class** (`SortPullRequestsForReview`, `src/pkg/github/review_priority.go:334`; fixes → refactors/docs → tests). diff --git a/src/pkg/dashboard/api_repo_item_decision.go b/src/pkg/dashboard/api_repo_item_decision.go index ccccc7979b..05e83d78d8 100644 --- a/src/pkg/dashboard/api_repo_item_decision.go +++ b/src/pkg/dashboard/api_repo_item_decision.go @@ -65,7 +65,11 @@ const ( repoItemDecisionDirection = "direction" repoItemDecisionCloseSuperseded = "close-superseded" repoItemDecisionCloseWontFix = "close-wontfix" - repoItemDecisionAdopt = "adopt" + // close-read closes an advisory issue (triage/advisory, a dedupe + // checklist) as completed once a maintainer has read it + // (hivecommons/hive#15381): the row's "Close (read)" action. + repoItemDecisionCloseRead = "close-read" + repoItemDecisionAdopt = "adopt" // Merge-gate answers on a PR parked at stage/090-ready-for-human-merge // (hivecommons/hive#15078). merge-now merges through the hive's App at // once, attributed to the operator; queue-merge records the operator's @@ -97,6 +101,7 @@ const ( adoptRequestLabelDesc = "Owner-delegate request: adopt now in supersede mode" issueStateReasonNotPlanned = "not_planned" + issueStateReasonCompleted = "completed" ) // repoItemDecisionChangeRequests is the store a PR direction is recorded in: @@ -274,6 +279,10 @@ func repoItemDecisionResultWith(repoFull string, number int, itemType, decision, out.Action = rowActionClosed out.Outcome = "Closed as won't fix (not planned)." out.Next = "Nothing further to do; the row leaves the tracker on its next refresh." + case repoItemDecisionCloseRead: + out.Action = rowActionClosed + out.Outcome = "Closed as read (advisory acknowledged)." + out.Next = "Nothing further to do; the row leaves the tracker on its next refresh." case repoItemDecisionAdopt: out.Action = rowActionAdopted out.Outcome = "Adoption queued: `" + label + "` applied." @@ -385,9 +394,17 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request) s.audit.LogRecord(user, action, auditDetail("repo", repoFull, "number", numStr, "decision", event.Decision), "", repoFull, number) jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: "unparked", Label: ghpkg.HumanAckLabel, Result: repoItemDecisionResult(repoFull, number, itemType, decision, comment, "", ghpkg.HumanAckLabel, nil)}) - case repoItemDecisionCloseSuperseded, repoItemDecisionCloseWontFix: + case repoItemDecisionCloseSuperseded, repoItemDecisionCloseWontFix, repoItemDecisionCloseRead: verb := "won't fix" + stateReason := issueStateReasonNotPlanned supersededBy := "" + if decision == repoItemDecisionCloseRead { + if itemType != "issue" { + jsonError(w, "close-read applies to issues", http.StatusBadRequest) + return + } + verb, stateReason = "read (advisory acknowledged)", issueStateReasonCompleted + } if decision == repoItemDecisionCloseSuperseded { verb = "superseded" ref, err := parseRepoItemSupersededBy(body.SupersededBy, repoFull) @@ -416,7 +433,7 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request) err := gh.CloseIssue(ctx, repoFull, number, ghpkg.IssueCloseOptions{ OverrideReason: "closed as " + verb + " by @" + user + " from the Hive dashboard", SuppressOverrideComment: true, - StateReason: issueStateReasonNotPlanned, + StateReason: stateReason, // A recorded human decision may close a tracking issue; // only the automated paths are refused. AllowTrackingIssue: true, @@ -478,7 +495,7 @@ func (s *Server) handleRepoItemDecision(w http.ResponseWriter, r *http.Request) } s.handlePullRequestMergeDecision(ctx, w, repoFull, number, user, decision, comment) default: - jsonError(w, "unknown decision; want approve, direction, close-superseded, close-wontfix, adopt, reroute, re-author, merge-now or queue-merge", http.StatusBadRequest) + jsonError(w, "unknown decision; want approve, direction, close-superseded, close-wontfix, close-read, adopt, reroute, re-author, merge-now or queue-merge", http.StatusBadRequest) } } diff --git a/src/pkg/dashboard/api_repo_item_decision_test.go b/src/pkg/dashboard/api_repo_item_decision_test.go index 75f3cab323..e813d4ed20 100644 --- a/src/pkg/dashboard/api_repo_item_decision_test.go +++ b/src/pkg/dashboard/api_repo_item_decision_test.go @@ -320,6 +320,32 @@ func TestRepoItemDecisionCloseWontFixCommentsAndCloses(t *testing.T) { } } +// close-read (hivecommons/hive#15381): an advisory issue is closed as +// completed through the same comment + close path; a PR is refused. +func TestRepoItemDecisionCloseReadClosesAsCompleted(t *testing.T) { + mock := &repoItemDecisionMock{issueLabels: []string{"triage/advisory"}} + srv := newRepoItemDecisionServer(t, mock) + + w := postRepoItemDecision(t, srv, 7, "writer", `{"decision":"close-read"}`) + if w.Code != http.StatusOK { + t.Fatalf("close-read: code=%d body=%s", w.Code, w.Body.String()) + } + if len(mock.comments) != 1 || !strings.Contains(mock.comments[0], "Closed as read (advisory acknowledged) by @writer") { + t.Fatalf("comments = %v", mock.comments) + } + if len(mock.edits) != 1 || mock.edits[0]["state"] != "closed" || mock.edits[0]["state_reason"] != issueStateReasonCompleted { + t.Fatalf("edits = %v", mock.edits) + } + var resp repoItemDecisionResponse + _ = json.Unmarshal(w.Body.Bytes(), &resp) + if resp.Status != "closed" || resp.Result == nil || resp.Result.Outcome != "Closed as read (advisory acknowledged)." { + t.Fatalf("resp = %+v", resp) + } + if w := postRepoItemDecision(t, srv, 8, "writer", `{"decision":"close-read","type":"pr"}`); w.Code != http.StatusBadRequest { + t.Fatalf("close-read on a PR: code=%d want 400 body=%s", w.Code, w.Body.String()) + } +} + func TestRepoItemDecisionCloseSupersededPRUsesSweepPath(t *testing.T) { mock := &repoItemDecisionMock{} srv := newRepoItemDecisionServer(t, mock) diff --git a/src/pkg/dashboard/operator_actions.go b/src/pkg/dashboard/operator_actions.go index e821108ec8..67a6b09f38 100644 --- a/src/pkg/dashboard/operator_actions.go +++ b/src/pkg/dashboard/operator_actions.go @@ -36,6 +36,7 @@ const ( operatorActionGiveDirection = "give-direction" operatorActionCloseSuperseded = "close-superseded" operatorActionWontFix = "wontfix" + operatorActionCloseRead = "close-read" operatorActionLetHiveDecide = "let-hive-decide" operatorActionHold = "hold" operatorActionRelease = "release" @@ -326,6 +327,8 @@ func operatorActionFromBody(endpoint string, body []byte) (operatorActionRequest out.Target = strings.TrimSpace(raw.SupersededBy) case repoItemDecisionCloseWontFix: out.Action = operatorActionWontFix + case repoItemDecisionCloseRead: + out.Action = operatorActionCloseRead case repoItemDecisionMergeNow: out.Action = operatorActionMergeNow case repoItemDecisionQueueMerge: diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 86125788ff..89cb2d3507 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -310,6 +310,11 @@ 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"` + // Advisory is set on an issue that is a note for maintainers, not work + // (triage/advisory label, dedupe checklist, "Decision required: no"): + // read it, then close it (hivecommons/hive#15381). Its Chip is the + // Open chevron's word; the row never counts as stalled or attention. + Advisory *StageTrackerAdvisory `json:"advisory,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 / @@ -2112,7 +2117,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto prOpen := func(repo string, number int) bool { return prState(repo, number) == blockedOnPRStateOpen } supersedes := stageTrackerSupersedesIndex(store, status.GitHubBaseURL) issueFilter := s.issueFilterConfig() - addIssue := func(repoName string, issue github.Issue, bucket, bucketReason string, progress *github.IssueChildren) { + addIssue := func(repoName string, issue github.Issue, bucket, bucketReason string, progress *github.IssueChildren, advisoryHint *github.IssueAdvisory) { // A closed issue has no stage; a stage label it closed wearing is // the closed-issue sweep's to remove, not a row to render // (hivecommons/homebrew-hive#127). @@ -2162,7 +2167,10 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto finish(&it, issue.Labels, stage, rec, ok, false) stageTrackerBlockedBy(&it, issue.OpenBlockers()) stageTrackerBlockedOnPR(&it, issue.Body, bucketReason, status.GitHubBaseURL, prState) - applyStageTrackerNew(&it, stageTrackerNewState(it, ok, issueFilter, status.Governor, now)) + advisory := stageTrackerAdvisoryFor(issue.Labels, issue.Body, advisoryHint) + if advisory == nil { + applyStageTrackerNew(&it, stageTrackerNewState(it, ok, issueFilter, status.Governor, now)) + } if it.Stage == trackerNumberClaimed { it.ClaimantKind = s.stageTrackerClaimantKind(repoName, issue.Number) } @@ -2180,6 +2188,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } it.DecisionNeeded = stageTrackerDecisionNeededWith(it, nil, sentinelLabel, now, bctx) it.StageActor = stageTrackerStageActor(it, workers, now) + applyStageTrackerAdvisory(&it, advisory) add(it) } addPR := func(repoName string, pr github.PullRequest, verdict *github.MergeVerdict, bucket, bucketReason string) { @@ -2269,7 +2278,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto for _, it := range repoOpenItems(repo) { switch { case it.Kind == "issue" && !it.Sidelined: - addIssue(repoName, it.Issue, "", "", nil) + addIssue(repoName, it.Issue, "", "", nil, nil) case it.Kind == "pr" && !it.Sidelined: addPR(repoName, it.PR.pr, it.PR.verdict, "", "") case it.Kind == "issue": @@ -2277,7 +2286,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto // bucket, the open items the first tracker never showed. w := it.WorkIssue addIssue(repoName, github.Issue{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, Labels: w.Labels, Assignees: w.Assignees, - CreatedAt: w.CreatedAt, UpdatedAt: w.UpdatedAt, URL: w.URL, ClaimKind: w.ClaimKind, ClaimedBy: w.ClaimedBy, LinkedPRs: w.LinkedPRs, ClaimContext: w.ClaimContext, IsTracker: w.IsTracker, Children: w.Children}, w.Bucket, w.Reason, w.TrackerProgress) + CreatedAt: w.CreatedAt, UpdatedAt: w.UpdatedAt, URL: w.URL, ClaimKind: w.ClaimKind, ClaimedBy: w.ClaimedBy, LinkedPRs: w.LinkedPRs, ClaimContext: w.ClaimContext, IsTracker: w.IsTracker, Children: w.Children}, w.Bucket, w.Reason, w.TrackerProgress, w.Advisory) default: w := it.WorkPR addPR(repoName, github.PullRequest{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, Labels: w.Labels, Draft: w.Draft, @@ -2340,7 +2349,9 @@ var stageTrackerNeedsHumanMods = []string{modNeedsHuman, modNeedsDecision, modUn // 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) { + // An advisory waits on nobody: reading and closing it is a courtesy, + // not a decision the pipeline is parked on (hivecommons/hive#15381). + if stageTrackerOnHold(it) || it.Advisory != nil { return false } if slices.ContainsFunc(it.Modifiers, func(m string) bool { return slices.Contains(stageTrackerNeedsHumanMods, m) }) { @@ -2397,7 +2408,7 @@ func stageTrackerRegressionHandled(it StageTrackerItem) bool { // parked on a person. Only the shown Modifiers count, so a merge-gate pill // held back until the gate never promotes a row. func stageTrackerNeedsAttention(it StageTrackerItem) bool { - if stageTrackerRegressionHandled(it) { + if it.Advisory != nil || stageTrackerRegressionHandled(it) { return false } return len(it.Modifiers) > 0 || slices.Contains(stageTrackerAttentionStages, it.Stage) diff --git a/src/pkg/dashboard/stage_tracker_advisory.go b/src/pkg/dashboard/stage_tracker_advisory.go new file mode 100644 index 0000000000..d6798d858a --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_advisory.go @@ -0,0 +1,98 @@ +package dashboard + +import ( + "slices" + "strings" + + "github.com/hivecommons/hive/pkg/github" +) + +// An advisory issue (hivecommons/hive#15381): a `triage/advisory` issue, a +// dedupe checklist, or any body whose second line reads "Decision required: +// no" is a note for maintainers to read and close — no agent picks it up, +// nothing waits on it. The tracker says so instead of drawing it as a plain +// "Open · since 3h" row that reads as stalled work. + +const ( + // StageTrackerAdvisoryKind is StageTrackerAdvisory.Kind; the row's own + // kind stays "issue" (keys and URLs depend on it). + StageTrackerAdvisoryKind = "advisory" + // StageTrackerAdvisoryChip / StageTrackerAdvisoryEmptyChip are the Open + // chevron's word (≤ 8 words). Empty is for a checklist that itself says + // it found nothing actionable. + StageTrackerAdvisoryChip = "Advisory · read & close" + StageTrackerAdvisoryEmptyChip = "Advisory · nothing found · safe to close" + // StageTrackerAdvisoryCaption / StageTrackerAdvisoryEmptyCaption are + // the row captions. + StageTrackerAdvisoryCaption = "Advisory for maintainers · read, then close" + StageTrackerAdvisoryEmptyCaption = "Advisory for maintainers · nothing found · safe to close" + // stageTrackerAdvisoryWhy is the StageActor sentence. + stageTrackerAdvisoryWhy = "advisory for maintainers — read it, then close it; nothing waits on it and no agent picks it up" + + stageTrackerAdvisorySourceLabel = "label" + stageTrackerAdvisorySourceChecklist = "dedupe-checklist" + stageTrackerAdvisorySourceVerdict = "decision-no" +) + +// StageTrackerAdvisory is the payload block on an advisory row. +type StageTrackerAdvisory struct { + Kind string `json:"kind"` + // Source says what classified it: label (triage/advisory), + // dedupe-checklist (the body marker) or decision-no (the verdict line). + Source string `json:"source"` + // Empty is true when the advisory's own body says it found nothing. + Empty bool `json:"empty,omitempty"` + Chip string `json:"chip"` + Caption string `json:"caption"` +} + +// stageTrackerAdvisoryFor classifies an issue from its labels, its body +// (when the caller has it) and the enumeration's body-derived hint (when +// it does not). nil for an ordinary issue. +func stageTrackerAdvisoryFor(labels []string, body string, hint *github.IssueAdvisory) *StageTrackerAdvisory { + if hint == nil && strings.TrimSpace(body) != "" { + hint = github.IssueAdvisoryFromBody(body) + } + adv := &StageTrackerAdvisory{Kind: StageTrackerAdvisoryKind} + switch { + case slices.ContainsFunc(labels, func(l string) bool { return strings.EqualFold(strings.TrimSpace(l), github.DedupeAdvisoryLabelName) }): + adv.Source = stageTrackerAdvisorySourceLabel + case hint != nil && hint.DedupeChecklist: + adv.Source = stageTrackerAdvisorySourceChecklist + case hint != nil && hint.DecisionNo: + adv.Source = stageTrackerAdvisorySourceVerdict + default: + return nil + } + adv.Empty = hint != nil && hint.Empty + adv.Chip, adv.Caption = StageTrackerAdvisoryChip, StageTrackerAdvisoryCaption + if adv.Empty { + adv.Chip, adv.Caption = StageTrackerAdvisoryEmptyChip, StageTrackerAdvisoryEmptyCaption + } + return adv +} + +// stageTrackerAdvisoryMods are the pills an advisory never wears: it is +// not work, so it cannot stall or be sent back. +var stageTrackerAdvisoryMods = []string{modStalled, modRegressed} + +// applyStageTrackerAdvisory marks it as an advisory: the caption and the +// actor say "read, then close", the stall/regression pills come off, the +// 000-new block (which would say "waiting for triage") is dropped, and the +// stage actor is a human with nothing blocking on them. +func applyStageTrackerAdvisory(it *StageTrackerItem, adv *StageTrackerAdvisory) { + if it == nil || adv == nil { + return + } + it.Advisory = adv + it.Caption = adv.Caption + it.Actor = "maintainer" + it.Modifiers = slices.DeleteFunc(it.Modifiers, func(m string) bool { return slices.Contains(stageTrackerAdvisoryMods, m) }) + if it.New != nil { + it.New = nil + if it.StageSlug == StageTrackerNewSlug { + it.StageSlug = "" + } + } + it.StageActor = &StageTrackerActor{Kind: StageActorHuman, Why: stageTrackerAdvisoryWhy, Since: it.StageSince} +} diff --git a/src/pkg/dashboard/stage_tracker_advisory_test.go b/src/pkg/dashboard/stage_tracker_advisory_test.go new file mode 100644 index 0000000000..2465ffe63f --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_advisory_test.go @@ -0,0 +1,268 @@ +package dashboard + +import ( + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" +) + +// hivecommons/hive#15381 as the enumeration saw it: labels help wanted, +// agent/dedupe, triage/advisory; a dedupe-checklist body with zero +// actionable findings. +var issue15381Labels = []string{"help wanted", "agent/dedupe", "triage/advisory"} + +func issue15381Body(t *testing.T) string { + t.Helper() + b, err := os.ReadFile(filepath.Join("..", "github", "testdata", "dedupe_checklist_15381.md")) + if err != nil { + t.Fatal(err) + } + return string(b) +} + +func TestStageTrackerAdvisoryFor(t *testing.T) { + body := issue15381Body(t) + adv := stageTrackerAdvisoryFor(issue15381Labels, body, nil) + if adv == nil || adv.Kind != StageTrackerAdvisoryKind || adv.Source != stageTrackerAdvisorySourceLabel || !adv.Empty { + t.Fatalf("#15381 from labels+body = %+v", adv) + } + if adv.Chip != "Advisory · nothing found · safe to close" || adv.Caption != StageTrackerAdvisoryEmptyCaption { + t.Errorf("#15381 chip/caption = %q / %q", adv.Chip, adv.Caption) + } + // The sidelined path has no body, only the enumeration's hint. + hint := github.IssueAdvisoryFromBody(body) + if got := stageTrackerAdvisoryFor(issue15381Labels, "", hint); got == nil || !got.Empty || got.Chip != adv.Chip { + t.Errorf("#15381 from labels+hint = %+v", got) + } + // Label alone, body unknown: an advisory, not known to be empty. + if got := stageTrackerAdvisoryFor([]string{"Triage/Advisory"}, "", nil); got == nil || got.Empty || got.Chip != "Advisory · read & close" || got.Caption != "Advisory for maintainers · read, then close" { + t.Errorf("label only = %+v", got) + } + // Marker without the label; verdict line without either. + if got := stageTrackerAdvisoryFor(nil, "\nDecision required: yes\n\n- [ ] #1 dup of #2\n", nil); got == nil || got.Source != stageTrackerAdvisorySourceChecklist || got.Empty { + t.Errorf("marker only = %+v", got) + } + if got := stageTrackerAdvisoryFor(nil, "FYI\nDecision required: no\n", nil); got == nil || got.Source != stageTrackerAdvisorySourceVerdict { + t.Errorf("verdict only = %+v", got) + } + if got := stageTrackerAdvisoryFor([]string{"kind/bug"}, "Please fix.", nil); got != nil { + t.Errorf("ordinary issue = %+v", got) + } +} + +// An advisory row in the built tracker: advisory block set, "read, then +// close" caption, no stalled/attention/needs-human accounting, no 000-new +// block, human actor with nothing waiting. +func TestStageTrackerAdvisoryRow(t *testing.T) { + now := time.Date(2026, 10, 29, 12, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + created := now.Add(-3 * time.Hour) + body := issue15381Body(t) + + s.statusMu.Lock() + repo := &s.status.Repos[0] + repo.NonActionableIssues = []any{ + github.RepoWorkIssue{Repo: "acme/console", Number: 15381, Title: "triage: duplicate and overlapping open issues/PRs to consolidate", Author: "hive-app[bot]", + Labels: issue15381Labels, Bucket: "hive_advisory", Reason: "triage/advisory", CreatedAt: created, UpdatedAt: created, + Advisory: github.IssueAdvisoryFromBody(body)}, + github.RepoWorkIssue{Repo: "acme/console", Number: 15382, Title: "Advisory with actions pending", Author: "hive-app[bot]", + Labels: []string{"triage/advisory"}, Bucket: "hive_advisory", Reason: "triage/advisory", CreatedAt: created}, + } + s.statusMu.Unlock() + + resp := s.buildStageTracker(s.status, store, now) + it := trackerItem(t, resp, "issue", 15381) + if it.Advisory == nil || !it.Advisory.Empty || it.Advisory.Kind != "advisory" { + t.Fatalf("#15381 advisory = %+v", it.Advisory) + } + if it.Caption != "Advisory for maintainers · nothing found · safe to close" || it.Advisory.Chip != "Advisory · nothing found · safe to close" { + t.Errorf("#15381 caption/chip = %q / %q", it.Caption, it.Advisory.Chip) + } + if it.Kind != "issue" || it.Stage != 0 || it.New != nil || it.StageSlug == StageTrackerNewSlug { + t.Errorf("#15381 kind/stage/new = %q/%d/%+v slug=%q", it.Kind, it.Stage, it.New, it.StageSlug) + } + if it.NeedsHuman || stageTrackerNeedsAttention(it) || hasMod(it, modStalled) { + t.Errorf("#15381 counted as work: needs_human=%v attention=%v mods=%v", it.NeedsHuman, stageTrackerNeedsAttention(it), it.Modifiers) + } + if it.StageActor == nil || it.StageActor.Kind != StageActorHuman || !strings.Contains(it.StageActor.Why, "nothing waits on it") { + t.Errorf("#15381 actor = %+v", it.StageActor) + } + other := trackerItem(t, resp, "issue", 15382) + if other.Advisory == nil || other.Advisory.Empty || other.Caption != "Advisory for maintainers · read, then close" || other.Advisory.Chip != "Advisory · read & close" { + t.Errorf("label-only advisory = %+v caption=%q", other.Advisory, other.Caption) + } + for _, n := range []int{1, 2, 3} { + if plain, ok := trackerItemOK(resp, "issue", n); ok && plain.Advisory != nil { + t.Errorf("ordinary issue #%d classified as advisory: %+v", n, plain.Advisory) + } + } +} + +func trackerItemOK(resp StageTrackerResponse, kind string, number int) (StageTrackerItem, bool) { + for _, it := range resp.Items { + if it.Kind == kind && it.Number == number { + return it, true + } + } + return StageTrackerItem{}, false +} + +// The SPA side (hivecommons/hive#15381): the Open chevron of an advisory +// row is its chip with no "· since Nh" and no stale tint, the headline is +// the chip, the row leads with Close (read) which posts the existing +// decision path with `close-read`, and the attention / needs-human filters +// skip it. +func TestStageTrackerAdvisoryChipAndAction(t *testing.T) { + html := indexHTML(t) + for _, want := range []string{ + ".ham-seg.active.ham-open-advisory {", + "'decide:close-read': 'Close (read)'", + "function stageTrackerAdvisoryOf(item)", + } { + if !strings.Contains(html, want) { + t.Fatalf("index.html missing %q", want) + } + } + if _, err := exec.LookPath("node"); err != nil { + t.Skip("node not on PATH — the advisory chip/action was NOT executed by this run") + } + // Rendering: the chip, the headline, the filters. + runStageTrackerRowActionsScript(t, "const assert = require('assert');\nfunction esc(s) { return String(s).replace(/&/g, '&').replace(/Advisory · nothing found · safe to close'), strip); +assert.ok(/title="Advisory for maintainers · nothing found · safe to close/.test(strip), strip); +assert.strictEqual(stageTrackerHeadline(empty), 'Advisory · nothing found · safe to close'); +assert.strictEqual(stageTrackerHeadline(plainAdvisory), 'Advisory · read & close'); +assert.strictEqual(stageTrackerActorKind(empty), 'human'); +// Not counted as attention or needs-human. +assert.strictEqual(stageTrackerNeedsAttention(empty), false); +assert.strictEqual(stageTrackerItemNeedsHuman(empty), false); +// An ordinary Open row still says since / stale. +const ordinary = { repo: 'o/r', number: 2, kind: 'issue', stage: 0, caption: 'No stage recorded yet', stage_since: '2026-10-26T09:00:00Z', labels: [], modifiers: [] }; +const os = stageTrackerSegments(ordinary, stages, now)[0]; +assert.strictEqual(os.short, 'Open · since 3d', os.short); +assert.ok(os.openSince && os.openSince.stale); +assert.strictEqual(stageTrackerHeadline(ordinary), 'Open'); + +`) + // Row action: Close (read) leads and posts the existing decision path. + runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+stageTrackerConfirmOptOutJS(t, html)+jsFunc(t, html, "stageTrackerAdvisoryOf")+` +const empty = { repo: 'hivecommons/hive', number: 15381, kind: 'issue', title: 'triage: duplicate and overlapping open issues/PRs to consolidate', author: 'hivecommons-hive[bot]', author_kind: 'hive', + stage: 0, created_at: '2026-10-29T09:00:00Z', stage_since: '2026-10-26T09:00:00Z', labels: ['help wanted', 'agent/dedupe', 'triage/advisory'], bucket: 'hive_advisory', modifiers: [], + caption: 'Advisory for maintainers · nothing found · safe to close', + advisory: { kind: 'advisory', source: 'label', empty: true, chip: 'Advisory · nothing found · safe to close', caption: 'Advisory for maintainers · nothing found · safe to close' }, + stage_actor: { kind: 'human', why: 'advisory for maintainers — read it, then close it; nothing waits on it and no agent picks it up' } }; +const plainAdvisory = Object.assign({}, empty, { number: 15382, advisory: { kind: 'advisory', source: 'label', chip: 'Advisory · read & close', caption: 'Advisory for maintainers · read, then close' } }); +const ordinary = { repo: 'o/r', number: 2, kind: 'issue', stage: 0, caption: 'No stage recorded yet', stage_since: '2026-10-26T09:00:00Z', labels: [], modifiers: [] }; + +// Row action: Close (read) leads, posts the existing decision path with close-read. +const ids = as => as.map(a => a.id); +const ctx = { user: true, canHold: true, canHuman: true }; +const as = stageTrackerRowActions(empty, ctx); +assert.deepStrictEqual(ids(as), ['decide:close-read', 'hold', 'retry', 'needs-human', 'open', 'copy'], ids(as).join(',')); +assert.strictEqual(as[0].label, 'Close (read)'); +assert.ok(as[0].lead && as[0].enabled, JSON.stringify(as[0])); +assert.ok(as[0].hint.startsWith('nothing found'), as[0].hint); +assert.ok(stageTrackerRowActions(plainAdvisory, ctx)[0].hint.startsWith('advisory acknowledged')); +const ro = stageTrackerRowActions(empty, { user: false, canHold: true }); +assert.strictEqual(ro[0].enabled, false); assert.strictEqual(ro[0].why, STAGE_TRACKER_WHY_WRITE); +assert.strictEqual(ids(stageTrackerRowActions(ordinary, ctx)).indexOf('decide:close-read'), -1, 'no Close (read) on an ordinary issue'); +const req = stageTrackerActionRequest(empty, 'decide:close-read', {}); +assert.deepStrictEqual(req, { url: '/api/repos/hivecommons/hive/items/15381/decision', body: { decision: 'close-read', comment: '', type: 'issue' } }); +assert.strictEqual(stageTrackerActionLabel('decide:close-read'), 'Close (read)'); +assert.strictEqual(stageTrackerActingCaption('decide:close-read', empty), 'Closing…'); +(async () => { + assert.deepStrictEqual(await stageTrackerActionPayload([empty], 'decide:close-read'), {}); + assert.strictEqual(dialogs.length, 1); + assert.strictEqual(dialogs[0].kind, 'confirm'); + assert.ok(dialogs[0].cfg.message.includes('hivecommons/hive#15381') && dialogs[0].cfg.message.includes('closes as completed'), dialogs[0].cfg.message); + dialogAnswer = false; + assert.strictEqual(await stageTrackerActionPayload([empty], 'decide:close-read'), null); +})().catch(e => { console.error(e); process.exit(1); }); +`) +} diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 966b13fb34..eabaf0daff 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -304,6 +304,10 @@ it a move but the next pass" (hivecommons/hive#15094). */ .ham-seg.active.ham-open-new { background: var(--blue); color: var(--surface-0); } .ham-seg.active.ham-open-new .ham-seg-t::before { content: '✦'; margin-right: var(--sp-1); } + /* Advisory (hivecommons/hive#15381): a note for maintainers, not + work — muted, never stale-tinted, read then close. */ + .ham-seg.active.ham-open-advisory { background: var(--surface-2); color: var(--muted); } + .ham-seg.active.ham-open-advisory .ham-seg-t::before { content: 'ⓘ'; margin-right: var(--sp-1); } .ham-seg.active.ham-open-stale { background: color-mix(in srgb, var(--amber) 65%, var(--red)); } .ham-detour { white-space: normal; overflow-wrap: anywhere; } .ham-current-stage { display: none; margin: 0; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; } diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index f43bb5eb6a..0049fe8d05 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -34,6 +34,7 @@ const STAGE_TRACKER_ACTION_LABELS = { 'decide:delegate': 'Let hive decide', 'decide:delegate-all': 'Let hive decide — all PRs', 'decide:delegate:rerun': 'Re-run decision', 'decide:approve': 'Approve', 'decide:direction': 'Give direction', 'decide:close-superseded': 'Close as superseded by', 'decide:close-wontfix': "Close as won't-fix", + 'decide:close-read': 'Close (read)', 'decide:adopt': 'Adopt (hive takes over)', 'decide:merge-now': 'Approve & merge as maintainer', 'decide:queue-merge': 'Approve — let hive merge', 'decide:re-author': 'Re-author as hive PR', @@ -390,6 +391,11 @@ // hold): the ask the row makes has its answer first. const triage = stageTrackerTriageNeeded(item); if (triage) out.push({ id: 'accept-triage', label: 'Accept triage', hint: stageTrackerTriageHint(item, ctx, ctx.nowMs, ctx.governor), enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, lead: true }); + // An advisory issue (hivecommons/hive#15381) asks for one thing: + // read it, then close it. "Close (read)" leads; it is the existing + // decision close path with the verdict `close-read`. + const advisory = typeof stageTrackerAdvisoryOf === 'function' ? stageTrackerAdvisoryOf(item) : null; + if (advisory) out.push(Object.assign({ id: 'decide:close-read', label: STAGE_TRACKER_ACTION_LABELS['decide:close-read'], hint: advisory.empty ? 'nothing found · closes as completed' : 'advisory acknowledged · closes as completed', lead: true }, stageTrackerActionAllowed('decide:close-read', ctx))); for (const a of lead) out.push(a); if (target) { const on = target === item ? '' : ' PR #' + (Number(target.number) || 0); @@ -1432,6 +1438,8 @@ const v = await stageTrackerAsk(id, 'prompt', { title: stageTrackerActionLabel(id), label: 'Comment for ' + refs + ' (optional)', placeholder: 'Why this is closed', confirmLabel: 'Close' }); return v == null ? null : { comment: v }; } + case 'decide:close-read': + return (await stageTrackerAsk(id, 'confirm', { title: 'Close (read)', message: 'Close ' + refs + ' as read, as ' + who + '? It is an advisory for maintainers — nothing waits on it; the issue closes as completed with a note that you read it.', confirmLabel: 'Close' })) ? {} : null; case 'decide:merge-now': { const base = items.map(it => it.base_ref || '').filter(Boolean)[0] || 'its base branch'; if (items.some(stageTrackerNeedsRebase)) { @@ -1509,7 +1517,7 @@ const STAGE_TRACKER_ACTING_CAPTIONS = { 'hold': 'Holding…', 'release': 'Releasing hold…', 'retry': 'Re-evaluating…', 'needs-human': 'Marking needs-human…', 'accept-triage': 'Accepting triage…', 'blocker:recheck': 'Checking App permissions…', 'blocker:close-partial': 'Closing as partial…', - 'decide:delegate': 'Hive deciding…', 'decide:delegate-all': 'Hive deciding each PR…', 'decide:delegate:rerun': 'Hive deciding again…', 'decide:approve': 'Approving…', 'decide:direction': 'Recording direction…', 'decide:close-superseded': 'Closing…', 'decide:close-wontfix': 'Closing…', + 'decide:delegate': 'Hive deciding…', 'decide:delegate-all': 'Hive deciding each PR…', 'decide:delegate:rerun': 'Hive deciding again…', 'decide:approve': 'Approving…', 'decide:direction': 'Recording direction…', 'decide:close-superseded': 'Closing…', 'decide:close-wontfix': 'Closing…', 'decide:close-read': 'Closing…', 'decide:merge-now': 'Merging…', 'decide:queue-merge': 'Queuing for merge…', 'decide:re-author': 'Queuing re-authoring…', 'decide:merge-now': 'Merging…', 'decide:queue-merge': 'Queuing for merge…', 'decide:adopt': 'Adopting…', 'decide:adopt-now': 'Adopting now…', 'decide:reroute': 'Rerouting…', diff --git a/src/pkg/dashboard/static-src/js/tracker-filter.js b/src/pkg/dashboard/static-src/js/tracker-filter.js index f02c3a4e63..985ac6b889 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter.js @@ -67,6 +67,8 @@ function stageTrackerNeedsAttention(item) { const mods = Array.isArray(item.modifiers) ? item.modifiers : []; const n = Number(item.stage) || 0; + // An advisory is a note, not work (hivecommons/hive#15381). + if (item && item.advisory) return false; if (stageTrackerRegressionHandled(item)) return false; return mods.length > 0 || STAGE_TRACKER_ATTENTION_STAGES.indexOf(n) >= 0; } @@ -109,7 +111,7 @@ // 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; + if (!item || item.advisory || 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; diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 6e62e04bb5..5f11fb93d1 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -69,19 +69,22 @@ // 000-new: the payload says nothing has placed the item yet and // names who moves it next (hivecommons/hive#15094). const openNew = n === 0 && state === 'active' && !openHold && !openBlocked && !openDraft && typeof stageTrackerNewState === 'function' && !!stageTrackerNewState(item); + const advisory = n === 0 && state === 'active' && !openHold && !openBlocked && typeof stageTrackerAdvisoryOf === 'function' ? stageTrackerAdvisoryOf(item) : null; if (openHold) word = 'Open · hold'; else if (openBlocked) word = 'Open · blocked'; + else if (advisory) word = advisory.chip || 'Advisory · read & close'; else if (openDraft) word = 'Draft'; else if (openNew) word = 'New'; // A plain, blocked or draft Open step (no stage label, not held) // says how long it has sat there, from the same instant the since - // column shows — a stale blocked item is exactly what should stand out. + // column shows — a stale blocked item is exactly what should stand + // out. An advisory never does: nothing waits on it. let openSince = null; - if (n === 0 && state === 'active' && !openHold && !detour && nowMs) { + if (n === 0 && state === 'active' && !openHold && !advisory && !detour && nowMs) { const os = stageTrackerOpenSince(item); if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: !openDraft && nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); } } - return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew, openSince }; + return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; }); segs.push({ number: STAGE_TRACKER_TERMINAL, code: '', short: 'Merged', label: 'Merged', description: 'Merged — the pipeline is complete', state: terminal ? 'active' : 'todo', terminal, cap: true, detour: null }); return segs; @@ -181,6 +184,14 @@ return state + (sa.kind === 'bot' ? ' · bot PR' : ' · nobody on it'); } + // Advisory (hivecommons/hive#15381): a payload `advisory` block means + // the issue is a note for maintainers, not work — the chevron word is + // its chip, it never reads stale or "since Nh", and the row action is + // Close (read). Pure so the fixture tests can lift it by name. + function stageTrackerAdvisoryOf(item) { + if (!item || item.kind === 'pr' || !item.advisory || typeof item.advisory !== 'object') return null; + return item.advisory; + } // 000-new (hivecommons/hive#15094): a payload `new` block on a stage-0 // row means nothing has placed the item yet. These are pure so the // fixture tests can lift them by name. @@ -271,7 +282,7 @@ if (sg.number < from || sg.number > to) return ``; const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; if (active) { @@ -279,6 +290,7 @@ if (sg.blocked) tip += ' — ' + stageTrackerBlockedTip(item); if (sg.draft) tip += ' — ' + STAGE_TRACKER_DRAFT_TIP; if (sg.isNew && typeof stageTrackerNewLines === 'function') tip = 'New — ' + stageTrackerNewLines(item, nowMs).join(' — '); + if (sg.advisory) tip = (item.advisory && item.advisory.caption) || 'Advisory for maintainers · read, then close'; if (sg.openSince) tip += ' — open since ' + new Date(sg.openSince.ms).toISOString() + (sg.openSince.fromCreated ? ' (opened)' : ''); // The shared Merge gate word hides 080 vs 095 vs 100; the chevron tooltip carries it. // With merge_gate in the payload the sentence is the gate's own @@ -565,7 +577,7 @@ request still on the wire) is a different thing drawn on the chevron; this badge appears once the server has recorded the action. */ const STAGE_TRACKER_ACTED_LABELS = { - approve: 'Approve', 'give-direction': 'Give direction', 'close-superseded': 'Close as superseded', wontfix: "Close as won't-fix", + approve: 'Approve', 'give-direction': 'Give direction', 'close-superseded': 'Close as superseded', wontfix: "Close as won't-fix", 'close-read': 'Closed (read)', 'let-hive-decide': 'Let hive decide', hold: 'Hold', release: 'Release hold', 'accept-triage': 'Accept triage', 'mark-needs-human': 'Mark needs-human', 'merge-now': 'Approve & merge as maintainer', 'queue-merge': 'Approve — let hive merge', adopt: 'Adopt', 'adopt-now': 'Adopt now', reroute: 'Reroute to another clanker', @@ -679,7 +691,7 @@ } // Row-menu action id each ledger action was submitted under, so the // option the owner just took is not offered back to them. - const STAGE_TRACKER_ACTED_OPTION_ID = { 'let-hive-decide': 'decide:delegate', approve: 'decide:approve', 'give-direction': 'decide:direction', 'close-superseded': 'decide:close-superseded', wontfix: 'decide:close-wontfix', 'accept-triage': 'accept-triage', hold: 'hold', 'merge-now': 'decide:merge-now', 'queue-merge': 'decide:queue-merge', 're-author': 'decide:re-author', adopt: 'decide:adopt', 'adopt-now': 'decide:adopt-now', reroute: 'decide:reroute' }; + const STAGE_TRACKER_ACTED_OPTION_ID = { 'let-hive-decide': 'decide:delegate', approve: 'decide:approve', 'give-direction': 'decide:direction', 'close-superseded': 'decide:close-superseded', wontfix: 'decide:close-wontfix', 'close-read': 'decide:close-read', 'accept-triage': 'accept-triage', hold: 'hold', 'merge-now': 'decide:merge-now', 'queue-merge': 'decide:queue-merge', 're-author': 'decide:re-author', adopt: 'decide:adopt', 'adopt-now': 'decide:adopt-now', reroute: 'decide:reroute' }; // Pure: what the owner can still do when their action changed nothing // (no-op) or the item has not moved (stuck): the enabled options from // the row's decision_needed payload, minus the one just taken. diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index d328b0f0ab..7bdf783755 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -347,6 +347,8 @@ const holdLabels = stageTrackerHoldLabels(item); if (mods.indexOf('stalled') >= 0) return 'Stalled'; if (mods.indexOf('regressed') >= 0 && !stageTrackerRegressionHandled(item)) return 'Sent back'; + // Advisory (hivecommons/hive#15381): the chip is the headline. + if (n === 0 && item.kind !== 'pr' && item.advisory && typeof item.advisory === 'object') return item.advisory.chip || 'Advisory · read & close'; if (n === 0 && mods.indexOf('hold') >= 0) return 'Open · on hold' + (holdLabels.length ? ' (' + holdLabels.join(', ') + ')' : ''); if (n === 0 && mods.indexOf('blocked') >= 0) return 'Open · blocked'; if (n === 0 && mods.indexOf('draft') >= 0) return 'Open · draft'; diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 2428f0540b..834b3aceab 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1627,6 +1627,10 @@ it a move but the next pass" (hivecommons/hive#15094). */ .ham-seg.active.ham-open-new { background: var(--blue); color: var(--surface-0); } .ham-seg.active.ham-open-new .ham-seg-t::before { content: '✦'; margin-right: var(--sp-1); } + /* Advisory (hivecommons/hive#15381): a note for maintainers, not + work — muted, never stale-tinted, read then close. */ + .ham-seg.active.ham-open-advisory { background: var(--surface-2); color: var(--muted); } + .ham-seg.active.ham-open-advisory .ham-seg-t::before { content: 'ⓘ'; margin-right: var(--sp-1); } .ham-seg.active.ham-open-stale { background: color-mix(in srgb, var(--amber) 65%, var(--red)); } .ham-detour { white-space: normal; overflow-wrap: anywhere; } .ham-current-stage { display: none; margin: 0; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; } @@ -14480,6 +14484,8 @@

Where to get help

const holdLabels = stageTrackerHoldLabels(item); if (mods.indexOf('stalled') >= 0) return 'Stalled'; if (mods.indexOf('regressed') >= 0 && !stageTrackerRegressionHandled(item)) return 'Sent back'; + // Advisory (hivecommons/hive#15381): the chip is the headline. + if (n === 0 && item.kind !== 'pr' && item.advisory && typeof item.advisory === 'object') return item.advisory.chip || 'Advisory · read & close'; if (n === 0 && mods.indexOf('hold') >= 0) return 'Open · on hold' + (holdLabels.length ? ' (' + holdLabels.join(', ') + ')' : ''); if (n === 0 && mods.indexOf('blocked') >= 0) return 'Open · blocked'; if (n === 0 && mods.indexOf('draft') >= 0) return 'Open · draft'; @@ -15361,19 +15367,22 @@

Where to get help

// 000-new: the payload says nothing has placed the item yet and // names who moves it next (hivecommons/hive#15094). const openNew = n === 0 && state === 'active' && !openHold && !openBlocked && !openDraft && typeof stageTrackerNewState === 'function' && !!stageTrackerNewState(item); + const advisory = n === 0 && state === 'active' && !openHold && !openBlocked && typeof stageTrackerAdvisoryOf === 'function' ? stageTrackerAdvisoryOf(item) : null; if (openHold) word = 'Open · hold'; else if (openBlocked) word = 'Open · blocked'; + else if (advisory) word = advisory.chip || 'Advisory · read & close'; else if (openDraft) word = 'Draft'; else if (openNew) word = 'New'; // A plain, blocked or draft Open step (no stage label, not held) // says how long it has sat there, from the same instant the since - // column shows — a stale blocked item is exactly what should stand out. + // column shows — a stale blocked item is exactly what should stand + // out. An advisory never does: nothing waits on it. let openSince = null; - if (n === 0 && state === 'active' && !openHold && !detour && nowMs) { + if (n === 0 && state === 'active' && !openHold && !advisory && !detour && nowMs) { const os = stageTrackerOpenSince(item); if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: !openDraft && nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); } } - return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew, openSince }; + return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, isNew: openNew && !advisory, advisory: !!advisory, openSince }; }); segs.push({ number: STAGE_TRACKER_TERMINAL, code: '', short: 'Merged', label: 'Merged', description: 'Merged — the pipeline is complete', state: terminal ? 'active' : 'todo', terminal, cap: true, detour: null }); return segs; @@ -15473,6 +15482,14 @@

Where to get help

return state + (sa.kind === 'bot' ? ' · bot PR' : ' · nobody on it'); } + // Advisory (hivecommons/hive#15381): a payload `advisory` block means + // the issue is a note for maintainers, not work — the chevron word is + // its chip, it never reads stale or "since Nh", and the row action is + // Close (read). Pure so the fixture tests can lift it by name. + function stageTrackerAdvisoryOf(item) { + if (!item || item.kind === 'pr' || !item.advisory || typeof item.advisory !== 'object') return null; + return item.advisory; + } // 000-new (hivecommons/hive#15094): a payload `new` block on a stage-0 // row means nothing has placed the item yet. These are pure so the // fixture tests can lift them by name. @@ -15563,7 +15580,7 @@

Where to get help

if (sg.number < from || sg.number > to) return ``; const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; if (active) { @@ -15571,6 +15588,7 @@

Where to get help

if (sg.blocked) tip += ' — ' + stageTrackerBlockedTip(item); if (sg.draft) tip += ' — ' + STAGE_TRACKER_DRAFT_TIP; if (sg.isNew && typeof stageTrackerNewLines === 'function') tip = 'New — ' + stageTrackerNewLines(item, nowMs).join(' — '); + if (sg.advisory) tip = (item.advisory && item.advisory.caption) || 'Advisory for maintainers · read, then close'; if (sg.openSince) tip += ' — open since ' + new Date(sg.openSince.ms).toISOString() + (sg.openSince.fromCreated ? ' (opened)' : ''); // The shared Merge gate word hides 080 vs 095 vs 100; the chevron tooltip carries it. // With merge_gate in the payload the sentence is the gate's own @@ -15857,7 +15875,7 @@

Where to get help

request still on the wire) is a different thing drawn on the chevron; this badge appears once the server has recorded the action. */ const STAGE_TRACKER_ACTED_LABELS = { - approve: 'Approve', 'give-direction': 'Give direction', 'close-superseded': 'Close as superseded', wontfix: "Close as won't-fix", + approve: 'Approve', 'give-direction': 'Give direction', 'close-superseded': 'Close as superseded', wontfix: "Close as won't-fix", 'close-read': 'Closed (read)', 'let-hive-decide': 'Let hive decide', hold: 'Hold', release: 'Release hold', 'accept-triage': 'Accept triage', 'mark-needs-human': 'Mark needs-human', 'merge-now': 'Approve & merge as maintainer', 'queue-merge': 'Approve — let hive merge', adopt: 'Adopt', 'adopt-now': 'Adopt now', reroute: 'Reroute to another clanker', @@ -15971,7 +15989,7 @@

Where to get help

} // Row-menu action id each ledger action was submitted under, so the // option the owner just took is not offered back to them. - const STAGE_TRACKER_ACTED_OPTION_ID = { 'let-hive-decide': 'decide:delegate', approve: 'decide:approve', 'give-direction': 'decide:direction', 'close-superseded': 'decide:close-superseded', wontfix: 'decide:close-wontfix', 'accept-triage': 'accept-triage', hold: 'hold', 'merge-now': 'decide:merge-now', 'queue-merge': 'decide:queue-merge', 're-author': 'decide:re-author', adopt: 'decide:adopt', 'adopt-now': 'decide:adopt-now', reroute: 'decide:reroute' }; + const STAGE_TRACKER_ACTED_OPTION_ID = { 'let-hive-decide': 'decide:delegate', approve: 'decide:approve', 'give-direction': 'decide:direction', 'close-superseded': 'decide:close-superseded', wontfix: 'decide:close-wontfix', 'close-read': 'decide:close-read', 'accept-triage': 'accept-triage', hold: 'hold', 'merge-now': 'decide:merge-now', 'queue-merge': 'decide:queue-merge', 're-author': 'decide:re-author', adopt: 'decide:adopt', 'adopt-now': 'decide:adopt-now', reroute: 'decide:reroute' }; // Pure: what the owner can still do when their action changed nothing // (no-op) or the item has not moved (stuck): the enabled options from // the row's decision_needed payload, minus the one just taken. @@ -17082,6 +17100,8 @@

Where to get help

function stageTrackerNeedsAttention(item) { const mods = Array.isArray(item.modifiers) ? item.modifiers : []; const n = Number(item.stage) || 0; + // An advisory is a note, not work (hivecommons/hive#15381). + if (item && item.advisory) return false; if (stageTrackerRegressionHandled(item)) return false; return mods.length > 0 || STAGE_TRACKER_ATTENTION_STAGES.indexOf(n) >= 0; } @@ -17124,7 +17144,7 @@

Where to get help

// 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; + if (!item || item.advisory || 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; @@ -17943,6 +17963,7 @@

All labels

const STAGE_TRACKER_ACTION_LABELS = { 'decide:delegate': 'Let hive decide', 'decide:delegate-all': 'Let hive decide — all PRs', 'decide:delegate:rerun': 'Re-run decision', 'decide:approve': 'Approve', 'decide:direction': 'Give direction', 'decide:close-superseded': 'Close as superseded by', 'decide:close-wontfix': "Close as won't-fix", + 'decide:close-read': 'Close (read)', 'decide:adopt': 'Adopt (hive takes over)', 'decide:merge-now': 'Approve & merge as maintainer', 'decide:queue-merge': 'Approve — let hive merge', 'decide:re-author': 'Re-author as hive PR', @@ -18299,6 +18320,11 @@

All labels

// hold): the ask the row makes has its answer first. const triage = stageTrackerTriageNeeded(item); if (triage) out.push({ id: 'accept-triage', label: 'Accept triage', hint: stageTrackerTriageHint(item, ctx, ctx.nowMs, ctx.governor), enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, lead: true }); + // An advisory issue (hivecommons/hive#15381) asks for one thing: + // read it, then close it. "Close (read)" leads; it is the existing + // decision close path with the verdict `close-read`. + const advisory = typeof stageTrackerAdvisoryOf === 'function' ? stageTrackerAdvisoryOf(item) : null; + if (advisory) out.push(Object.assign({ id: 'decide:close-read', label: STAGE_TRACKER_ACTION_LABELS['decide:close-read'], hint: advisory.empty ? 'nothing found · closes as completed' : 'advisory acknowledged · closes as completed', lead: true }, stageTrackerActionAllowed('decide:close-read', ctx))); for (const a of lead) out.push(a); if (target) { const on = target === item ? '' : ' PR #' + (Number(target.number) || 0); @@ -19341,6 +19367,8 @@

All labels

const v = await stageTrackerAsk(id, 'prompt', { title: stageTrackerActionLabel(id), label: 'Comment for ' + refs + ' (optional)', placeholder: 'Why this is closed', confirmLabel: 'Close' }); return v == null ? null : { comment: v }; } + case 'decide:close-read': + return (await stageTrackerAsk(id, 'confirm', { title: 'Close (read)', message: 'Close ' + refs + ' as read, as ' + who + '? It is an advisory for maintainers — nothing waits on it; the issue closes as completed with a note that you read it.', confirmLabel: 'Close' })) ? {} : null; case 'decide:merge-now': { const base = items.map(it => it.base_ref || '').filter(Boolean)[0] || 'its base branch'; if (items.some(stageTrackerNeedsRebase)) { @@ -19418,7 +19446,7 @@

All labels

const STAGE_TRACKER_ACTING_CAPTIONS = { 'hold': 'Holding…', 'release': 'Releasing hold…', 'retry': 'Re-evaluating…', 'needs-human': 'Marking needs-human…', 'accept-triage': 'Accepting triage…', 'blocker:recheck': 'Checking App permissions…', 'blocker:close-partial': 'Closing as partial…', - 'decide:delegate': 'Hive deciding…', 'decide:delegate-all': 'Hive deciding each PR…', 'decide:delegate:rerun': 'Hive deciding again…', 'decide:approve': 'Approving…', 'decide:direction': 'Recording direction…', 'decide:close-superseded': 'Closing…', 'decide:close-wontfix': 'Closing…', + 'decide:delegate': 'Hive deciding…', 'decide:delegate-all': 'Hive deciding each PR…', 'decide:delegate:rerun': 'Hive deciding again…', 'decide:approve': 'Approving…', 'decide:direction': 'Recording direction…', 'decide:close-superseded': 'Closing…', 'decide:close-wontfix': 'Closing…', 'decide:close-read': 'Closing…', 'decide:merge-now': 'Merging…', 'decide:queue-merge': 'Queuing for merge…', 'decide:re-author': 'Queuing re-authoring…', 'decide:merge-now': 'Merging…', 'decide:queue-merge': 'Queuing for merge…', 'decide:adopt': 'Adopting…', 'decide:adopt-now': 'Adopting now…', 'decide:reroute': 'Rerouting…', diff --git a/src/pkg/github/attribution.go b/src/pkg/github/attribution.go index 5b29679115..5aa2362177 100644 --- a/src/pkg/github/attribution.go +++ b/src/pkg/github/attribution.go @@ -45,6 +45,10 @@ const ( // required "Gap vs existing" section. The detail names the match so the // refusal is visible to operators, not just in the agent's bead store. AuditActionAgentIssuePriorArtRefused = "agent_issue_prior_art_refused" + // AuditActionAgentIssueEmptyAdvisoryRefused: the relay refused an + // issue-create whose body is a dedupe checklist with nothing actionable + // in it (hivecommons/hive#15381). + AuditActionAgentIssueEmptyAdvisoryRefused = "agent_issue_empty_advisory_refused" // AuditActionHiveIssueCreated is the audit action recorded when the hive // itself creates an issue (advisory issue, ACMM-gap issue). AuditActionHiveIssueCreated = "hive_issue_created" diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index 75eafc815c..9927550a53 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -4633,6 +4633,10 @@ type RepoWorkIssue struct { // RecheckDone is set once the soak triage has stamped // `` into the body (hivecommons/hive#13311). RecheckDone bool `json:"recheck_done,omitempty"` + // Advisory is the body-derived advisory classification (dedupe + // checklist marker, "Decision required: no"), read here because the + // body itself is not carried (hivecommons/hive#15381). + Advisory *IssueAdvisory `json:"advisory,omitempty"` } func repoWorkIssueFromIssue(issue Issue, bucket, reason string) RepoWorkIssue { @@ -4657,6 +4661,7 @@ func repoWorkIssueFromIssue(issue Issue, bucket, reason string) RepoWorkIssue { Children: issue.Children, TrackerProgress: progress, IsTracker: RendersAsTracker(issue.IsTracker, issue.Labels, progress), + Advisory: IssueAdvisoryFromBody(issue.Body), } } @@ -4691,6 +4696,7 @@ func repoWorkIssue(repo string, issue *gh.Issue, labels []string, bucket, reason TrackerProgress: progress, Bucket: bucket, Reason: reason, + Advisory: IssueAdvisoryFromBody(issue.GetBody()), } } diff --git a/src/pkg/github/dedupe_checklist_findings.go b/src/pkg/github/dedupe_checklist_findings.go new file mode 100644 index 0000000000..5421bd7eb9 --- /dev/null +++ b/src/pkg/github/dedupe_checklist_findings.go @@ -0,0 +1,135 @@ +package github + +import ( + "fmt" + "regexp" + "strconv" + "strings" +) + +// DedupeChecklistFindings is what a dedupe-agent checklist body asks a +// maintainer to DO, read off the body alone: the verdict on line two, the +// counts the Summary sentence states, and the `- [ ] #N` task lines the +// policy requires for every recommended action. A checklist with no action +// in it — no near-duplicate pair, no item to close as resolved, no missing +// PR↔issue link, no task line, verdict "no" — is a triage pass that found +// nothing, and the policy says such a pass files nothing: a merge-order +// reminder already declared in the PR body and a "related but distinct" +// cross-link are notes, not work (hivecommons/hive#15381 sat open for hours +// as "Open · since 3h" with exactly that content). +type DedupeChecklistFindings struct { + // Repo is the owner/repo the marker names ("" when malformed). + Repo string + // DecisionRequired is true when line two says "Decision required: yes". + DecisionRequired bool + // NearDuplicates, Resolved and MissingLinks are the Summary counts + // ("Found near-duplicate pairs, … items that appear already + // resolved", " missing PR↔issue links"); 0 when absent. + NearDuplicates int + Resolved int + MissingLinks int + // Clusters is the same-root-cause cluster count. It is informational: + // a cluster row that asks for a close carries a task line, and one + // that only cross-links is not an action. + Clusters int + // TaskItems counts the `- [ ]` lines: every recommended action is one. + TaskItems int +} + +// dedupeChecklistCountPatterns read the Summary sentence's counts. Each +// pattern captures the integer that precedes the phrase. +var ( + dedupeCountNearDupPattern = regexp.MustCompile(`(?i)\b(\d+)\s+near-duplicate`) + dedupeCountClusterPattern = regexp.MustCompile(`(?i)\b(\d+)\s+same-root-cause`) + dedupeCountResolvedPattern = regexp.MustCompile(`(?i)\b(\d+)\s+(?:items?\s+(?:that\s+)?(?:appear\s+)?(?:to\s+be\s+)?)?(?:already\s+)?resolved`) + dedupeCountLinksPattern = regexp.MustCompile(`(?i)\b(\d+)\s+missing\s+PR\s*(?:↔|<->|->|/|-|to)\s*issue\s+links?`) + dedupeTaskLinePattern = regexp.MustCompile(`(?m)^\s*[-*]\s+\[ \]`) +) + +// ParseDedupeChecklistFindings reports whether body is a dedupe-agent +// checklist (it opens with the `` +// marker) and, when it is, what the checklist asks for. Fenced code blocks +// are ignored so a template quoted in the body does not count as a finding. +func ParseDedupeChecklistFindings(body string) (DedupeChecklistFindings, bool) { + repo, verdict, ok := parseDedupeChecklist(body) + if !ok { + return DedupeChecklistFindings{}, false + } + f := DedupeChecklistFindings{Repo: repo, DecisionRequired: verdict == dedupeVerdictYes} + text := stripFencedCode(htmlCommentPattern.ReplaceAllString(body, "")) + f.NearDuplicates = dedupeChecklistCount(dedupeCountNearDupPattern, text) + f.Clusters = dedupeChecklistCount(dedupeCountClusterPattern, text) + f.Resolved = dedupeChecklistCount(dedupeCountResolvedPattern, text) + f.MissingLinks = dedupeChecklistCount(dedupeCountLinksPattern, text) + f.TaskItems = len(dedupeTaskLinePattern.FindAllStringIndex(text, -1)) + return f, true +} + +// Actionable reports whether the checklist asks a maintainer to close, +// relabel or edit anything. A verdict of "yes", any task line, or a +// positive near-duplicate / resolved / missing-link count is an action; +// clusters, merge-order notes and cross-links are not. +func (f DedupeChecklistFindings) Actionable() bool { + return f.DecisionRequired || f.TaskItems > 0 || f.NearDuplicates > 0 || f.Resolved > 0 || f.MissingLinks > 0 +} + +// Summary is the one-line digest of the counts, for logs and beads. +func (f DedupeChecklistFindings) Summary() string { + verdict := "no" + if f.DecisionRequired { + verdict = "yes" + } + return fmt.Sprintf("decision required: %s; %d near-duplicate pair(s), %d same-root-cause cluster(s), %d resolved, %d missing PR↔issue link(s), %d task line(s)", + verdict, f.NearDuplicates, f.Clusters, f.Resolved, f.MissingLinks, f.TaskItems) +} + +// IssueAdvisory is the body-derived part of "this issue is a maintainer +// advisory, not work", carried on an enumerated issue so the stage tracker +// can draw it without the body (the sidelined work-detail rows have none). +type IssueAdvisory struct { + // DedupeChecklist is true when the body opens with the dedupe-checklist + // marker; DecisionNo when its verdict line says "Decision required: no". + DedupeChecklist bool `json:"dedupe_checklist,omitempty"` + DecisionNo bool `json:"decision_no,omitempty"` + // Empty is true when the body is a dedupe checklist with nothing + // actionable in it (DedupeChecklistFindings.Actionable is false). + Empty bool `json:"empty,omitempty"` +} + +// dedupeDecisionNoLinePattern finds a "Decision required: no" line anywhere +// near the top of a body that lacks the marker (an advisory a different +// lane wrote by hand to the same convention). +var dedupeDecisionNoLinePattern = regexp.MustCompile(`(?im)^\s*decision required:\s*no\b`) + +// IssueAdvisoryFromBody classifies body; nil when it is neither a dedupe +// checklist nor carries a "Decision required: no" line. +func IssueAdvisoryFromBody(body string) *IssueAdvisory { + if strings.TrimSpace(body) == "" { + return nil + } + if f, ok := ParseDedupeChecklistFindings(body); ok { + return &IssueAdvisory{DedupeChecklist: true, DecisionNo: !f.DecisionRequired, Empty: !f.Actionable()} + } + if dedupeDecisionNoLinePattern.MatchString(stripFencedCode(body)) { + return &IssueAdvisory{DecisionNo: true} + } + return nil +} + +func dedupeChecklistCount(re *regexp.Regexp, text string) int { + total := 0 + for _, m := range re.FindAllStringSubmatch(text, -1) { + n, err := strconv.Atoi(m[1]) + if err != nil { + continue + } + total += n + } + return total +} + +var fencedCodePattern = regexp.MustCompile("(?s)```.*?```") + +func stripFencedCode(s string) string { + return fencedCodePattern.ReplaceAllString(s, "") +} diff --git a/src/pkg/github/dedupe_checklist_findings_test.go b/src/pkg/github/dedupe_checklist_findings_test.go new file mode 100644 index 0000000000..9f478329cd --- /dev/null +++ b/src/pkg/github/dedupe_checklist_findings_test.go @@ -0,0 +1,192 @@ +package github + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "strings" + "testing" +) + +// The real body of hivecommons/hive#15381: a dedupe pass that found 0 +// near-duplicate pairs and 0 missing links, filed anyway on the strength of +// a merge-order reminder and a cross-link note, and shown as stalled work +// for hours. +func dedupeChecklist15381(t *testing.T) string { + t.Helper() + b, err := os.ReadFile(filepath.Join("testdata", "dedupe_checklist_15381.md")) + if err != nil { + t.Fatal(err) + } + return string(b) +} + +const dedupeChecklistActionable = ` +Decision required: yes + +## Summary + +Found 1 near-duplicate pairs, 0 same-root-cause clusters, 1 items that appear already resolved, and 2 missing PR↔issue links. + +## Near-duplicates (close one) + +- [ ] #12 duplicates #10 — close #12 + +## Already resolved + +- [ ] #20 — fixed by merged PR #19 + +## Missing links + +- [ ] PR #30 → add ` + "`Fixes #29`" + ` +- [ ] PR #31 → add ` + "`Fixes #28`" + ` +` + +func TestParseDedupeChecklistFindings(t *testing.T) { + f, ok := ParseDedupeChecklistFindings(dedupeChecklist15381(t)) + if !ok { + t.Fatal("#15381 body not recognised as a dedupe checklist") + } + want := DedupeChecklistFindings{Repo: "hivecommons/hive", Clusters: 1} + if f != want { + t.Errorf("#15381 findings = %+v, want %+v", f, want) + } + if f.Actionable() { + t.Error("#15381 (0 pairs, 0 missing links, no task lines, decision no) must not be actionable") + } + if !strings.Contains(f.Summary(), "0 near-duplicate pair(s)") || !strings.Contains(f.Summary(), "decision required: no") { + t.Errorf("summary = %q", f.Summary()) + } + + f, ok = ParseDedupeChecklistFindings(dedupeChecklistActionable) + if !ok { + t.Fatal("actionable body not recognised") + } + want = DedupeChecklistFindings{Repo: "o/r", DecisionRequired: true, NearDuplicates: 1, Resolved: 1, MissingLinks: 2, TaskItems: 4} + if f != want { + t.Errorf("actionable findings = %+v, want %+v", f, want) + } + if !f.Actionable() { + t.Error("a checklist with task lines must be actionable") + } + + // Each single signal is enough on its own; the template quoted in a + // fence is not. + for name, body := range map[string]string{ + "task line only": "\nDecision required: no\n\nFound 0 near-duplicate pairs.\n\n- [ ] #5 → add `Fixes #4`\n", + "verdict yes only": "\nDecision required: yes\n\nSee above.\n", + "missing links only": "\nDecision required: no\n\nFound 0 near-duplicate pairs and 3 missing PR↔issue links.\n", + } { + if f, ok := ParseDedupeChecklistFindings(body); !ok || !f.Actionable() { + t.Errorf("%s: ok=%v actionable=%v (%+v)", name, ok, f.Actionable(), f) + } + } + fenced := "\nDecision required: no\n\nFound 0 near-duplicate pairs.\n\n```\n- [ ] #5 example\nFound 2 missing PR↔issue links\n```\n" + if f, _ := ParseDedupeChecklistFindings(fenced); f.Actionable() { + t.Errorf("fenced template counted as findings: %+v", f) + } + if _, ok := ParseDedupeChecklistFindings("## Summary\n\nFound 0 near-duplicate pairs."); ok { + t.Error("a body without the marker is not a checklist") + } +} + +func TestIssueAdvisoryFromBody(t *testing.T) { + got := IssueAdvisoryFromBody(dedupeChecklist15381(t)) + if got == nil || !got.DedupeChecklist || !got.DecisionNo || !got.Empty { + t.Errorf("#15381 advisory = %+v, want checklist+decision-no+empty", got) + } + got = IssueAdvisoryFromBody(dedupeChecklistActionable) + if got == nil || !got.DedupeChecklist || got.DecisionNo || got.Empty { + t.Errorf("actionable advisory = %+v, want checklist, decision yes, not empty", got) + } + got = IssueAdvisoryFromBody("Some lane's note\nDecision required: no\n\nFYI only.") + if got == nil || got.DedupeChecklist || !got.DecisionNo || got.Empty { + t.Errorf("hand-written advisory = %+v, want decision-no only", got) + } + if IssueAdvisoryFromBody("Please fix the relay.") != nil || IssueAdvisoryFromBody("") != nil { + t.Error("ordinary bodies are not advisories") + } +} + +// The relay refuses `issue-create` for an empty dedupe checklist, records +// the audit + a bead, and consumes the request; an actionable checklist is +// filed as before. +func TestIssueRequestWatcher_EmptyDedupeAdvisoryRefused(t *testing.T) { + cases := []struct { + name string + body string + wantCreated bool + }{ + {"#15381 body is refused", "", false}, + {"actionable checklist is filed", dedupeChecklistActionable, true}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + body := tc.body + if body == "" { + body = dedupeChecklist15381(t) + } + var bodies []string + srv := newPriorArtIssueMockServer(t, &bodies) + defer srv.Close() + c := issueTestClient(t, srv.URL) + dir := withIssueDir(t) + + var audits []AuditRecord + c.SetAttributionAuditRecord(func(rec AuditRecord) { + if rec.Action == AuditActionAgentIssueEmptyAdvisoryRefused { + audits = append(audits, rec) + } + }) + var beads []priorArtBead + c.SetPriorArtFilingGate(nil, nil, func(title, detail, agent, ref string) { + beads = append(beads, priorArtBead{title, detail, agent, ref}) + }) + + reqPath, err := WriteIssueRequest(dir, IssueRequest{ + Repo: "o/r", Title: "triage: duplicate and overlapping open issues/PRs to consolidate", Body: body, + Labels: []string{"agent/dedupe", "triage/advisory"}, Agent: "dedupe", + }) + if err != nil { + t.Fatal(err) + } + c.ProcessIssueRequestsOnce(context.Background()) + + if got := len(bodies) == 1; got != tc.wantCreated { + t.Fatalf("created = %v (%d creates), want %v", got, len(bodies), tc.wantCreated) + } + if _, err := os.Stat(reqPath); !os.IsNotExist(err) { + t.Errorf("request file should be consumed") + } + var res IssueResponse + b, err := os.ReadFile(strings.TrimSuffix(reqPath, ".json") + ".result.json") + if err != nil { + t.Fatalf("result file missing: %v", err) + } + if err := json.Unmarshal(b, &res); err != nil { + t.Fatal(err) + } + if res.OK != tc.wantCreated { + t.Errorf("result OK = %v, want %v (%+v)", res.OK, tc.wantCreated, res) + } + if tc.wantCreated { + if len(audits) != 0 || len(beads) != 0 { + t.Errorf("actionable checklist audited/beaded as empty: %d/%d", len(audits), len(beads)) + } + return + } + for _, want := range []string{"not filed", "no actionable findings", "0 near-duplicate pair(s)", "0 missing PR↔issue link(s)", "kick output"} { + if !strings.Contains(res.Error, want) { + t.Errorf("result error %q missing %q", res.Error, want) + } + } + if len(audits) != 1 || audits[0].Agent != "dedupe" || audits[0].Repo != "o/r" || !strings.Contains(audits[0].Detail, "0 near-duplicate") { + t.Errorf("audits = %+v", audits) + } + if len(beads) != 1 || beads[0].agent != "dedupe" || beads[0].ref != "o/r" || !strings.Contains(beads[0].title, "found nothing to act on") { + t.Errorf("beads = %+v", beads) + } + }) + } +} diff --git a/src/pkg/github/issue_request_watcher.go b/src/pkg/github/issue_request_watcher.go index ba80d4a3cc..bd46a6545b 100644 --- a/src/pkg/github/issue_request_watcher.go +++ b/src/pkg/github/issue_request_watcher.go @@ -553,6 +553,23 @@ func (c *Client) handleOneIssueRequest(ctx context.Context, path string, nowFn f body = withParentMarker(body, req.Parent) } if kind == "issue" { + // An empty dedupe checklist is not an issue (hivecommons/hive#15381): + // a pass that found nothing to act on goes to the hive's own log, + // not to the maintainers' queue. Terminal, like a prior-art refusal. + if f, isChecklist := ParseDedupeChecklistFindings(body); isChecklist && !f.Actionable() { + refusal := "not filed: dedupe checklist has no actionable findings (" + f.Summary() + "); merge-order reminders, cross-links and checked-not-duplicates are notes, not work — report them in your kick output instead" + c.recordWriteAudit(AuditActionAgentIssueEmptyAdvisoryRefused, meta, + WriteTarget{Repo: req.Repo}, "findings", f.Summary()) + if c.priorArtFilingRecord != nil { + c.priorArtFilingRecord("dedupe pass found nothing to act on: "+strings.TrimSpace(req.Title), f.Summary(), req.Agent, req.Repo) + } + c.logger.Info("issue-request watcher: refused empty dedupe advisory", + slog.String("repo", req.Repo), slog.String("agent", req.Agent), slog.String("findings", f.Summary())) + c.writeIssueResult(path, IssueResponse{OK: false, Error: refusal, At: nowFn().UTC().Format(time.RFC3339)}) + _ = os.Remove(path) + c.issueClearRetry(path) + return + } // Prior-art filing verdict (hivecommons/hive#13879). A refusal is // terminal: retrying the same request cannot change the match. var refusal string diff --git a/src/pkg/github/standing_issues.go b/src/pkg/github/standing_issues.go index 7a45928354..4a4619124e 100644 --- a/src/pkg/github/standing_issues.go +++ b/src/pkg/github/standing_issues.go @@ -20,6 +20,10 @@ var botControlPanelTitleFragments = []string{"dependency dashboard", "renovate d // out of the held bucket; it is counted as a hive advisory report. const dedupeAdvisoryLabelName = "triage/advisory" +// DedupeAdvisoryLabelName is dedupeAdvisoryLabelName for the dashboard's +// stage tracker, which classifies issues wearing it as advisories. +const DedupeAdvisoryLabelName = dedupeAdvisoryLabelName + // standingMetaIssueReason preserves the diagnostic predicate introduced by // #6158 while the typed classifier lets the repository breakdown distinguish // advisory reports from dependency dashboards without reimplementing policy. diff --git a/src/pkg/github/testdata/dedupe_checklist_15381.md b/src/pkg/github/testdata/dedupe_checklist_15381.md new file mode 100644 index 0000000000..9530d52c8b --- /dev/null +++ b/src/pkg/github/testdata/dedupe_checklist_15381.md @@ -0,0 +1,63 @@ + +Decision required: no + +## Summary + +Triage pass over the 28 open issues and 12 open PRs in hivecommons/hive as of +2026-10-29. Found 0 near-duplicate pairs, 1 stacked-PR merge-order dependency, +1 same-root-cause family worth cross-referencing, and 0 missing PR↔issue links +(all 11 non-stacked open PRs carry a closing keyword). No actions have been +taken; this is a checklist for maintainers. Inventory note: `gh search prs` +returned an empty index for this repo, so the PR inventory comes from the hive +actionable snapshot (13 PR rows, 2026-10-29T07:32 ET) plus the held PR #15303; +issues from search (28 of 28). + +## Conflicting PRs: merge order matters + +- #15380 is stacked on #15308 (its base branch *is* #15308's head + `hive/adopt-15226`; it edits `automerge_native_queue.go`, + `derive_pr_classify.go`, `prstage/reasons.go` that only exist in #15308). + Merge #15308 first, then retarget/merge #15380 — already declared in + #15380's body, so this is a sequencing reminder only. + +## Related but distinct: cross-link only + +- #15311 and #15313 — two `agent_pane_timeout`-family self-reports filed the + same day by the same bot, but different findings: #15311 is the truncated + `tail_500` pane excerpt (fixed by PR #15319, `Closes #15311`), #15313 is the + pre-restart kick-undeliverable WARN flood (fixed by PR #15315, + `Fixes #15313`). Not duplicates; each has its own PR. +- PRs #15315 and #15374 both edit `src/pkg/fleetreport/fleetreport.go`, but in + disjoint functions (`benignSubstrings` @787 vs `IsGitHubUpstreamUnavailable`/ + `IsBenignMessage` @853–894). No semantic overlap; whichever lands second gets + a trivial context-shift rebase at most. +- PRs #15319 and #15374 both edit `slogfeed/slogfeed_test.go`, in disjoint + tests (@76 vs @571). Not duplicates. +- Issues #15364 (rate-limited label reconciliation WARNs), #15369 (gateway + errors counted), #15376 (missing review-verdict artifact warns) plus #15313 + are one symptom family — benign operational noise crossing the fleet + self-report threshold — with four separate single-site fixes (PRs #15367, + #15374, #15378, #15315). Sites are distinct; no consolidation needed, just + awareness that they all tune the same classifier/threshold machinery. + +## Checked and not duplicates + +- #15340 vs #15182 — near-identical reviewer-backlog titles ("Previous + security finding … unchanged"), but different findings on different PRs: + #15340 tracks the run-time script fetch in + `.github/workflows/crux-file-size-ratchet.yml:48` (blocked on open PR + #15332); #15182 tracks `src/pkg/rebasemerge/rebasemerge.go` from PR #15104. +- PR↔issue pairs verified (closing keyword present in each PR body): + #15307→#15133, #15308→#15198 (also supersedes closed #15226), #15312→#15273 + (body also covers the #15155 duplicate), #15315→#15313, #15319→#15311, + #15324→#15320, #15332→#15331 (Refs #15330), #15343→#15338, #15367→#15364, + #15374→#15369, #15378→#15376, #15380→#15377. Nothing to add. + +--- +*Filed by dedupe agent (issues-only mode). Recommendations only — nothing has been closed, labelled, or merged.* + +--- +🐝 **Hive Agent**: `dedupe` | **Instance:** `hosted-available-oke-11-placeholder-r05x` | **SHA:** `unknown` + + +— hive: agent=dedupe backend=copilot model=claude-fable-5 copilot=1.0.88 \ No newline at end of file diff --git a/src/pkg/policies/dedupe_policy_test.go b/src/pkg/policies/dedupe_policy_test.go index cbdb021e93..8731daf091 100644 --- a/src/pkg/policies/dedupe_policy_test.go +++ b/src/pkg/policies/dedupe_policy_test.go @@ -67,6 +67,17 @@ func TestDedupePolicyShips(t *testing.T) { if !strings.Contains(body, "\nDecision required: \n") { t.Error("dedupe-issues.md template must put the Decision required verdict directly under the marker line") } + // An advisory-only pass never opens a new checklist (hivecommons/hive#15381): + // merge-order reminders and cross-links go to the kick output. + for _, want := range []string{ + "every row is advisory** → file nothing", + "never a fresh filing", + "The relay refuses the create for a", + } { + if !strings.Contains(body, want) { + t.Errorf("dedupe-issues.md is missing %q", want) + } + } // Recommendations only: the lane must forbid itself the actions whose // absence makes the two reference checklists (cncf/endusers#1283, diff --git a/src/pkg/policies/defaults/dedupe-issues.md b/src/pkg/policies/defaults/dedupe-issues.md index 372bafed69..c6755715e8 100644 --- a/src/pkg/policies/defaults/dedupe-issues.md +++ b/src/pkg/policies/defaults/dedupe-issues.md @@ -205,8 +205,18 @@ gh search issues --repo --state open --match body "hive:dedupe-chec new ones. If the body changed, post **one** comment summarising the delta ("+2 near-duplicates, −3 resolved since ") so watchers are notified once. If nothing changed, **post nothing** — silence is the correct outcome. -- **No checklist exists and you have at least one verified finding** → open one - with the command below. +- **No checklist exists and you have at least one action-required row** (a + near-duplicate pair, a candidate to close as resolved, a missing PR↔issue + link, a consolidation close — each written as a `- [ ] #N …` task line) → + open one with the command below. +- **No checklist exists and every row is advisory** → file nothing. Merge-order + reminders already declared in a PR body, "related but distinct" cross-links + and "checked and not duplicates" entries are notes, not work: a maintainer + has nothing to do with them, no agent picks them up, and the issue sits in + the dashboard looking like stalled work. Put the notes in your kick output + (one paragraph) and stop. The relay refuses the create for a + dedupe-checklist body whose verdict is `no` with zero near-duplicate pairs, + zero resolved candidates, zero missing links and no task lines. - **No checklist exists and you found nothing** → file nothing. A checklist that says "no duplicates" is noise. @@ -235,7 +245,9 @@ gh issue create --repo --needs-decision \ --body-file /tmp/.md ``` -An **advisory-only** checklist (`Decision required: no`) has nothing to decide, +An **advisory-only** checklist (`Decision required: no`) is only ever the +result of editing an existing checklist in place whose action rows have all +since closed — never a fresh filing. It has nothing to decide, so it is **not** parked: no `--needs-decision`, no "What to reply" notice, no `needs-decision` entry in the dashboard's held bucket. File it with the `triage/advisory` label instead, which keeps it out of the work queue: diff --git a/src/policies/dedupe-issues.md b/src/policies/dedupe-issues.md index 372bafed69..c6755715e8 100644 --- a/src/policies/dedupe-issues.md +++ b/src/policies/dedupe-issues.md @@ -205,8 +205,18 @@ gh search issues --repo --state open --match body "hive:dedupe-chec new ones. If the body changed, post **one** comment summarising the delta ("+2 near-duplicates, −3 resolved since ") so watchers are notified once. If nothing changed, **post nothing** — silence is the correct outcome. -- **No checklist exists and you have at least one verified finding** → open one - with the command below. +- **No checklist exists and you have at least one action-required row** (a + near-duplicate pair, a candidate to close as resolved, a missing PR↔issue + link, a consolidation close — each written as a `- [ ] #N …` task line) → + open one with the command below. +- **No checklist exists and every row is advisory** → file nothing. Merge-order + reminders already declared in a PR body, "related but distinct" cross-links + and "checked and not duplicates" entries are notes, not work: a maintainer + has nothing to do with them, no agent picks them up, and the issue sits in + the dashboard looking like stalled work. Put the notes in your kick output + (one paragraph) and stop. The relay refuses the create for a + dedupe-checklist body whose verdict is `no` with zero near-duplicate pairs, + zero resolved candidates, zero missing links and no task lines. - **No checklist exists and you found nothing** → file nothing. A checklist that says "no duplicates" is noise. @@ -235,7 +245,9 @@ gh issue create --repo --needs-decision \ --body-file /tmp/.md ``` -An **advisory-only** checklist (`Decision required: no`) has nothing to decide, +An **advisory-only** checklist (`Decision required: no`) is only ever the +result of editing an existing checklist in place whose action rows have all +since closed — never a fresh filing. It has nothing to decide, so it is **not** parked: no `--needs-decision`, no "What to reply" notice, no `needs-decision` entry in the dashboard's held bucket. File it with the `triage/advisory` label instead, which keeps it out of the work queue: