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.

Make Patrol assessment primary

rcourtmanb23b3dff9a1e
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 46b793cdc6..959a077604 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -114,6 +114,7 @@ Own canonical runtime payload shapes between backend and frontend.
7. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/stores/aiIntelligenceSummaryModel.ts`, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, the Patrol-owned section files under `frontend-modern/src/features/patrol/`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, store normalization owner, runtime hook, feature shell, section owners, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
while keeping the learning counters backend-only coverage, so the summary page keeps Patrol health and findings primary and renders timeline, correlation, and policy-posture data as secondary investigation context rather than as a separate headline product metric
and the Patrol findings empty-state behavior, so `0 active findings` only renders as a healthy frontend conclusion when the same governed AI summary contract still reports healthy overall health; degraded or not-fully-verified health predictions must flow through to the Patrol findings surface instead of being replaced by page-local "looks healthy" copy
+ and the Patrol assessment headline plus compact summary-strip behavior, so the same governed AI summary contract decides whether the page leads with verified health, issues detected, coverage incomplete, or another attention state instead of letting count-only page fragments emit a stale `No issues found` conclusion
and the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` card, so canonical recent-change timelines stay rendered through one governed frontend card instead of separate page-local list loops
and the shared `frontend-modern/src/utils/resourceChangePresentation.ts` formatter used by the summary page and resource drawer, so canonical change wording does not drift across surfaces
and the `/api/ai/intelligence/changes` route plus `internal/api/contract_test.go`, so the canonical recent-changes endpoint stays on the same intelligence facade and contract snapshot instead of bypassing the shared timeline source
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 7d87eeb635..c512471e7b 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -737,6 +737,10 @@ That same route-owned page-health rule now also applies to Patrol: a feature
surface may not present a green or all-clear primary summary when the owning
runtime contract says the page is blocked or unavailable, even if the last
successful snapshot was healthy.
+That same rule also applies to compact Patrol summary fragments inside the
+feature surface: count-only strips or metric cards must not emit `No issues
+found` or other reassuring copy when the owning overall-health summary is
+degraded or not fully verified.
Shared primitive consumers that split status-dot tone and status-text tone
must now keep both values routed through the same exported presentation helper.
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 9bb2a8f23f..36336c0125 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -120,6 +120,14 @@ overall-health summary is degraded or not fully verified. The green healthy
empty state belongs only to an actually healthy Patrol summary, while degraded
coverage or paused-runtime states must surface the governing warning/error copy
through `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`.
+The Patrol summary surface must follow that same hierarchy. The primary summary
+headline in `frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx`
+should state Patrol's current assessment first, such as verified healthy,
+issues detected, or coverage incomplete, with the health grade only as
+supporting evidence. Secondary metric strips must not render `No issues found`
+when the same governed overall-health summary says coverage is incomplete or
+health still requires attention; that compact summary state now belongs to the
+shared `frontend-modern/src/utils/patrolSummaryPresentation.ts` helper.
hook-local fallback logic.
The Patrol header now also has explicit helper ownership for its quickstart and
schedule presentation. `frontend-modern/src/utils/aiQuickstartPresentation.ts`
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index f7cb5b03d1..9e16e5d32c 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -3,9 +3,10 @@ import ActivityIcon from 'lucide-solid/icons/activity';
import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
import CheckCircleIcon from 'lucide-solid/icons/check-circle';
import AlertCircleIcon from 'lucide-solid/icons/alert-circle';
+import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import {
+ getPatrolAssessmentPresentation,
getPatrolSummaryPresentation,
- PATROL_NO_ISSUES_LABEL,
} from '@/utils/patrolSummaryPresentation';
import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
import { getSemanticTonePresentation } from '@/utils/semanticTonePresentation';
@@ -17,14 +18,15 @@ import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceState }) {
const state = props.state;
+ const summaryStats = createMemo(() => state.summaryStats());
const criticalSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('critical', state.summaryStats().criticalFindings > 0),
+ getPatrolSummaryPresentation('critical', summaryStats().criticalFindings > 0),
);
const warningSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('warning', state.summaryStats().warningFindings > 0),
+ getPatrolSummaryPresentation('warning', summaryStats().warningFindings > 0),
);
const fixedSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('success', state.summaryStats().fixedCount > 0),
+ getPatrolSummaryPresentation('success', summaryStats().fixedCount > 0),
);
const runtimePresentation = createMemo(() =>
getPatrolRuntimePresentation(state.runtimeState(), state.blockedReason()),
@@ -38,6 +40,28 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
runtimeState === 'blocked' || runtimeState === 'disabled' || runtimeState === 'unavailable'
);
});
+ const assessment = createMemo(() =>
+ getPatrolAssessmentPresentation({
+ overallHealth: state.intelligenceSummary()?.overall_health,
+ runtimeState: state.runtimeState(),
+ blockedReason: state.blockedReason(),
+ criticalFindings: summaryStats().criticalFindings,
+ warningFindings: summaryStats().warningFindings,
+ }),
+ );
+ const assessmentTonePresentation = createMemo(() =>
+ getSemanticTonePresentation(assessment().tone),
+ );
+ const assessmentSummaryPresentation = createMemo(() =>
+ getPatrolSummaryPresentation(
+ assessment().tone === 'error'
+ ? 'critical'
+ : assessment().tone === 'warning'
+ ? 'warning'
+ : 'success',
+ true,
+ ),
+ );
return (
<>
@@ -73,17 +97,67 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<Show when={!showRuntimeSummary()}>
<Show when={state.intelligenceSummary()}>
{(summary) => (
- <section class="rounded-md border border-border bg-surface p-4">
+ <section class={`rounded-md border p-4 ${assessmentTonePresentation().panelClass}`}>
<div class="flex flex-wrap items-start justify-between gap-4">
- <div>
- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
- Patrol summary
- </p>
- <h2 class="mt-1 text-lg font-semibold text-base-content">
- Health {summary().overall_health.grade} ·{' '}
- {Math.round(summary().overall_health.score)}/100
- </h2>
- <p class="mt-1 text-sm text-muted">{summary().overall_health.prediction}</p>
+ <div class="flex items-start gap-3">
+ <div class="flex-shrink-0 rounded-md bg-base/70 p-2">
+ <Show
+ when={assessment().tone === 'success'}
+ fallback={
+ <Show
+ when={assessment().tone === 'error'}
+ fallback={
+ <Show
+ when={assessment().tone === 'warning'}
+ fallback={
+ <AlertCircleIcon
+ class={`w-5 h-5 ${assessmentTonePresentation().iconClass}`}
+ />
+ }
+ >
+ <AlertTriangleIcon
+ class={`w-5 h-5 ${assessmentTonePresentation().iconClass}`}
+ />
+ </Show>
+ }
+ >
+ <ShieldAlertIcon
+ class={`w-5 h-5 ${assessmentTonePresentation().iconClass}`}
+ />
+ </Show>
+ }
+ >
+ <CheckCircleIcon class={`w-5 h-5 ${assessmentTonePresentation().iconClass}`} />
+ </Show>
+ </div>
+
+ <div>
+ <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
+ {assessment().eyebrow}
+ </p>
+ <h2 class="mt-1 text-lg font-semibold text-base-content">
+ {assessment().title}
+ </h2>
+ <p class="mt-1 text-sm text-base-content">{summary().overall_health.prediction}</p>
+ <div class="mt-3 flex flex-wrap items-center gap-2">
+ <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
+ Health {summary().overall_health.grade} ·{' '}
+ {Math.round(summary().overall_health.score)}/100
+ </span>
+ <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
+ Active findings {summaryStats().totalActive}
+ </span>
+ <Show when={state.patrolStatus()?.last_patrol_at}>
+ <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
+ Last patrol{' '}
+ {formatRelativeTime(state.patrolStatus()!.last_patrol_at, {
+ compact: true,
+ emptyText: 'never',
+ })}
+ </span>
+ </Show>
+ </div>
+ </div>
</div>
<div class="flex flex-wrap items-center gap-2">
@@ -97,7 +171,7 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
</div>
<Show when={state.hasInvestigationContext()}>
- <div class="mt-4 rounded-md border border-border-subtle bg-base p-3">
+ <div class="mt-4 rounded-md border border-border-subtle bg-base/90 p-3">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
@@ -158,23 +232,38 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
</Show>
</Show>
- <Show
- when={
- !showRuntimeSummary() &&
- (state.summaryStats().criticalFindings > 0 ||
- state.summaryStats().warningFindings > 0 ||
- state.summaryStats().fixedCount > 0)
- }
- fallback={
- <Show when={!showRuntimeSummary() && state.patrolStatus()?.last_patrol_at}>
- <div class="flex items-center gap-2 px-4 py-3 bg-surface rounded-md border border-border">
- <CheckCircleIcon class="w-4 h-4 text-green-500 dark:text-green-400" />
- <span class="text-sm text-muted">{PATROL_NO_ISSUES_LABEL}</span>
+ <Show when={!showRuntimeSummary() && state.intelligenceSummary()}>
+ <div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-3">
+ <div class="bg-surface rounded-md border border-border p-3">
+ <div class="flex items-center gap-2">
+ <div
+ class={`p-1.5 rounded-md border ${assessmentSummaryPresentation().iconContainerClass}`}
+ >
+ <Show
+ when={assessment().tone === 'success'}
+ fallback={
+ <Show
+ when={assessment().tone === 'error'}
+ fallback={
+ <AlertTriangleIcon class={`w-4 h-4 ${assessmentSummaryPresentation().iconClass}`} />
+ }
+ >
+ <ShieldAlertIcon class={`w-4 h-4 ${assessmentSummaryPresentation().iconClass}`} />
+ </Show>
+ }
+ >
+ <CheckCircleIcon class={`w-4 h-4 ${assessmentSummaryPresentation().iconClass}`} />
+ </Show>
+ </div>
+ <div>
+ <p class="text-xs text-muted">Assessment</p>
+ <p class={`text-sm font-semibold ${assessmentSummaryPresentation().valueClass}`}>
+ {assessment().compactLabel}
+ </p>
+ </div>
</div>
- </Show>
- }
- >
- <div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
+ </div>
+
<div class="bg-surface rounded-md border border-border p-3">
<div class="flex items-center gap-2">
<div
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index e903587dc2..bd4ed1e5b2 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -582,7 +582,8 @@ describe('AIIntelligence entitlement gating', () => {
await waitFor(() => {
expect(getPatrolStatusMock).toHaveBeenCalled();
- expect(screen.getByText('Patrol summary')).toBeInTheDocument();
+ expect(screen.getByText('Patrol assessment')).toBeInTheDocument();
+ expect(screen.getByText('No active issues detected')).toBeInTheDocument();
});
expect(screen.getByText(/Health A · 91\/100/)).toBeInTheDocument();
@@ -728,6 +729,61 @@ describe('AIIntelligence entitlement gating', () => {
expect(screen.getByText(/Health A · 100\/100/)).toBeInTheDocument();
});
+ it('surfaces coverage incomplete as the primary patrol assessment instead of no-issues copy', async () => {
+ hasFeatureMock.mockReturnValue(true);
+ licenseStatusMock.mockReturnValue({ subscription_state: 'active' });
+ getPatrolStatusMock.mockResolvedValue(
+ defaultPatrolStatus({
+ runtime_state: 'active',
+ last_patrol_at: '2026-03-12T09:57:00Z',
+ }),
+ );
+ intelligenceState.summary = {
+ timestamp: '2026-03-12T10:00:00Z',
+ overall_health: {
+ score: 70,
+ grade: 'C',
+ trend: 'stable',
+ factors: [
+ {
+ name: 'Patrol coverage incomplete',
+ impact: -0.35,
+ description:
+ 'Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',
+ category: 'coverage',
+ },
+ ],
+ prediction:
+ 'Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',
+ },
+ findings_count: {
+ critical: 0,
+ warning: 0,
+ watch: 0,
+ info: 0,
+ total: 0,
+ },
+ predictions_count: 0,
+ recent_changes_count: 0,
+ learning: {
+ resources_with_knowledge: 0,
+ total_notes: 0,
+ resources_with_baselines: 0,
+ patterns_detected: 0,
+ correlations_learned: 0,
+ incidents_tracked: 0,
+ },
+ };
+
+ render(() => <AIIntelligence />);
+
+ await waitFor(() => {
+ expect(screen.getAllByText('Coverage incomplete').length).toBeGreaterThan(0);
+ });
+
+ expect(screen.queryByText('No issues found')).not.toBeInTheDocument();
+ });
+
it('treats a selected zero-finding run as an empty snapshot and uses effective scope ids', async () => {
hasFeatureMock.mockReturnValue(true);
licenseStatusMock.mockReturnValue({ subscription_state: 'active' });
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index 84e70bd6cf..486e72c957 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
+ getPatrolAssessmentPresentation,
+ getPatrolNoIssuesPresentation,
getPatrolSummaryPresentation,
PATROL_NO_ISSUES_LABEL,
} from '@/utils/patrolSummaryPresentation';
@@ -24,4 +26,67 @@ describe('getPatrolSummaryPresentation', () => {
it('exports canonical patrol empty-state copy', () => {
expect(PATROL_NO_ISSUES_LABEL).toBe('No issues found');
});
+
+ it('promotes coverage gaps into the primary patrol assessment state', () => {
+ expect(
+ getPatrolAssessmentPresentation({
+ overallHealth: {
+ score: 70,
+ grade: 'C',
+ trend: 'stable',
+ factors: [
+ {
+ name: 'Patrol coverage incomplete',
+ impact: -0.35,
+ description: 'Patrol coverage is incomplete.',
+ category: 'coverage',
+ },
+ ],
+ prediction: 'Patrol coverage is incomplete.',
+ },
+ }),
+ ).toEqual({
+ title: 'Coverage incomplete',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Coverage incomplete',
+ tone: 'warning',
+ });
+ });
+
+ it('reports issues detected when active warning findings exist', () => {
+ expect(
+ getPatrolAssessmentPresentation({
+ overallHealth: {
+ score: 84,
+ grade: 'B',
+ trend: 'stable',
+ factors: [],
+ prediction: 'Warnings require review.',
+ },
+ warningFindings: 2,
+ }),
+ ).toEqual({
+ title: 'Issues detected',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Issues detected',
+ tone: 'warning',
+ });
+ });
+
+ it('keeps no-issues copy only for fully healthy patrol states', () => {
+ expect(
+ getPatrolNoIssuesPresentation({
+ overallHealth: {
+ score: 100,
+ grade: 'A',
+ trend: 'stable',
+ factors: [],
+ prediction: 'Infrastructure is healthy with no significant issues detected.',
+ },
+ }),
+ ).toEqual({
+ label: 'No issues found',
+ tone: 'success',
+ });
+ });
});
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 4b4a227fcc..ddda82f995 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -1,3 +1,8 @@
+import type { PatrolRuntimeState } from '@/api/patrol';
+import type { IntelligenceHealthScore } from '@/types/aiIntelligence';
+import type { SemanticTone } from '@/utils/semanticTonePresentation';
+import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
+
export type PatrolSummaryTone = 'critical' | 'warning' | 'success';
export interface PatrolSummaryPresentation {
@@ -6,6 +11,18 @@ export interface PatrolSummaryPresentation {
valueClass: string;
}
+export interface PatrolNoIssuesPresentation {
+ label: string;
+ tone: SemanticTone;
+}
+
+export interface PatrolAssessmentPresentation {
+ title: string;
+ eyebrow: string;
+ compactLabel: string;
+ tone: SemanticTone;
+}
+
export const PATROL_NO_ISSUES_LABEL = 'No issues found';
const QUIET_ICON_CONTAINER = 'bg-surface border-border';
@@ -43,3 +60,84 @@ export function getPatrolSummaryPresentation(
}
return ACTIVE_PRESENTATION[tone];
}
+
+function getHealthSummaryTone(overallHealth: IntelligenceHealthScore): SemanticTone {
+ return overallHealth.grade === 'D' || overallHealth.grade === 'F' ? 'error' : 'warning';
+}
+
+export function getPatrolAssessmentPresentation(args: {
+ overallHealth?: IntelligenceHealthScore;
+ runtimeState?: PatrolRuntimeState;
+ blockedReason?: string;
+ criticalFindings?: number;
+ warningFindings?: number;
+}): PatrolAssessmentPresentation {
+ if (
+ args.runtimeState === 'blocked' ||
+ args.runtimeState === 'disabled' ||
+ args.runtimeState === 'unavailable'
+ ) {
+ const runtime = getPatrolRuntimePresentation(args.runtimeState, args.blockedReason);
+ return {
+ title: runtime.label,
+ eyebrow: runtime.title,
+ compactLabel: runtime.label,
+ tone: runtime.tone,
+ };
+ }
+
+ if ((args.criticalFindings ?? 0) > 0) {
+ return {
+ title: 'Critical issues detected',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Issues detected',
+ tone: 'error',
+ };
+ }
+
+ if ((args.warningFindings ?? 0) > 0) {
+ return {
+ title: 'Issues detected',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Issues detected',
+ tone: 'warning',
+ };
+ }
+
+ if (args.overallHealth?.factors.some((factor) => factor.category === 'coverage')) {
+ return {
+ title: 'Coverage incomplete',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Coverage incomplete',
+ tone: getHealthSummaryTone(args.overallHealth),
+ };
+ }
+
+ if (args.overallHealth && args.overallHealth.grade !== 'A') {
+ return {
+ title: 'Health requires attention',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Health requires attention',
+ tone: getHealthSummaryTone(args.overallHealth),
+ };
+ }
+
+ return {
+ title: 'No active issues detected',
+ eyebrow: 'Patrol assessment',
+ compactLabel: PATROL_NO_ISSUES_LABEL,
+ tone: 'success',
+ };
+}
+
+export function getPatrolNoIssuesPresentation(args: {
+ overallHealth?: IntelligenceHealthScore;
+ runtimeState?: PatrolRuntimeState;
+ blockedReason?: string;
+}): PatrolNoIssuesPresentation {
+ const assessment = getPatrolAssessmentPresentation(args);
+ return {
+ label: assessment.compactLabel,
+ tone: assessment.tone,
+ };
+}