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.

Promote correlations into AI store

rcourtman16f8fd7e001e
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b7315d5026..77a911dfd5 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -79,6 +79,7 @@ Own canonical runtime payload shapes between backend and frontend.
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 canonical policy-posture snapshot derived from unified resources, so sensitivity, routing, and redaction counts stay owned by the same AI summary contract instead of being reconstructed as a page-local governance rollup
and the resource-intelligence payload carried by the drawer AI card, so the governed posture snapshot remains visible on the resource-detail surface without introducing a separate posture endpoint
+ 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 copy
8. Route frontend API-client parsed error propagation, API-error-status fallback handling, allowed-status handling, custom status-specific error handling, command-trigger success envelope handling, shared response parsing pipelines, missing-resource lookup handling, metadata CRUD routing, stream event consumption, response status, collection normalization, scalar payload coercion, and structured error normalization through canonical shared helpers under `frontend-modern/src/api/`
9. Add or change API token scope, assignment, and revocation presentation through `frontend-modern/src/components/Settings/APITokenManager.tsx`
10. Add or change infrastructure operations token generation, lookup, assignment, and reporting/install presentation through `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`
@@ -178,9 +179,11 @@ The same AI resource-intelligence payload now also carries dependency and
dependent graph arrays plus correlation evidence, so the drawer can render
canonical graph context from the shared AI contract instead of inferring it
from the relationship facet payload alone.
-The same AI frontend client now also fetches `/api/ai/intelligence/correlations`
-for the Patrol intelligence page, so the learned-correlation list is governed
-by the same API contract that backs the resource drawer's graph evidence.
+The same AI frontend client now also loads `/api/ai/intelligence/correlations`
+through the shared `frontend-modern/src/stores/aiIntelligence.ts` store for
+the Patrol intelligence page and the AI summary page, so the
+learned-correlation list is governed by the same API contract that backs the
+resource drawer's graph evidence instead of being fetched as page-local state.
The unified action, lifecycle, and export audit reads now also clamp oversized
`limit` requests to the governed maximum of `1000`, so the control-plane audit
surface stays bounded even when callers ask for arbitrarily large history
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index d1ba2b792f..564947d8fc 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -99,10 +99,11 @@ That same resource-intelligence payload also carries canonical dependency and
dependent graph context plus canonical correlation evidence, so the resource
drawer can surface relationship reachability and learned edge patterns
directly from the AI contract instead of inventing a second graph summary.
-The Patrol intelligence page now also fetches the learned correlation list
-from the canonical AI correlations endpoint, so the global summary and the
-resource drawer both reflect the same learned edge evidence instead of only
-showing a count.
+The Patrol intelligence page now also consumes the learned correlation list
+from the canonical AI correlations endpoint through the shared
+`frontend-modern/src/stores/aiIntelligence.ts` store, so the global summary
+and the resource drawer both reflect the same learned edge evidence instead
+of each page fetching its own copy.
The Patrol page and resource drawer now also share the canonical
`frontend-modern/src/utils/resourceChangePresentation.ts` formatter so
recent-change kind and headline wording stays aligned wherever the canonical
diff --git a/frontend-modern/src/pages/AIIntelligence.tsx b/frontend-modern/src/pages/AIIntelligence.tsx
index acd20e1671..00d0e99c26 100644
--- a/frontend-modern/src/pages/AIIntelligence.tsx
+++ b/frontend-modern/src/pages/AIIntelligence.tsx
@@ -109,14 +109,12 @@ import {
getTrialStartErrorMessage,
getTrialTryAgainLaterMessage,
} from '@/utils/upgradePresentation';
-import { AIAPI } from '@/api/ai';
import { buildInfrastructurePath } from '@/routing/resourceLinks';
import type {
ResourceRedactionHint,
ResourceRoutingScope,
ResourceSensitivity,
} from '@/types/resource';
-import type { CorrelationsResponse } from '@/types/aiIntelligence';
type PatrolTab = 'findings' | 'history';
const policySensitivityOrder: ResourceSensitivity[] = [
@@ -511,8 +509,6 @@ export function AIIntelligence() {
},
);
- const [correlations, setCorrelations] = createSignal<CorrelationsResponse | null>(null);
-
const licenseRequired = createMemo(() => patrolStatus()?.license_required ?? false);
const upgradeUrl = createMemo(() => getUpgradeActionUrlOrFallback('ai_autofix'));
const blockedReason = createMemo(() => patrolStatus()?.blocked_reason?.trim() ?? '');
@@ -580,9 +576,11 @@ export function AIIntelligence() {
const intelligenceSummary = createMemo(() => aiIntelligenceStore.intelligenceSummary);
const policyPosture = createMemo(() => intelligenceSummary()?.policy_posture);
const correlationHighlights = createMemo(
- () => correlations()?.correlations?.slice(0, 3) ?? [],
+ () => aiIntelligenceStore.correlations?.correlations?.slice(0, 3) ?? [],
+ );
+ const correlationTotal = createMemo(
+ () => aiIntelligenceStore.correlations?.count ?? correlationHighlights().length,
);
- const correlationTotal = createMemo(() => correlations()?.count ?? correlationHighlights().length);
// Live in-progress run entry for history list
const liveRunRecord = createMemo<PatrolRunRecord | null>(() => {
@@ -768,14 +766,9 @@ export function AIIntelligence() {
aiIntelligenceStore.loadFindings(),
aiIntelligenceStore.loadCircuitBreakerStatus(),
aiIntelligenceStore.loadPendingApprovals(),
+ aiIntelligenceStore.loadCorrelations(),
refetchPatrolStatus(),
]);
- try {
- setCorrelations(await AIAPI.getCorrelations());
- } catch (err) {
- console.error('Failed to load correlations:', err);
- setCorrelations(null);
- }
// Trigger refresh of patrol status bar
setActivityRefreshTrigger((prev) => prev + 1);
} finally {
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 3f6f87f374..c36fa074c8 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { AIIntelligence } from '../AIIntelligence';
-import { AIAPI } from '@/api/ai';
const { findingsPanelState, runHistoryState, intelligenceState } = vi.hoisted(() => ({
findingsPanelState: {
@@ -64,9 +64,32 @@ const { findingsPanelState, runHistoryState, intelligenceState } = vi.hoisted(()
};
}
| null,
+ correlations: null as
+ | {
+ correlations: Array<{
+ source_id: string;
+ source_name: string;
+ source_type: string;
+ target_id: string;
+ target_name: string;
+ target_type: string;
+ event_pattern: string;
+ occurrences: number;
+ avg_delay: number | string;
+ confidence: number;
+ last_seen: string;
+ description?: string;
+ }>;
+ count: number;
+ }
+ | null,
},
}));
+const getCorrelationsMock = vi.fn();
+const [correlationsState, setCorrelationsState] = createSignal<
+ (typeof intelligenceState)['correlations']
+>(null);
const getPatrolStatusMock = vi.fn();
const getPatrolAutonomySettingsMock = vi.fn();
const updatePatrolAutonomySettingsMock = vi.fn();
@@ -93,10 +116,7 @@ vi.mock('@/api/patrol', () => ({
vi.mock('@/api/ai', () => ({
AIAPI: {
- getCorrelations: vi.fn().mockResolvedValue({
- correlations: [],
- count: 0,
- }),
+ getCorrelations: (...args: unknown[]) => getCorrelationsMock(...args),
},
}));
@@ -131,9 +151,18 @@ vi.mock('@/stores/aiIntelligence', () => ({
loadIntelligenceSummary: vi.fn().mockResolvedValue(undefined),
loadCircuitBreakerStatus: vi.fn().mockResolvedValue(undefined),
loadPendingApprovals: vi.fn().mockResolvedValue(undefined),
+ loadCorrelations: vi.fn().mockImplementation(async () => {
+ const response = await getCorrelationsMock();
+ intelligenceState.correlations = response;
+ setCorrelationsState(response);
+ return response;
+ }),
get intelligenceSummary() {
return intelligenceState.summary;
},
+ get correlations() {
+ return correlationsState();
+ },
},
}));
@@ -269,6 +298,9 @@ describe('AIIntelligence entitlement gating', () => {
findingsPanelState.latestProps = null;
runHistoryState.selection = null;
intelligenceState.summary = null;
+ intelligenceState.correlations = null;
+ setCorrelationsState(null);
+ getCorrelationsMock.mockReset();
getPatrolStatusMock.mockResolvedValue(defaultPatrolStatus());
getPatrolAutonomySettingsMock.mockResolvedValue({
@@ -304,7 +336,7 @@ describe('AIIntelligence entitlement gating', () => {
getUpgradeActionUrlOrFallbackMock.mockImplementation(
(feature?: string) => `/upgrade${feature ? `?feature=${feature}` : ''}`,
);
- vi.mocked(AIAPI.getCorrelations).mockResolvedValue({
+ getCorrelationsMock.mockResolvedValue({
correlations: [],
count: 0,
});
@@ -342,8 +374,7 @@ describe('AIIntelligence entitlement gating', () => {
incidents_tracked: 0,
},
};
- const { AIAPI } = await import('@/api/ai');
- vi.mocked(AIAPI.getCorrelations).mockResolvedValue({
+ getCorrelationsMock.mockResolvedValue({
correlations: [
{
source_id: 'storage-1',
diff --git a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
index 0c4937b793..e7b6723dc3 100644
--- a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
+++ b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
@@ -5,6 +5,7 @@ vi.mock('@/api/ai', () => ({
getUnifiedFindings: vi.fn(),
getPendingApprovals: vi.fn(),
getIntelligenceSummary: vi.fn(),
+ getCorrelations: vi.fn(),
},
}));
@@ -136,6 +137,35 @@ describe('aiIntelligenceStore', () => {
expect(aiIntelligenceStore.intelligenceSummary?.policy_posture?.routing_counts?.['local-only']).toBe(1);
});
+ it('loads the canonical correlations response', async () => {
+ vi.mocked(AIAPI.getCorrelations).mockResolvedValueOnce({
+ correlations: [
+ {
+ source_id: 'storage-1',
+ source_name: 'Storage 1',
+ source_type: 'storage',
+ target_id: 'vm-42',
+ target_name: 'VM 42',
+ target_type: 'vm',
+ event_pattern: 'disk_full -> restart',
+ occurrences: 2,
+ avg_delay: '1m30s',
+ confidence: 0.875,
+ last_seen: '2026-03-01T00:00:00Z',
+ description: 'Disk pressure often precedes restarts',
+ },
+ ],
+ count: 1,
+ });
+
+ await aiIntelligenceStore.loadCorrelations();
+
+ expect(aiIntelligenceStore.correlations).toMatchObject({
+ count: 1,
+ });
+ expect(aiIntelligenceStore.correlations?.correlations).toHaveLength(1);
+ });
+
it('treats queued fixes without a live approval as findings needing attention', async () => {
vi.mocked(AIAPI.getUnifiedFindings).mockResolvedValueOnce({
findings: [
diff --git a/frontend-modern/src/stores/aiIntelligence.ts b/frontend-modern/src/stores/aiIntelligence.ts
index c60e569194..b06a255fd1 100644
--- a/frontend-modern/src/stores/aiIntelligence.ts
+++ b/frontend-modern/src/stores/aiIntelligence.ts
@@ -25,7 +25,10 @@ import {
} from '@/utils/aiFindingPresentation';
import { getApprovalExpiryTime, isLivePendingApproval } from '@/utils/approvalState';
import { logger } from '@/utils/logger';
-import type { IntelligenceSummary } from '@/types/aiIntelligence';
+import type {
+ CorrelationsResponse,
+ IntelligenceSummary,
+} from '@/types/aiIntelligence';
// ============================================
// Enum validation helpers
@@ -226,6 +229,12 @@ const [intelligenceSummary, setIntelligenceSummary] = createSignal<IntelligenceS
null,
);
+// ============================================
+// Learned Correlations
+// ============================================
+
+const [correlations, setCorrelations] = createSignal<CorrelationsResponse | null>(null);
+
// ============================================
// Store API
// ============================================
@@ -489,12 +498,30 @@ export const aiIntelligenceStore = {
},
circuitBreakerStatusSignal: circuitBreakerStatus,
+ // Learned Correlations
+ get correlations() {
+ return correlations();
+ },
+ correlationsSignal: correlations,
+
// Canonical Intelligence Summary
get intelligenceSummary() {
return intelligenceSummary();
},
intelligenceSummarySignal: intelligenceSummary,
+ async loadCorrelations(resourceId?: string) {
+ try {
+ const response = await AIAPI.getCorrelations(resourceId);
+ setCorrelations(response);
+ return response;
+ } catch (e) {
+ logger.error('Failed to load correlations:', e);
+ setCorrelations(null);
+ return null;
+ }
+ },
+
async loadIntelligenceSummary() {
try {
const summary = await AIAPI.getIntelligenceSummary();
@@ -524,6 +551,7 @@ export const aiIntelligenceStore = {
this.loadRemediationPlans(),
this.loadCircuitBreakerStatus(),
this.loadPendingApprovals(),
+ this.loadCorrelations(),
]);
},