Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Add Patrol recommended next step

rcourtman4b1b7ea0d1d0
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b95d799e01..859f8bc65b 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -568,6 +568,11 @@ the canonical monitored-system blocked payload.
14. Keep Patrol status transport semantics explicit in that same AI handler layer: the Patrol status endpoint must carry machine-readable runtime availability such as blocked, running, disabled, active, or unavailable rather than asking frontend consumers to infer operator state from stale summaries or run history.
15. Keep legacy Patrol quickstart transport semantics retired from the public v6 GA contract: ordinary AI settings and Patrol status payloads must not expose quickstart credit/status fields, and any stale hosted-model blocked copy that survives from compatibility state must normalize back to provider/local-model setup rather than presenting credit badges or acquisition prompts.
16. Keep Patrol intelligence summary transport semantics single-voiced: the canonical overall-health payload and Patrol run-history payload together must support one primary assessment plus one explicit verification explanation, and frontend consumers must not need to derive a second compact assessment or verification verdict row from the same payloads beneath the primary summary card.
+ That same transport split now supports the visible Patrol recommended next
+ step without adding another API field: the frontend summary contract derives
+ the recommendation from existing overall-health, run-history, active
+ finding, runtime, and pending-approval state, so the API remains the source
+ of facts while Patrol presentation owns the operator decision wording.
17. Keep Pulse Mobile relay credential minting and permission ownership on backend ownership: `internal/api/router_routes_auth_security.go`, `internal/api/security_tokens.go`, `internal/api/auth.go`, `internal/api/relay_mobile_capability.go`, `internal/api/router_routes_ai_relay.go`, and `frontend-modern/src/api/security.ts` may expose the canonical mobile runtime token creator and governed route gates, but browser callers must only consume that route and must not define the mobile runtime scope, compatibility gate list, route inventory, or token-purpose metadata locally.
18. Keep hosted tenant browser-session precedence on the shared auth boundary: `internal/api/auth.go`, `internal/api/contract_test.go`, and hosted tenant callers must treat a valid `pulse_session` as authoritative before any API-only token fallback or no-local-auth anonymous fallback, so cloud handoff can continue into protected hosted routes without flattening the operator back to `anonymous` or forcing a browser session through bearer-token-only mode after the tenant has minted API tokens.
That same shared auth boundary also owns hosted handoff authorization. `internal/api/cloud_handoff.go`,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 7db6a7b9ba..c7ba77e731 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -222,6 +222,14 @@ path: SAML and OIDC provider creation stay on the same settings-shell control
surface, while paid-plan copy and compatibility feature probes stay out of the
frontend primitive boundary.
+Feature surfaces under `frontend-modern/src/features/` may own product-specific
+assessment and recommendation semantics, but they must keep those semantics in
+their governed presentation helpers and render them inside the shared neutral
+Pulse surface language rather than introducing page-local verdict bands or
+nested cards. Patrol's primary recommended next step follows this boundary:
+the Patrol helper owns the decision text, while the section component only
+renders a compact inline accent inside the existing assessment shell.
+
1. Add shared primitives in `frontend-modern/src/components/shared/`
Framed product table surfaces must consume the shared `TableCard` frame and
`TableCardHeader` title/action band instead of composing page-local `Card`
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 633cbb06c0..d67d47a024 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -485,6 +485,16 @@ estate. When there is exactly one active Patrol runtime finding, that same
assessment copy should name the concrete runtime failure, such as
`Provider billing or quota issue`, instead of reducing the state to a generic count of
runtime findings.
+That primary assessment must also expose a single visible recommended next
+step derived from the same Patrol summary contract, not a page-local helper.
+`frontend-modern/src/utils/patrolSummaryPresentation.ts` owns that decision
+from pending governed approvals, Patrol runtime issues, active infrastructure
+findings, verification posture, and the current assessment tone. Pending
+approvals take priority over general triage, coverage-incomplete states must
+ask for full verification before any all-clear claim, runtime impairment must
+point the operator back to restoring Patrol visibility, and verified healthy
+states should fall back to continued scheduled monitoring rather than
+inviting generic Assistant chat.
That same runtime-owned assessment must expose the fix path directly. When the
primary Patrol issue is a Patrol runtime/provider problem rather than an
infrastructure finding, the summary card should offer a direct `Open Patrol
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index deb18c3664..616aa459bb 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -9,6 +9,7 @@ import {
getPatrolAssessmentAction,
getPatrolAssessmentShellPresentation,
getPatrolAssessmentPresentation,
+ getPatrolRecommendedNextStepPresentation,
getPatrolRecencyPresentation,
getPatrolScoreChipLabel,
getPatrolVerificationPresentation,
@@ -169,6 +170,14 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
activeFindings: state.activePatrolFindings(),
}),
);
+ const recommendedNextStep = createMemo(() =>
+ getPatrolRecommendedNextStepPresentation({
+ assessment: assessment(),
+ verification: verification(),
+ activeFindings: state.activePatrolFindings(),
+ pendingApprovalCount: aiIntelligenceStore.patrolPendingApprovals.length,
+ }),
+ );
const hasAttentionMetrics = createMemo(
() => metricState().primaryValue > 0 || metricState().secondaryValue > 0,
);
@@ -367,6 +376,20 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<p class="mt-1.5 max-w-3xl text-sm leading-6 text-muted">
{assessment().description}
</p>
+ <div
+ data-testid="patrol-recommended-next-step"
+ class={`mt-4 border-l-2 pl-3 ${getPatrolRecommendedNextStepAccentClass(recommendedNextStep().tone)}`}
+ >
+ <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
+ Recommended next step
+ </p>
+ <p class="mt-1 text-sm font-semibold text-base-content">
+ {recommendedNextStep().title}
+ </p>
+ <p class="mt-1 max-w-3xl text-sm leading-6 text-muted">
+ {recommendedNextStep().description}
+ </p>
+ </div>
<div class="mt-4 flex flex-wrap items-center gap-2">
<Show when={assessmentAction()}>
{(action) => (
@@ -530,3 +553,18 @@ function buildPatrolAssessmentApprovalProposedFixBriefing(approval: ApprovalRequ
commandCount: approval.command ? 1 : 0,
});
}
+
+function getPatrolRecommendedNextStepAccentClass(
+ tone: ReturnType<typeof getPatrolRecommendedNextStepPresentation>['tone'],
+) {
+ switch (tone) {
+ case 'success':
+ return 'border-emerald-400 dark:border-emerald-500';
+ case 'warning':
+ return 'border-amber-400 dark:border-amber-500';
+ case 'error':
+ return 'border-red-400 dark:border-red-500';
+ default:
+ return 'border-blue-400 dark:border-blue-500';
+ }
+}
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
index 8d1b2aaba8..72b1fbac74 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
@@ -47,6 +47,13 @@ describe('PatrolIntelligenceSummary', () => {
render(() => <PatrolIntelligenceSummary state={createPatrolState()} />);
+ expect(screen.getByTestId('patrol-recommended-next-step').textContent).toContain(
+ 'Review the pending Patrol approval',
+ );
+ expect(screen.getByTestId('patrol-recommended-next-step').textContent).toContain(
+ 'risk, dry-run posture, and expiry',
+ );
+
fireEvent.click(screen.getByTestId('patrol-assessment-assistant-button'));
await waitFor(() => expect(openWithPrompt).toHaveBeenCalledTimes(1));
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 033835be9b..1e7a42c360 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -1102,12 +1102,19 @@ describe('AIIntelligence entitlement gating', () => {
await waitFor(() => {
expect(screen.getAllByText('Coverage incomplete').length).toBeGreaterThan(0);
+ expect(screen.getByText('Recommended next step')).toBeInTheDocument();
+ expect(screen.getByText('Verify full coverage')).toBeInTheDocument();
expect(screen.getByText('No recent full patrol')).toBeInTheDocument();
expect(screen.getAllByText(/Last activity/i)).toHaveLength(1);
expect(findingsPanelState.latestProps).not.toBeNull();
});
expect(screen.queryByText('No issues found')).not.toBeInTheDocument();
+ expect(
+ screen.getByText(
+ 'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.',
+ ),
+ ).toBeInTheDocument();
expect(screen.queryByText(/Last patrol/i)).not.toBeInTheDocument();
expect(screen.queryByText(/^Last:/i)).not.toBeInTheDocument();
expect(screen.queryByText('Partial verification')).not.toBeInTheDocument();
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index acebd51ed6..f8246b4be1 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -3,6 +3,7 @@ import {
getPatrolAssessmentPresentation,
getPatrolAssessmentAction,
getPatrolAssessmentShellPresentation,
+ getPatrolRecommendedNextStepPresentation,
getPatrolRecencyPresentation,
getPatrolScoreChipLabel,
getPatrolSummaryMetricState,
@@ -235,6 +236,93 @@ describe('getPatrolSummaryPresentation', () => {
).toBeUndefined();
});
+ it('turns pending approvals into the primary recommended next step', () => {
+ expect(
+ getPatrolRecommendedNextStepPresentation({
+ assessment: {
+ title: 'Critical issues detected',
+ description: 'Patrol surfaced one active critical finding.',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Issues detected',
+ tone: 'error',
+ },
+ verification: {
+ title: 'Recently verified',
+ description: 'The most recent full patrol completed successfully.',
+ compactLabel: 'Recently verified',
+ tone: 'success',
+ },
+ activeFindings: [
+ {
+ status: 'active',
+ severity: 'critical',
+ resourceId: 'vm-100',
+ resourceName: 'web-1',
+ title: 'High CPU usage',
+ },
+ ] as never,
+ pendingApprovalCount: 1,
+ }),
+ ).toEqual({
+ title: 'Review the pending Patrol approval',
+ description:
+ 'Patrol is waiting on 1 governed Patrol approval. Review risk, dry-run posture, and expiry before approving or starting another remediation.',
+ tone: 'warning',
+ });
+ });
+
+ it('recommends a full verification when Patrol has no active findings but coverage is incomplete', () => {
+ expect(
+ getPatrolRecommendedNextStepPresentation({
+ assessment: {
+ title: 'Coverage incomplete',
+ description: 'Patrol coverage is incomplete.',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Coverage incomplete',
+ tone: 'warning',
+ },
+ verification: {
+ title: 'Recently verified',
+ description:
+ 'The most recent full patrol completed successfully and checked 47 resources.',
+ compactLabel: 'Recently verified',
+ tone: 'success',
+ },
+ }),
+ ).toEqual({
+ title: 'Verify full coverage',
+ description:
+ 'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.',
+ tone: 'warning',
+ });
+ });
+
+ it('keeps a verified healthy Patrol assessment in monitoring mode', () => {
+ expect(
+ getPatrolRecommendedNextStepPresentation({
+ assessment: {
+ title: 'No active issues detected',
+ description: 'Infrastructure is healthy with no significant issues detected.',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'No issues found',
+ tone: 'success',
+ },
+ verification: {
+ title: 'Recently verified',
+ description: 'The most recent full patrol completed successfully.',
+ compactLabel: 'Recently verified',
+ tone: 'success',
+ },
+ activeFindings: [],
+ }),
+ ).toEqual({
+ title: 'Keep Patrol monitoring',
+ description:
+ 'Patrol has no active findings and has recent full-run verification. Keep scheduled Patrol enabled and let alert or anomaly triggers start scoped follow-up checks.',
+ tone: 'success',
+ });
+ });
+
it('splits infrastructure findings from patrol runtime issues in supporting metrics', () => {
expect(
getPatrolSummaryMetricState({
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 0d2c3e2db4..afec53b3a6 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -46,6 +46,12 @@ export interface PatrolAssessmentAction {
href: string;
}
+export interface PatrolRecommendedNextStepPresentation {
+ title: string;
+ description: string;
+ tone: SemanticTone;
+}
+
export interface PatrolSummaryMetricState {
primaryLabel: string;
primaryValue: number;
@@ -83,6 +89,8 @@ export const PATROL_NO_ISSUES_LABEL = 'No issues found';
const QUIET_ICON_CONTAINER = 'bg-surface border-border';
const QUIET_ICON = 'text-muted';
const QUIET_VALUE = 'text-muted';
+const VERIFY_FULL_COVERAGE_DESCRIPTION =
+ 'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.';
const ACTIVE_PRESENTATION: Record<PatrolSummaryTone, PatrolSummaryPresentation> = {
critical: {
@@ -262,6 +270,101 @@ export function getPatrolAssessmentAction(args: {
return undefined;
}
+function formatPendingApprovalCount(count: number): string {
+ return `${count} governed Patrol approval${count === 1 ? '' : 's'}`;
+}
+
+function assessmentHasCoverageGap(assessment: PatrolAssessmentPresentation): boolean {
+ const title = assessment.title.trim().toLowerCase();
+ const description = assessment.description.trim().toLowerCase();
+ const compactLabel = assessment.compactLabel.trim().toLowerCase();
+ return (
+ title.includes('coverage incomplete') ||
+ description.includes('coverage incomplete') ||
+ compactLabel.includes('coverage incomplete')
+ );
+}
+
+export function getPatrolRecommendedNextStepPresentation(args: {
+ assessment: PatrolAssessmentPresentation;
+ verification: PatrolVerificationPresentation;
+ activeFindings?: PatrolAssessmentFinding[];
+ pendingApprovalCount?: number;
+}): PatrolRecommendedNextStepPresentation {
+ const classified = classifyActiveFindings(args.activeFindings);
+ const pendingApprovalCount = Math.max(0, args.pendingApprovalCount ?? 0);
+
+ if (pendingApprovalCount > 0) {
+ return {
+ title:
+ pendingApprovalCount === 1
+ ? 'Review the pending Patrol approval'
+ : 'Review pending Patrol approvals',
+ description: `Patrol is waiting on ${formatPendingApprovalCount(pendingApprovalCount)}. Review risk, dry-run posture, and expiry before approving or starting another remediation.`,
+ tone: 'warning',
+ };
+ }
+
+ if (classified.infrastructureTotal === 0 && classified.runtimeTotal > 0) {
+ return {
+ title: 'Restore Patrol visibility',
+ description:
+ 'Fix the Patrol runtime issue and rerun Patrol before treating the infrastructure assessment as current.',
+ tone: args.assessment.tone,
+ };
+ }
+
+ if (classified.infrastructureCritical > 0) {
+ return {
+ title: 'Triage the critical finding',
+ description:
+ 'Start with the highest-risk active finding, review the attached evidence and approval posture, then choose the safest governed action.',
+ tone: 'error',
+ };
+ }
+
+ if (classified.infrastructureTotal > 0) {
+ return {
+ title: 'Review active findings',
+ description:
+ 'Use the findings workspace to prioritize current risk, recent changes, and any governed remediation before waiting for the next scheduled Patrol run.',
+ tone: 'warning',
+ };
+ }
+
+ if (assessmentHasCoverageGap(args.assessment)) {
+ return {
+ title: 'Verify full coverage',
+ description: VERIFY_FULL_COVERAGE_DESCRIPTION,
+ tone: args.assessment.tone,
+ };
+ }
+
+ if (args.verification.tone !== 'success') {
+ return {
+ title: 'Verify full coverage',
+ description: VERIFY_FULL_COVERAGE_DESCRIPTION,
+ tone: args.verification.tone,
+ };
+ }
+
+ if (args.assessment.tone !== 'success') {
+ return {
+ title: 'Review assessment evidence',
+ description:
+ 'Review the supporting context or discuss the assessment with Assistant to understand why Patrol still marks it as needing attention.',
+ tone: args.assessment.tone,
+ };
+ }
+
+ return {
+ title: 'Keep Patrol monitoring',
+ description:
+ 'Patrol has no active findings and has recent full-run verification. Keep scheduled Patrol enabled and let alert or anomaly triggers start scoped follow-up checks.',
+ tone: 'success',
+ };
+}
+
function joinAssessmentParts(parts: string[]): string {
if (parts.length <= 1) return parts[0] ?? '';
if (parts.length === 2) return `${parts[0]} and ${parts[1]}`;