diff --git a/changelog.d/fixed-15754-advisory-checklists-autoclose.md b/changelog.d/fixed-15754-advisory-checklists-autoclose.md new file mode 100644 index 0000000000..4a412a924d --- /dev/null +++ b/changelog.d/fixed-15754-advisory-checklists-autoclose.md @@ -0,0 +1 @@ +- Hive-authored dedupe advisory checklists now tick each item once it is closed or merged and close themselves when all are resolved (`dedupe.advisory_autoclose`, default on); their tracker row reads "Advisory · hive is working the items (k/N resolved)" instead of parking on a person, and "Let hive decide" on an issue now says "Approve the direction of #N and let the hive pick it up." diff --git a/src/cmd/hive/close_on_merge_advisory_autoclose_test.go b/src/cmd/hive/close_on_merge_advisory_autoclose_test.go new file mode 100644 index 0000000000..d14fc3b9ef --- /dev/null +++ b/src/cmd/hive/close_on_merge_advisory_autoclose_test.go @@ -0,0 +1,27 @@ +package main + +import ( + "testing" + + "github.com/hivecommons/hive/pkg/config" +) + +// dedupe.advisory_autoclose reaches the close-on-merge backfill +// (hivecommons/hive#15754): unset is on, false turns the item pass off. +func TestCloseOnMergeOptionsAdvisoryAutoclose(t *testing.T) { + off := false + for _, tc := range []struct { + name string + cfg config.Config + wantDisable bool + }{ + {"unset", config.Config{}, false}, + {"off", config.Config{Dedupe: config.DedupeAdvisoryConfig{AdvisoryAutoclose: &off}}, true}, + } { + t.Run(tc.name, func(t *testing.T) { + if got := closeOnMergeOptionsFor(&tc.cfg, nil, nil).DisableAdvisoryAutoclose; got != tc.wantDisable { + t.Fatalf("DisableAdvisoryAutoclose = %v, want %v", got, tc.wantDisable) + } + }) + } +} diff --git a/src/cmd/hive/close_on_merge_sweep.go b/src/cmd/hive/close_on_merge_sweep.go index 0ddeded022..858e30ddbf 100644 --- a/src/cmd/hive/close_on_merge_sweep.go +++ b/src/cmd/hive/close_on_merge_sweep.go @@ -110,6 +110,8 @@ func closeOnMergeOptionsFor(cfg *config.Config, logger *slog.Logger, now func() Now: now, LabelDriven: cfg.RepoLabelDriven, RepoOnGitHub: cfg.RepoOnGitHub, + + DisableAdvisoryAutoclose: !cfg.Dedupe.AdvisoryAutocloseEnabled(), } } diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index c82943212d..aac97e9c74 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -320,6 +320,8 @@ A row that already wears a hold, `blocked`, a draft marker or any stage record i 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). +An advisory is never parked on a person ([#15754](https://github.com/hivecommons/hive/issues/15754)): a dedupe checklist at `stage/045-needs-decision` drops the 045 stage, the *needs-decision* pill and the `decision_needed` / `blocker` blocks. A dedupe checklist with `- [ ]` task lines that the hive resolves itself (`dedupe.advisory_autoclose`, default on — the close-on-merge backfill ticks each item once it is closed or merged and closes the checklist when all are resolved) also carries `advisory.items`, `advisory.resolved`, `working: true` and `lead: "Close now"`: its chip and caption read **Advisory · hive is working the items (k/N resolved)**, the actor is the hive, and the row menu's lead is the optional **Close now** (the same `close-read` decision). + 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 diff --git a/src/docs/labels-and-control-signals/reference.md b/src/docs/labels-and-control-signals/reference.md index 430d5af7ed..d89d95ec48 100644 --- a/src/docs/labels-and-control-signals/reference.md +++ b/src/docs/labels-and-control-signals/reference.md @@ -322,6 +322,8 @@ Hive advisory report is never actionable and never appears on the Hold list. Advisory-only dedupe checklist (`Decision required: no`, #11864) is never actionable and never appears on the Hold list; action-required checklists are parked with `needs-decision` instead. The close-on-merge backfill closes it once every `#N` it references is closed or merged, or after 7 days, and swaps it for `needs-decision` plus the "What to reply" notice if line two turns to `Decision required: yes` (#11871). +Every hive-authored dedupe checklist — labelled or not, including one parked at 045 with `Decision required: yes` — also gets an item pass on each backfill (#15754): a `- [ ] #N …` line is ticked to `- [x]` once #N is closed or merged, and once every task-list line is resolved the hive posts one comment ("All N items resolved (#a closed, #b merged …) — closing this advisory.") and closes the checklist as *completed*. A line that does not lead with a reference waits for a person to tick it. Set `dedupe.advisory_autoclose: false` (default on) to turn the item pass off; the `triage/advisory` rules above still apply. + **Who applies it:** Dedupe agent. **Checked by:** Standing meta classifier. **When:** Before holds/exempts. diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 2d3867a641..1ca39b9cb2 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -977,6 +977,31 @@ someone re-runs it. The shared-CI rerun sweep |---|---|---| | `shared_ci_rerun.enabled` | `true` (unset) | Set `false` to stop re-running PRs when a `[shared-ci]` incident closes. | +## Advisory checklist auto-close (`dedupe`) + +The dedupe agent files one checklist per repository (body opens with +``). Its items are usually resolved by +the hive's own merges and supersessions, so a checklist parked on a person +asked for a click nothing needed +([#15754](https://github.com/hivecommons/hive/issues/15754)). On every +close-on-merge backfill, for each open checklist this hive authored: + +- each `- [ ] #N …` line (also `- [ ] PR #N …`, `owner/repo#N`) is ticked to + `- [x]` once #N is closed or merged; a line that does not lead with a + reference waits for a person to tick it; +- once every task-list line is resolved, one comment ("All N items resolved + (#a closed, #b merged …) — closing this advisory.") is posted and the + checklist closes as *completed*. A checklist a person reopened after that + comment is left alone. + +The stage tracker draws such a row as **Advisory · hive is working the items +(k/N resolved)** with an optional **Close now**, never as *Needs human +decision*. + +| Key | Default | Meaning | +|---|---|---| +| `dedupe.advisory_autoclose` | `true` (unset) | Set `false` to leave dedupe checklists for a person; `triage/advisory` checklists still close on their own rules. | + ## Open-PR dispatch guard and duplicate-fix sweep (`scanner`) An issue whose fix is already open must not be dispatched again diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index d6d794683c..f9fb3701ad 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -174,6 +174,9 @@ type Config struct { // `` once incident #n closes // (hivecommons/hive#12253). Default on. SharedCIRerun SharedCIRerunConfig `yaml:"shared_ci_rerun,omitempty" json:"shared_ci_rerun,omitempty"` + // Dedupe tunes what the hive does with the dedupe agent's advisory + // checklists (hivecommons/hive#15754); see DedupeAdvisoryConfig. + Dedupe DedupeAdvisoryConfig `yaml:"dedupe,omitempty" json:"dedupe,omitempty"` // Scanner tunes the pre-dispatch guards every automated claim producer // runs before an issue is handed out (hivecommons/hive#14799). Scanner ScannerConfig `yaml:"scanner,omitempty" json:"scanner,omitempty"` diff --git a/src/pkg/config/dedupe.go b/src/pkg/config/dedupe.go new file mode 100644 index 0000000000..275a73c412 --- /dev/null +++ b/src/pkg/config/dedupe.go @@ -0,0 +1,17 @@ +package config + +// DedupeAdvisoryConfig tunes what the hive does with the dedupe agent's advisory +// checklists (hivecommons/hive#15754). +type DedupeAdvisoryConfig struct { + // AdvisoryAutoclose lets the close-on-merge backfill tick each + // `- [ ] #N` item of a hive-authored dedupe checklist once #N is closed + // or merged, and close the checklist as completed once every item is + // resolved. *bool so unset means on; set + // `dedupe.advisory_autoclose: false` to leave checklists for a person. + AdvisoryAutoclose *bool `yaml:"advisory_autoclose,omitempty" json:"advisory_autoclose,omitempty"` +} + +// AdvisoryAutocloseEnabled reports whether the item pass runs; unset means on. +func (c DedupeAdvisoryConfig) AdvisoryAutocloseEnabled() bool { + return c.AdvisoryAutoclose == nil || *c.AdvisoryAutoclose +} diff --git a/src/pkg/config/dedupe_test.go b/src/pkg/config/dedupe_test.go new file mode 100644 index 0000000000..a610f78874 --- /dev/null +++ b/src/pkg/config/dedupe_test.go @@ -0,0 +1,29 @@ +package config + +import ( + "testing" + + "gopkg.in/yaml.v3" +) + +func TestDedupeAdvisoryAutocloseDefaultsOn(t *testing.T) { + for _, tc := range []struct { + name string + yaml string + want bool + }{ + {"unset", "hive_id: h\n", true}, + {"explicit on", "dedupe:\n advisory_autoclose: true\n", true}, + {"explicit off", "dedupe:\n advisory_autoclose: false\n", false}, + } { + t.Run(tc.name, func(t *testing.T) { + var cfg Config + if err := yaml.Unmarshal([]byte(tc.yaml), &cfg); err != nil { + t.Fatal(err) + } + if got := cfg.Dedupe.AdvisoryAutocloseEnabled(); got != tc.want { + t.Fatalf("AdvisoryAutocloseEnabled() = %v, want %v", got, tc.want) + } + }) + } +} diff --git a/src/pkg/config/testdata/agent_runtime_golden.json b/src/pkg/config/testdata/agent_runtime_golden.json index d417b2075f..cf56d42f2f 100644 --- a/src/pkg/config/testdata/agent_runtime_golden.json +++ b/src/pkg/config/testdata/agent_runtime_golden.json @@ -736,6 +736,7 @@ "good_first_issue": {}, "supersession_sweep": {}, "shared_ci_rerun": {}, + "dedupe": {}, "scanner": {}, "upstream_watch": {}, "convergence": {}, diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go index 9a882787b7..c9904128d8 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan.go @@ -149,6 +149,7 @@ func (s *Server) planDelegatedDecision(ctx context.Context, repoFull string, num plan.Acting = verb.Acting } plan.Summary, plan.Consequences = delegatedPlanWording(in, d) + plan.Summary, plan.Consequences = delegatedPlanIssueWording(in, d, plan.Summary, plan.Consequences) plan.Why = delegatedPlanWhy(in, d) plan.Ladder = d.Ladder plan.MergeableAsIs = delegatedPlanMergeableAsIs(in, d) diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue.go new file mode 100644 index 0000000000..8e6aee1e64 --- /dev/null +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue.go @@ -0,0 +1,22 @@ +package dashboard + +import ( + "strconv" + + "github.com/hivecommons/hive/pkg/delegatedecision" +) + +// delegatedPlanIssueWording rewords an approval on an issue +// (hivecommons/hive#15754). delegatedPlanWording speaks PR: the plan for +// issue #15734 read "Approve #15734 as it is and let the merge queue merge +// it" — but an issue has no head to approve and nothing to merge. Approving +// an issue records the direction and lifts its decision park, so an agent +// can pick it up. Any other decision keeps its wording. +func delegatedPlanIssueWording(in delegatedecision.Input, d delegatedecision.Decision, summary string, consequences []string) (string, []string) { + if in.Kind != delegatedecision.KindIssue || d.Verdict != delegatedecision.VerdictApprove { + return summary, consequences + } + ref := "#" + strconv.Itoa(in.Number) + return "Approve the direction of " + ref + " and let the hive pick it up.", + []string{"Hive records the approval and lifts the decision park on " + ref + ".", "An agent claims " + ref + " and opens a PR for it."} +} diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue_test.go b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue_test.go new file mode 100644 index 0000000000..f5f37b4237 --- /dev/null +++ b/src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue_test.go @@ -0,0 +1,47 @@ +package dashboard + +import ( + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/delegatedecision" +) + +// hivecommons/hive#15754: default-approve on an issue said "Approve #15734 +// as it is and let the merge queue merge it." The plan for an issue speaks +// issue; a PR's stays as it was. +func TestDelegatedPlanWordingBranchesOnItemType(t *testing.T) { + approve := delegatedecision.Decision{Verdict: delegatedecision.VerdictApprove, Rule: "default-approve"} + for _, tc := range []struct { + name string + in delegatedecision.Input + d delegatedecision.Decision + summary string + first string + notWords []string + }{ + {"issue approve", delegatedecision.Input{Kind: delegatedecision.KindIssue, Number: 15734}, approve, + "Approve the direction of #15734 and let the hive pick it up.", + "Hive records the approval and lifts the decision park on #15734.", []string{"merge", "commit", "CI"}}, + {"pr approve", delegatedecision.Input{Kind: delegatedecision.KindPR, Number: 8}, approve, + "Approve #8 as it is and let the merge queue merge it.", + "Hive approves the current commit.", nil}, + {"issue close duplicate", delegatedecision.Input{Kind: delegatedecision.KindIssue, Number: 5}, + delegatedecision.Decision{Verdict: delegatedecision.VerdictCloseDuplicate, Actions: []delegatedecision.Action{{Target: 4}}}, + "Close #5 as a duplicate of #4.", "#5 is closed with a comment pointing at #4.", nil}, + } { + t.Run(tc.name, func(t *testing.T) { + summary, consequences := delegatedPlanWording(tc.in, tc.d) + summary, consequences = delegatedPlanIssueWording(tc.in, tc.d, summary, consequences) + if summary != tc.summary || len(consequences) == 0 || consequences[0] != tc.first { + t.Fatalf("summary=%q consequences=%q", summary, consequences) + } + text := summary + " " + strings.Join(consequences, " ") + for _, w := range tc.notWords { + if strings.Contains(text, w) { + t.Errorf("issue plan mentions %q: %s", w, text) + } + } + }) + } +} diff --git a/src/pkg/dashboard/settings_parity_allowlist.txt b/src/pkg/dashboard/settings_parity_allowlist.txt index 6f889a011f..bf014238a3 100644 --- a/src/pkg/dashboard/settings_parity_allowlist.txt +++ b/src/pkg/dashboard/settings_parity_allowlist.txt @@ -179,6 +179,7 @@ contribute.token_max_age # TODO #11854 convergence.mutation.max_writers_per_target # boundary capacity tuning; yaml-only (#14645) debug.pprof_addr # loopback-only pprof bind address, operator/debug knob, not a Settings control (#14681) deployment.runtime # set via HIVE_DEPLOYMENT_RUNTIME env var or auto-detected, not a Settings control (#14072) +dedupe.advisory_autoclose # advisory checklist auto-close (#15754); yaml-only duplicate_sweep.bot_authors[] # TODO #11854 evidence.complexity.enabled # TODO #11854 evidence.complexity.static_analysis # TODO #11854 diff --git a/src/pkg/dashboard/stage_tracker_advisory.go b/src/pkg/dashboard/stage_tracker_advisory.go index d6798d858a..dc6304678c 100644 --- a/src/pkg/dashboard/stage_tracker_advisory.go +++ b/src/pkg/dashboard/stage_tracker_advisory.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" ) // An advisory issue (hivecommons/hive#15381): a `triage/advisory` issue, a @@ -44,6 +45,14 @@ type StageTrackerAdvisory struct { Empty bool `json:"empty,omitempty"` Chip string `json:"chip"` Caption string `json:"caption"` + // Items / Resolved count a dedupe checklist's task-list lines and the + // ticked ones. Working is true while the hive ticks and closes them + // itself (hivecommons/hive#15754); Lead is then the row's optional + // human action, "Close now". + Items int `json:"items,omitempty"` + Resolved int `json:"resolved,omitempty"` + Working bool `json:"working,omitempty"` + Lead string `json:"lead,omitempty"` } // stageTrackerAdvisoryFor classifies an issue from its labels, its body @@ -65,6 +74,9 @@ func stageTrackerAdvisoryFor(labels []string, body string, hint *github.IssueAdv return nil } adv.Empty = hint != nil && hint.Empty + if hint != nil && hint.DedupeChecklist { + adv.Items, adv.Resolved = hint.Items, hint.Resolved + } adv.Chip, adv.Caption = StageTrackerAdvisoryChip, StageTrackerAdvisoryCaption if adv.Empty { adv.Chip, adv.Caption = StageTrackerAdvisoryEmptyChip, StageTrackerAdvisoryEmptyCaption @@ -79,7 +91,11 @@ 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. +// stage actor is a human with nothing blocking on them. An advisory is +// never parked on a person (hivecommons/hive#15754): a 045 park, its +// needs-decision pill and its decision_needed / blocker blocks come off +// too, so the row reads as the advisory it is. While the hive works the +// checklist's items the actor is the hive. func applyStageTrackerAdvisory(it *StageTrackerItem, adv *StageTrackerAdvisory) { if it == nil || adv == nil { return @@ -87,12 +103,23 @@ func applyStageTrackerAdvisory(it *StageTrackerItem, adv *StageTrackerAdvisory) 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) }) + it.Modifiers = slices.DeleteFunc(it.Modifiers, func(m string) bool { + return slices.Contains(stageTrackerAdvisoryMods, m) || m == modNeedsDecision + }) if it.New != nil { it.New = nil if it.StageSlug == StageTrackerNewSlug { it.StageSlug = "" } } + if it.Stage == stagelabels.IssueNeedsDecision.Number() { + it.Stage, it.StageSlug, it.StageLabel = 0, "", "" + } + it.DecisionNeeded, it.Blocker = nil, nil + if adv.Working { + it.Actor = StageActorHive + it.StageActor = &StageTrackerActor{Kind: StageActorHive, Why: stageTrackerAdvisoryWorkingWhy, Since: it.StageSince} + return + } it.StageActor = &StageTrackerActor{Kind: StageActorHuman, Why: stageTrackerAdvisoryWhy, Since: it.StageSince} } diff --git a/src/pkg/dashboard/stage_tracker_advisory_working.go b/src/pkg/dashboard/stage_tracker_advisory_working.go new file mode 100644 index 0000000000..014353eb30 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_advisory_working.go @@ -0,0 +1,43 @@ +package dashboard + +import ( + "fmt" + + "github.com/hivecommons/hive/pkg/config" +) + +// A dedupe checklist the hive resolves itself (hivecommons/hive#15754): the +// close-on-merge backfill ticks each `- [ ] #N` item once #N is closed or +// merged and closes the checklist when every item is resolved. Its row says +// the hive is on it — "Advisory · hive is working the items (k/N resolved)" +// — instead of asking a person to read and close it; "Close now" stays as +// the optional human lead. + +const ( + // stageTrackerAdvisoryWorkingFormat is the chip and caption, given the + // resolved and total item counts. + stageTrackerAdvisoryWorkingFormat = "Advisory · hive is working the items (%d/%d resolved)" + // StageTrackerAdvisoryCloseNowLead is the optional human action. + StageTrackerAdvisoryCloseNowLead = "Close now" + // stageTrackerAdvisoryWorkingWhy is the StageActor sentence. + stageTrackerAdvisoryWorkingWhy = "hive ticks each item once it is closed or merged and closes the advisory when all are resolved; nothing waits on a person" +) + +// stageTrackerAdvisoryWorking marks a dedupe checklist with task-list items +// as worked by the hive when the auto-close knob is on. Any other advisory +// is left as it is. +func stageTrackerAdvisoryWorking(adv *StageTrackerAdvisory, autoclose bool) { + if adv == nil || !autoclose || adv.Source == stageTrackerAdvisorySourceVerdict || adv.Items <= 0 { + return + } + adv.Working = true + adv.Chip = fmt.Sprintf(stageTrackerAdvisoryWorkingFormat, adv.Resolved, adv.Items) + adv.Caption = adv.Chip + adv.Lead = StageTrackerAdvisoryCloseNowLead +} + +// stageTrackerAdvisoryAutoclose reads the dedupe knob; unset (or no +// config) means on. +func stageTrackerAdvisoryAutoclose(cfg *config.Config) bool { + return cfg == nil || cfg.Dedupe.AdvisoryAutocloseEnabled() +} diff --git a/src/pkg/dashboard/stage_tracker_advisory_working_test.go b/src/pkg/dashboard/stage_tracker_advisory_working_test.go new file mode 100644 index 0000000000..b266b193e4 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_advisory_working_test.go @@ -0,0 +1,109 @@ +package dashboard + +import ( + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" +) + +// hivecommons/hive#15734 as the hive filed it: a dedupe checklist parked +// at 045 with "Decision required: yes", one of three items already ticked. +const advisory15734Body = "\nDecision required: yes\n\n" + + "## Summary\n\nFound 3 near-duplicate pairs, 0 same-root-cause clusters, 0 items that appear already resolved, and 0 missing PR↔issue links.\n\n" + + "## Near-duplicates: close one\n\n" + + "- [x] #15312 — close as superseded by #15646\n" + + "- [ ] #15433 — close as superseded by #15649\n" + + "- [ ] #15482 — close as superseded by #15650\n" + +var advisory15734Labels = []string{"help wanted", "agent/dedupe", "stage/045-needs-decision"} + +func TestStageTrackerAdvisoryWorkingWording(t *testing.T) { + adv := stageTrackerAdvisoryFor(advisory15734Labels, advisory15734Body, nil) + if adv == nil || adv.Source != stageTrackerAdvisorySourceChecklist || adv.Items != 3 || adv.Resolved != 1 { + t.Fatalf("#15734 advisory = %+v", adv) + } + stageTrackerAdvisoryWorking(adv, true) + want := "Advisory · hive is working the items (1/3 resolved)" + if !adv.Working || adv.Chip != want || adv.Caption != want || adv.Lead != "Close now" { + t.Errorf("working advisory = %+v", adv) + } + + off := stageTrackerAdvisoryFor(advisory15734Labels, advisory15734Body, nil) + stageTrackerAdvisoryWorking(off, false) + if off.Working || off.Chip != StageTrackerAdvisoryChip || off.Lead != "" { + t.Errorf("auto-close off = %+v, want the read & close advisory", off) + } + // No task list: nothing for the hive to work. + plain := stageTrackerAdvisoryFor([]string{"triage/advisory"}, "", nil) + stageTrackerAdvisoryWorking(plain, true) + if plain.Working || plain.Chip != StageTrackerAdvisoryChip { + t.Errorf("label-only advisory = %+v", plain) + } +} + +func TestStageTrackerAdvisoryAutocloseKnob(t *testing.T) { + off := false + if !stageTrackerAdvisoryAutoclose(nil) || !stageTrackerAdvisoryAutoclose(&config.Config{}) { + t.Error("unset knob must read as on") + } + if stageTrackerAdvisoryAutoclose(&config.Config{Dedupe: config.DedupeAdvisoryConfig{AdvisoryAutoclose: &off}}) { + t.Error("knob set false must read as off") + } +} + +// An advisory is never parked on a person: the 045 park, its pill and the +// decision / blocker blocks come off, and the hive is the actor while it +// works the items. +func TestApplyStageTrackerAdvisoryNeverParks(t *testing.T) { + adv := stageTrackerAdvisoryFor(advisory15734Labels, advisory15734Body, nil) + stageTrackerAdvisoryWorking(adv, true) + it := StageTrackerItem{Kind: "issue", Number: 15734, Stage: 45, StageSlug: "needs-decision", StageLabel: "Needs human decision", + Modifiers: []string{modNeedsDecision, modStalled}, DecisionNeeded: &StageTrackerDecision{}, Blocker: &StageTrackerBlocker{}} + applyStageTrackerAdvisory(&it, adv) + if it.Stage != 0 || it.StageSlug != "" || it.StageLabel != "" { + t.Errorf("stage = %d/%q/%q, want the 045 park dropped", it.Stage, it.StageSlug, it.StageLabel) + } + if it.DecisionNeeded != nil || it.Blocker != nil || hasMod(it, modNeedsDecision) || hasMod(it, modStalled) { + t.Errorf("decision=%+v blocker=%+v mods=%v, want no park on a person", it.DecisionNeeded, it.Blocker, it.Modifiers) + } + if it.Caption != adv.Caption || it.Actor != StageActorHive || it.StageActor == nil || it.StageActor.Kind != StageActorHive { + t.Errorf("caption=%q actor=%q stage_actor=%+v", it.Caption, it.Actor, it.StageActor) + } + if stageTrackerNeedsHuman(it) { + t.Error("advisory counted as needs-human") + } + if kind, _ := stageTrackerWaitKind(it); kind != "" { + t.Errorf("wait kind = %q, want none", kind) + } +} + +// The built row for #15734: the enumeration's hint carries the counts, the +// row reads "hive is working the items" with no decision block. +func TestStageTrackerAdvisoryWorkingRow(t *testing.T) { + now := time.Date(2026, 10, 30, 12, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + created := now.Add(-3 * time.Hour) + + s.statusMu.Lock() + repo := &s.status.Repos[0] + repo.NonActionableIssues = []any{ + github.RepoWorkIssue{Repo: "acme/console", Number: 15734, Title: "triage: duplicate and overlapping open issues/PRs to consolidate", Author: "hive-app[bot]", + Labels: advisory15734Labels, Bucket: "needs-decision", Reason: "parked", CreatedAt: created, UpdatedAt: created, + Advisory: github.IssueAdvisoryFromBody(advisory15734Body)}, + } + s.statusMu.Unlock() + + resp := s.buildStageTracker(s.status, store, now) + it := trackerItem(t, resp, "issue", 15734) + if it.Advisory == nil || !it.Advisory.Working || it.Advisory.Lead != "Close now" { + t.Fatalf("#15734 advisory = %+v", it.Advisory) + } + if want := "Advisory · hive is working the items (1/3 resolved)"; it.Caption != want || it.Advisory.Chip != want { + t.Errorf("#15734 caption/chip = %q / %q", it.Caption, it.Advisory.Chip) + } + if it.DecisionNeeded != nil || it.Stage != 0 || it.NeedsHuman || it.WaitingOnYou || hasMod(it, modNeedsDecision) { + t.Errorf("#15734 parked on a person: decision=%+v stage=%d needs_human=%v waiting=%v mods=%v", it.DecisionNeeded, it.Stage, it.NeedsHuman, it.WaitingOnYou, it.Modifiers) + } +} diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index b4c0d11a35..5336b636e5 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -289,6 +289,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto stageTrackerBlockedBy(&it, issue.OpenBlockers()) stageTrackerBlockedOnPR(&it, issue.Body, bucketReason, status.GitHubBaseURL, prState) advisory := stageTrackerAdvisoryFor(issue.Labels, issue.Body, advisoryHint) + stageTrackerAdvisoryWorking(advisory, stageTrackerAdvisoryAutoclose(cfg)) if advisory == nil { applyStageTrackerNew(&it, stageTrackerNewState(it, ok, issueFilter, status.Governor, now)) } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 934d50c71a..7d059850ad 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -19710,7 +19710,9 @@