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.

Separate Patrol runtime issues from summary metrics

rcourtmanf1fc217b241d
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 536fbbd484..31d00a663f 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -181,6 +181,11 @@ findings, so the findings list must not offer generic acknowledge, snooze,
dismiss, resolve, or suppress controls for them. The correct operator path is
to fix AI/provider configuration and rerun Patrol, optionally adding context
notes, rather than hiding the runtime issue.
+That same runtime-versus-infrastructure split must carry through the summary
+metrics strip as well. When Patrol-owned runtime issues are active, the
+supporting metrics must stop counting them under generic infrastructure
+`Warnings` or `Active findings`; the strip should break out `Runtime issues`
+separately and reserve infrastructure finding counts for actual estate issues.
The summary recency chip must follow the same governed scope distinction. When
the latest completed activity was only a scoped run, the summary should label
that timestamp as `Last activity` instead of `Last patrol`; `Last full patrol`
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index 3ae5e02630..7c41e4f463 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -9,6 +9,7 @@ import {
getPatrolAssessmentPresentation,
getPatrolRecencyPresentation,
getPatrolScoreChipLabel,
+ getPatrolSummaryMetricState,
getPatrolVerificationPresentation,
getPatrolSummaryPresentation,
} from '@/utils/patrolSummaryPresentation';
@@ -23,8 +24,14 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
const criticalSummaryPresentation = createMemo(() =>
getPatrolSummaryPresentation('critical', summaryStats().criticalFindings > 0),
);
+ const metricState = createMemo(() =>
+ getPatrolSummaryMetricState({
+ activeFindings: state.activePatrolFindings(),
+ fixedCount: summaryStats().fixedCount,
+ }),
+ );
const warningSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('warning', summaryStats().warningFindings > 0),
+ getPatrolSummaryPresentation(metricState().secondarySeverity, metricState().secondaryValue > 0),
);
const runtimePresentation = createMemo(() =>
getPatrolRuntimePresentation(state.runtimeState(), state.blockedReason()),
@@ -53,12 +60,8 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
);
const activeFindingsSummaryPresentation = createMemo(() =>
getPatrolSummaryPresentation(
- summaryStats().criticalFindings > 0
- ? 'critical'
- : summaryStats().totalActive > 0
- ? 'warning'
- : 'warning',
- summaryStats().totalActive > 0,
+ metricState().primarySeverity,
+ metricState().primaryValue > 0,
),
);
const verification = createMemo(() =>
@@ -241,9 +244,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
</Show>
</div>
<div>
- <p class="text-xs text-muted">Active findings</p>
+ <p class="text-xs text-muted">{metricState().primaryLabel}</p>
<p class={`text-lg font-bold ${activeFindingsSummaryPresentation().valueClass}`}>
- {summaryStats().totalActive}
+ {metricState().primaryValue}
</p>
</div>
</div>
@@ -257,9 +260,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<ActivityIcon class={`w-4 h-4 ${warningSummaryPresentation().iconClass}`} />
</div>
<div>
- <p class="text-xs text-muted">Warnings</p>
+ <p class="text-xs text-muted">{metricState().secondaryLabel}</p>
<p class={`text-lg font-bold ${warningSummaryPresentation().valueClass}`}>
- {state.summaryStats().warningFindings}
+ {metricState().secondaryValue}
</p>
</div>
</div>
@@ -273,9 +276,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<ShieldAlertIcon class={`w-4 h-4 ${criticalSummaryPresentation().iconClass}`} />
</div>
<div>
- <p class="text-xs text-muted">Critical</p>
+ <p class="text-xs text-muted">{metricState().criticalLabel}</p>
<p class={`text-lg font-bold ${criticalSummaryPresentation().valueClass}`}>
- {state.summaryStats().criticalFindings}
+ {metricState().criticalValue}
</p>
</div>
</div>
@@ -289,9 +292,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<CheckCircleIcon class={`w-4 h-4 ${fixedSummaryPresentation().iconClass}`} />
</div>
<div>
- <p class="text-xs text-muted">Fixed</p>
+ <p class="text-xs text-muted">{metricState().fixedLabel}</p>
<p class={`text-lg font-bold ${fixedSummaryPresentation().valueClass}`}>
- {state.summaryStats().fixedCount}
+ {metricState().fixedValue}
</p>
</div>
</div>
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 18decabf47..b28b7f6170 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -952,6 +952,8 @@ describe('AIIntelligence entitlement gating', () => {
'Patrol has an active runtime issue: Insufficient API credits. Recent coverage is also incomplete, so the rest of your infrastructure is not fully verified.',
),
).toBeInTheDocument();
+ expect(screen.getByText('Infrastructure findings')).toBeInTheDocument();
+ expect(screen.getByText('Runtime issues')).toBeInTheDocument();
});
expect(screen.getByText(/Assessment C · 60\/100/)).toBeInTheDocument();
@@ -959,6 +961,7 @@ describe('AIIntelligence entitlement gating', () => {
'href',
'/settings/system-ai',
);
+ expect(screen.queryByText('Warnings')).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Findings' }).textContent).toBe('Findings 1');
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index 38eca106c0..3f66af3f15 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -4,6 +4,7 @@ import {
getPatrolAssessmentAction,
getPatrolRecencyPresentation,
getPatrolScoreChipLabel,
+ getPatrolSummaryMetricState,
getPatrolVerificationPresentation,
getPatrolNoIssuesPresentation,
getPatrolSummaryPresentation,
@@ -213,6 +214,62 @@ describe('getPatrolSummaryPresentation', () => {
).toBeUndefined();
});
+ it('splits infrastructure findings from patrol runtime issues in supporting metrics', () => {
+ expect(
+ getPatrolSummaryMetricState({
+ activeFindings: [
+ {
+ status: 'active',
+ severity: 'warning',
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ },
+ ] as never,
+ fixedCount: 0,
+ }),
+ ).toEqual({
+ primaryLabel: 'Infrastructure findings',
+ primaryValue: 0,
+ primarySeverity: 'warning',
+ secondaryLabel: 'Runtime issues',
+ secondaryValue: 1,
+ secondarySeverity: 'warning',
+ criticalLabel: 'Critical',
+ criticalValue: 0,
+ fixedLabel: 'Fixed',
+ fixedValue: 0,
+ });
+ });
+
+ it('keeps active findings and warnings labels when only infrastructure findings are active', () => {
+ expect(
+ getPatrolSummaryMetricState({
+ activeFindings: [
+ {
+ status: 'active',
+ severity: 'warning',
+ resourceId: 'vm-101',
+ resourceName: 'db-01',
+ title: 'Disk nearly full',
+ },
+ ] as never,
+ fixedCount: 2,
+ }),
+ ).toEqual({
+ primaryLabel: 'Active findings',
+ primaryValue: 1,
+ primarySeverity: 'warning',
+ secondaryLabel: 'Warnings',
+ secondaryValue: 1,
+ secondarySeverity: 'warning',
+ criticalLabel: 'Critical',
+ criticalValue: 0,
+ fixedLabel: 'Fixed',
+ fixedValue: 2,
+ });
+ });
+
it('keeps health labeling for verified healthy states', () => {
expect(
getPatrolScoreChipLabel({
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 0a5b6bcc18..69ee3a178d 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -31,6 +31,19 @@ export interface PatrolAssessmentAction {
href: string;
}
+export interface PatrolSummaryMetricState {
+ primaryLabel: string;
+ primaryValue: number;
+ primarySeverity: 'critical' | 'warning';
+ secondaryLabel: string;
+ secondaryValue: number;
+ secondarySeverity: 'critical' | 'warning';
+ criticalLabel: string;
+ criticalValue: number;
+ fixedLabel: string;
+ fixedValue: number;
+}
+
export interface PatrolVerificationPresentation {
title: string;
description: string;
@@ -148,6 +161,27 @@ function classifyActiveFindings(activeFindings: PatrolAssessmentFinding[] | unde
};
}
+export function getPatrolSummaryMetricState(args: {
+ activeFindings?: PatrolAssessmentFinding[];
+ fixedCount?: number;
+}): PatrolSummaryMetricState {
+ const classified = classifyActiveFindings(args.activeFindings);
+ const hasRuntimeIssues = classified.runtimeTotal > 0;
+
+ return {
+ primaryLabel: hasRuntimeIssues ? 'Infrastructure findings' : 'Active findings',
+ primaryValue: classified.infrastructureTotal,
+ primarySeverity: classified.infrastructureCritical > 0 ? 'critical' : 'warning',
+ secondaryLabel: hasRuntimeIssues ? 'Runtime issues' : 'Warnings',
+ secondaryValue: hasRuntimeIssues ? classified.runtimeTotal : classified.infrastructureWarning,
+ secondarySeverity: classified.runtimeCritical > 0 ? 'critical' : 'warning',
+ criticalLabel: 'Critical',
+ criticalValue: classified.infrastructureCritical + classified.runtimeCritical,
+ fixedLabel: 'Fixed',
+ fixedValue: args.fixedCount ?? 0,
+ };
+}
+
export function getPatrolScoreChipLabel(args: {
overallHealth?: IntelligenceHealthScore;
activeFindings?: PatrolAssessmentFinding[];