Skip to content

✨ Sentinel: fold informational notices on trusted authors' PRs into the status card - #18456

Merged
hivecommons-hive[bot] merged 16 commits into
v5from
feat/spam-sentinel-notice
Nov 16, 2026
Merged

hivecommons-hive[bot] merged 16 commits into
v5from
feat/spam-sentinel-notice

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #18453 (part of #18450, item 3).

What

The sentinel posted a notice comment on most PRs (~17/day), and 26 of 27 sampled were "informational; author is trusted, merge is not blocked". Nobody had to act on those.

Sentinel results are now split into two kinds:

  • Actionable (hold): untrusted author, or sentinel.trusted_authors_block: true. The sentinel-alert label goes on and the <!-- hive-sentinel --> alert comment is posted, in every notification mode. A security hold is never folded into the card. When the PR's card still has an informational section, it is dropped after the alert is posted. Removing a section never creates a card.
  • Informational: the author is trusted and the merge is not blocked. In github.notifications.mode: quiet (the default), this is now the sentinel section of the PR's hive:status card, edited in place through prstatus.Write. A new head rewrites the section. The section is stamped <!-- hive-sentinel-notice <head> --> and never carries <!-- hive-sentinel -->. The sweep reads that marker back for its alert and clearance state, so a card carrying it could be mistaken for the alert comment.
  • A PR that already has a hive sentinel comment from an earlier head keeps it, rewritten in place (no notification), so the PR never shows a stale notice next to the card.
  • normal mode is unchanged.

Files

  • src/pkg/github/sentinel_status_card.go: classification helper, card section renderer, fold and clear.
  • src/pkg/github/sentinel_sweep.go: informational path folds in quiet mode; alert path clears the stale section.
  • src/pkg/github/notification_write_sites.go + src/docs/notifications.md: inventory entry for foldSentinelNotice (status).
  • Docs: src/docs/notifications.md (new "Sentinel notices in the PR status card"), src/docs/operator-reference/sweeps-and-operations.md (sentinel section, trusted_authors_block row, quiet-mode list).
  • changelog.d/changed-18453-sentinel-notice-status-card.md

Tests

src/pkg/github/sentinel_status_card_test.go:

  • quiet + trusted: no sentinel comment, card created with the section; a new head edits the card in place and counts as suppressed
  • quiet + untrusted: the hold still labels and posts the alert comment; the stale informational section is cleared and other sections survive
  • quiet + trusted_authors_block: the security alert is its own comment, not a card
  • normal mode: the trusted notice comment is posted as before
  • quiet + legacy prior notice comment: rewritten in place, no card
  • section shape (path cap, no mentions, never the comment marker), the classifier, and error paths

🤖 Generated with Claude Code

In quiet notification mode, the sentinel's informational notice on a
trusted author's PR (no label, merge not blocked) becomes the sentinel
section of the hive:status card, edited in place. A hold still posts its
own alert comment in every mode and drops any stale informational
section. Normal mode is unchanged.

Fixes #18453

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 16, 2026
@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 hanthor 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 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
#18455 ✨ Fold the auto-merge note into the PR hive:status card (quiet mode) same files src/docs/notifications.md
src/docs/operator-reference/sweeps-and-operations.md

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

✅ Resolved: no surviving or uncovered mutants in changed files on the current head.

Verdict: pass (#17349).

@hivecommons-hive

hivecommons-hive Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Failing checks:

  • overlayfs-exec-guard

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.

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

Docs-currency review at head f57a8b3. The new docs (notifications.md, sweeps-and-operations.md, the changelog) match the diff. Two operator-facing strings still describe the old behaviour, a comment per push. I read both at this head.

  1. Dashboard help text is stale (src/pkg/dashboard/static-src/js/config-watchdog-security.js:1023, :1027). Line 1023 says a matching PR "gets one explanatory comment per push". Line 1027 says trusted-author PRs "still get a Sentinel notice". In quiet mode, the default, the notice is now a hive:status card section, not a comment. This is the in-product help behind the settings toggle that links to the updated operator reference, so the two now disagree.
        <div class="config-toggle">
          <div class="config-toggle-switch ${sn.enabled ? 'on' : ''}" data-action="toggleSentinelEnabled"></div>
          <span class="config-toggle-label">Suspicious-activity alerts ${settingHelpMark('operator-reference/sweeps-and-operations', 'suspicious-activity-alerts-sentinel', 'Suspicious-activity alerts', `Every sweep (~15 min) inspects open PRs from any author. A PR matching a behavior below is flagged on each push: untrusted authors get the blocking alert label and an alert comment; trusted Hive authors get an informational notice that does not block merge. In quiet notification mode (the default) that notice is a section of the PR status card rather than a comment.`)}</span>

For line 1027, change the help text to: Default off: Hive App PRs, owner-authored PRs and allow-listed bot PRs get an informational Sentinel notice (a status-card section in quiet mode, a comment in normal mode) and an audit record, but Hive does not add the alert label or block merge. Turn on to add the label and post the alert comment for trusted authors too.

  1. Config field comment is stale (src/pkg/config/sentinel.go:51-52). It says the default "still evaluates and comments, but only as an informational notice". Suggested replacement:
	// bots and authorized owners) into the blocking label. The default false
	// still evaluates, but only as an informational notice (a status-card
	// section in quiet notification mode, a comment in normal mode).

Minor: the line added to sweeps-and-operations.md around [#18453](...) is one very long line. Re-wrap it for diff readability, but this is not blocking.

I could not read the test file or the full trySentinelPR flow in depth, because this perspective covers docs only.

Evidence bundle `#184562ec61bb` sha256:01bac4e31ffc0118bc59a577071099b13a7df8a0d4aee1a9f4471d3b1ce5f713 — download from the dashboard or `hivectl review evidence #18456`.

Signed-off-by: Andy Anderson <andy@clubanderson.com>

@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.

Style review at f57a8b3: no in-scope blocker. The Go code follows the existing status-card idioms (noteCommentSuppressed, UpsertPRStatusSection, a write-site inventory entry, the #NNNN comment convention).

One advisory nit, not blocking:

  • src/docs/operator-reference/sweeps-and-operations.md (the sentinel paragraph, around diff line 701): the added sentence cites the issue as a markdown link and then runs on, joined mid-line to "A maintainer who removes the label keeps the PR clear until". The paragraph is otherwise hard-wrapped at about 80 columns, and the other new doc text in this PR cites hivecommons/hive#18453 as plain text. Re-wrap the paragraph and use the plain form.

— hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.325

@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.

Read the tree at the PR head (sentinel_sweep.go trySentinelPR, pr_status_comment.go, prstatus/writer.go). The fold path looks correct to me: the card section deliberately omits SentinelMarker, so the sweep's marker read-back cannot mistake it for an alert, and blocking holds still post their own comment and clear the stale section (sentinel_sweep.go:805-810).

One low-severity observation (not a blocker):

  • sentinel_sweep.go:782-790 — in the fold branch posted is always false (the card has no <!-- hive-sentinel <head> -->), so for an unchanged head every sweep re-runs the files fetch, both findOwnMarkerComment reads and UpsertPRStatusSection. The write itself is a no-op (prstatus/writer.go:218, next == base), but foldSentinelNotice (sentinel_status_card.go:68) calls noteCommentSuppressed() each time because created is false, so the "suppressed comments" counter grows by one per PR per sweep rather than once per head. Cost is extra API reads and an inflated metric, no wrong output. Optionally check the existing section's hive-sentinel-notice <head> stamp before counting/writing.

Suggestion only: a test that sweeps twice on the same head and asserts the suppressed counter moves once would pin this down.

— hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.325

@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 review at 1c0ea3a: one in-scope finding.

Attacker-controlled file paths can put <!-- hive-sentinel --> into the status card (medium). The PR body says the card section "never carries <!-- hive-sentinel -->", and SentinelStatusSection guarantees that only for its own header line. It writes each f.Paths entry into the card verbatim (src/pkg/github/sentinel_status_card.go, the quoted = append(quoted, ""+p+"") line). Paths come from the PR's changed files, and git permits <, >, !, spaces and backticks in file names.

The card is a bot-authored comment. findOwnMarkerComment (sentinel_sweep.go:896-913) matches any own-account comment whose body contains the marker (strings.Contains, sentinel_sweep.go:906). The trusted-author check is on the comment's account, not its content. A trusted author's PR that touches a file named <!-- hive-sentinel --> would make the card match as the sentinel comment (sentinel_sweep.go:703-712). The sweep's clearance and head logic would then read the card as the alert, and writeSentinelComment could overwrite the card in place. That edit sends no notification, which is the failure the PR's own comment at sentinel_status_card.go:19-25 describes.

Before this PR the path text sat only inside the sentinel comment itself, so this cross-comment confusion could not happen.

Suggested fix: neutralize paths and summary in the section before rendering.

+func sentinelCardSafe(s string) string {
+	s = strings.ReplaceAll(s, "<!--", "<!​--")
+	s = strings.ReplaceAll(s, "-->", "--​>")
+	return strings.ReplaceAll(s, "`", "'")
+}

Apply it to p and f.Summary in SentinelStatusSection. Add a test with a path of <!-- hive-sentinel --> that asserts the rendered section does not contain SentinelMarker.

Not verified: whether prstatus.Write or UpsertPRStatusSection already strips HTML comments from section text. I only read the pr_status_comment.go function list, not the prstatus package. If it does, this finding does not apply.

The rest holds. The alert path always posts its own comment (sentinel_sweep.go:805-810). The notice stays a separate comment unless quiet mode is on and no prior comment exists. clearSentinelNoticeSection only removes a section.

— hive: agent=adjudicator-2 backend=claude model=claude-sonnet-5-5 claude=2.1.325

@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.

Read the diff, then trySentinelPR (sentinel_sweep.go:685-815), prstatus.write/editCompareAndRetry and findMarkerCommentWhere at the base. The fold itself is sound: blocking alerts keep their own comment and the stale section is cleared on alert. Two low-severity points, neither blocking.

  1. Folded notices lose the per-head "already posted" short-circuit (low). Before, posted (the SentinelMarker <head> comment) made later ticks skip the write at sentinel_sweep.go:~780. A folded notice leaves no such comment, so every tick for an unchanged head re-enters foldSentinelNotice (sentinel_status_card.go). editCompareAndRetry returns early when the text is unchanged, so no GitHub write happens, but foldSentinelNotice then calls noteCommentSuppressed() for every !created result, whether or not anything was edited. The suppressed-comment counter rises once per trusted PR per sweep, not once per avoided comment. That overstates the quiet-mode savings the PR is meant to show. Count it only when the section actually changed, or only on the first fold for a head.

  2. Open question: path text inside the card (low). SentinelStatusSection embeds PR-controlled file paths in backticks inside the hive-owned status card. findOwnMarkerComment(..., SentinelMarker) matches by strings.Contains on any trusted-account comment (findMarkerCommentWhere). A trusted author's PR touching a file whose name contains the literal <!-- hive-sentinel --> would make the card match as the prior sentinel comment. The next alert would then edit the shared card instead of the sentinel comment. The pre-existing SentinelComment embeds paths too, but it is itself the marker comment, so it had no equivalent. I have not confirmed that git paths of that shape survive the sensitive-path filter, so treat this as something to check, not a defect. A cheap guard is dropping paths that contain <!-- when rendering the card.

Otherwise the body matches the diff (quiet mode folds, normal unchanged, holds always comment), and the tests cover fold, new-head edit, hold-clears-section and legacy-comment cases. Looks correct to me apart from the points above.

— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.325

@hivecommons-hive
hivecommons-hive Bot merged commit eeb1d22 into v5 Nov 16, 2026
83 of 84 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/spam-sentinel-notice branch November 16, 2026 23:58
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 2ec61bb.

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/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.

📉 Spam phase 2: sentinel informational notices on trusted authors' PRs go into the status card

1 participant