Skip to content

✨ feat(notifications): neutralise incidental mentions in copied text inside hive-authored bodies - #16367

Merged
hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-16360
Nov 3, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-16360

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Copying a title or quoting a comment that contains @user re-notifies that person every time the hive writes or refreshes a status comment. Copied text is now neutralised at the shared status-writer funnel using the existing advisory.NeutralizeMentions convention (emails, URLs and code left intact), while deliberate mentions, which are posted separately, are preserved.

Closes #16360
Part of #16270 (parent tracker; the other attention-pilot children remain open)

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…inside hive-authored bodies

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@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 nicholasjackson 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 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
#16351 🐛 fix(automerge): route engine status-comment creates through the notification primitive same files src/docs/notifications.md
src/pkg/github/automerge/automerge_stage_labels.go
#16371 ✨ feat(notifications): attention-pilot opt-in flag and issue-side hive:status card same files src/docs/notifications.md
#16366 🐛 fix(prstatus): only treat this hive's own App login as the status-comment owner same files src/pkg/github/automerge/automerge_stage_labels.go

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Security/trust-boundary review of bb44c83

Deliberate human notification silently dropped and falsely recorded as sent (in-scope, medium).
prstatus.Write now rewrites all text (src/pkg/prstatus/writer.go:74), but in quiet-notification mode the deliberate 071 mention is routed through that same funnel: TrustedHuman071Note emits @author (src/pkg/github/automerge/automerge_contributor_nudge.go:379-382) → postStageNote → writeStatusSection → prstatus.Write (automerge_stage_labels.go:1478-1479,1494). The @ is stripped to `author`, so the trusted human is never notified that their PR is held, while store.MarkMentioned (automerge_contributor_nudge.go:428-429) still records the mention as delivered, so it is never retried for that cause. The PR body's claim that "deliberate mentions, which are posted separately, are preserved" does not hold for this path. CI confirms it: TestQuietNotificationsHuman071MentionOncePerCause fails at head (automerge_quiet_notifications_test.go:165, "first note must mention the author").

Requested change: neutralise at the point where copied text is composed (titles/quotes/evidence) rather than unconditionally in Write, or give Write an explicit opt-out used only by noteTrustedHuman071 when mention is true — and keep the existing quiet-mode test green.

Advisory (not blocking from this perspective): issue #16360's second acceptance item ("issue/PR body composers used by the hive's own filers") is not touched by this diff; only the status writer is covered.

— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness review (head bb44c833, read via local clone; GitHub API cap prevented reading the issue/PR body, so intent was judged from the commit message and changelog.d/added-16360.md).

The change is sound: src/pkg/prstatus/writer.go:74 neutralises text before the lock, so both the create (Upsert(Merge(bodies...), key, text), :91) and edit (editCompareAndRetry → Upsert(cur, key, text), :115) paths carry neutralised section text; mentionPattern (pkg/advisory/sanitize.go:15) excludes a preceding backtick so re-running Write on an already-neutralised body is a no-op and the compare-and-retry stays idempotent. go build passes.

One non-blocking edge case:

  • writer.go:86-91 — on the create path, bodies of foreign (non-hive-authored) hive:status comments are merged verbatim via Merge(bodies...) into the new hive-authored comment. Only text is neutralised, so a live @login inside a foreign status section is copied into a hive-owned body and re-pings on every later edit of that comment. Low likelihood (foreign status comments are normally other hives, which also neutralise), but advisory.NeutralizeMentions(Merge(bodies...)) would close it cheaply.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the diff against v5 plus every caller of the two writers it changes. Looks correct to me; no defects found.

What I checked:

  • No deliberate mention is caught by the new default. All six UpsertPRStatusSection callers (attention.go:55, issue_blocked.go:665, issue_request_watcher.go:671, pr_duplicate_guard.go:293, review_evidence_merge.go:107, review_request_watcher.go:485) compose status/evidence text, not pings. The 085 needs-decision comment, which carries the one @approver the hive relies on, is posted through c.gh.Issues.CreateComment directly (automerge_stage_human.go:684) and never passes through prstatus.Write, so it is unaffected.
  • The question marker still parses. reviewDecisionRequestFromBody reads req.Body at verdict-record time (review_verdict_relay.go:341), before any folding into the status comment, so a <!-- hive-decision-question: @login … --> in a folded findings section being rewritten to `login` is cosmetic and intended.
  • 071 note keeps its live @author. TrustedHuman071Note neutralises only the copied check names / review asks (automerge_contributor_nudge.go:403) and routes through postStageNoteMentioning → prstatus.WriteMentioning (automerge_stage_labels.go:1486), while stall/regression notes stay on postStageNote → prstatus.Write.
  • foreignBody is scoped right (writer.go:194): only non-Own comments are neutralised on merge, so a hive-authored deliberate section is not degraded by reconciliation.
  • Tests cover each branch (TestWriteNeutralisesIncidentalMentions, TestWriteMentioningKeepsDeliberateMention, TestWriteNeutralisesMergedForeignStatusBodies, TestTrustedHuman071NoteNeutralisesCopiedMentions); CI is green on 2fb97a9.

One non-blocking note: foreignBody runs NeutralizeMentions over a foreign body on every reconcile pass, but the function is idempotent (sanitize.go:34, documented in notifications.md), so repeated passes are stable.

hive/awaiting-ci: pushed 2fb97a9 removing the orphaned writeStatusSection wrapper that golangci-lint (unused) flagged at 786f040. CI pending — sweep will merge when green.


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

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer (folded here because this head already carries its hive review):

Read the tree at 2fb97a9, not just the diff. This looks correct to me; the only risk a change to the shared status funnel carries is silently de-notifying a deliberate mention, and I checked every path that reaches prstatus.Write:

  • pkg/github/pr_status_comment.go:28 (UpsertPRStatusSection) is the only non-engine caller. Its feeders — attention.go:55, issue_blocked.go:665, issue_request_watcher.go:671 (one-line awaiting-ci/parking/already-fixed notes), pr_duplicate_guard.go:293, review_evidence_merge.go:107, review_request_watcher.go:485, review_backlog.go:520, and PostClaimNote — all carry copied prose, none composes an @author.
  • The engine's postStageNote callers at automerge_stage_labels.go:1274/1430 use stagelabels.StallComment/RegressionComment (pkg/stagelabels/store.go:2516,2527), which contain no mention; only the copied reason is neutralised, which is the point.
  • The nudges that do mention the author (automerge_contributor_nudge.go:204,206,329) go straight to Issues.CreateComment (:297, :353), so they are untouched; the 071 note is the one mention that lived in the status comment and it now goes through WriteMentioning.
  • reviewFindingsSection (review_request_watcher.go:976) folds a full review body, so a <!-- hive-decision-question: @login … --> marker inside it gets rewritten too. That is harmless: decisionQuestionFromBody is only ever applied to req.Body (review_verdict_relay.go:79, review_request_watcher.go:902), never to a posted comment.
  • NeutralizeMentions (pkg/advisory/sanitize.go:34) requires the char before @ to be outside [\w/.]`, so emails and URL paths survive as the docs claim.

One open question, not a defect: machine-readable markers in folded sections are now rewritten along with prose, and issueclaim.Marker (pkg/issueclaim/issueclaim.go:169) writes who=<identity> raw. Today identities reach it without a leading @ (claims/comments.go:159 only tolerates one defensively), so who= is safe; if a future writer ever passes @login, the folded marker would parse as `login`. Worth a one-line note on Write if you touch this again.

Evidence bundle `#1636782a161f` sha256:427a6547e76364845a769a09e5fc4c25e22013b2eecdc1a5d56bd147661d6119 — download from the dashboard or `hivectl review evidence #16367`.

…gn status bodies

Write neutralised every body, which also stripped the trusted-human 071
note's deliberate @author in quiet-notification mode while the store
still recorded the mention as sent. Split the writer: Write neutralises
copied text, WriteMentioning posts a section verbatim and is used only
by the 071 note, whose composer now neutralises the copied check names
and review asks itself. Foreign status-comment bodies merged into the
hive-owned comment (create and reconcile paths) are neutralised too, so
a live mention there cannot re-notify on every later edit.

Review findings on #16367.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: ci-maintainer <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
golangci-lint (unused) flagged it after postStageNote moved to
writeStatusSectionWith; the docs move onto the surviving function.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Style re-review at 2fb97a9 (delta since bb44c83): approve.

Both previous findings are fixed: prstatus.WriteMentioning (src/pkg/prstatus/writer.go:84-90) posts verbatim, and the 071 note is routed through it via postStageNoteMentioning (src/pkg/github/automerge/automerge_contributor_nudge.go:430) while its composer neutralises only the copied check names/review asks (automerge_contributor_nudge.go:390-403). foreignBody (writer.go:194-199) and the statusWriter func type (automerge_stage_labels.go:1499-1500) are small and read well; docs in src/docs/notifications.md:206-217 match the code. Builds clean.

Advisory, not blocking (backlog): in normal (non-quiet) mode postStageNoteWith posts the stall/regression body straight through Issues.CreateComment (automerge_stage_labels.go:1492-1495), so obs.Reason text in stagelabels.StallComment/RegressionComment (automerge_stage_labels.go:1273, 1429) bypasses neutralisation. The new doc comment at :1476-1477 scopes the guarantee to quiet mode, so this is documented, but it is one path where copied text can still notify.

— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the tree at 82a161f, not just the diff. Looks correct to me.

The risk in making prstatus.Write neutralise unconditionally is a caller that mentions on purpose. I checked every non-test caller:

  • src/pkg/github/pr_status_comment.go:28 → UpsertPRStatusSection, used by attention.go:55 / attention_command.go:83 (already strips @ itself via the replacer at attention.go:154), issue_blocked.go:665, issue_request_watcher.go:671 (only the one-line awaiting-ci / parking / already-fixed notes, per relayStatusNoteKey), pr_duplicate_guard.go:293, review_evidence_merge.go:107, and the per-head-cap fold at review_request_watcher.go:485. None of these composes a deliberate mention.
  • The folded review findings may carry <!-- hive-decision-question: @login -->, but decisionQuestionFromBody is read from req.Body at review_request_watcher.go:902 before the fold, so neutralising the stored copy does not break routing.
  • The 071 note is the one deliberate mention and now goes through postStageNoteMentioning → WriteMentioning (automerge_stage_labels.go:1486), with the copied check names / review asks neutralised at compose time (automerge_contributor_nudge.go:403). Test covers both halves.
  • foreignBody in reconcile (writer.go:166) is idempotent: backticked logins contain no @, so repeated reconciles don't rewrite.

One note for the maintainer, not a defect: #16360's second acceptance item also names "the issue/PR body composers used by the hive's own filers". Most of those already call advisory.NeutralizeMentions at base (write_surface.go:158, recommendations.go:61, duplicate_sweep.go:361, upstream_watch.go:139), so Closes seems fair, but this PR itself only adds the status-writer funnel and the 071 note.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 61cc757 into v5 Nov 3, 2026
78 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-16360 branch November 3, 2026 04:09
@github-actions

github-actions Bot commented Nov 3, 2026

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

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Attention pilot: suppress incidental mentions in Hive-authored bodies

0 participants