Repository navigation
✨ Sentinel: fold informational notices on trusted authors' PRs into the status card - #18456
Conversation
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>
|
[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
|
Mutation testing✅ Resolved: no surviving or uncovered mutants in changed files on the current head. Verdict: |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @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. Review findings from Docs-currency review at head f57a8b3. The new docs (
For line 1027, change the help text to:
Minor: the line added to I could not read the test file or the full |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
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 citeshivecommons/hive#18453as 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
There was a problem hiding this comment.
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 branchpostedis always false (the card has no<!-- hive-sentinel <head> -->), so for an unchanged head every sweep re-runs the files fetch, bothfindOwnMarkerCommentreads andUpsertPRStatusSection. The write itself is a no-op (prstatus/writer.go:218,next == base), butfoldSentinelNotice(sentinel_status_card.go:68) callsnoteCommentSuppressed()each time becausecreatedis 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'shive-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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
-
Folded notices lose the per-head "already posted" short-circuit (low). Before,
posted(theSentinelMarker <head>comment) made later ticks skip the write atsentinel_sweep.go:~780. A folded notice leaves no such comment, so every tick for an unchanged head re-entersfoldSentinelNotice(sentinel_status_card.go).editCompareAndRetryreturns early when the text is unchanged, so no GitHub write happens, butfoldSentinelNoticethen callsnoteCommentSuppressed()for every!createdresult, 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. -
Open question: path text inside the card (low).
SentinelStatusSectionembeds PR-controlled file paths in backticks inside the hive-owned status card.findOwnMarkerComment(..., SentinelMarker)matches bystrings.Containson 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 thepriorsentinel comment. The next alert would then edit the shared card instead of the sentinel comment. The pre-existingSentinelCommentembeds 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
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 2ec61bb. |
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:
sentinel.trusted_authors_block: true. Thesentinel-alertlabel 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.github.notifications.mode: quiet(the default), this is now thesentinelsection of the PR'shive:statuscard, edited in place throughprstatus.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.normalmode 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 forfoldSentinelNotice(status).src/docs/notifications.md(new "Sentinel notices in the PR status card"),src/docs/operator-reference/sweeps-and-operations.md(sentinel section,trusted_authors_blockrow, quiet-mode list).changelog.d/changed-18453-sentinel-notice-status-card.mdTests
src/pkg/github/sentinel_status_card_test.go:trusted_authors_block: the security alert is its own comment, not a card🤖 Generated with Claude Code