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.

Surface verified-resource coverage on the Patrol recency line

rcourtman7593097e04c1
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index bb198695cc..d74a9d70bf 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1065,7 +1065,14 @@ the canonical monitored-system blocked payload.
already plumbed through the patrol status payload). It must not
introduce a new fetch path or duplicate data plumbing — the strip is
a render-only consumer of the existing canonical signal so the
- header line and the workspace's detailed Trust strip stay aligned
+ header line and the workspace's detailed Trust strip stay aligned.
+ The same page-header recency line also reads
+ `PatrolRecencyPresentation.resourcesChecked` — populated by
+ `getPatrolRecencyPresentation` from
+ `PatrolRunRecord.resources_checked` on the latest completed run —
+ so the operator sees coverage alongside recency without needing a
+ new API surface, and the field stays optional (omitted on zero) to
+ keep degenerate runs from rendering an alarm-shaped "verified 0"
and the Assistant finding-context request contract, so `/api/ai/chat`
payloads carrying `finding_id` may hydrate a structured investigation
summary from the unified finding, but raw proposed-fix commands must stay
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 6ec724a529..a1ee114611 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1262,6 +1262,13 @@ strip. The detailed breakdown stays in
`PatrolIntelligenceWorkspace.tsx` for the canonical view; the header
line is the entry-point summary so operators see active, regressed,
and verified-fix counts before scrolling into the workspace tabs.
+The recency line beside the header actions also renders coverage
+alongside time when the canonical `getPatrolRecencyPresentation` helper
+returns `resourcesChecked` from the latest completed run. Render code
+must gate on `<Show when={recency().resourcesChecked}>` (truthy) so
+zero-coverage runs don't surface a misleading "verified 0 resources"
+line; the truthy gate also means the absence of the helper field
+gracefully omits the coverage span without code changes.
`frontend-modern/src/utils/discoveryPresentation.ts` owns resource discovery
command guidance targets. Discovery surfaces that need to tell operators where
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index bb4f90bd24..205b3ce0e7 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -1153,3 +1153,13 @@ empty header strip. The detailed Trust strip in
operators reviewing findings; the header line is the
trust-at-a-glance entry point that names what Patrol's loop has
produced before the operator scrolls into the workspace tabs.
+The same page-header recency line must also surface the coverage
+signal from the most recent completed run via
+`PatrolRecencyPresentation.resourcesChecked`, populated by
+`getPatrolRecencyPresentation` from
+`PatrolRunRecord.resources_checked`. The render reads "Last full
+patrol: 3m ago — verified 47 resources" so operators see both
+temporal recency and coverage in one line. The field stays optional
+(omitted when zero) so a degenerate run that completed without
+checking any resources does not render a misleading "verified 0
+resources" line.
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
index e5d6a34de3..eaf55d6fa5 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
@@ -88,6 +88,13 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState
compact: true,
emptyText: 'Never',
})}
+ <Show when={recency().resourcesChecked}>
+ {' '}
+ <span class="text-muted">
+ — verified {recency().resourcesChecked} resource
+ {recency().resourcesChecked === 1 ? '' : 's'}
+ </span>
+ </Show>
</span>
<Show when={state.patrolStatus()?.next_patrol_at}>
<span class="text-muted">|</span>
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
index e8d3b9dece..d39b62c515 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
@@ -1629,6 +1629,22 @@ describe('patrolInvestigationContextModel', () => {
});
describe('Patrol page header IA framing', () => {
+ it('surfaces verified-resource coverage on the recency line in the page header', () => {
+ // Third wedge of the Patrol page IA reframe. The recency line tells the
+ // operator when Pulse last ran; the coverage signal tells them what it
+ // covered. Pin the wiring so the recency render reads
+ // resourcesChecked from getPatrolRecencyPresentation and gates on a
+ // truthy <Show> so zero-coverage runs don't render "verified 0
+ // resources" as an alarm.
+ const headerSource = readFileSync(
+ resolve(__dirname, '..', 'PatrolIntelligenceHeader.tsx'),
+ 'utf-8',
+ );
+ expect(headerSource).toContain('recency().resourcesChecked');
+ expect(headerSource).toContain('Show when={recency().resourcesChecked}');
+ expect(headerSource).toContain('verified ');
+ });
+
it('hoists a trust-at-a-glance summary into the page header above the runtime row', () => {
// The compact trust summary on the Patrol page header is the second
// wedge of the IA reframe (the first being PATROL_PAGE_DESCRIPTION).
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index ca3a0ccb5d..8d571dfe3b 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -729,6 +729,7 @@ describe('getPatrolSummaryPresentation', () => {
).toEqual({
label: 'Last activity',
timestamp: '2026-03-12T09:59:00Z',
+ resourcesChecked: 1,
});
});
@@ -769,6 +770,7 @@ describe('getPatrolSummaryPresentation', () => {
).toEqual({
label: 'Last full patrol',
timestamp: '2026-03-12T09:57:00Z',
+ resourcesChecked: 58,
});
});
@@ -783,4 +785,50 @@ describe('getPatrolSummaryPresentation', () => {
timestamp: '2026-03-12T09:59:00Z',
});
});
+
+ it('omits resourcesChecked when the most recent completed run reports zero coverage', () => {
+ // A run that completed without checking any resources (e.g. an early
+ // failure or a no-op trigger fire) should not surface a "verified 0
+ // resources" line on the page header — that reads as an alarm signal
+ // when it's just a degenerate run. The presentation must omit the
+ // field instead of returning resourcesChecked: 0 so render code's
+ // truthy <Show> gate cleanly hides the coverage span.
+ expect(
+ getPatrolRecencyPresentation({
+ runs: [
+ {
+ id: 'run-empty',
+ started_at: '2026-03-12T09:50:00Z',
+ completed_at: '2026-03-12T09:51:00Z',
+ duration_ms: 60000,
+ type: 'patrol',
+ resources_checked: 0,
+ nodes_checked: 0,
+ guests_checked: 0,
+ docker_checked: 0,
+ storage_checked: 0,
+ hosts_checked: 0,
+ truenas_checked: 0,
+ pbs_checked: 0,
+ pmg_checked: 0,
+ kubernetes_checked: 0,
+ new_findings: 0,
+ existing_findings: 0,
+ rejected_findings: 0,
+ resolved_findings: 0,
+ auto_fix_count: 0,
+ findings_summary: '',
+ finding_ids: [],
+ error_count: 0,
+ status: 'no_issues',
+ triage_flags: 0,
+ tool_call_count: 0,
+ },
+ ] as never,
+ }),
+ ).toEqual({
+ label: 'Last full patrol',
+ timestamp: '2026-03-12T09:51:00Z',
+ });
+ });
});
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 95012a7611..00e15c53ba 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -91,6 +91,13 @@ export interface PatrolVerificationPresentation {
export interface PatrolRecencyPresentation {
label: string;
timestamp?: string;
+ // resourcesChecked is the coverage signal for the most recent completed
+ // run — populated from `PatrolRunRecord.resources_checked` when a run is
+ // available. Lets the page header read "Last full patrol: 3m ago —
+ // verified 47 resources", giving operators temporal AND coverage signal
+ // in one line. Stays optional because legacy fall-back paths
+ // (lastPatrolAt / lastActivityAt without a run record) carry no count.
+ resourcesChecked?: number;
}
type PatrolAssessmentFinding = Pick<
@@ -737,9 +744,11 @@ export function getPatrolRecencyPresentation(args: {
}): PatrolRecencyPresentation {
const latestCompletedRun = (args.runs ?? []).find((run) => isCompletedPatrolRun(run));
if (latestCompletedRun?.completed_at) {
+ const resourcesChecked = latestCompletedRun.resources_checked || 0;
return {
label: isFullPatrolRun(latestCompletedRun) ? 'Last full patrol' : 'Last activity',
timestamp: latestCompletedRun.completed_at,
+ resourcesChecked: resourcesChecked > 0 ? resourcesChecked : undefined,
};
}