Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-15754-advisory-checklists-autoclose.md
Original file line number Diff line number Diff line change
@@ -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."
27 changes: 27 additions & 0 deletions src/cmd/hive/close_on_merge_advisory_autoclose_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
2 changes: 2 additions & 0 deletions src/cmd/hive/close_on_merge_sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/docs/dashboard-sections/activity-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<!-- hive:dedupe-checklist repo=… -->`) 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
Expand Down
2 changes: 2 additions & 0 deletions src/docs/labels-and-control-signals/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
`<!-- hive:dedupe-checklist repo=… -->`). 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
Expand Down
3 changes: 3 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ type Config struct {
// `<!-- hive-shared-ci-<n> -->` 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"`
Expand Down
17 changes: 17 additions & 0 deletions src/pkg/config/dedupe.go
Original file line number Diff line number Diff line change
@@ -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
}
29 changes: 29 additions & 0 deletions src/pkg/config/dedupe_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
1 change: 1 addition & 0 deletions src/pkg/config/testdata/agent_runtime_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@
"good_first_issue": {},
"supersession_sweep": {},
"shared_ci_rerun": {},
"dedupe": {},
"scanner": {},
"upstream_watch": {},
"convergence": {},
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated_plan_issue.go
Original file line number Diff line number Diff line change
@@ -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."}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
})
}
}
1 change: 1 addition & 0 deletions src/pkg/dashboard/settings_parity_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 29 additions & 2 deletions src/pkg/dashboard/stage_tracker_advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -79,20 +91,35 @@ 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
}
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}
}
43 changes: 43 additions & 0 deletions src/pkg/dashboard/stage_tracker_advisory_working.go
Original file line number Diff line number Diff line change
@@ -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()
}
Loading
Loading