From 3262367de8b216056e0303262c01d10c7ce10ad9 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Mon, 16 Nov 2026 21:48:55 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Review=20follow-ups,=20trust-on?= =?UTF-8?q?ly=20090=20and=20issue=20pr-link=20notes=20become=20status-card?= =?UTF-8?q?=20sections=20(quiet=20mode)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In github.notifications.mode: quiet the review Follow-ups checklist is the collapsible review-followups section of the PR's hive:status card (ticks kept via the new prstatus.WriteFunc), a 090 ready-for-human-merge entry whose only objection is the author's trust tier is the stage-ready line, and the issue-side PR-link stage note is the issue card's issue-pr-link section. Every 085 and a held or manual-merge 090 still post a comment. Fixes #18606 Signed-off-by: Andy Anderson --- ...18606-statuscard-followups-ready-prlink.md | 1 + src/docs/notifications.md | 8 +- .../sweeps-and-operations.md | 13 +- .../github/automerge/automerge_stage_human.go | 45 ++++- .../automerge_stage_ready_status_test.go | 123 +++++++++++++ src/pkg/github/issue_stage_labels.go | 2 +- src/pkg/github/issue_status_card.go | 21 +++ src/pkg/github/issue_status_card_test.go | 51 ++++++ src/pkg/github/notification_write_sites.go | 2 + src/pkg/github/pr_status_comment.go | 15 ++ src/pkg/github/review_backlog_collapse.go | 128 +++++++++++-- .../review_followups_status_card_test.go | 169 ++++++++++++++++++ src/pkg/prstatus/prstatus.go | 10 ++ src/pkg/prstatus/writer.go | 31 +++- 14 files changed, 589 insertions(+), 30 deletions(-) create mode 100644 changelog.d/changed-18606-statuscard-followups-ready-prlink.md create mode 100644 src/pkg/github/automerge/automerge_stage_ready_status_test.go create mode 100644 src/pkg/github/review_followups_status_card_test.go diff --git a/changelog.d/changed-18606-statuscard-followups-ready-prlink.md b/changelog.d/changed-18606-statuscard-followups-ready-prlink.md new file mode 100644 index 0000000000..474123774e --- /dev/null +++ b/changelog.d/changed-18606-statuscard-followups-ready-prlink.md @@ -0,0 +1 @@ +- Notifications: in `github.notifications.mode: quiet` (the default) three more notes stop posting comments of their own and become `hive:status` card sections, edited in place: the review Follow-ups checklist (`review-followups`, collapsible, ticked entries kept), the 090 ready-for-human-merge entry when the author's trust tier is the only objection (`stage-ready`), and the issue-side stage note naming the PR that covers the issue (`issue-pr-link`). Every 085 needs-decision entry and a held or manual-merge 090 still post a notifying comment; `mode: normal` is unchanged (hivecommons/hive#18606). diff --git a/src/docs/notifications.md b/src/docs/notifications.md index 722270d30c..741c8e0f34 100644 --- a/src/docs/notifications.md +++ b/src/docs/notifications.md @@ -487,10 +487,12 @@ without a class. Review submissions and review requests are always counted as | `automerge.(*engineStatusForge).CreateComment` | `status` | passthrough wrapper shared by normal-mode stage notes and the quiet-mode status-comment forge under `prstatus.Write`; attributed to its caller | | `github.(*clientStatusForge).CreateComment` | `status` | passthrough wrapper (status-comment forge under `prstatus.Write`); attributed to its caller | | `github.(*Client).PostIssueNote` | `status` | passthrough wrapper (issue status card, `attention_pilot`); attributed to its caller | +| `github.(*Client).PostInformationalIssueNote` | `status` | passthrough wrapper (issue status card in quiet mode or under `attention_pilot`, for notes nobody acts on); attributed to its caller | | `github.(*Client).closeDecomposedParent` | `status` | | | `github.(*Client).closeIssueForMergedPRClaimWithIssue` | `status` | | | `github.(*Client).closeSupersededPRDecision` | `status` | | | `github.(*Client).fileReviewBacklog` | `status` | | +| `github.(*Client).foldReviewFollowUps` | `status` | review Follow-ups checklist folded into the PR status card (quiet mode) | | `github.(*Client).foldSentinelNotice` | `status` | informational sentinel notice folded into the PR status card (quiet mode); a blocking alert is never folded | | `github.(*Client).joinFleetReportIssue` | `status` | | | `github.(*Client).markInProgressStarted` | `status` | | @@ -578,7 +580,11 @@ Quiet mode (`github.notifications.mode: quiet`) folds the hive's PR bookkeeping into one edited `hive:status` comment (including the auto-merge note, under the `auto-merge` section: in `normal` mode it stays its own comment, and a merge blocked on a person still gets its 085 / 090 entry -comment, hivecommons/hive#18452) but leaves issue notes as +comment, hivecommons/hive#18452; the review Follow-ups checklist, under +`review-followups`, and a trust-only 090 entry, under `stage-ready`, while a +held or manual-merge 090 and every 085 stay comments, hivecommons/hive#18606) +but leaves issue notes (except the informational `issue-pr-link` stage note) +as comments of their own, so one issue lifecycle (partial merge, remainder, close) could still email its watchers several times. With the pilot on, the issue gets the same card, written through the same single status writer diff --git a/src/docs/operator-reference/sweeps-and-operations.md b/src/docs/operator-reference/sweeps-and-operations.md index 212906fa32..038a6b4f27 100644 --- a/src/docs/operator-reference/sweeps-and-operations.md +++ b/src/docs/operator-reference/sweeps-and-operations.md @@ -552,9 +552,16 @@ not what it records: Hive trusted-author auto-merge …" or "merged by Hive on behalf of …") is the card's `auto-merge` section too, with its @-mentions neutralised, so a merge no longer emails the author and every watcher; in `normal` it is - still its own comment. A merge that waits on a person (the 085 - needs-decision and 090 ready-for-human-merge entry comments) still posts - a comment of its own. + still its own comment. The review Follow-ups checklist (findings held + below `review.backlog.min_severity`) is the card's collapsible + `review-followups` section, ticks kept across passes (a PR that already + has the old Follow-ups comment keeps editing that one), and a 090 + ready-for-human-merge entry whose only objection is the author's trust + tier is the card's `stage-ready` line (hivecommons/hive#18606). A merge + that waits on a specific step from a person (every 085 needs-decision + entry, and a held or manual-merge 090) still posts a comment of its own. + On the issue side the stage note naming the covering PR + (`issue-pr-link`) is a section of the issue's card in quiet mode too. - **No "no findings" reviews.** A reviewer whose whole body is the clean acknowledgement — or whose body says it has no findings while its verdict report approves with an empty findings list, as the plain `reviewer` diff --git a/src/pkg/github/automerge/automerge_stage_human.go b/src/pkg/github/automerge/automerge_stage_human.go index 1c378be3e1..5baee66f9a 100644 --- a/src/pkg/github/automerge/automerge_stage_human.go +++ b/src/pkg/github/automerge/automerge_stage_human.go @@ -19,6 +19,7 @@ import ( "github.com/hivecommons/hive/pkg/authorkind" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/oktotest" + "github.com/hivecommons/hive/pkg/prstatus" "github.com/hivecommons/hive/pkg/review" "github.com/hivecommons/hive/pkg/stageengine" "github.com/hivecommons/hive/pkg/stageengine/prstage" @@ -701,7 +702,27 @@ func (c *Engine) postHumanEntry(ctx context.Context, store *stagelabels.Store, k // (hivecommons/hive#16433): a later head or cause rewrites the hive's // existing 085 / 090 comment with an "updated" line instead of posting // another copy, which emailed everyone again to say the same thing. - if existing := c.findOwnEntryComment(ctx, obs, stagelabels.EntryCommentMarker(route.Stage)); existing != nil { + existing := c.findOwnEntryComment(ctx, obs, stagelabels.EntryCommentMarker(route.Stage)) + if route.Stage == stagelabels.ReadyForHumanMerge && existing == nil && c.stagePolicy().QuietNotifications { + if readyEntryFolds(route) { + n, err := c.writeStatusSectionWith(ctx, obs.Owner, obs.Repo, obs.Number, prstatus.KeyStageReady, readyCardSection(body), prstatus.Write) + if err != nil { + c.warn("stage labels: ready line on the status card failed", "repo", obs.Display, "pr", obs.Number, "error", err) + return 0, err + } + store.MarkEntryCommentedCause(key, obs.HeadSHA, cause) + store.MarkEntryCommentedDecisionKey(key, decisionKey) + c.info("stage labels: ready entry folded into the status card", "repo", obs.Display, "pr", obs.Number) + return n, nil + } + // A held or manual-merge 090 is a person's step and posts its own + // comment below; the plain "ready" line it replaces is dropped so + // the card never reads ready next to the hold. Best effort. + if _, err := c.writeStatusSectionWith(ctx, obs.Owner, obs.Repo, obs.Number, prstatus.KeyStageReady, "", prstatus.Write); err != nil { + c.warn("stage labels: clearing the ready line on the status card failed", "repo", obs.Display, "pr", obs.Number, "error", err) + } + } + if existing != nil { updated := stagelabels.EntryCommentUpdated(body, c.now()) // Rewrites the comment the gate admitted when it was posted; an edit notifies nobody. if _, _, err := c.gh.Issues.EditComment(ctx, obs.Owner, obs.Repo, existing.GetID(), &gh.IssueComment{Body: gh.Ptr(updated)}); err != nil { // writeback:gated @@ -723,6 +744,28 @@ func (c *Engine) postHumanEntry(ctx context.Context, store *stagelabels.Store, k return 1, nil } +// readyCardMarker stamps the 090 status-card line. It deliberately is not +// stagelabels.ReadyCommentMarker: findOwnEntryComment would read a card +// carrying that marker as the entry comment and overwrite the whole card. +const readyCardMarker = "" + +// readyEntryFolds reports whether a 090 entry is the plain "ready for a +// human merge" note that quiet mode writes as the stage-ready line of the +// PR's hive:status card (hivecommons/hive#18606): the PR's only objection is +// the author's trust tier and the stage/090 label and tracker already show +// it. A held head (a sentinel alert or hold label, route.Gates) or an +// approved manual-merge route asks a person for a specific step, so it +// keeps its own notifying comment, as does every 085 entry. +func readyEntryFolds(route stagelabels.Route) bool { + return route.Stage == stagelabels.ReadyForHumanMerge && !route.ManualMerge && len(route.Gates) == 0 +} + +// readyCardSection is body (a stagelabels.ReadyComment) as a status-card +// section: the same text under readyCardMarker. +func readyCardSection(body string) string { + return strings.Replace(body, stagelabels.ReadyCommentMarker, readyCardMarker, 1) +} + // findOwnEntryComment returns the hive's existing entry comment carrying // marker on the PR, or nil. Only a comment the hive's App login wrote // counts: anyone can type the marker, and the hive must never edit a diff --git a/src/pkg/github/automerge/automerge_stage_ready_status_test.go b/src/pkg/github/automerge/automerge_stage_ready_status_test.go new file mode 100644 index 0000000000..89d4b531cb --- /dev/null +++ b/src/pkg/github/automerge/automerge_stage_ready_status_test.go @@ -0,0 +1,123 @@ +package automerge + +// Tests for the 090 ready-for-human-merge entry's quiet-mode delivery +// (hivecommons/hive#18606): a PR whose only objection is the author's trust +// tier gets a stage-ready line on its hive:status card instead of a comment +// of its own; a held 090 (sentinel alert, hold label) still posts its own +// notifying comment, as does every 085 needs-decision entry. + +import ( + "context" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/prstatus" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +func quietReadyEngine(t *testing.T) (*stageAPI, func(reason string, labels ...string), *stagelabels.Store) { + t.Helper() + api, closeAPI := seededStageAPI(t) + t.Cleanup(closeAPI) + api.statefulComments = true + api.posted = map[int][]map[string]any{9: {{ + "id": int64(900), + "body": prstatus.Upsert("", prstatus.KeyStageStalled, " waiting"), + "user": map[string]any{"login": testHiveAppBotLogin}, + }}} + clock := &contributorLaneClock{at: time.Date(2026, 11, 16, 12, 0, 0, 0, time.UTC)} + verdict := &ContributorLaneVerdict{Configured: true, Approved: true, Verdict: "approve"} + e, store := humanStageEngine(t, api.url, clock, verdict, 0) + e.stageLabelPolicy = func() StageLabelPolicy { return StageLabelPolicy{Enabled: true, QuietNotifications: true} } + sweep := func(reason string, labels ...string) { + t.Helper() + api.reset() + e.recordStage(stageLaneTrusted, "acme/widget", "acme", "widget", stagePR(9, labels...), "untrusted-author-role", false, nil) + e.recordStage(stageLaneContributor, "acme/widget", "acme", "widget", stagePR(9, labels...), reason, false, nil) + e.noteStageRole("acme", "widget", 9, stagelabels.RoleContributor) + if _, err := e.ApplyStageLabels(context.Background()); err != nil { + t.Fatal(err) + } + } + return api, sweep, store +} + +func cardOf(t *testing.T, api *stageAPI) string { + t.Helper() + api.mu.Lock() + defer api.mu.Unlock() + for _, c := range api.posted[9] { + if body, _ := c["body"].(string); prstatus.IsStatusComment(body) { + return body + } + } + t.Fatal("PR 9 has no status card") + return "" +} + +func TestReadyEntryQuietFoldsIntoStatusCard(t *testing.T) { + api, sweep, store := quietReadyEngine(t) + sweep(contributorLaneReasonClaimTier, "role/contributor", "author/human", "stage/050-review-pending") + if got := stageOf(t, store, 9); got != stagelabels.ReadyForHumanMerge { + t.Fatalf("stage=%v want 090", got) + } + if len(api.comments) != 0 { + t.Fatalf("quiet 090 posted %d comments, want none: %q", len(api.comments), api.comments) + } + card := cardOf(t, api) + if _, ok := prstatus.Get(card, prstatus.KeyStageStalled); !ok { + t.Fatalf("existing card section lost:\n%s", card) + } + section, ok := prstatus.Get(card, prstatus.KeyStageReady) + if !ok || !strings.Contains(section, "Ready for a human merge: verdict approved @sha") || !strings.Contains(section, "Blocked only by `role/contributor`") || !strings.Contains(section, "`/lgtm` `/approve`") { + t.Fatalf("stage-ready section = %q (found %v)", section, ok) + } + if strings.Contains(card, stagelabels.ReadyCommentMarker) { + t.Fatalf("the card must not carry the entry-comment marker (the entry upsert would overwrite it):\n%s", card) + } + + // Same head and cause again: nothing is written. + edits := len(api.commentEdits) + sweep(contributorLaneReasonClaimTier, "role/contributor", "author/human", "stage/090-ready-for-human-merge") + if len(api.comments) != 0 || len(api.commentEdits) != edits { + t.Fatalf("re-sweep wrote: comments=%q edits=%d→%d", api.comments, edits, len(api.commentEdits)) + } +} + +// A held 090 asks a person to clear the gate, so it still posts its own +// comment in quiet mode, and the plain ready line is dropped from the card. +func TestReadyEntryQuietHeldStillComments(t *testing.T) { + api, sweep, _ := quietReadyEngine(t) + sweep(contributorLaneReasonClaimTier, "role/contributor", "author/human", "stage/050-review-pending") + if _, ok := prstatus.Get(cardOf(t, api), prstatus.KeyStageReady); !ok { + t.Fatal("setup: no ready line on the card") + } + sweep(contributorLaneReasonSentinelBlocked, "role/contributor", "author/human", "stage/090-ready-for-human-merge", "sentinel-alert") + if len(api.comments) != 1 || !strings.HasPrefix(api.comments[0], stagelabels.ReadyCommentMarker) || !strings.Contains(api.comments[0], "Held: a sentinel alert is open on this PR.") { + t.Fatalf("held 090 must post its own comment: %q", api.comments) + } + if prstatus.IsStatusComment(api.comments[0]) { + t.Fatalf("held comment is the card: %q", api.comments[0]) + } + if section, ok := prstatus.Get(cardOf(t, api), prstatus.KeyStageReady); ok { + t.Fatalf("stale ready line kept next to the hold: %q", section) + } +} + +func TestReadyEntryFolds(t *testing.T) { + for _, tc := range []struct { + name string + route stagelabels.Route + want bool + }{ + {"plain ready", stagelabels.Route{Stage: stagelabels.ReadyForHumanMerge}, true}, + {"held ready", stagelabels.Route{Stage: stagelabels.ReadyForHumanMerge, Gates: []string{"a sentinel alert is open on this PR"}}, false}, + {"manual merge", stagelabels.Route{Stage: stagelabels.ReadyForHumanMerge, ManualMerge: true}, false}, + {"needs decision", stagelabels.Route{Stage: stagelabels.NeedsDecision}, false}, + } { + if got := readyEntryFolds(tc.route); got != tc.want { + t.Errorf("%s: readyEntryFolds=%v want %v", tc.name, got, tc.want) + } + } +} diff --git a/src/pkg/github/issue_stage_labels.go b/src/pkg/github/issue_stage_labels.go index 2866e8bc95..1e8902a54d 100644 --- a/src/pkg/github/issue_stage_labels.go +++ b/src/pkg/github/issue_stage_labels.go @@ -918,7 +918,7 @@ func ensureIssueStagePRLink(ctx context.Context, client *Client, in IssueStageIn if !ok || rec.EntryCommented { return false, false, false } - if _, err := client.PostIssueNote(ctx, in.Repo, in.Number, prstatus.KeyIssuePRLink, link.StageComment, func(ctx context.Context) error { + if _, err := client.PostInformationalIssueNote(ctx, in.Repo, in.Number, prstatus.KeyIssuePRLink, link.StageComment, func(ctx context.Context) error { return client.CreateIssueComment(ctx, in.Repo, in.Number, link.StageComment) }); err != nil { owner, name := client.splitRepo(in.Repo) diff --git a/src/pkg/github/issue_status_card.go b/src/pkg/github/issue_status_card.go index dc983542d7..1e7d13e612 100644 --- a/src/pkg/github/issue_status_card.go +++ b/src/pkg/github/issue_status_card.go @@ -52,6 +52,27 @@ func (c *Client) PostIssueNote(ctx context.Context, repo string, number int, key return created, err } +// PostInformationalIssueNote is PostIssueNote for a note nobody has to act +// on, such as the stage note naming the PR that covers the issue +// (prstatus.KeyIssuePRLink, hivecommons/hive#18606): it becomes a section of +// the issue's status card under the attention pilot or in +// github.notifications.mode: quiet (the default), and runs legacy only in +// mode normal with the pilot off. Reports whether a new comment was +// created. +func (c *Client) PostInformationalIssueNote(ctx context.Context, repo string, number int, key, body string, legacy func(context.Context) error) (bool, error) { + if c == nil { + return false, ErrNoGitHubClient + } + if !c.attentionPilot() && !c.notificationsQuiet() { + return true, legacy(ctx) + } + created, err := c.UpsertPRStatusSection(ctx, repo, number, key, body) + if err == nil && !created { + c.noteCommentSuppressed() + } + return created, err +} + // PostIssueAttention delivers a newly required action (cause names it, e.g. // the PR whose merge awaits confirmation). With the attention pilot off it // runs legacy. With it on the action is recorded on the status card and diff --git a/src/pkg/github/issue_status_card_test.go b/src/pkg/github/issue_status_card_test.go index abac0d075e..f4f0e716f1 100644 --- a/src/pkg/github/issue_status_card_test.go +++ b/src/pkg/github/issue_status_card_test.go @@ -241,3 +241,54 @@ func TestIssueStatusCardAttentionGateRefusalRetries(t *testing.T) { t.Fatalf("repeat: posted=%v err=%v creates=%d", posted, err, s.creates) } } + +// The PR-link stage note names the PR covering the issue; nobody has to +// act on it, so in github.notifications.mode: quiet it is the issue card's +// issue-pr-link section even with the attention pilot off, and an issue +// that already has a card gets no new comment (hivecommons/hive#18606). +// Mode normal with the pilot off keeps the legacy comment. +func TestInformationalIssueNoteFoldsInQuietMode(t *testing.T) { + ctx := context.Background() + link := issueStagePRLinkComment("https://github.com/o/r/pull/42", 42, "Partial work.") + + s := &statusCommentServer{} + c := testClient(t, s.start(t).URL) + c.SetAppBotLogin("hive-app[bot]") + c.SetNotificationsQuiet(func() bool { return true }) + noLegacy := func(context.Context) error { + t.Error("legacy write ran in quiet mode") + return nil + } + if _, err := c.UpsertPRStatusSection(ctx, "o/r", 5, prstatus.KeyStageRegressed, "stage regressed"); err != nil { + t.Fatal(err) + } + if s.creates != 1 { + t.Fatalf("setup: creates=%d, want the card", s.creates) + } + created, err := c.PostInformationalIssueNote(ctx, "o/r", 5, prstatus.KeyIssuePRLink, link, noLegacy) + if err != nil || created { + t.Fatalf("created=%v err=%v, want an in-place edit", created, err) + } + if s.creates != 1 || len(s.comments) != 1 { + t.Fatalf("creates=%d comments=%d, want no new comment", s.creates, len(s.comments)) + } + body, _ := s.comments[0]["body"].(string) + section, ok := prstatus.Get(body, prstatus.KeyIssuePRLink) + if !ok || !strings.Contains(section, "") || !strings.Contains(section, "PR #42 covers this issue: https://github.com/o/r/pull/42") { + t.Fatalf("pr-link section = %q (found %v)", section, ok) + } + + normal := &statusCommentServer{} + n := testClient(t, normal.start(t).URL) + n.SetNotificationsQuiet(func() bool { return false }) + legacyCalls := 0 + if _, err := n.PostInformationalIssueNote(ctx, "o/r", 5, prstatus.KeyIssuePRLink, link, func(ctx context.Context) error { + legacyCalls++ + return n.CreateIssueComment(ctx, "o/r", 5, link) + }); err != nil { + t.Fatal(err) + } + if legacyCalls != 1 || normal.creates != 1 { + t.Fatalf("normal mode: legacy=%d creates=%d, want the comment of its own", legacyCalls, normal.creates) + } +} diff --git a/src/pkg/github/notification_write_sites.go b/src/pkg/github/notification_write_sites.go index 798ab9a7d6..310a26a1ef 100644 --- a/src/pkg/github/notification_write_sites.go +++ b/src/pkg/github/notification_write_sites.go @@ -30,6 +30,8 @@ var notificationWriteSites = map[string]NotificationWriteSite{ "github.(*Client).EditIssueMarkerComment": {Class: NotificationClassStatus, Passthrough: true}, "github.(*clientStatusForge).CreateComment": {Class: NotificationClassStatus, Passthrough: true}, "github.(*Client).PostIssueNote": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).PostInformationalIssueNote": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).foldReviewFollowUps": {Class: NotificationClassStatus}, "automerge.(*engineStatusForge).CreateComment": {Class: NotificationClassStatus, Passthrough: true}, // status: bookkeeping readable on demand. diff --git a/src/pkg/github/pr_status_comment.go b/src/pkg/github/pr_status_comment.go index d8cc3ec806..eae78944a5 100644 --- a/src/pkg/github/pr_status_comment.go +++ b/src/pkg/github/pr_status_comment.go @@ -30,6 +30,21 @@ func (c *Client) UpsertPRStatusSection(ctx context.Context, repo string, number return res.Created, err } +// UpsertPRStatusSectionFunc is UpsertPRStatusSection for a section whose +// text is merged with what it already says (prstatus.WriteFunc): render +// receives the section's current body ("" when none) and is re-run on every +// compare-and-retry read, so an edit a person made in between survives. +// Reports whether a comment was created. +func (c *Client) UpsertPRStatusSectionFunc(ctx context.Context, repo string, number int, key string, render func(previous string) string) (bool, error) { + if c == nil { + return false, ErrNoGitHubClient + } + owner, repoName := c.splitRepo(repo) + f := &clientStatusForge{c: c, owner: owner, repo: repoName, number: number} + res, err := prstatus.WriteFunc(ctx, f, prstatus.ItemKey(owner+"/"+repoName, number), key, render) + return res.Created, err +} + // ownStatusCommentLogin reports whether login is exactly this hive's App bot // login. Any other account, including another bot, is not the owner, and an // unknown App login fails closed so nothing is ever edited or deleted. diff --git a/src/pkg/github/review_backlog_collapse.go b/src/pkg/github/review_backlog_collapse.go index 5dda3ae569..9e8a752d75 100644 --- a/src/pkg/github/review_backlog_collapse.go +++ b/src/pkg/github/review_backlog_collapse.go @@ -10,6 +10,7 @@ import ( "time" "github.com/hivecommons/hive/pkg/outputschema" + "github.com/hivecommons/hive/pkg/prstatus" "github.com/hivecommons/hive/pkg/review" ) @@ -245,6 +246,18 @@ func (c *Client) reviewBacklogGroupBody(req ReviewRequest, p review.Perspective, // and new ones appended. Best effort: a failure is logged, the pass is not // failed, and the findings return on the next review of the PR. func (c *Client) upsertReviewFollowUpsComment(ctx context.Context, req ReviewRequest, held []reviewBacklogHeldFinding, minSeverity string) { + if c.notificationsQuiet() { + folded, err := c.foldReviewFollowUps(ctx, req, held, minSeverity) + if err != nil { + c.logger.Warn("review backlog: follow-ups status-card section not updated", + slog.String("repo", req.Repo), slog.Int("number", req.Number), + slog.Int("held", len(held)), slog.String("error", err.Error())) + return + } + if folded { + return + } + } res, err := c.EditIssueMarkerComment(ctx, req.Repo, req.Number, reviewFollowUpsCommentMarker, func(previous string) string { return renderReviewFollowUpsComment(previous, held, minSeverity) }) @@ -263,16 +276,56 @@ func (c *Client) upsertReviewFollowUpsComment(ctx context.Context, req ReviewReq } } -// renderReviewFollowUpsComment merges held into previous (the comment's -// prior body, "" when none) and returns the full comment. Checklist lines -// are keyed on their text after the checkbox so a ticked entry stays ticked -// and a re-reported finding is not listed twice. -func renderReviewFollowUpsComment(previous string, held []reviewBacklogHeldFinding, minSeverity string) string { - type entry struct { - checked bool - text string +// foldReviewFollowUps is the quiet-mode delivery of the Follow-ups list +// (hivecommons/hive#18606): the checklist becomes the collapsible +// prstatus.KeyReviewFollowUps section of the PR's hive:status card, edited +// in place, instead of a comment of its own that emailed the author and +// every watcher on each reviewed PR. Nobody has to act on a held finding, +// so nothing is lost by not notifying. A PR that already carries the +// legacy Follow-ups comment keeps it (folded is false): that comment is +// edited in place, which notifies nobody either, and the PR never shows two +// copies of the list. folded is true when the card carries the list. +func (c *Client) foldReviewFollowUps(ctx context.Context, req ReviewRequest, held []reviewBacklogHeldFinding, minSeverity string) (bool, error) { + owner, repoName := c.splitRepo(req.Repo) + comments, err := c.listIssueComments(ctx, owner, repoName, req.Number) + if err != nil { + return false, err } - var entries []entry + for _, cm := range comments { + if cm != nil && strings.Contains(cm.GetBody(), reviewFollowUpsCommentMarker) && c.markerAuthorTrusted(cm.GetUser()) { + return false, nil + } + } + created, err := c.UpsertPRStatusSectionFunc(ctx, req.Repo, req.Number, prstatus.KeyReviewFollowUps, func(previous string) string { + return renderReviewFollowUpsSection(previous, held, minSeverity) + }) + if err != nil { + return false, err + } + if !created { + c.noteCommentSuppressed() + } + c.recordWriteAudit(AuditActionReviewBacklogSummaryPosted, hiveWriteMeta(), + WriteTarget{Repo: req.Repo, Number: req.Number}, + "held", strconv.Itoa(len(held)), + "min_severity", minSeverity, + "review_agent", req.Agent, + "delivery", "status-card") + return true, nil +} + +// reviewFollowUpEntry is one checklist line of the Follow-ups list. +type reviewFollowUpEntry struct { + checked bool + text string +} + +// mergeReviewFollowUps reads the checklist lines of previous (a Follow-ups +// comment or status-card section) and appends held, keyed on the text after +// the checkbox so a ticked entry stays ticked and a re-reported finding is +// not listed twice. Entries are sorted by text. +func mergeReviewFollowUps(previous string, held []reviewBacklogHeldFinding) []reviewFollowUpEntry { + var entries []reviewFollowUpEntry seen := map[string]bool{} for _, line := range strings.Split(previous, "\n") { trimmed := strings.TrimSpace(line) @@ -290,7 +343,7 @@ func renderReviewFollowUpsComment(previous string, held []reviewBacklogHeldFindi continue } seen[text] = true - entries = append(entries, entry{checked: checked, text: text}) + entries = append(entries, reviewFollowUpEntry{checked: checked, text: text}) } for _, h := range held { text := reviewFollowUpLine(h) @@ -298,23 +351,60 @@ func renderReviewFollowUpsComment(previous string, held []reviewBacklogHeldFindi continue } seen[text] = true - entries = append(entries, entry{text: text}) - } - if len(entries) == 0 { - return "" + entries = append(entries, reviewFollowUpEntry{text: text}) } sort.SliceStable(entries, func(i, j int) bool { return entries[i].text < entries[j].text }) - var b strings.Builder - b.WriteString(reviewFollowUpsCommentMarker) - fmt.Fprintf(&b, "\n### Review follow-ups (below `review.backlog.min_severity: %s`)\n", minSeverity) - b.WriteString("Non-blocking findings below the backlog filing line are listed here instead of as issues, one comment per PR, updated in place. Tick them off as they are fixed; set `review.backlog.min_severity: P3` to file every finding.\n\n") + return entries +} + +func writeReviewFollowUpEntries(b *strings.Builder, entries []reviewFollowUpEntry) { for _, e := range entries { box := "[ ]" if e.checked { box = "[x]" } - fmt.Fprintf(&b, "- %s %s\n", box, e.text) + fmt.Fprintf(b, "- %s %s\n", box, e.text) + } +} + +// renderReviewFollowUpsSection is the status-card form of the Follow-ups +// list: one summary line with the open count, the checklist collapsed +// under it. It keeps reviewFollowUpsCommentMarker so marker readers still +// find the list on the card. +func renderReviewFollowUpsSection(previous string, held []reviewBacklogHeldFinding, minSeverity string) string { + entries := mergeReviewFollowUps(previous, held) + if len(entries) == 0 { + return "" + } + open := 0 + for _, e := range entries { + if !e.checked { + open++ + } } + var b strings.Builder + b.WriteString(reviewFollowUpsCommentMarker) + fmt.Fprintf(&b, "\n
Review follow-ups: %d open of %d (below review.backlog.min_severity: %s)\n\n", open, len(entries), minSeverity) + b.WriteString("Non-blocking findings below the backlog filing line, listed here instead of as issues. Tick them off as they are fixed; set `review.backlog.min_severity: P3` to file every finding.\n\n") + writeReviewFollowUpEntries(&b, entries) + b.WriteString("\n
") + return b.String() +} + +// renderReviewFollowUpsComment merges held into previous (the comment's +// prior body, "" when none) and returns the full comment. Checklist lines +// are keyed on their text after the checkbox so a ticked entry stays ticked +// and a re-reported finding is not listed twice. +func renderReviewFollowUpsComment(previous string, held []reviewBacklogHeldFinding, minSeverity string) string { + entries := mergeReviewFollowUps(previous, held) + if len(entries) == 0 { + return "" + } + var b strings.Builder + b.WriteString(reviewFollowUpsCommentMarker) + fmt.Fprintf(&b, "\n### Review follow-ups (below `review.backlog.min_severity: %s`)\n", minSeverity) + b.WriteString("Non-blocking findings below the backlog filing line are listed here instead of as issues, one comment per PR, updated in place. Tick them off as they are fixed; set `review.backlog.min_severity: P3` to file every finding.\n\n") + writeReviewFollowUpEntries(&b, entries) return b.String() } diff --git a/src/pkg/github/review_followups_status_card_test.go b/src/pkg/github/review_followups_status_card_test.go new file mode 100644 index 0000000000..788c4f6887 --- /dev/null +++ b/src/pkg/github/review_followups_status_card_test.go @@ -0,0 +1,169 @@ +package github + +// Tests for the Follow-ups list's quiet-mode delivery +// (hivecommons/hive#18606): with github.notifications.mode: quiet the held +// findings are a collapsible section of the PR's hive:status card, edited +// in place, and never a comment of their own. + +import ( + "context" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/prstatus" +) + +func quietFollowUpsClient(t *testing.T, url string) (*Client, *fakeBacklogSink) { + t.Helper() + c := reviewTestClient(t, url) + c.SetAppBotLogin("hive[bot]") + c.SetNotificationsQuiet(func() bool { return true }) + sink := &fakeBacklogSink{dest: config.ReviewBacklogLinear} + c.SetReviewBacklogRouting(func() ReviewBacklogRouting { + return ReviewBacklogRouting{ + Severity: config.ReviewSeverityConfig{BlockAt: "P1"}, + Backlog: config.ReviewBacklogConfig{Destination: config.ReviewBacklogLinear, MinSeverity: "P1"}, + Sink: sink, + } + }) + return c, sink +} + +func followUpsCommentCount(bodies []string) int { + n := 0 + for _, b := range bodies { + if strings.Contains(b, reviewFollowUpsCommentMarker) && !prstatus.IsStatusComment(b) { + n++ + } + } + return n +} + +func statusCardBody(t *testing.T, bodies []string) string { + t.Helper() + var card string + n := 0 + for _, b := range bodies { + if prstatus.IsStatusComment(b) { + card = b + n++ + } + } + if n != 1 { + t.Fatalf("status cards = %d, want exactly one: %q", n, bodies) + } + return card +} + +func TestReviewFollowUpsQuietFoldIntoExistingStatusCard(t *testing.T) { + withReviewBacklogState(t) + server := &followUpsCommentServer{bodies: []string{ + prstatus.Upsert("", prstatus.KeyStageStalled, " waiting"), + }} + srv := httptest.NewServer(server.handler(t)) + defer srv.Close() + c, sink := quietFollowUpsClient(t, srv.URL) + ctx := context.Background() + now := time.Date(2026, 11, 16, 12, 0, 0, 0, time.UTC) + report := routingReport(t, 5, "abc", + nit("stale example", "low", "docs/a.md", 3, "shows the old flag, cc @alice"), + nit("naming", "info", "pkg/c.go", 4, "prefer camelCase"), + ) + if err := c.fileOutOfScopeReviewBacklog(ctx, ReviewRequest{Repo: "o/r", Number: 5, Agent: "reviewer", Report: report}, now); err != nil { + t.Fatal(err) + } + if len(sink.created) != 0 { + t.Fatalf("held findings filed: %+v", sink.created) + } + if got := followUpsCommentCount(server.bodies); got != 0 { + t.Fatalf("quiet mode posted %d Follow-ups comments, want none: %q", got, server.bodies) + } + card := statusCardBody(t, server.bodies) + if server.patches == 0 { + t.Fatal("the existing card was never edited") + } + if _, ok := prstatus.Get(card, prstatus.KeyStageStalled); !ok { + t.Fatalf("existing card section lost:\n%s", card) + } + section, ok := prstatus.Get(card, prstatus.KeyReviewFollowUps) + if !ok { + t.Fatalf("no %s section:\n%s", prstatus.KeyReviewFollowUps, card) + } + for _, want := range []string{"
", "Review follow-ups: 2 open of 2", "min_severity: P1", "- [ ] **P3 low**", "stale example (`docs/a.md:3`)", "naming (`pkg/c.go:4`)", "
"} { + if !strings.Contains(section, want) { + t.Errorf("section missing %q:\n%s", want, section) + } + } + if strings.Contains(section, "@alice") { + t.Errorf("section must not mention anyone live:\n%s", section) + } + + // A person ticks one entry on the card; the next head re-reports it + // and adds another. The tick survives, nothing is listed twice and no + // comment is posted. + server.bodies[0] = strings.Replace(server.bodies[0], "- [ ] **P3 info**", "- [x] **P3 info**", 1) + again := routingReport(t, 5, "abd", + nit("naming", "info", "pkg/c.go", 4, "prefer camelCase"), + nit("typo", "low", "pkg/b.go", 9, "receive"), + ) + if err := c.fileOutOfScopeReviewBacklog(ctx, ReviewRequest{Repo: "o/r", Number: 5, Agent: "reviewer", Report: again}, now.Add(time.Hour)); err != nil { + t.Fatal(err) + } + if len(server.bodies) != 1 || followUpsCommentCount(server.bodies) != 0 { + t.Fatalf("second pass posted a comment: %q", server.bodies) + } + section, _ = prstatus.Get(server.bodies[0], prstatus.KeyReviewFollowUps) + if strings.Count(section, "naming (`pkg/c.go:4`)") != 1 || !strings.Contains(section, "typo (`pkg/b.go:9`)") { + t.Fatalf("merged section wrong:\n%s", section) + } + if !strings.Contains(section, "- [x] **P3 info**") || !strings.Contains(section, "2 open of 3") { + t.Fatalf("the ticked entry must stay ticked and drop out of the open count:\n%s", section) + } +} + +func TestReviewFollowUpsQuietCreatesCardWhenNone(t *testing.T) { + withReviewBacklogState(t) + server := &followUpsCommentServer{} + srv := httptest.NewServer(server.handler(t)) + defer srv.Close() + c, _ := quietFollowUpsClient(t, srv.URL) + report := routingReport(t, 5, "abc", nit("stale example", "low", "docs/a.md", 3, "shows the old flag")) + if err := c.fileOutOfScopeReviewBacklog(context.Background(), ReviewRequest{Repo: "o/r", Number: 5, Agent: "reviewer", Report: report}, time.Date(2026, 11, 16, 12, 0, 0, 0, time.UTC)); err != nil { + t.Fatal(err) + } + if got := followUpsCommentCount(server.bodies); got != 0 { + t.Fatalf("Follow-ups comments = %d, want the list on the card only: %q", got, server.bodies) + } + section, ok := prstatus.Get(statusCardBody(t, server.bodies), prstatus.KeyReviewFollowUps) + if !ok || !strings.Contains(section, "stale example (`docs/a.md:3`)") { + t.Fatalf("section = %q (found %v)", section, ok) + } +} + +// A PR that already carries the legacy Follow-ups comment keeps it, edited +// in place, so the list is never shown twice. +func TestReviewFollowUpsQuietKeepsLegacyComment(t *testing.T) { + withReviewBacklogState(t) + legacy := reviewFollowUpsCommentMarker + "\n### Review follow-ups\n\n- [ ] **P3 low** docs-currency — old (`docs/z.md:1`)\n" + server := &followUpsCommentServer{bodies: []string{legacy}} + srv := httptest.NewServer(server.handler(t)) + defer srv.Close() + c, _ := quietFollowUpsClient(t, srv.URL) + report := routingReport(t, 5, "abc", nit("stale example", "low", "docs/a.md", 3, "shows the old flag")) + if err := c.fileOutOfScopeReviewBacklog(context.Background(), ReviewRequest{Repo: "o/r", Number: 5, Agent: "reviewer", Report: report}, time.Date(2026, 11, 16, 12, 0, 0, 0, time.UTC)); err != nil { + t.Fatal(err) + } + for _, b := range server.bodies { + if prstatus.IsStatusComment(b) { + if _, ok := prstatus.Get(b, prstatus.KeyReviewFollowUps); ok { + t.Fatalf("list duplicated onto the card:\n%s", b) + } + } + } + if server.patches == 0 || !strings.Contains(server.bodies[0], "stale example (`docs/a.md:3`)") || !strings.Contains(server.bodies[0], "old (`docs/z.md:1`)") { + t.Fatalf("legacy comment not edited in place: patches=%d body=%q", server.patches, server.bodies[0]) + } +} diff --git a/src/pkg/prstatus/prstatus.go b/src/pkg/prstatus/prstatus.go index 166adb6e3b..5a4d343cc8 100644 --- a/src/pkg/prstatus/prstatus.go +++ b/src/pkg/prstatus/prstatus.go @@ -173,4 +173,14 @@ const ( // or operator-approved auto-merge note, "merged by Hive …"), which used // to be a fresh comment on every merge (hivecommons/hive#18452). KeyAutoMerge = "auto-merge" + // KeyReviewFollowUps is the collapsible checklist of review findings + // held below review.backlog.min_severity, which used to be its own + // `` comment on every + // reviewed PR (hivecommons/hive#18606). + KeyReviewFollowUps = "review-followups" + // KeyStageReady is the 090 ready-for-human-merge line for a PR whose + // only objection is the author's trust tier, which used to be its own + // `` comment + // (hivecommons/hive#18606). A held or manual-merge 090 still posts one. + KeyStageReady = "stage-ready" ) diff --git a/src/pkg/prstatus/writer.go b/src/pkg/prstatus/writer.go index 373ebbae0d..8562a7c733 100644 --- a/src/pkg/prstatus/writer.go +++ b/src/pkg/prstatus/writer.go @@ -89,7 +89,24 @@ func WriteMentioning(ctx context.Context, f Forge, item, key, text string) (Writ return write(ctx, f, item, key, text) } +// WriteFunc is Write for a section whose new text depends on its current +// text: render receives the section's body as it stands on the comment +// being edited ("" when the section or the comment does not exist yet) and +// returns the replacement. It runs again on every compare-and-retry read, +// so a change a person made in between (a ticked checklist box) is merged +// rather than overwritten. Mentions in the rendered text are neutralised as +// in Write. +func WriteFunc(ctx context.Context, f Forge, item, key string, render func(previous string) string) (WriteResult, error) { + return writeWith(ctx, f, item, key, func(previous string) string { + return advisory.NeutralizeMentions(render(previous)) + }) +} + func write(ctx context.Context, f Forge, item, key, text string) (WriteResult, error) { + return writeWith(ctx, f, item, key, func(string) string { return text }) +} + +func writeWith(ctx context.Context, f Forge, item, key string, textFor func(previous string) string) (WriteResult, error) { unlock := lockItem(item) defer unlock() var res WriteResult @@ -98,9 +115,6 @@ func write(ctx context.Context, f Forge, item, key, text string) (WriteResult, e return res, err } if len(ownStatus(status)) == 0 { - if strings.TrimSpace(text) == "" { - return res, nil - } // Foreign status comments are merged from but never edited, so a // hive-owned comment is created to carry the merged sections. Their // text becomes part of a body the hive owns and re-edits, so any @@ -109,7 +123,13 @@ func write(ctx context.Context, f Forge, item, key, text string) (WriteResult, e for _, c := range status { bodies = append(bodies, foreignBody(c)) } - if err := f.CreateComment(ctx, Upsert(Merge(bodies...), key, text)); err != nil { + merged := Merge(bodies...) + previous, _ := Get(merged, key) + text := textFor(previous) + if strings.TrimSpace(text) == "" { + return res, nil + } + if err := f.CreateComment(ctx, Upsert(merged, key, text)); err != nil { return res, err } res.Created = true @@ -130,7 +150,8 @@ func write(ctx context.Context, f Forge, item, key, text string) (WriteResult, e } target := own[0] edited, err := editCompareAndRetry(ctx, f, target.ID, target.Body, func(cur string) string { - return Upsert(cur, key, text) + previous, _ := Get(cur, key) + return Upsert(cur, key, textFor(previous)) }) res.Edited = res.Edited || edited return res, err From 32c1d90bf46856b592440739673f4e7aeb9bfe74 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Mon, 16 Nov 2026 22:34:08 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20status-card=20follow-ups=20u?= =?UTF-8?q?se=20their=20own=20marker;=20tests=20expect=20neutralised=20men?= =?UTF-8?q?tions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The card section carried the legacy Follow-ups comment marker, so the next pass read the card as the legacy comment and EditIssueMarkerComment rewrote the whole card. Stamp the section with and skip status comments in the legacy check. The 090 card line goes through prstatus.Write, which neutralises '@sha' to a code span; the test now expects that. Signed-off-by: Andy Anderson --- .../automerge/automerge_stage_ready_status_test.go | 2 +- src/pkg/github/review_backlog_collapse.go | 13 +++++++++---- src/pkg/github/review_followups_status_card_test.go | 5 ++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pkg/github/automerge/automerge_stage_ready_status_test.go b/src/pkg/github/automerge/automerge_stage_ready_status_test.go index 89d4b531cb..7ce0389ec4 100644 --- a/src/pkg/github/automerge/automerge_stage_ready_status_test.go +++ b/src/pkg/github/automerge/automerge_stage_ready_status_test.go @@ -70,7 +70,7 @@ func TestReadyEntryQuietFoldsIntoStatusCard(t *testing.T) { t.Fatalf("existing card section lost:\n%s", card) } section, ok := prstatus.Get(card, prstatus.KeyStageReady) - if !ok || !strings.Contains(section, "Ready for a human merge: verdict approved @sha") || !strings.Contains(section, "Blocked only by `role/contributor`") || !strings.Contains(section, "`/lgtm` `/approve`") { + if !ok || !strings.Contains(section, "Ready for a human merge: verdict approved `sha`") || !strings.Contains(section, "Blocked only by `role/contributor`") || !strings.Contains(section, "`/lgtm` `/approve`") { t.Fatalf("stage-ready section = %q (found %v)", section, ok) } if strings.Contains(card, stagelabels.ReadyCommentMarker) { diff --git a/src/pkg/github/review_backlog_collapse.go b/src/pkg/github/review_backlog_collapse.go index 9e8a752d75..51e1dcf3f4 100644 --- a/src/pkg/github/review_backlog_collapse.go +++ b/src/pkg/github/review_backlog_collapse.go @@ -20,6 +20,12 @@ import ( // such comment however many reviews it gets. const reviewFollowUpsCommentMarker = "" +// reviewFollowUpsCardMarker stamps the status-card form of the list +// (hivecommons/hive#18606). It deliberately is not +// reviewFollowUpsCommentMarker: EditIssueMarkerComment would otherwise find +// the whole card as "the Follow-ups comment" and overwrite it. +const reviewFollowUpsCardMarker = "" + // reviewFollowUpsSummaryMaxLen bounds the one-line summary quoted per held // finding in the Follow-ups comment. const reviewFollowUpsSummaryMaxLen = 200 @@ -292,7 +298,7 @@ func (c *Client) foldReviewFollowUps(ctx context.Context, req ReviewRequest, hel return false, err } for _, cm := range comments { - if cm != nil && strings.Contains(cm.GetBody(), reviewFollowUpsCommentMarker) && c.markerAuthorTrusted(cm.GetUser()) { + if cm != nil && !prstatus.IsStatusComment(cm.GetBody()) && strings.Contains(cm.GetBody(), reviewFollowUpsCommentMarker) && c.markerAuthorTrusted(cm.GetUser()) { return false, nil } } @@ -369,8 +375,7 @@ func writeReviewFollowUpEntries(b *strings.Builder, entries []reviewFollowUpEntr // renderReviewFollowUpsSection is the status-card form of the Follow-ups // list: one summary line with the open count, the checklist collapsed -// under it. It keeps reviewFollowUpsCommentMarker so marker readers still -// find the list on the card. +// under it, stamped with reviewFollowUpsCardMarker. func renderReviewFollowUpsSection(previous string, held []reviewBacklogHeldFinding, minSeverity string) string { entries := mergeReviewFollowUps(previous, held) if len(entries) == 0 { @@ -383,7 +388,7 @@ func renderReviewFollowUpsSection(previous string, held []reviewBacklogHeldFindi } } var b strings.Builder - b.WriteString(reviewFollowUpsCommentMarker) + b.WriteString(reviewFollowUpsCardMarker) fmt.Fprintf(&b, "\n
Review follow-ups: %d open of %d (below review.backlog.min_severity: %s)\n\n", open, len(entries), minSeverity) b.WriteString("Non-blocking findings below the backlog filing line, listed here instead of as issues. Tick them off as they are fixed; set `review.backlog.min_severity: P3` to file every finding.\n\n") writeReviewFollowUpEntries(&b, entries) diff --git a/src/pkg/github/review_followups_status_card_test.go b/src/pkg/github/review_followups_status_card_test.go index 788c4f6887..e857406f80 100644 --- a/src/pkg/github/review_followups_status_card_test.go +++ b/src/pkg/github/review_followups_status_card_test.go @@ -92,7 +92,10 @@ func TestReviewFollowUpsQuietFoldIntoExistingStatusCard(t *testing.T) { if !ok { t.Fatalf("no %s section:\n%s", prstatus.KeyReviewFollowUps, card) } - for _, want := range []string{"
", "Review follow-ups: 2 open of 2", "min_severity: P1", "- [ ] **P3 low**", "stale example (`docs/a.md:3`)", "naming (`pkg/c.go:4`)", "
"} { + if strings.Contains(card, reviewFollowUpsCommentMarker) { + t.Errorf("the card must not carry the legacy comment marker (the marker upsert would overwrite the card):\n%s", card) + } + for _, want := range []string{reviewFollowUpsCardMarker, "
", "Review follow-ups: 2 open of 2", "min_severity: P1", "- [ ] **P3 low**", "stale example (`docs/a.md:3`)", "naming (`pkg/c.go:4`)", "
"} { if !strings.Contains(section, want) { t.Errorf("section missing %q:\n%s", want, section) }