Skip to content

🐛 Sentinel judges the PR's current head and clears its own stale alert - #19266

Open
clubanderson wants to merge 2 commits into
v5from
fix/sentinel-head-scoped
Open

clubanderson wants to merge 2 commits into
v5from
fix/sentinel-head-scoped

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Summary

The sentinel result was sticky across pushes. trySentinelPR returned early for any PR already wearing the alert label on the blocking path, so a finding on an early head (for example a sensitive_path hit on Makefile) kept sentinel-alert, the dashboard's "Needs human · sentinel" state and the status section's Head <old sha> matched line on every later head, even a docs-only one.

Now the sentinel judges the current head:

  • Every new head is evaluated, including on a labelled PR. An unchanged head is still skipped through the heads map, so a steady state costs no extra calls.
  • Finding on the new head: the label stays (nothing is re-added) and the hive's sentinel comment is rewritten as the alert for that head.
  • Clean new head: the label is removed only when all of these hold: the hive can name its own accounts, the hive's own sentinel comment is a blocking alert for an earlier head, and the newest label event is the hive's own labeled, made no later than that comment. The comment is rewritten as a clean record for the current head with the earlier alert kept in a collapsed block (its marker and heading neutralised so it is never read back as an alert or a maintainer clearance). The quiet-mode sentinel status section is rewritten for the current head (never created). The audit log records sentinel-alert-cleared.
  • Manual labels are untouched: a label a person added, directly or through the dashboard after the alert, fails the provenance check and stays. A labelled PR with no hive sentinel comment is left alone.
  • History kept: the /api/sentinel ring keeps one row per head, so the earlier head's finding stays for audit, as does that head's review evidence bundle.
  • Dashboard: the tracker's sentinel state already follows the live label plus the findings recorded for the current head, so it clears with the label. A new test pins that an old head's finding never flags the new head.
  • Trusted authors: notice behavior is unchanged. A trusted author's PR still carrying a label the hive added for an earlier head is cleared the same way, once per head.
  • A failed evaluation on a labelled PR forgets the head so the next pass retries it.

Tests

  • TestSweepSentinelCleanNewHeadClearsHiveAddedLabel: finding on the old head, clean new head: label removed, comment rewritten clean, audit hook sees the clearance, second pass is a no-op.
  • TestSweepSentinelFindingOnNewHeadKeepsLabel: finding on the new head keeps the label and rewrites the alert for it; an unlabelled PR with a finding gets the label.
  • TestSweepSentinelCleanNewHeadLeavesLabelItCannotAttribute: a person's label, a label re-added after the alert, no hive comment, no comment timestamp, and an unknown hive identity all leave the label and comments untouched.
  • TestSentinelQuietTrustedNoticeSectionClearsOnCleanHead: the status section naming an old head is rewritten for the clean head; a clean PR without a card never gets one.
  • TestStageTrackerSentinelJudgesCurrentHead: dashboard sentinel state and human gate follow the current head; a live label still flags; ring keeps both heads.

Docs: security-model.md, notifications.md, operator-reference/sweeps-and-operations.md. Changelog fragment included.

Fixes #19262

…e alert

A PR that already carried sentinel-alert was never evaluated again, so a
finding on an early head kept the label, the dashboard sentinel gate and the
status section on every later head. Every new head is now evaluated. On a
clean head the hive removes the label only when it added it itself for an
earlier head's alert, rewrites its comment and the quiet-mode status section
to say the current head is clean, and audits sentinel-alert-cleared. A
finding on the new head keeps the label and rewrites the alert for it.

Fixes #19262

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 19, 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 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
#19253 ✨ customers: hub import disclosure, docs and consent views same files src/docs/security-model.md
#19288 🐛 Pin git source, GitHub token check and mail relay dials to checked addresses same files src/docs/security-model.md

@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 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:

  • coverage

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 follow-ups: 1 open of 1 (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line, listed here instead of as issues. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 low correctness — Label removed but comment edit failure leaves a stale alert comment (src/pkg/github/sentinel_head_scope.go:199): In clearStaleSentinelAlert the label is removed (RemoveLabelForIssue) before EditComment. If the edit fails, the error path calls sentinelHeads.forget, but on the retry the label is gone, so trySenti…

Refs #19262

Signed-off-by: Andy Anderson <andy@clubanderson.com>
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentinel alert label and status stay attached to an old PR head after new pushes

1 participant