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 learned correlations in AI summary

rcourtman8adbdfbf1f0d
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index e222017033..eef29bce0d 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -160,6 +160,10 @@ AI resource and incident context now also surfaces a canonical resource-graph
section from unified-resource relationships, so relationship wording and edge
provenance stay aligned with the same shared resource model instead of being
reconstructed from the drawer or prompt helpers.
+The Patrol intelligence page now also fetches the learned correlation list
+from the canonical AI correlations endpoint, so the global AI surface and the
+resource drawer both expose the same learned edge evidence instead of only
+showing a correlation count.
The Patrol intelligence seed context now also prefers the canonical
unified-resource timeline before falling back to the patrol-local change
detector, so deterministic patrol context and resource detail context share
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 529f559317..b7315d5026 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -178,6 +178,9 @@ 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 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 39c7f55739..d1ba2b792f 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -99,6 +99,10 @@ 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 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/api/__tests__/ai.test.ts b/frontend-modern/src/api/__tests__/ai.test.ts
index 5e750dd325..3a808d28ef 100644
--- a/frontend-modern/src/api/__tests__/ai.test.ts
+++ b/frontend-modern/src/api/__tests__/ai.test.ts
@@ -115,6 +115,12 @@ describe('AIAPI', () => {
expect(apiFetchJSONMock).toHaveBeenCalledWith(
'/api/ai/intelligence?resource_id=vm%2F100%3Ffilter%3Dall',
);
+
+ apiFetchJSONMock.mockResolvedValueOnce({} as any);
+ await AIAPI.getCorrelations('storage/1?filter=all');
+ expect(apiFetchJSONMock).toHaveBeenCalledWith(
+ '/api/ai/intelligence/correlations?resource_id=storage%2F1%3Ffilter%3Dall',
+ );
});
it('treats 402 responses from optional AI paywalled collections as empty state', async () => {
diff --git a/frontend-modern/src/api/ai.ts b/frontend-modern/src/api/ai.ts
index f86912e294..a67f835416 100644
--- a/frontend-modern/src/api/ai.ts
+++ b/frontend-modern/src/api/ai.ts
@@ -19,6 +19,7 @@ import type {
} from '@/types/ai';
import type {
AnomaliesResponse,
+ CorrelationsResponse,
IntelligenceSummary,
LearningStatusResponse,
ResourceIntelligence,
@@ -149,6 +150,13 @@ export class AIAPI {
return (await this.fetchIntelligence(resourceId)) as ResourceIntelligence;
}
+ static async getCorrelations(resourceId?: string): Promise<CorrelationsResponse> {
+ const params = resourceId ? `?resource_id=${encodeURIComponent(resourceId)}` : '';
+ return apiFetchJSON(
+ `${this.baseUrl}/ai/intelligence/correlations${params}`,
+ ) as Promise<CorrelationsResponse>;
+ }
+
// Analyze a Kubernetes cluster with AI
static async analyzeKubernetesCluster(clusterId: string): Promise<AIExecuteResponse> {
return apiFetchJSON(`${this.baseUrl}/ai/kubernetes/analyze`, {
diff --git a/frontend-modern/src/pages/AIIntelligence.tsx b/frontend-modern/src/pages/AIIntelligence.tsx
index 310370b491..acd20e1671 100644
--- a/frontend-modern/src/pages/AIIntelligence.tsx
+++ b/frontend-modern/src/pages/AIIntelligence.tsx
@@ -93,6 +93,11 @@ import {
formatResourceChangeHeadline,
formatResourceChangeKind,
} from '@/utils/resourceChangePresentation';
+import {
+ formatResourceCorrelationEndpoint,
+ formatResourceCorrelationPattern,
+ formatResourceCorrelationSummary,
+} from '@/utils/resourceCorrelationPresentation';
import {
getResourceRedactionHintLabel,
getResourceRoutingScopeLabel,
@@ -104,11 +109,14 @@ 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[] = [
@@ -503,6 +511,8 @@ 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() ?? '');
@@ -569,6 +579,10 @@ export function AIIntelligence() {
const intelligenceSummary = createMemo(() => aiIntelligenceStore.intelligenceSummary);
const policyPosture = createMemo(() => intelligenceSummary()?.policy_posture);
+ const correlationHighlights = createMemo(
+ () => correlations()?.correlations?.slice(0, 3) ?? [],
+ );
+ const correlationTotal = createMemo(() => correlations()?.count ?? correlationHighlights().length);
// Live in-progress run entry for history list
const liveRunRecord = createMemo<PatrolRunRecord | null>(() => {
@@ -756,6 +770,12 @@ export function AIIntelligence() {
aiIntelligenceStore.loadPendingApprovals(),
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 {
@@ -1411,6 +1431,60 @@ export function AIIntelligence() {
</dl>
</div>
+ <Show when={correlationHighlights().length > 0}>
+ <div class="rounded-md border border-border-subtle bg-base p-4">
+ <div class="flex items-center justify-between gap-2">
+ <h3 class="text-sm font-semibold text-base-content">
+ Learned correlations
+ </h3>
+ <span class="text-xs text-muted">{correlationTotal()} total</span>
+ </div>
+
+ <div class="mt-3 space-y-2">
+ <For each={correlationHighlights()}>
+ {(correlation) => {
+ const sourceHref = buildInfrastructurePath({
+ resource: correlation.source_id,
+ });
+ const targetHref = buildInfrastructurePath({
+ resource: correlation.target_id,
+ });
+ return (
+ <div class="rounded-md bg-surface px-3 py-2">
+ <div class="flex flex-wrap items-center gap-1 text-sm">
+ <a
+ class="font-medium text-blue-700 hover:underline dark:text-blue-300"
+ href={sourceHref}
+ >
+ {formatResourceCorrelationEndpoint(correlation, 'source')}
+ </a>
+ <span class="text-muted">→</span>
+ <a
+ class="font-medium text-blue-700 hover:underline dark:text-blue-300"
+ href={targetHref}
+ >
+ {formatResourceCorrelationEndpoint(correlation, 'target')}
+ </a>
+ <span class="rounded-full border border-border-subtle bg-base px-2 py-0.5 text-[11px] font-medium text-muted">
+ {formatResourceCorrelationPattern(correlation)}
+ </span>
+ </div>
+ <p class="mt-1 text-xs text-muted">
+ {formatResourceCorrelationSummary(correlation)}
+ </p>
+ <Show when={correlation.description}>
+ <p class="mt-1 text-xs text-muted">
+ {correlation.description}
+ </p>
+ </Show>
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ </div>
+ </Show>
+
<Show when={policyPosture()}>
{(posture) => (
<div class="rounded-md border border-border-subtle bg-base p-4">
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 9d194a9e75..3f6f87f374 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { AIIntelligence } from '../AIIntelligence';
+import { AIAPI } from '@/api/ai';
const { findingsPanelState, runHistoryState, intelligenceState } = vi.hoisted(() => ({
findingsPanelState: {
@@ -90,6 +91,15 @@ vi.mock('@/api/patrol', () => ({
getPatrolRunHistory: (...args: unknown[]) => getPatrolRunHistoryMock(...args),
}));
+vi.mock('@/api/ai', () => ({
+ AIAPI: {
+ getCorrelations: vi.fn().mockResolvedValue({
+ correlations: [],
+ count: 0,
+ }),
+ },
+}));
+
vi.mock('@/utils/apiClient', () => ({
apiFetchJSON: (...args: unknown[]) => apiFetchJSONMock(...args),
}));
@@ -294,6 +304,77 @@ describe('AIIntelligence entitlement gating', () => {
getUpgradeActionUrlOrFallbackMock.mockImplementation(
(feature?: string) => `/upgrade${feature ? `?feature=${feature}` : ''}`,
);
+ vi.mocked(AIAPI.getCorrelations).mockResolvedValue({
+ correlations: [],
+ count: 0,
+ });
+ });
+
+ it('renders canonical learned correlations in the summary page', async () => {
+ hasFeatureMock.mockReturnValue(true);
+ licenseStatusMock.mockReturnValue({ subscription_state: 'active' });
+ getPatrolStatusMock.mockResolvedValue(defaultPatrolStatus({ license_required: false }));
+ intelligenceState.summary = {
+ timestamp: '2026-03-01T00:00:00Z',
+ overall_health: {
+ score: 91,
+ grade: 'A',
+ trend: 'stable',
+ factors: [],
+ prediction: 'Stable',
+ },
+ findings_count: {
+ critical: 0,
+ warning: 0,
+ watch: 0,
+ info: 0,
+ total: 0,
+ },
+ predictions_count: 0,
+ recent_changes_count: 0,
+ recent_changes: [],
+ learning: {
+ resources_with_knowledge: 0,
+ total_notes: 0,
+ resources_with_baselines: 0,
+ patterns_detected: 0,
+ correlations_learned: 1,
+ incidents_tracked: 0,
+ },
+ };
+ const { AIAPI } = await import('@/api/ai');
+ vi.mocked(AIAPI.getCorrelations).mockResolvedValue({
+ correlations: [
+ {
+ source_id: 'storage-1',
+ source_name: 'Storage 1',
+ source_type: 'storage',
+ target_id: 'vm-100',
+ target_name: 'VM 100',
+ target_type: 'vm',
+ event_pattern: 'disk_full -> restart',
+ occurrences: 2,
+ avg_delay: '1m30s',
+ confidence: 0.875,
+ last_seen: '2026-03-01T00:05:00Z',
+ description: 'Disk pressure often precedes restarts',
+ },
+ ],
+ count: 1,
+ });
+
+ render(() => <AIIntelligence />);
+
+ await waitFor(() => {
+ expect(screen.getByText('Learned correlations')).toBeInTheDocument();
+ });
+
+ expect(screen.getByText('1 total')).toBeInTheDocument();
+ expect(screen.getByText('Storage 1')).toBeInTheDocument();
+ expect(screen.getByText('VM 100')).toBeInTheDocument();
+ expect(screen.getByText('Disk Full → Restart')).toBeInTheDocument();
+ expect(screen.getByText(/2 occurrences · avg delay 2m · 88% confidence/)).toBeInTheDocument();
+ expect(screen.getByText('Disk pressure often precedes restarts')).toBeInTheDocument();
});
afterEach(() => {
diff --git a/frontend-modern/src/types/aiIntelligence.ts b/frontend-modern/src/types/aiIntelligence.ts
index 6181ac5ceb..2f0d468ad6 100644
--- a/frontend-modern/src/types/aiIntelligence.ts
+++ b/frontend-modern/src/types/aiIntelligence.ts
@@ -103,12 +103,20 @@ export interface ResourceCorrelation {
target_type: string;
event_pattern: string;
occurrences: number;
- avg_delay: number;
+ avg_delay: number | string;
confidence: number;
last_seen: string;
description: string;
}
+export interface CorrelationsResponse {
+ correlations: ResourceCorrelation[];
+ count: number;
+ message?: string;
+ license_required?: boolean;
+ upgrade_url?: string;
+}
+
export interface IntelligenceSummary {
timestamp: string;
overall_health: IntelligenceHealthScore;
diff --git a/frontend-modern/src/utils/resourceCorrelationPresentation.ts b/frontend-modern/src/utils/resourceCorrelationPresentation.ts
index 84481bea5d..6086c91bf2 100644
--- a/frontend-modern/src/utils/resourceCorrelationPresentation.ts
+++ b/frontend-modern/src/utils/resourceCorrelationPresentation.ts
@@ -1,6 +1,30 @@
import type { ResourceCorrelation } from '@/types/aiIntelligence';
import { formatDurationMs } from '@/utils/patrolFormat';
+const parseGoDurationMs = (value: string): number | null => {
+ const normalized = value.trim();
+ if (!normalized) return null;
+
+ let totalNs = 0;
+ let matched = false;
+ const pattern = /(\d+(?:\.\d+)?)(h|m|s|ms|us|µs|ns)/g;
+ for (const match of normalized.matchAll(pattern)) {
+ matched = true;
+ const amount = Number.parseFloat(match[1]);
+ if (!Number.isFinite(amount)) continue;
+ const unit = match[2];
+ if (unit === 'h') totalNs += amount * 60 * 60 * 1_000_000_000;
+ else if (unit === 'm') totalNs += amount * 60 * 1_000_000_000;
+ else if (unit === 's') totalNs += amount * 1_000_000_000;
+ else if (unit === 'ms') totalNs += amount * 1_000_000;
+ else if (unit === 'us' || unit === 'µs') totalNs += amount * 1_000;
+ else if (unit === 'ns') totalNs += amount;
+ }
+
+ if (!matched || !Number.isFinite(totalNs) || totalNs <= 0) return null;
+ return Math.round(totalNs / 1_000_000);
+};
+
const humanizeCorrelationToken = (value?: string): string => {
const normalized = (value || '').trim();
if (!normalized) return 'Correlation';
@@ -42,8 +66,11 @@ export function formatResourceCorrelationSummary(correlation: ResourceCorrelatio
parts.push(`${correlation.occurrences} occurrence${correlation.occurrences === 1 ? '' : 's'}`);
}
- const avgDelayMs = Math.round((correlation.avg_delay || 0) / 1_000_000);
- const formattedDelay = formatDurationMs(avgDelayMs);
+ const avgDelayMs =
+ typeof correlation.avg_delay === 'number'
+ ? Math.round(correlation.avg_delay / 1_000_000)
+ : parseGoDurationMs(correlation.avg_delay);
+ const formattedDelay = avgDelayMs ? formatDurationMs(avgDelayMs) : '';
if (formattedDelay) {
parts.push(`avg delay ${formattedDelay}`);
}