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.

Canonicalize Patrol run snapshot coverage copy

rcourtman968667330f46
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index c9467c4bdb..f74f7a53d7 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -202,6 +202,12 @@ 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`
belongs only to the most recent completed full Patrol run.
That same recency contract also applies to the header metadata row. The top
+That same empty-state contract must become run-snapshot-aware when the user is
+filtering findings to an explicit Patrol run. A selected run with an explicit
+empty `finding_ids` snapshot should explain that no findings were recorded for
+that run and, when applicable, carry the canonical run coverage summary and
+issue caveat instead of falling back to the generic `No Patrol findings to
+display` copy.
header must not revert to a generic `Last:` timestamp when the rest of Patrol
is explicitly distinguishing activity from full verification recency.
That summary surface must also avoid reintroducing a second compact assessment
@@ -366,6 +372,11 @@ and the resource drawer both reflect the same learned edge evidence instead
of each page fetching its own copy. Both surfaces now render that evidence
through the shared `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx`
card, so the correlation layout stays governed by one component instead of
+Within that same run-history surface, coverage copy must stay canonical across
+the header chips, narrative summary, and selected-run snapshot. Scoped runs
+must not present scope size and checked-resource count as contradictory
+independent facts; the shared run presenter should collapse them into one
+coverage statement such as `Checked 1 of 2 scoped resources`.
two page-local card implementations. That shared card also owns the
correlation ordering and truncation rule, so the page and drawer hand it raw
correlation lists instead of slicing or re-sorting them locally.
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index d8b9e6e5e2..efe48d9ec5 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -18,7 +18,7 @@ import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
import { InvestigationSection, ApprovalSection } from '@/components/patrol';
import { AIAPI, type RemediationPlan } from '@/api/ai';
-import type { PatrolRuntimeState } from '@/api/patrol';
+import type { PatrolRunRecord, PatrolRuntimeState } from '@/api/patrol';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import { formatRelativeTime } from '@/utils/format';
import { getFindingAlertIdentifier, hasTriggeringAlert } from '@/utils/findingAlertIdentity';
@@ -68,6 +68,15 @@ interface FindingsPanelProps {
showControls?: boolean;
scopeResourceIds?: string[];
scopeResourceTypes?: string[];
+ runSnapshot?: Pick<
+ PatrolRunRecord,
+ | 'resources_checked'
+ | 'scope_resource_ids'
+ | 'effective_scope_resource_ids'
+ | 'finding_ids'
+ | 'status'
+ | 'error_count'
+ >;
showScopeWarnings?: boolean;
runtimeState?: PatrolRuntimeState;
blockedReason?: string;
@@ -233,6 +242,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
buildFindingFilterOptions({
needsAttentionCount: aiIntelligenceStore.needsAttentionCount,
pendingApprovalCount: aiIntelligenceStore.pendingApprovalCount,
+ runSnapshot: props.runSnapshot,
}),
);
const emptyStateCopy = createMemo(() =>
diff --git a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
index c19dd1623a..79c5fa5f46 100644
--- a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
+++ b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
@@ -12,7 +12,12 @@ import {
sanitizeAnalysis,
} from '@/utils/patrolFormat';
import { formatRelativeTime } from '@/utils/format';
-import { getPatrolRunStatusPresentation, isPatrolRunHealthy } from '@/utils/patrolRunPresentation';
+import {
+ getPatrolRunCoverageSummary,
+ getPatrolRunResourcesHeading,
+ getPatrolRunStatusPresentation,
+ isPatrolRunHealthy,
+} from '@/utils/patrolRunPresentation';
import BrainCircuitIcon from 'lucide-solid/icons/brain-circuit';
import ActivityIcon from 'lucide-solid/icons/activity';
@@ -146,6 +151,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
const runStatus = getPatrolRunStatusPresentation(run.status, run.error_count);
const canonicalScopeResourceIds = getCanonicalScopeResourceIds(run);
const runIsHealthy = isPatrolRunHealthy(run.status, run.error_count);
+ const coverageSummary = getPatrolRunCoverageSummary(run);
return (
<div
@@ -166,14 +172,14 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
</span>
<span class={`px-1.5 py-0.5 rounded ${runStatus.badgeClass}`}>{runStatus.label}</span>
<span>{formatTriggerReason(run.trigger_reason)}</span>
- <Show when={scopeSummary}>
+ <Show when={scopeSummary && !coverageSummary}>
<span>• {scopeSummary}</span>
</Show>
<Show when={duration}>
<span>• {duration}</span>
</Show>
- <Show when={run.resources_checked}>
- <span>• {run.resources_checked} resources</span>
+ <Show when={coverageSummary}>
+ <span>• {coverageSummary}</span>
</Show>
<Show when={run.new_findings}>
<span>• {run.new_findings} new</span>
@@ -193,8 +199,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
<p>
{run.resources_checked > 0 ? (
<>
- Scanned <strong>{run.resources_checked}</strong> resource
- {run.resources_checked !== 1 ? 's' : ''}{' '}
+ {coverageSummary}{' '}
{formatDurationMs(run.duration_ms) ? (
<>
in <strong>{formatDurationMs(run.duration_ms)}</strong>
@@ -260,7 +265,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
<div class="flex items-center gap-1.5 mb-2">
<SearchIcon class="w-3.5 h-3.5 text-muted" />
<span class="text-[10px] font-semibold tracking-wider uppercase text-muted">
- Resources Scanned ({run.resources_checked})
+ {getPatrolRunResourcesHeading(run)}
</span>
</div>
<div class="flex flex-wrap gap-1.5">
@@ -434,6 +439,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
scopeResourceTypes={run.scope_resource_types}
showScopeWarnings={true}
showControls={false}
+ runSnapshot={run}
/>
</div>
</Show>
diff --git a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
index 1271f53a65..df93c7864e 100644
--- a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
@@ -24,6 +24,7 @@ vi.mock('@/components/AI/FindingsPanel', () => ({
: props.scopeResourceTypes,
showControls: props.showControls,
showScopeWarnings: props.showScopeWarnings,
+ runSnapshot: props.runSnapshot,
};
return <div data-testid="findings-panel" />;
},
@@ -111,9 +112,45 @@ describe('RunHistoryEntry', () => {
scopeResourceTypes: ['vm'],
showControls: false,
showScopeWarnings: true,
+ runSnapshot: run,
});
});
+ it('uses a shared coverage summary when a scoped run checked fewer resources than its scope', () => {
+ render(() => (
+ <RunHistoryEntry
+ run={{
+ ...run,
+ id: 'run-partial-scope',
+ duration_ms: 453,
+ effective_scope_resource_ids: ['expanded-a', 'expanded-b'],
+ resources_checked: 1,
+ guests_checked: 1,
+ error_count: 1,
+ status: 'error',
+ }}
+ isLive={false}
+ patrolStream={patrolStream}
+ selected={true}
+ onSelect={vi.fn()}
+ />
+ ));
+
+ expect(screen.getByText('• Checked 1 of 2 scoped resources')).toBeInTheDocument();
+ expect(screen.getByText('Resources checked (1 of 2 scoped)')).toBeInTheDocument();
+ expect(screen.queryByText('• 1 resources')).not.toBeInTheDocument();
+ expect(
+ screen.getByText((_, element) =>
+ element?.tagName === 'P' &&
+ (element.textContent?.includes('Checked 1 of 2 scoped resources') ??
+ false) &&
+ (element.textContent?.includes('453ms') ?? false) &&
+ (element.textContent?.includes('Patrol completed with issues requiring review.') ??
+ false),
+ ),
+ ).toBeInTheDocument();
+ });
+
it('does not claim all clear when the run still had existing issues', () => {
render(() => (
<RunHistoryEntry
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
index fe334c823a..b1e415da80 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -108,6 +108,7 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt
filterFindingIds={state.selectedRunFindingIds()}
scopeResourceIds={state.selectedRunScopeResourceIds()}
scopeResourceTypes={state.selectedRun()?.scope_resource_types}
+ runSnapshot={state.selectedRun() ?? undefined}
showScopeWarnings={Boolean(state.selectedRun())}
runtimeState={state.runtimeState()}
blockedReason={state.blockedReason()}
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index b28b7f6170..a50b99695f 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -16,6 +16,7 @@ const { findingsPanelState, runHistoryState, intelligenceState } = vi.hoisted(()
lastPatrolAt?: string;
lastPatrolLabel?: string;
patrolIntervalMs?: number;
+ runSnapshotId?: string;
} | null,
},
runHistoryState: {
@@ -202,6 +203,12 @@ vi.mock('@/components/AI/FindingsPanel', () => ({
typeof props.lastPatrolLabel === 'string' ? props.lastPatrolLabel : undefined,
patrolIntervalMs:
typeof props.patrolIntervalMs === 'number' ? props.patrolIntervalMs : undefined,
+ runSnapshotId:
+ props.runSnapshot &&
+ typeof props.runSnapshot === 'object' &&
+ typeof (props.runSnapshot as { id?: unknown }).id === 'string'
+ ? ((props.runSnapshot as { id: string }).id ?? undefined)
+ : undefined,
};
return <div data-testid="findings-panel" />;
},
@@ -1012,6 +1019,7 @@ describe('AIIntelligence entitlement gating', () => {
await waitFor(() => {
expect(getPatrolStatusMock).toHaveBeenCalled();
expect(findingsPanelState.latestProps).not.toBeNull();
+ runSnapshotId: 'run-empty',
});
fireEvent.click(screen.getByRole('button', { name: 'Runs' }));
@@ -1071,6 +1079,7 @@ describe('AIIntelligence entitlement gating', () => {
await waitFor(() => {
expect(getPatrolStatusMock).toHaveBeenCalled();
expect(findingsPanelState.latestProps).not.toBeNull();
+ runSnapshotId: 'run-empty-effective-scope',
});
fireEvent.click(screen.getByRole('button', { name: 'Runs' }));
@@ -1129,6 +1138,7 @@ describe('AIIntelligence entitlement gating', () => {
await waitFor(() => {
expect(getPatrolStatusMock).toHaveBeenCalled();
expect(findingsPanelState.latestProps).not.toBeNull();
+ runSnapshotId: 'run-missing-snapshot',
});
fireEvent.click(screen.getByRole('button', { name: 'Runs' }));
diff --git a/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
index 5a21e2b31e..1dbbfae010 100644
--- a/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
@@ -124,4 +124,24 @@ describe('patrolEmptyStatePresentation', () => {
tone: 'success',
});
});
+
+ it('describes a selected run snapshot with no recorded findings using coverage-aware copy', () => {
+ expect(
+ getPatrolFindingsEmptyState({
+ filter: 'all',
+ runSnapshot: {
+ resources_checked: 1,
+ scope_resource_ids: ['seed-resource'],
+ effective_scope_resource_ids: ['expanded-a', 'expanded-b'],
+ finding_ids: [],
+ status: 'error',
+ error_count: 1,
+ },
+ }),
+ ).toEqual({
+ title: 'No findings recorded for this run',
+ body: 'Checked 1 of 2 scoped resources. This run recorded no snapshot findings, but it ended with issues requiring review.',
+ tone: 'warning',
+ });
+ });
});
diff --git a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
index 68910d54ce..5ff7a579c7 100644
--- a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
@@ -1,6 +1,9 @@
import { describe, expect, it } from 'vitest';
+import type { PatrolRunRecord } from '@/api/patrol';
import {
getPatrolRunKindLabel,
+ getPatrolRunCoverageSummary,
+ getPatrolRunResourcesHeading,
getPatrolRunStatusPresentation,
isPatrolRunHealthy,
getRunHistoryLoadingState,
@@ -11,6 +14,24 @@ import {
} from '@/utils/patrolRunPresentation';
describe('patrolRunPresentation', () => {
+ const scopedCoverageRun: Pick<
+ PatrolRunRecord,
+ 'resources_checked' | 'scope_resource_ids' | 'effective_scope_resource_ids'
+ > = {
+ resources_checked: 1,
+ scope_resource_ids: ['seed-resource'],
+ effective_scope_resource_ids: ['expanded-a', 'expanded-b'],
+ };
+
+ const fullCoverageRun: Pick<
+ PatrolRunRecord,
+ 'resources_checked' | 'scope_resource_ids' | 'effective_scope_resource_ids'
+ > = {
+ resources_checked: 58,
+ scope_resource_ids: [],
+ effective_scope_resource_ids: [],
+ };
+
it('maps critical and error runs to danger styling', () => {
expect(getPatrolRunStatusPresentation('critical').badgeClass).toContain('red-100');
expect(getPatrolRunStatusPresentation('error').badgeClass).toContain('red-100');
@@ -58,6 +79,20 @@ describe('patrolRunPresentation', () => {
expect(getPatrolRunKindLabel('')).toBe('Full patrol');
});
+ it('expresses scoped run coverage against the effective scope', () => {
+ expect(getPatrolRunCoverageSummary(scopedCoverageRun)).toBe(
+ 'Checked 1 of 2 scoped resources',
+ );
+ expect(getPatrolRunResourcesHeading(scopedCoverageRun)).toBe(
+ 'Resources checked (1 of 2 scoped)',
+ );
+ });
+
+ it('uses checked-resource language for non-scoped coverage summaries', () => {
+ expect(getPatrolRunCoverageSummary(fullCoverageRun)).toBe('Checked 58 resources');
+ expect(getPatrolRunResourcesHeading(fullCoverageRun)).toBe('Resources checked (58)');
+ });
+
it('returns canonical patrol run loading and unavailable copy', () => {
expect(getRunHistoryLoadingState()).toBe('Loading run history…');
expect(getToolCallsLoadingState()).toBe('Loading tool calls...');
diff --git a/frontend-modern/src/utils/patrolEmptyStatePresentation.ts b/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
index bdde8839b2..a953b10515 100644
--- a/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
+++ b/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
@@ -1,9 +1,10 @@
-import type { PatrolRuntimeState } from '@/api/patrol';
+import type { PatrolRunRecord, PatrolRuntimeState } from '@/api/patrol';
import type { FindingsFilter } from '@/utils/aiFindingPresentation';
import { getFindingEmptyStateCopy } from '@/utils/aiFindingPresentation';
import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
import type { SemanticTone } from '@/utils/semanticTonePresentation';
import type { IntelligenceHealthScore } from '@/types/aiIntelligence';
+import { getPatrolRunCoverageSummary, isPatrolRunHealthy } from '@/utils/patrolRunPresentation';
export function getInvestigationMessagesState(loading: boolean, hasMessages: boolean) {
if (loading) {
@@ -59,6 +60,17 @@ export interface PatrolFindingsEmptyStateCopy {
tone: SemanticTone;
}
+interface PatrolRunSnapshotEmptyStateArgs
+ extends Pick<
+ PatrolRunRecord,
+ | 'resources_checked'
+ | 'scope_resource_ids'
+ | 'effective_scope_resource_ids'
+ | 'finding_ids'
+ | 'status'
+ | 'error_count'
+ > {}
+
const HEALTHY_PATROL_EMPTY_STATE_BODY = 'Your infrastructure looks healthy!';
const DEGRADED_COVERAGE_EMPTY_STATE_BODY =
'Patrol has not surfaced active findings, but coverage is incomplete, so this is not a full all-clear.';
@@ -89,12 +101,43 @@ function getDegradedPatrolEmptyStateBody(overallHealth: IntelligenceHealthScore)
return DEGRADED_HEALTH_EMPTY_STATE_BODY;
}
+function getPatrolRunSnapshotEmptyState(
+ run: PatrolRunSnapshotEmptyStateArgs,
+): PatrolFindingsEmptyStateCopy {
+ const coverageSummary = getPatrolRunCoverageSummary(run);
+ const coveragePrefix = coverageSummary ? `${coverageSummary}. ` : '';
+
+ if (!isPatrolRunHealthy(run.status, run.error_count)) {
+ return {
+ title: 'No findings recorded for this run',
+ body: `${coveragePrefix}This run recorded no snapshot findings, but it ended with issues requiring review.`,
+ tone: 'warning',
+ };
+ }
+
+ return {
+ title: 'No findings recorded for this run',
+ body: `${coveragePrefix}This run recorded no Patrol findings.`,
+ tone: 'info',
+ };
+}
+
export function getPatrolFindingsEmptyState(args: {
filter: FindingsFilter;
overallHealth?: IntelligenceHealthScore;
runtimeState?: PatrolRuntimeState;
blockedReason?: string;
+ runSnapshot?: PatrolRunSnapshotEmptyStateArgs;
}): PatrolFindingsEmptyStateCopy {
+ if (
+ args.filter === 'all' &&
+ args.runSnapshot &&
+ Array.isArray(args.runSnapshot.finding_ids) &&
+ args.runSnapshot.finding_ids.length === 0
+ ) {
+ return getPatrolRunSnapshotEmptyState(args.runSnapshot);
+ }
+
if (args.filter !== 'active') {
return {
...getFindingEmptyStateCopy(args.filter),
diff --git a/frontend-modern/src/utils/patrolRunPresentation.ts b/frontend-modern/src/utils/patrolRunPresentation.ts
index fffbf8482c..ed60a52d39 100644
--- a/frontend-modern/src/utils/patrolRunPresentation.ts
+++ b/frontend-modern/src/utils/patrolRunPresentation.ts
@@ -1,11 +1,18 @@
-import type { PatrolRunStatus } from '@/api/patrol';
+import type { PatrolRunRecord, PatrolRunStatus } from '@/api/patrol';
import { formatIdentifierLabel } from '@/utils/textPresentation';
+import { getCanonicalScopeResourceIds } from '@/utils/patrolFormat';
export interface PatrolRunStatusPresentation {
badgeClass: string;
label: string;
}
+function formatResourceCount(count: number, qualifier?: string): string {
+ const normalized = Math.max(0, count || 0);
+ const qualifierPrefix = qualifier ? `${qualifier} ` : '';
+ return `${normalized} ${qualifierPrefix}resource${normalized === 1 ? '' : 's'}`;
+}
+
function normalizePatrolRunType(type: string | undefined): string {
return String(type || '')
.trim()
@@ -83,6 +90,38 @@ export function getPatrolRunKindLabel(type: string | undefined): string {
return normalizePatrolRunType(type) === 'scoped' ? 'Scoped run' : 'Full patrol';
}
+export function getPatrolRunCoverageSummary(run: Pick<PatrolRunRecord, 'resources_checked' | 'scope_resource_ids' | 'effective_scope_resource_ids'>): string {
+ const resourcesChecked = Math.max(0, run.resources_checked || 0);
+ const scopedResourceCount = getCanonicalScopeResourceIds(run)?.length ?? 0;
+
+ if (scopedResourceCount > 0) {
+ if (resourcesChecked > 0 && resourcesChecked < scopedResourceCount) {
+ return `Checked ${resourcesChecked} of ${scopedResourceCount} scoped resources`;
+ }
+ if (resourcesChecked > 0) {
+ return `Checked ${formatResourceCount(resourcesChecked, 'scoped')}`;
+ }
+ return `Scoped to ${formatResourceCount(scopedResourceCount)}`;
+ }
+
+ if (resourcesChecked > 0) {
+ return `Checked ${formatResourceCount(resourcesChecked)}`;
+ }
+
+ return '';
+}
+
+export function getPatrolRunResourcesHeading(run: Pick<PatrolRunRecord, 'resources_checked' | 'scope_resource_ids' | 'effective_scope_resource_ids'>): string {
+ const resourcesChecked = Math.max(0, run.resources_checked || 0);
+ const scopedResourceCount = getCanonicalScopeResourceIds(run)?.length ?? 0;
+
+ if (scopedResourceCount > 0 && resourcesChecked > 0 && resourcesChecked < scopedResourceCount) {
+ return `Resources checked (${resourcesChecked} of ${scopedResourceCount} scoped)`;
+ }
+
+ return `Resources checked (${resourcesChecked})`;
+}
+
export function getRunHistoryLoadingState(): string {
return 'Loading run history…';
}