Repository navigation
π Fold hive PR notes into one edited status comment and stop no-findings review spam - #15876
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson this PR is held at Failing checks:
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. |
|
stage 080-awaiting-merge-admission β 071-needs-author: optional-check-failing:relative links and anchors resolve |
|
This PR's changes to (or hand-edit π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
@clubanderson this PR is held at Failing checks:
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. |
|
stage 080-awaiting-merge-admission β 071-needs-author: optional-check-failing:relative links and anchors resolve |
|
Test gap (quality review @5ce49c4): the one quiet-mode branch in Suggested (same fixtures as the existing test): submit a findings body for Everything else behaviour-changing here ( π Hive Agent: β hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
stage 080-awaiting-merge-admission β 050-review-pending: review-gate:no-review-bundle |
There was a problem hiding this comment.
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, thenIssues.EditCommentat: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
There was a problem hiding this comment.
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
|
@clubanderson this PR is held at Why:
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. |
β¦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>
5ce49c4 to
b9dd1ff
Compare
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
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-notecomments each @-mentioning the author, threehive:stage-regressedof which two wererequired-check-pendingafter a push, ahive:stage-stalledfor 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:hive:stage-stalled,hive:stage-regressed,hive:human-071-noteandhive:create-pr-duplicate-guardbecome sections of a single<!-- hive:status -->comment (newpkg/prstatus). Created the first time, PATCHed afterwards β editing a comment does not email. Built on the existingUpsertIssueMarkerCommentfind-by-marker-then-edit helper (Client.UpsertPRStatusSection); the automerge engine has its owneditStatusSectionsharing the oneCreateCommentcall site so the direct-write ratchet is unchanged.**Reviewed** β no findings from β¦asrecord_verdictand submits nothing (result note explains).review.acknowledge_no_findingsis forced off in the prompts in quiet mode so reviewers use--record-verdict.maxReviewsPerHeadis 1 in quiet mode; a later perspective's findings on an already-reviewed head are folded into the status comment underreview-findings:<agent>instead of becoming a second review.regressionNotable: notciReasonPending, not a hive-controlled wait). Stalled never formerge-train:queued-behind*/merge-train:rebasing/base-refresh:*(stageReasonWaitsOnHive). These two apply in both modes β they were simply wrong.stagelabels.Record.MentionCause+MentionDue/MarkMentioned; cause class collapsescheck-failing:unit/check-failing:lint/required-check-failing:*into one ask. New head, same cause β section rewritten without the@.operator-reference.mdβ "Notification mode" (with the why: every comment emails authors and watchers paragraph) andagent-configuration.md.Before / after (comment-emitting sites on PRs)
hive:human-071-notehive:stage-regressedhive:stage-stalledhive:create-pr-duplicate-guardFor #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(UpsertPRStatusSectioncreates once then edits; duplicate guard quiet path edits on retry; watcher suppresses the no-findings ack and still posts findings;maxReviewsPerHeadquiet),pkg/github/automerge(stall + regression fold into one edited comment;required-check-pendingis not a regression;regressionNotable/stageReasonWaitsOnHivetables; 071 mention once per cause across heads),pkg/stagelabels(MentionDue),pkg/review(ack matcher),pkg/config. Notime.Sleep. Ratchet baseline forautomerge_contributor_nudge.golowered 3β2.