From fc0ef2d7d0e9f711dc2c130b46fa089d1b963ee1 Mon Sep 17 00:00:00 2001 From: Karibhou <157208370+Karibhou@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:47:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20refuse=20empty=20dedupe?= =?UTF-8?q?=20advisory=20filings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hive-Run: hivecommons/hive#15415 Hive-Plan: empty-dedupe-advisory Hive-Spec: issue-15415#relay-guard Signed-off-by: Karibhou <157208370+Karibhou@users.noreply.github.com> --- changelog.d/fixed-empty-dedupe-advisory.md | 1 + src/pkg/github/attribution.go | 2 + src/pkg/github/dedupe_empty_advisory.go | 48 +++++++++++++++ src/pkg/github/dedupe_empty_advisory_test.go | 35 +++++++++++ src/pkg/github/issue_request_watcher.go | 11 ++++ src/pkg/github/testdata/dedupe-15381.txt | 63 ++++++++++++++++++++ src/pkg/policies/dedupe_policy_test.go | 2 +- src/pkg/policies/defaults/dedupe-issues.md | 20 ++----- src/policies/dedupe-issues.md | 20 ++----- 9 files changed, 173 insertions(+), 29 deletions(-) create mode 100644 changelog.d/fixed-empty-dedupe-advisory.md create mode 100644 src/pkg/github/dedupe_empty_advisory.go create mode 100644 src/pkg/github/dedupe_empty_advisory_test.go create mode 100644 src/pkg/github/testdata/dedupe-15381.txt diff --git a/changelog.d/fixed-empty-dedupe-advisory.md b/changelog.d/fixed-empty-dedupe-advisory.md new file mode 100644 index 0000000000..2dcf8b003a --- /dev/null +++ b/changelog.d/fixed-empty-dedupe-advisory.md @@ -0,0 +1 @@ +- Empty dedupe advisories with no actionable findings are no longer filed as issues. diff --git a/src/pkg/github/attribution.go b/src/pkg/github/attribution.go index 5b29679115..d97b8abb2d 100644 --- a/src/pkg/github/attribution.go +++ b/src/pkg/github/attribution.go @@ -45,6 +45,8 @@ 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 records an empty dedupe filing refusal. + 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/dedupe_empty_advisory.go b/src/pkg/github/dedupe_empty_advisory.go new file mode 100644 index 0000000000..92d128a82f --- /dev/null +++ b/src/pkg/github/dedupe_empty_advisory.go @@ -0,0 +1,48 @@ +package github + +import ( + "regexp" + "strings" +) + +var ( + dedupeTaskLine = regexp.MustCompile(`(?mi)^\s*[-*+]\s+\[ \]`) + dedupeNearCounts = regexp.MustCompile(`(?i)\b([0-9]+)\s+near[- ]duplicate\s+pairs?\b`) + dedupeLinkCounts = regexp.MustCompile(`(?i)\b([0-9]+)\s+missing\s+PR\s*(?:↔|<->|/)\s*issue\s+links?\b`) + dedupeResolvedCounts = regexp.MustCompile(`(?i)\b([0-9]+)\s+(?:items?\s+(?:that\s+appear\s+)?(?:already\s+)?resolved|resolved\s+(?:items?|candidates?))\b`) +) + +// emptyDedupeAdvisory only refuses bodies with explicit zero counts for the +// two principal finding classes. Unknown formats remain eligible for filing. +func emptyDedupeAdvisory(body string) bool { + _, verdict, ok := parseDedupeChecklist(body) + if !ok || verdict != dedupeVerdictNo || dedupeTaskLine.MatchString(body) { + return false + } + summary := body + if i := strings.Index(strings.ToLower(summary), "## summary"); i >= 0 { + summary = summary[i+len("## summary"):] + if j := strings.Index(summary, "\n## "); j >= 0 { + summary = summary[:j] + } + } else { + return false + } + for _, pattern := range []*regexp.Regexp{dedupeNearCounts, dedupeLinkCounts} { + counts := pattern.FindAllStringSubmatch(summary, -1) + if len(counts) == 0 { + return false + } + for _, count := range counts { + if count[1] != "0" { + return false + } + } + } + for _, count := range dedupeResolvedCounts.FindAllStringSubmatch(summary, -1) { + if count[1] != "0" { + return false + } + } + return true +} diff --git a/src/pkg/github/dedupe_empty_advisory_test.go b/src/pkg/github/dedupe_empty_advisory_test.go new file mode 100644 index 0000000000..462b665f87 --- /dev/null +++ b/src/pkg/github/dedupe_empty_advisory_test.go @@ -0,0 +1,35 @@ +package github + +import ( + "os" + "strings" + "testing" +) + +func TestEmptyDedupeAdvisory(t *testing.T) { + data, err := os.ReadFile("testdata/dedupe-15381.txt") + if err != nil { + t.Fatal(err) + } + body := string(data) + cases := []struct { + name, body string + want bool + }{ + {"reported body", body, true}, + {"unchecked task", body + "\n- [ ] #1 close duplicate\n", false}, + {"duplicate", strings.Replace(body, "0 near-duplicate pairs", "1 near-duplicate pairs", 1), false}, + {"missing link", strings.Replace(body, "0 missing PR↔issue links", "2 missing PR↔issue links", 1), false}, + {"resolved", strings.Replace(body, "0 near-duplicate pairs", "0 near-duplicate pairs, 1 resolved candidate", 1), false}, + {"unknown count", strings.Replace(body, "0 near-duplicate pairs", "no near-duplicate pairs", 1), false}, + {"decision", strings.Replace(body, "Decision required: no", "Decision required: yes", 1), false}, + {"other issue", strings.Replace(body, "hive:dedupe-checklist", "other", 1), false}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if got := emptyDedupeAdvisory(tc.body); got != tc.want { + t.Errorf("got %v, want %v", got, tc.want) + } + }) + } +} diff --git a/src/pkg/github/issue_request_watcher.go b/src/pkg/github/issue_request_watcher.go index ba80d4a3cc..c8133dacc9 100644 --- a/src/pkg/github/issue_request_watcher.go +++ b/src/pkg/github/issue_request_watcher.go @@ -552,6 +552,17 @@ func (c *Client) handleOneIssueRequest(ctx context.Context, path string, nowFn f // spoke-local, so the body carries the relation too. body = withParentMarker(body, req.Parent) } + if kind == "issue" && emptyDedupeAdvisory(req.Body) { + reason := "not filed: dedupe advisory has no actionable findings or unchecked tasks" + if c.priorArtFilingRecord != nil { + c.priorArtFilingRecord("empty dedupe advisory not filed: "+req.Title, req.Body, req.Agent, req.Repo) + } + c.recordWriteAudit(AuditActionAgentIssueEmptyAdvisoryRefused, meta, WriteTarget{Repo: req.Repo}) + c.writeIssueResult(path, IssueResponse{OK: false, Error: reason, At: nowFn().UTC().Format(time.RFC3339)}) + _ = os.Remove(path) + c.issueClearRetry(path) + return + } if kind == "issue" { // Prior-art filing verdict (hivecommons/hive#13879). A refusal is // terminal: retrying the same request cannot change the match. diff --git a/src/pkg/github/testdata/dedupe-15381.txt b/src/pkg/github/testdata/dedupe-15381.txt new file mode 100644 index 0000000000..5a0dd30ab3 --- /dev/null +++ b/src/pkg/github/testdata/dedupe-15381.txt @@ -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 diff --git a/src/pkg/policies/dedupe_policy_test.go b/src/pkg/policies/dedupe_policy_test.go index cbdb021e93..b2fc0e8e09 100644 --- a/src/pkg/policies/dedupe_policy_test.go +++ b/src/pkg/policies/dedupe_policy_test.go @@ -58,7 +58,7 @@ func TestDedupePolicyShips(t *testing.T) { // label instead (hivecommons/hive#11864). for _, want := range []string{ "Decision required: ", - "--label triage/advisory", + "Do not create an advisory-only checklist", } { if !strings.Contains(body, want) { t.Errorf("dedupe-issues.md is missing %q", want) diff --git a/src/pkg/policies/defaults/dedupe-issues.md b/src/pkg/policies/defaults/dedupe-issues.md index 372bafed69..aed5d58bcf 100644 --- a/src/pkg/policies/defaults/dedupe-issues.md +++ b/src/pkg/policies/defaults/dedupe-issues.md @@ -151,7 +151,7 @@ for maintainers. ## Conflicting PRs: merge order matters -- [ ] PR #1262 pins the contract that PR #1249 changes — merge #1249 first, or fold the test into #1249 +- PR #1262 pins the contract that PR #1249 changes — merge #1249 first, or fold the test into #1249 (kick output only) ## Candidates to close as resolved @@ -205,10 +205,11 @@ 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 +- **No checklist exists and you have at least one action-required `- [ ]` task** → open one with the command below. -- **No checklist exists and you found nothing** → file nothing. A checklist that - says "no duplicates" is noise. +- **No checklist exists and there are no action-required tasks** → file nothing. + Merge-order reminders, cross-links and checked non-duplicates are notes for the + kick output, not findings that justify an issue. Every checklist must stay out of the hive's work queue — an agent handed "close #1210 as superseded" as a task would do exactly the thing this lane is forbidden @@ -235,16 +236,7 @@ gh issue create --repo --needs-decision \ --body-file /tmp/.md ``` -An **advisory-only** checklist (`Decision required: no`) 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: - -```bash -gh issue create --repo --label triage/advisory \ - --title "triage: duplicate and overlapping open issues/PRs to consolidate" \ - --body-file /tmp/.md -``` +Do not create an advisory-only checklist. Put informational notes in the kick output. When you edit an existing checklist in place, recompute the verdict and rewrite line two. If an advisory checklist gains an action-required row, say so on the diff --git a/src/policies/dedupe-issues.md b/src/policies/dedupe-issues.md index 372bafed69..aed5d58bcf 100644 --- a/src/policies/dedupe-issues.md +++ b/src/policies/dedupe-issues.md @@ -151,7 +151,7 @@ for maintainers. ## Conflicting PRs: merge order matters -- [ ] PR #1262 pins the contract that PR #1249 changes — merge #1249 first, or fold the test into #1249 +- PR #1262 pins the contract that PR #1249 changes — merge #1249 first, or fold the test into #1249 (kick output only) ## Candidates to close as resolved @@ -205,10 +205,11 @@ 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 +- **No checklist exists and you have at least one action-required `- [ ]` task** → open one with the command below. -- **No checklist exists and you found nothing** → file nothing. A checklist that - says "no duplicates" is noise. +- **No checklist exists and there are no action-required tasks** → file nothing. + Merge-order reminders, cross-links and checked non-duplicates are notes for the + kick output, not findings that justify an issue. Every checklist must stay out of the hive's work queue — an agent handed "close #1210 as superseded" as a task would do exactly the thing this lane is forbidden @@ -235,16 +236,7 @@ gh issue create --repo --needs-decision \ --body-file /tmp/.md ``` -An **advisory-only** checklist (`Decision required: no`) 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: - -```bash -gh issue create --repo --label triage/advisory \ - --title "triage: duplicate and overlapping open issues/PRs to consolidate" \ - --body-file /tmp/.md -``` +Do not create an advisory-only checklist. Put informational notes in the kick output. When you edit an existing checklist in place, recompute the verdict and rewrite line two. If an advisory checklist gains an action-required row, say so on the