diff --git a/changelog.d/fixed-standing-meta-no-stage.md b/changelog.d/fixed-standing-meta-no-stage.md new file mode 100644 index 0000000000..fbf861b628 --- /dev/null +++ b/changelog.d/fixed-standing-meta-no-stage.md @@ -0,0 +1 @@ +- Bot Dependency Dashboards and the Hive Advisory Report no longer get a stage label. A triage bot's `needs-human` on mergeraptor's Dependency Dashboards (projectbluefin/gutenprint-printer-app#45, ps-printer-app#50, hplip-printer-app#42) parked them at `stage/045-needs-decision`; the sweep and the out-of-cycle facts now derive no stage for standing meta issues, so the 045 comes off. diff --git a/src/docs/dashboard.md b/src/docs/dashboard.md index 06baa1d9f3..95b644c3e5 100644 --- a/src/docs/dashboard.md +++ b/src/docs/dashboard.md @@ -520,6 +520,12 @@ and exposes the editable rows. | Draft PRs | Pull request is open but marked draft. | GitHub draft state. | Use GitHub's **Ready for review** action. | | Hold-adjacent/other | Safety remainder for open items that did not match a named actionable, held, blocked, or outside classifier. | Fixed scanner fallback. | Check labels and scanner rules; add a dedicated classifier if the remainder is meaningful. | +A standing meta issue (bot Dependency Dashboard, Hive Advisory Report) derives +no stage label, in the sweep and out of cycle: a `needs-human` a triage bot puts +on a Dependency Dashboard used to park it at `stage/045-needs-decision` +(projectbluefin/gutenprint-printer-app#45). The stage writer takes such a 045 +off; the bot's own labels stay. + The Issues and PRs panels link directly to `/api/overview/issues.csv` and `/api/overview/prs.csv` by default, or to the matching `.json` endpoints when JSON export is selected; non-empty legend rows add a `slice` query filter (the diff --git a/src/pkg/github/stage_facts_sink.go b/src/pkg/github/stage_facts_sink.go index ecdba72a52..724671e97f 100644 --- a/src/pkg/github/stage_facts_sink.go +++ b/src/pkg/github/stage_facts_sink.go @@ -160,6 +160,16 @@ func (c *Client) enrichStageFacts(ctx context.Context, f stageengine.Facts) (sta f.Issue.Bucket = stageengine.BucketFiltered f.Issue.FilteredReason = issueFilterReason } + // A standing meta issue derives no stage out of cycle either, or a + // webhook on a Renovate dashboard re-parks it between sweeps. + if f.Issue != nil { + switch standingMetaIssueKindFor(issue.GetTitle(), issue.GetUser().GetLogin(), labels) { + case standingMetaDependencyDashboard: + f.Issue.Bucket = stageengine.BucketDependencyDashboard + case standingMetaHiveAdvisory: + f.Issue.Bucket = stageengine.BucketHiveAdvisory + } + } if f.Issue != nil { resolveIssueLabelFacts(issueInputFrom(f), &f) f.Issue.Stalled = issueHasLabel(f.Labels, stagelabels.StalledLabel) diff --git a/src/pkg/github/stage_facts_sink_test.go b/src/pkg/github/stage_facts_sink_test.go index 305c9a1f06..1f0f60005f 100644 --- a/src/pkg/github/stage_facts_sink_test.go +++ b/src/pkg/github/stage_facts_sink_test.go @@ -26,6 +26,9 @@ type stageFactsServer struct { state string isPR bool body string + // title / login, when set, are the issue's title and author. + title string + login string added []string removed []string // prState / prMerged answer GET /pulls/N (the covering-PR re-read); @@ -57,7 +60,11 @@ func newStageFactsServer(t *testing.T, labels ...string) *stageFactsServer { } _ = json.NewEncoder(w).Encode(body) case r.Method == http.MethodGet && strings.Contains(r.URL.Path, "/issues/"): - body := map[string]any{"number": 7, "state": s.state, "labels": wireLabelsOf(s.labels), "user": map[string]any{"login": "dev"}, "body": s.body} + login := s.login + if login == "" { + login = "dev" + } + body := map[string]any{"number": 7, "state": s.state, "labels": wireLabelsOf(s.labels), "user": map[string]any{"login": login}, "body": s.body, "title": s.title} if s.isPR { body["pull_request"] = map[string]any{"url": "https://api.github.com/repos/o/r/pulls/7"} } diff --git a/src/pkg/github/stage_standing_meta_test.go b/src/pkg/github/stage_standing_meta_test.go new file mode 100644 index 0000000000..65e009bf61 --- /dev/null +++ b/src/pkg/github/stage_standing_meta_test.go @@ -0,0 +1,46 @@ +package github + +import ( + "context" + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/stageengine" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// projectbluefin/gutenprint-printer-app#45, ps-printer-app#50 and +// hplip-printer-app#42: mergeraptor's Dependency Dashboards wore stage/045 +// because a triage bot added `needs-human`. A standing meta issue is not +// work and derives no stage: the sweep row and an out-of-cycle fact both +// take the 045 off and write nothing else. +func TestStandingMetaIssueDerivesNoStage(t *testing.T) { + for _, bucket := range []string{"dependency_dashboard", "hive_advisory"} { + in := IssueStageInput{Repo: "o/r", Number: 45, Labels: []string{"triage/accepted", "needs-human", stagelabels.IssueNeedsDecision.Label()}, Bucket: bucket} + if d := issueStageDecision(in, nil); d.Stage != stagelabels.None || !strings.Contains(d.Reason, "standing meta issue") { + t.Fatalf("%s: decision = %+v, want no stage", bucket, d) + } + } + + srv := newStageFactsServer(t, "triage/accepted", "kind/cleanup", "needs-human", stagelabels.IssueNeedsDecision.Label()) + srv.title, srv.login = "Dependency Dashboard", "mergeraptor[bot]" + c := testClient(t, srv.srv.URL) + if err := c.StageFacts().Parked(context.Background(), c.IssueStageRef("o/r", 7), "needs-human"); err != nil { + t.Fatal(err) + } + labels, added, removed := srv.snapshot() + if stagelabels.Current(labels) != stagelabels.None || len(added) != 0 || strings.Join(removed, ",") != stagelabels.IssueNeedsDecision.Label() { + t.Fatalf("labels=%v added=%v removed=%v, want 045 removed and nothing added", labels, added, removed) + } + if !issueHasLabel(labels, "needs-human") { + t.Fatalf("labels = %v: the bot's needs-human is not the hive's to remove", labels) + } + + f, err := c.enrichStageFacts(context.Background(), stageengine.Facts{Ref: c.IssueStageRef("o/r", 7), Issue: &stageengine.IssueFacts{Bucket: stageengine.BucketActionable}}) + if err != nil { + t.Fatal(err) + } + if f.Issue.Bucket != stageengine.BucketDependencyDashboard { + t.Fatalf("bucket = %q, want dependency_dashboard", f.Issue.Bucket) + } +} diff --git a/src/pkg/stageengine/derive_issue.go b/src/pkg/stageengine/derive_issue.go index dd83ef878a..0d0f55bcde 100644 --- a/src/pkg/stageengine/derive_issue.go +++ b/src/pkg/stageengine/derive_issue.go @@ -17,12 +17,14 @@ import ( // mapping is pinned byte-for-byte on both sides of the move. const ( - reasonIssueNotIssue = "stage facts: not an issue" - reasonIssueNoBucket = "stage facts: no enumeration bucket for the issue" - reasonIssueClosed = "closed" - reasonIssueLikelyDone = "merged PR awaiting confirmation" - reasonIssueActionable = "actionable" - reasonIssueOpenPR = "open PR covers it" + reasonIssueNotIssue = "stage facts: not an issue" + reasonIssueNoBucket = "stage facts: no enumeration bucket for the issue" + // reasonIssueStandingMeta prefixes the bucket of a standing meta issue. + reasonIssueStandingMeta = "standing meta issue, not work: " + reasonIssueClosed = "closed" + reasonIssueLikelyDone = "merged PR awaiting confirmation" + reasonIssueActionable = "actionable" + reasonIssueOpenPR = "open PR covers it" // reasonIssueOpenPRPartial is 040 under a PR that references the issue // without closing it (ClaimFact.Partial); ReasonIsPartialCover reads it. reasonIssueOpenPRPartial = "open PR addresses part of it (references it without a closing keyword)" @@ -137,6 +139,13 @@ func issueTriageClear(f Facts, stage stagelabels.Stage) []string { // belongs to the PR, whose stage the reason names). func issueStage(f Facts) (stage stagelabels.Stage, covered bool, reason string) { is := f.Issue + // A standing meta issue is a control panel or a report, never work: + // projectbluefin/gutenprint-printer-app#45, ps-printer-app#50 and + // hplip-printer-app#42 (mergeraptor's Dependency Dashboards) wore + // stage/045 because a triage bot added `needs-human`. + if is.Bucket == BucketDependencyDashboard || is.Bucket == BucketHiveAdvisory { + return stagelabels.None, false, reasonIssueStandingMeta + string(is.Bucket) + } if is.LikelyDone { return stagelabels.None, false, reasonIssueLikelyDone } diff --git a/src/pkg/stageengine/derive_issue_test.go b/src/pkg/stageengine/derive_issue_test.go index cbe1245dc2..2644787016 100644 --- a/src/pkg/stageengine/derive_issue_test.go +++ b/src/pkg/stageengine/derive_issue_test.go @@ -32,6 +32,14 @@ func TestDeriveIssueTable(t *testing.T) { reason string }{ {"actionable", nil, stagelabels.Actionable, false, "actionable"}, + {"dependency dashboard parked by a bot", func(f *Facts) { + f.Issue.Bucket = BucketDependencyDashboard + f.Park.NeedsHuman = true + }, stagelabels.None, false, "standing meta issue, not work: dependency_dashboard"}, + {"hive advisory with a decision label", func(f *Facts) { + f.Issue.Bucket = BucketHiveAdvisory + f.Park.DecisionLabel = "stage/045-needs-decision" + }, stagelabels.None, false, "standing meta issue, not work: hive_advisory"}, {"reporter triage bucket", func(f *Facts) { f.Issue.Bucket = BucketReporterTriage f.Issue.TriageAwaiting = "reporter-trust gate: awaiting the triage label" diff --git a/src/pkg/stageengine/facts.go b/src/pkg/stageengine/facts.go index 8aac290aea..4ab12199d1 100644 --- a/src/pkg/stageengine/facts.go +++ b/src/pkg/stageengine/facts.go @@ -120,6 +120,12 @@ const ( // (#9665) holds out until a maintainer adds the triage label; it // derives 015-triage-needed. BucketReporterTriage IssueBucket = "reporter_triage" + // BucketDependencyDashboard and BucketHiveAdvisory are the standing meta + // issues (a bot's Dependency Dashboard, the hive's own advisory report): + // structurally not work, so they derive no stage at all — not even 045 + // from a `needs-human` a triage bot put on them. + BucketDependencyDashboard IssueBucket = "dependency_dashboard" + BucketHiveAdvisory IssueBucket = "hive_advisory" ) // IssueFacts is the issue-side evidence.