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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Extract Patrol investigation context model owner
rcourtman8adbdbc05814
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 5cceae4954..e97bc8dd63 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -116,6 +116,7 @@ Own canonical runtime payload shapes between backend and frontend.and the learned-correlation payload loaded into the shared AI intelligence store, so the Patrol intelligence page and the AI summary page consume the same governed correlation slice instead of each page fetching its own copyand the shared dashboard-load bundle inside `frontend-modern/src/stores/aiIntelligence.ts`, so the page orchestration stays on the store-owned bundle instead of enumerating the AI fetches inlineand the shared `frontend-modern/src/components/Infrastructure/ResourcePolicySummary.tsx` card, so the AI summary page renders the governed policy-posture counts while the resource drawer stays on per-resource policy lines instead of carrying duplicate posture UI loops+ and the dedicated `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts` owner, so recent-change, learned-correlation, and governed-resource summary text stays derived from the canonical AI payload in one place instead of as hook-local count and pluralization logicand the shared `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx` card, so learned correlations and correlation context stay rendered through one governed frontend card instead of separate page-local list loopsand the same shared correlation card's ordering and truncation rule, so callers pass raw correlations instead of encoding their own top-N sort behaviorand the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` and `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx` cards' infrastructure resource-link default, so the Patrol page, resource drawer, and problem-resource dashboard panels inherit the canonical resource-filter path construction instead of rebuilding infrastructure URLs inlinediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex b0360075fa..4cbc626c05 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -621,10 +621,12 @@ keep their shell/runtime split explicit once a subsystem grows real transportor polling lifecycle. The Patrol feature is the current reference shape:`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` stays thefeature shell, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`-owns the runtime state machine, and the Patrol-owned header/banner/summary/workspace-section files under `frontend-modern/src/features/patrol/` own the heavy render-surfaces. Shared shell governance should reinforce that pattern instead of-letting feature render surfaces re-accumulate API and timer orchestration inline.+owns the runtime state machine, `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`+owns the pure investigation-context summary derivation, and the Patrol-owned+header/banner/summary/workspace section files under+`frontend-modern/src/features/patrol/` own the heavy render surfaces. Shared+shell governance should reinforce that pattern instead of letting feature render+surfaces re-accumulate API and timer orchestration inline.Shared primitive consumers that split status-dot tone and status-text tonemust 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.mdindex 37c9e7ad20..2308fbf552 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -27,20 +27,21 @@ Patrol-specific presentation helpers.4. `frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx`5. `frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx`6. `frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx`-7. `frontend-modern/src/pages/AIIntelligence.tsx`-8. `frontend-modern/src/stores/aiIntelligence.ts`-9. `frontend-modern/src/types/aiIntelligence.ts`-10. `frontend-modern/src/components/AI/FindingsPanel.tsx`-11. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`-12. `frontend-modern/src/components/patrol/`-13. `frontend-modern/src/utils/aiFindingPresentation.ts`-14. `frontend-modern/src/utils/approvalRiskPresentation.ts`-15. `frontend-modern/src/utils/findingAlertIdentity.ts`-16. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`-17. `frontend-modern/src/utils/patrolFormat.ts`-18. `frontend-modern/src/utils/patrolRunPresentation.ts`-19. `frontend-modern/src/utils/patrolSummaryPresentation.ts`-20. `frontend-modern/src/utils/textPresentation.ts`+7. `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`+8. `frontend-modern/src/pages/AIIntelligence.tsx`+9. `frontend-modern/src/stores/aiIntelligence.ts`+10. `frontend-modern/src/types/aiIntelligence.ts`+11. `frontend-modern/src/components/AI/FindingsPanel.tsx`+12. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`+13. `frontend-modern/src/components/patrol/`+14. `frontend-modern/src/utils/aiFindingPresentation.ts`+15. `frontend-modern/src/utils/approvalRiskPresentation.ts`+16. `frontend-modern/src/utils/findingAlertIdentity.ts`+17. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`+18. `frontend-modern/src/utils/patrolFormat.ts`+19. `frontend-modern/src/utils/patrolRunPresentation.ts`+20. `frontend-modern/src/utils/patrolSummaryPresentation.ts`+21. `frontend-modern/src/utils/textPresentation.ts`## Shared Boundaries@@ -48,7 +49,7 @@ Patrol-specific presentation helpers.## Extension Points-1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, keep `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` as the feature shell, keep the Patrol-owned section files under `frontend-modern/src/features/patrol/` as the heavy render owners, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together+1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, keep `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts` as the canonical investigation-context derivation owner, keep `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` as the feature shell, keep the Patrol-owned section files under `frontend-modern/src/features/patrol/` as the heavy render owners, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together2. Add or change Patrol findings, approvals, investigation, or run-history presentation through `frontend-modern/src/components/AI/FindingsPanel.tsx` and `frontend-modern/src/components/patrol/`3. Keep Patrol and chat identifier-label presentation aligned through the shared `frontend-modern/src/utils/textPresentation.ts`4. Keep Patrol and chat stream-matching / mention dedupe aligned through the shared `frontend-modern/src/utils/chatIdentifiers.ts`@@ -184,6 +185,11 @@ rendering recent changes, learned correlations, and policy posture assecondary investigation context behind an explicit disclosure, so expansionlane concepts stay available for deeper investigation without reading as theheadline Patrol product story.+That secondary investigation-context summary now also routes through the+dedicated `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`+owner, so the Patrol hook composes one canonical payload-to-summary derivation+instead of rebuilding recent-change, correlation, and governed-resource count+copy inline.The Patrol page's run-history tab label is now also tightened to `Runs`, whilethe underlying run-history panel remains canonical for snapshot filtering andtool-call inspection. That copy change is intentional: run history is supportdiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex ac8b43133a..6bf75432ee 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2537,6 +2537,7 @@"frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx","frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx","frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx",+ "frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts","frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts","frontend-modern/src/pages/AIIntelligence.tsx","frontend-modern/src/stores/aiIntelligence.ts",@@ -2571,6 +2572,7 @@"frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx","frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx","frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx",+ "frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts","frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts","frontend-modern/src/pages/AIIntelligence.tsx","frontend-modern/src/stores/aiIntelligence.ts",diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsnew file mode 100644index 0000000000..478a09aab0--- /dev/null+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -0,0 +1,82 @@+import { describe, expect, it } from 'vitest';++import { buildPatrolInvestigationContextSummary } from '../patrolInvestigationContextModel';++describe('patrolInvestigationContextModel', () => {+ it('builds the canonical investigation context summary from recent changes, correlations, and policy posture', () => {+ expect(+ buildPatrolInvestigationContextSummary({+ recentChangesCount: 1,+ correlations: {+ count: 2,+ correlations: [],+ },+ policyPosture: {+ total_resources: 4,+ sensitivity_counts: {},+ routing_counts: {},+ },+ }),+ ).toEqual({+ recentChangeCount: 1,+ correlationCount: 2,+ governedResourceCount: 4,+ hasContext: true,+ summaryText: '1 recent change · 2 correlations · 4 governed resources',+ });+ });++ it('falls back to correlation list length and suppresses empty context parts', () => {+ expect(+ buildPatrolInvestigationContextSummary({+ recentChangesCount: 0,+ correlations: {+ correlations: [+ {+ source_id: 'a',+ source_name: 'A',+ source_type: 'host',+ target_id: 'b',+ target_name: 'B',+ target_type: 'vm',+ event_pattern: 'cpu -> restart',+ occurrences: 1,+ avg_delay: 30,+ confidence: 0.7,+ last_seen: '2026-03-01T00:00:00Z',+ description: 'desc',+ },+ ],+ count: Number.NaN,+ },+ policyPosture: {+ total_resources: 0,+ sensitivity_counts: {},+ routing_counts: {},+ },+ }),+ ).toEqual({+ recentChangeCount: 0,+ correlationCount: 1,+ governedResourceCount: 0,+ hasContext: true,+ summaryText: '1 correlation',+ });+ });++ it('returns an empty context summary when no secondary investigation signals exist', () => {+ expect(+ buildPatrolInvestigationContextSummary({+ recentChangesCount: undefined,+ correlations: null,+ policyPosture: null,+ }),+ ).toEqual({+ recentChangeCount: 0,+ correlationCount: 0,+ governedResourceCount: 0,+ hasContext: false,+ summaryText: '',+ });+ });+});diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsnew file mode 100644index 0000000000..330496e461--- /dev/null+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -0,0 +1,62 @@+import type { CorrelationsResponse, IntelligencePolicyPostureSummary } from '@/types/aiIntelligence';++export interface PatrolInvestigationContextSummaryInput {+ recentChangesCount?: number | null;+ correlations?: CorrelationsResponse | null;+ policyPosture?: IntelligencePolicyPostureSummary | null;+}++export interface PatrolInvestigationContextSummary {+ recentChangeCount: number;+ correlationCount: number;+ governedResourceCount: number;+ hasContext: boolean;+ summaryText: string;+}++export function buildPatrolInvestigationContextSummary(+ input: PatrolInvestigationContextSummaryInput,+): PatrolInvestigationContextSummary {+ const recentChangeCount = normalizeNonNegativeCount(input.recentChangesCount);+ const correlationCount = normalizeCorrelationCount(input.correlations);+ const governedResourceCount = normalizeNonNegativeCount(input.policyPosture?.total_resources);++ const parts: string[] = [];+ if (recentChangeCount > 0) {+ parts.push(`${recentChangeCount} recent change${recentChangeCount === 1 ? '' : 's'}`);+ }+ if (correlationCount > 0) {+ parts.push(`${correlationCount} correlation${correlationCount === 1 ? '' : 's'}`);+ }+ if (governedResourceCount > 0) {+ parts.push(+ `${governedResourceCount} governed resource${governedResourceCount === 1 ? '' : 's'}`,+ );+ }++ return {+ recentChangeCount,+ correlationCount,+ governedResourceCount,+ hasContext: parts.length > 0,+ summaryText: parts.join(' · '),+ };+}++function normalizeCorrelationCount(correlations?: CorrelationsResponse | null): number {+ if (!correlations) return 0;+ if (typeof correlations.count === 'number' && Number.isFinite(correlations.count)) {+ return Math.max(0, Math.trunc(correlations.count));+ }+ if (Array.isArray(correlations.correlations)) {+ return correlations.correlations.length;+ }+ return 0;+}++function normalizeNonNegativeCount(value?: number | null): number {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return 0;+ }+ return Math.max(0, Math.trunc(value));+}diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex 6335eca215..24a89c5c09 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -29,6 +29,7 @@ import {startProTrial,} from '@/stores/license';import { getCanonicalScopeResourceIds } from '@/utils/patrolFormat';+import { buildPatrolInvestigationContextSummary } from './patrolInvestigationContextModel';import {getProTrialStartedMessage,getTrialAlreadyUsedMessage,@@ -448,39 +449,19 @@ export function usePatrolIntelligenceState() {const intelligenceSummary = createMemo(() => aiIntelligenceStore.intelligenceSummary);const policyPosture = createMemo(() => intelligenceSummary()?.policy_posture);- const correlationTotal = createMemo(- () =>- aiIntelligenceStore.correlations?.count ??- aiIntelligenceStore.correlations?.correlations?.length ??- 0,+ const investigationContext = createMemo(() =>+ buildPatrolInvestigationContextSummary({+ recentChangesCount:+ intelligenceSummary()?.recent_changes_count ?? intelligenceSummary()?.recent_changes?.length,+ correlations: aiIntelligenceStore.correlations,+ policyPosture: policyPosture(),+ }),);+ const correlationTotal = createMemo(() => investigationContext().correlationCount);const correlations = createMemo(() => aiIntelligenceStore.correlations?.correlations ?? []);- const recentChangeCount = createMemo(- () =>- intelligenceSummary()?.recent_changes_count ?? intelligenceSummary()?.recent_changes?.length ?? 0,- );- const hasInvestigationContext = createMemo(- () =>- recentChangeCount() > 0 ||- correlationTotal() > 0 ||- (policyPosture()?.total_resources ?? 0) > 0,- );- const investigationContextSummary = createMemo(() => {- const parts: string[] = [];- if (recentChangeCount() > 0) {- parts.push(`${recentChangeCount()} recent change${recentChangeCount() === 1 ? '' : 's'}`);- }- if (correlationTotal() > 0) {- parts.push(`${correlationTotal()} correlation${correlationTotal() === 1 ? '' : 's'}`);- }- const governedResources = policyPosture()?.total_resources ?? 0;- if (governedResources > 0) {- parts.push(- `${governedResources} governed resource${governedResources === 1 ? '' : 's'}`,- );- }- return parts.join(' · ');- });+ const recentChangeCount = createMemo(() => investigationContext().recentChangeCount);+ const hasInvestigationContext = createMemo(() => investigationContext().hasContext);+ const investigationContextSummary = createMemo(() => investigationContext().summaryText);const liveRunRecord = createMemo<PatrolRunRecord | null>(() => {if (!shouldShowLiveRun()) return null;diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 051b07efc4..c9f8033e33 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -585,6 +585,7 @@ import patrolIntelligenceBannersSource from '@/features/patrol/PatrolIntelligencimport patrolIntelligenceHeaderSource from '@/features/patrol/PatrolIntelligenceHeader.tsx?raw';import patrolIntelligenceSummarySource from '@/features/patrol/PatrolIntelligenceSummary.tsx?raw';import patrolIntelligenceSurfaceSource from '@/features/patrol/PatrolIntelligenceSurface.tsx?raw';+import patrolInvestigationContextModelSource from '@/features/patrol/patrolInvestigationContextModel.ts?raw';import patrolIntelligenceStateSource from '@/features/patrol/usePatrolIntelligenceState.ts?raw';import patrolIntelligenceWorkspaceSource from '@/features/patrol/PatrolIntelligenceWorkspace.tsx?raw';import aiQuickstartPresentationSource from '@/utils/aiQuickstartPresentation.ts?raw';@@ -4324,6 +4325,14 @@ describe('frontend resource type boundaries', () => {expect(patrolIntelligenceStateSource).toContain('getPatrolStatus');expect(patrolIntelligenceStateSource).toContain('usePatrolStream');expect(patrolIntelligenceStateSource).toContain('trackPaywallViewed');+ expect(patrolIntelligenceStateSource).toContain(+ "import { buildPatrolInvestigationContextSummary } from './patrolInvestigationContextModel';",+ );+ expect(patrolIntelligenceStateSource).not.toContain('governed resource${');+ expect(patrolInvestigationContextModelSource).toContain(+ 'export function buildPatrolInvestigationContextSummary',+ );+ expect(patrolInvestigationContextModelSource).toContain('governed resource');expect(patrolIntelligenceHeaderSource).toContain('buildPatrolScheduleOptions');expect(patrolIntelligenceHeaderSource).toContain('getAIQuickstartCreditsPresentation');expect(patrolIntelligenceSummarySource).toContain('getPatrolSummaryPresentation');diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex 6b608fcf82..6c808f80bd 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -3521,6 +3521,29 @@ class SubsystemLookupTest(unittest.TestCase):],)+ def test_lookup_paths_assigns_patrol_investigation_context_model_to_patrol_intelligence(+ self,+ ) -> None:+ result = lookup_paths(+ ["frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts"]+ )+ self.assertEqual(result["unowned_runtime_files"], [])+ self.assertEqual(+ {item["subsystem"] for item in result["impacted_subsystems"]},+ {"patrol-intelligence"},+ )+ file_entry = result["files"][0]+ self.assertEqual(file_entry["classification"], "runtime")+ self.assertEqual(+ {match["subsystem"] for match in file_entry["matches"]},+ {"patrol-intelligence"},+ )+ match = file_entry["matches"][0]+ self.assertEqual(+ match["verification_requirement"]["id"],+ "patrol-page-and-state",+ )+def test_lookup_paths_assigns_findings_panel_to_patrol_intelligence(self) -> None:result = lookup_paths(["frontend-modern/src/components/AI/FindingsPanel.tsx"])self.assertEqual(result["unowned_runtime_files"], [])