Skip to content

πŸ› Fold hive PR notes into one edited status comment and stop no-findings review spam - #15876

Merged
clubanderson merged 2 commits into
v5from
fix/notification-spam
Oct 30, 2026
Merged

clubanderson merged 2 commits into
v5from
fix/notification-spam

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Closes #15875

Problem

Every issue comment and review the hive posts emails the PR author and every watcher. On hivecommons/hive today: PR #15817 got 8 bot comments + 3 bot reviews in two hours (three hive:human-071-note comments each @-mentioning the author, three hive:stage-regressed of which two were required-check-pending after a push, a hive:stage-stalled for a PR merely queued in the merge train, a duplicate-guard redirect); #15834 got 5 reviews (two "Reviewed β€” no findings") + 3 comments; #15831 5 reviews + 5 comments. Times ~30 open PRs.

Fix

New knob github.notifications.mode β€” quiet (default) | normal (restores previous behaviour). In quiet mode:

  1. One status comment per PR, edited in place. hive:stage-stalled, hive:stage-regressed, hive:human-071-note and hive:create-pr-duplicate-guard become sections of a single <!-- hive:status --> comment (new pkg/prstatus). Created the first time, PATCHed afterwards β€” editing a comment does not email. Built on the existing UpsertIssueMarkerComment find-by-marker-then-edit helper (Client.UpsertPRStatusSection); the automerge engine has its own editStatusSection sharing the one CreateComment call site so the direct-write ratchet is unchanged.
  2. No "no findings" reviews. The review relay records a body matching **Reviewed** β€” no findings from … as record_verdict and submits nothing (result note explains). review.acknowledge_no_findings is forced off in the prompts in quiet mode so reviewers use --record-verdict. maxReviewsPerHead is 1 in quiet mode; a later perspective's findings on an already-reviewed head are folded into the status comment under review-findings:<agent> instead of becoming a second review.
  3. Regression only on a real failure (regressionNotable: not ciReasonPending, not a hive-controlled wait). Stalled never for merge-train:queued-behind* / merge-train:rebasing / base-refresh:* (stageReasonWaitsOnHive). These two apply in both modes β€” they were simply wrong.
  4. @-mention once per cause. stagelabels.Record.MentionCause + MentionDue/MarkMentioned; cause class collapses check-failing:unit/check-failing:lint/required-check-failing:* into one ask. New head, same cause β†’ section rewritten without the @.
  5. Docs: operator-reference.md β†’ "Notification mode" (with the why: every comment emails authors and watchers paragraph) and agent-configuration.md.

Before / after (comment-emitting sites on PRs)

Site Before (per PR) After, quiet
hive:human-071-note 1 comment + @-mention per head section of 1 status comment; mention once per cause
hive:stage-regressed 1 comment per regression incl. pending flaps section; only real failures
hive:stage-stalled 1 comment incl. merge-train queued section; never for hive-controlled waits
hive:create-pr-duplicate-guard 1 comment per redirect head section
no-findings reviews 1 review per clean perspective 0
reviews with findings 1 per perspective 1 per head (others fold into the status comment)

For #15817 that is 8 comments + 3 reviews β†’ 1 comment (created once, then edited) + ≀1 review: ~90 % fewer notifications. Issue-side notes (issue_stage_labels.go) are untouched; this PR is about PRs.

Tests

pkg/prstatus (parse/render/upsert), pkg/github (UpsertPRStatusSection creates once then edits; duplicate guard quiet path edits on retry; watcher suppresses the no-findings ack and still posts findings; maxReviewsPerHead quiet), pkg/github/automerge (stall + regression fold into one edited comment; required-check-pending is not a regression; regressionNotable / stageReasonWaitsOnHive tables; 071 mention once per cause across heads), pkg/stagelabels (MentionDue), pkg/review (ack matcher), pkg/config. No time.Sleep. Ratchet baseline for automerge_contributor_nudge.go lowered 3β†’2.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15731 πŸ“– docs: split the operator reference same files src/docs/operator-reference.md
#15877 ✨ feature: show abandoned counts on contributor cards and status same files src/docs/operator-reference.md
#15885 ✨ Add integration-aware orchestration above preparation and native queues same files src/cmd/hive/main_sweeps.go
src/pkg/config/config.go
src/pkg/config/testdata/agent_runtime_golden.json
src/pkg/config/validate.go
#15819 🌱 refactor: split src/pkg/github/automerge/automerge_sweep.go into 4 files same files src/pkg/writeback/testdata/direct-writes-baseline.txt

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • relative links and anchors resolve

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 071-needs-author: optional-check-failing:relative links and anchors resolve

@hivecommons-hive

Copy link
Copy Markdown
Contributor

relative links and anchors resolve fails on 31a90e19 in the docs-citation step, not the link checker:

DRIFT src/docs/scale-envelope.md:37 src/pkg/github/client.go:4936-4946 -> lacks anchor(s) near cited range: AgeMinutes

This PR's changes to src/pkg/github/client.go shifted RankActionableIssues down to line 4963 (the AgeMinutes comparison is now at 4971). Re-anchor the citation with the repo's own fixer and push:

python3 src/scripts/check-docs-citations.py --fix
git commit -s -am "docs: re-anchor scale-envelope citation"

(or hand-edit src/docs/scale-envelope.md:37 to src/pkg/github/client.go:4963-4973). Human-authored branch, so leaving this as a note rather than pushing.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • relative links and anchors resolve

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 071-needs-author: optional-check-failing:relative links and anchors resolve

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test gap (quality review @5ce49c4): the one quiet-mode branch in review_request_watcher.go with no test is the fold on perHeadReviewRefusal β€” the second perspective's findings for an already-reviewed head go to UpsertPRStatusSection(…, prstatus.KeyReviewFindingsPrefix+verdictSlug(agent), reviewFindingsSection(req)) instead of being dropped. TestReviewRequestWatcher_QuietModeSuppressesNoFindingsReview and TestMaxReviewsPerHeadQuietMode cover the cap and the ack, but nothing asserts the findings actually land. That is the branch where a regression is silent: the review still returns record_verdict, the head still "has its review", and real findings vanish with only a Warn on ferr.

Suggested (same fixtures as the existing test): submit a findings body for o/r#5 once in quiet mode (posts, reviewed == 1), then a second findings body from a different Agent on the same head; assert reviewed stays 1 and the mock's issue-comments store contains a review-findings:<slug> section with the second body. A second submission from the same slug should edit that section rather than add one.

Everything else behaviour-changing here (stageReasonWaitsOnHive merge-train arms, duplicate-guard redirect, 071 note once per head, AcknowledgeNoFindings && !Quiet()) has a paired test β€” nice.


🐝 Hive Agent: quality | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 050-review-pending: review-gate:no-review-bundle

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security perspective (read at head 5ce49c4)

1. The status comment is located by marker only β€” any commenter can plant <!-- hive:status --> and the hive will edit their comment (medium, in-scope)

Both quiet-mode delivery paths pick the first comment whose body contains the marker with no author check:

  • src/pkg/github/pr_status_comment.go:21 β†’ UpsertIssueMarkerComment (src/pkg/github/gfi_forge.go:34, then Issues.EditComment at :41)
  • src/pkg/github/automerge/automerge_stage_labels.go:1474-1477 (editStatusSection)

The App token has issues write, so EditComment succeeds on a comment the hive did not author. Consequences: (a) prstatus.Parse drops everything outside sections (src/pkg/prstatus/prstatus.go:36-38), so a human's comment that happens to contain the marker is overwritten wholesale; (b) a PR author or drive-by commenter who posts the marker first owns the hive's status channel for that PR β€” the 071 trusted-human note, stage notes, duplicate-guard redirect and folded review-findings:* (review_request_watcher.go quiet branch under perHeadReviewRefusal) all land inside a comment the attacker can rewrite or delete at will, while the hive keeps "updating" it. Before this PR the marker lookups on PRs were read-only dedupe checks (pr_duplicate_guard.go:307-311); writing to a marker-selected comment on PRs is new here.

Fix β€” only accept comments authored by a hive bot login (hiveBotLogins() / c.transport.AppBotLogin() already exist):

--- a/src/pkg/github/automerge/automerge_stage_labels.go
+++ b/src/pkg/github/automerge/automerge_stage_labels.go
@@ func (c *Engine) editStatusSection(
+	self := strings.TrimSpace(c.transport.AppBotLogin())
 	for _, cm := range comments {
-		if cm == nil || !prstatus.IsStatusComment(cm.GetBody()) {
+		if cm == nil || !prstatus.IsStatusComment(cm.GetBody()) ||
+			(self != "" && !strings.EqualFold(cm.GetUser().GetLogin(), self)) {
 			continue
 		}

and in UpsertPRStatusSection either add the same author filter (a dedicated lookup rather than UpsertIssueMarkerComment) or extend UpsertIssueMarkerComment with an isHiveBotLogin(c.hiveBotLogins(), cm.GetUser().GetLogin()) guard when hiveBotLogins() is non-empty. Add a test with a non-bot comment carrying the marker that asserts no PATCH and a fresh create.

2. Section delimiters are not neutralised in section text (low, in-scope)

prstatus.Upsert/Render (prstatus.go:76-96) write text verbatim. reviewFindingsSection (review_request_watcher.go) puts an agent's review body straight in; a body containing <!-- /hive:status:section --> followed by <!-- hive:status:section=human-071-note -->… rewrites another section on the next Parse (prompt-injected reviewer β†’ spoofed 071 ask). Suggest Render strip/escape <!-- hive:status:section= and <!-- /hive:status:section --> from s.Body (e.g. replace <!-- with <!- - inside bodies).

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness review (head 5ce49c4)

1. NoFindingsAcknowledgement swallows a single-line body that carries a finding β€” src/pkg/review/no_findings.go:13. The tail no findings from[^\n]*?\.?\s*\z accepts anything on the rest of the line, so a one-line body such as **Reviewed** β€” no findings from security, but src/auth.go:42 logs the token. matches, and in quiet mode review_request_watcher.go:308-313 flips it to record_verdict: the finding is never posted and never folded into the status comment (the per-head fold at :478-489 only runs for !recordOnly). The negative cases in no_findings_test.go:19-24 are all multi-line or lack the Reviewed β€” prefix, so this path is untested. Suggest refusing any further sentence on the line:

var noFindingsRe = regexp.MustCompile(`(?is)\A\s*(?:\*\*|_)?\s*reviewed\s*(?:\*\*|_)?\s*[—–-]+\s*no findings from[^\n.]*\.?\s*\z`)

(and a no case like "**Reviewed** β€” no findings from security, but src/x.go:12 leaks a token.").

2. regressionNotable still reports the post-push review wait as a regression β€” automerge_stage_labels.go:1441-1443 is a deny-list (ciReasonPending + stageReasonWaitsOnHive), so an 080β†’050 transition after a push whose reason is review-gate:awaiting / review-gate:no-bundle / contributor-lane:no-verdict / contributor-lane:soaking is still Notable and posts/edits a "stage regressed" note, although the hive itself already classifies exactly those reasons as its own wait in preparationKeepsOwner (automerge_base_preparation.go:233-238). #15875 item 3 asks for a regression note only "when something actually failed". Suggest widening stageReasonWaitsOnHive (automerge_stage_sharedci.go:74) with those four reasons so stall and regression agree with base-preparation.

3. Advisory β€” folded findings lose the human-routing path. With maxReviewsPerHead()==1 in quiet mode (review_request_watcher.go:956-960), the first perspective to post claims the head; a later request_changes / requires_human body goes through UpsertPRStatusSection as raw req.Body (:484), bypassing relayBody/leadWithDecisionQuestion (:533) and landing in a non-notifying edit. A **HUMAN DECISION NEEDED** lead from the second perspective therefore reaches nobody's inbox. If that is intended, say so in operator-reference.md; otherwise exempt bodies starting with that marker from the fold.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the branch conflicts with the base and needs a rebase

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
…s review spam

Every issue comment and review the hive posts emails the PR author and
every watcher. Measured on hivecommons/hive: 8 comments + 3 reviews on one
PR in two hours, most of them a 071 note per head, a 'regressed' note for
a check that merely went back to pending, a 'stalled' note for a PR queued
in the merge train, and 'Reviewed - no findings' reviews.

- github.notifications.mode (quiet default | normal). In quiet mode the
  stage-stalled / stage-regressed notes, the trusted-human 071 note and the
  duplicate-PR redirect are sections of one <!-- hive:status --> comment
  per PR, created once and PATCHed afterwards.
- A review whose body is only the no-findings acknowledgement is recorded
  as a verdict and never submitted; a head carries at most one hive review,
  later perspectives' findings fold into the status comment. The reviewer
  prompts stop asking for the acknowledgement line in quiet mode.
- The 071 note @-mentions the author once per cause class, not per head.
- required-check-pending after a push is not a regression; merge-train
  queued-behind / rebasing and base-refresh waits are never stalled.
- Docs in operator-reference.md and agent-configuration.md; changelog
  fragment; unit tests for edit-in-place, suppression, mention-once.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the fix/notification-spam branch from 5ce49c4 to b9dd1ff Compare October 30, 2026 21:33
@clubanderson
clubanderson merged commit c07fd6e into v5 Oct 30, 2026
75 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/notification-spam branch October 30, 2026 21:43
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hive PR comments and reviews spam every author and watcher with email

1 participant