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.

Move correlation ordering into graph summary

rcourtman341df19401c2
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8d6500faf4..716d4e5602 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -166,7 +166,9 @@ resource drawer both expose the same learned edge evidence instead of only
showing a correlation count. The same page and drawer now render that list
through the shared `frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx`
card, so the learned-correlation layout and edge wording stay aligned across
-both surfaces.
+both surfaces. That shared card also owns the correlation ordering and
+truncation rule, so callers pass raw learned edges instead of page-specific
+top-N slices.
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 4e41adb654..89ef8b6d9f 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -83,6 +83,7 @@ Own canonical runtime payload shapes between backend and frontend.
and 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 inline
and the shared `frontend-modern/src/components/Infrastructure/ResourcePolicySummary.tsx` card, so the AI summary page and resource drawer render the same governed policy-posture counts instead of carrying duplicate posture UI loops
and the shared `frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx` card, so learned correlations and graph context stay rendered through one governed frontend card instead of separate page-local list loops
+ and the same shared graph card's ordering and truncation rule, so callers pass raw correlations instead of encoding their own top-N sort behavior
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`
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 734c7484bb..12a6248826 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -106,7 +106,9 @@ 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/ResourceGraphSummary.tsx`
card, so the correlation layout stays governed by one component instead of
-two page-local card implementations.
+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.
That same store now owns the Patrol dashboard load bundle as well, so the
page refresh path stays aligned on a single orchestrated AI bundle instead of
repeating the individual summary, findings, approval, and correlation fetches
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 4f6a39dcc2..10c9ad0e73 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -109,7 +109,9 @@ reasoning from raw events. The Patrol intelligence page now also renders that
correlation evidence through the shared
`frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx`
card, so the same learned-edge list stays governed by one frontend surface
-instead of separate page-local implementations.
+instead of separate page-local implementations. That shared card also owns
+the correlation ordering and truncation rule, so callers pass raw correlation
+lists instead of encoding their own sort or top-N behavior.
The change emitter now also classifies canonical restart changes for Docker
and Kubernetes resources when restart counters increase or uptime resets, so
the timeline can distinguish restarts from generic state transitions instead
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 57b91a5c4b..c926835da1 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -399,15 +399,6 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
const historyFacetCounts = createMemo(
() => historyFacetBundle()?.counts ?? resourceFacetCounts(),
);
- const sortedResourceCorrelations = createMemo(() =>
- [...resourceCorrelations()].sort((left, right) => {
- const confidenceDiff = (right.confidence || 0) - (left.confidence || 0);
- if (confidenceDiff !== 0) return confidenceDiff;
- const leftTime = Date.parse(left.last_seen || '');
- const rightTime = Date.parse(right.last_seen || '');
- return (Number.isFinite(rightTime) ? rightTime : 0) - (Number.isFinite(leftTime) ? leftTime : 0);
- }),
- );
const hasTimelineFilters = createMemo(
() =>
Boolean(
@@ -891,7 +882,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
title="Graph context"
dependencies={resourceDependencies()}
dependents={resourceDependents()}
- correlations={sortedResourceCorrelations()}
+ correlations={resourceCorrelations()}
buildResourceHref={buildInfrastructureResourceHref}
showLastSeen
/>
diff --git a/frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx
index 57e0900001..4387ff659a 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceGraphSummary.tsx
@@ -1,4 +1,4 @@
-import { For, Show, type Component } from 'solid-js';
+import { For, Show, createMemo, type Component } from 'solid-js';
import type { ResourceCorrelation } from '@/types/aiIntelligence';
import { formatRelativeTime } from '@/utils/format';
import {
@@ -26,9 +26,18 @@ const formatPluralCount = (count: number, singular: string, plural: string): str
const formatSummaryParts = (parts: Array<string | null | undefined>): string =>
parts.filter((part): part is string => Boolean(part && part.trim())).join(' · ');
+const sortResourceCorrelations = (correlations: ResourceCorrelation[]): ResourceCorrelation[] =>
+ [...correlations].sort((left, right) => {
+ const confidenceDiff = (right.confidence || 0) - (left.confidence || 0);
+ if (confidenceDiff !== 0) return confidenceDiff;
+ const leftTime = Date.parse(left.last_seen || '');
+ const rightTime = Date.parse(right.last_seen || '');
+ return (Number.isFinite(rightTime) ? rightTime : 0) - (Number.isFinite(leftTime) ? leftTime : 0);
+ });
+
export const ResourceGraphSummary: Component<ResourceGraphSummaryProps> = (props) => {
const className = () => props.class?.trim() ?? '';
- const correlations = () => props.correlations ?? [];
+ const correlations = createMemo(() => sortResourceCorrelations(props.correlations ?? []));
const dependencies = () => props.dependencies ?? [];
const dependents = () => props.dependents ?? [];
const maxCorrelations = () => props.maxCorrelations ?? 3;
diff --git a/frontend-modern/src/pages/AIIntelligence.tsx b/frontend-modern/src/pages/AIIntelligence.tsx
index 7dc31f300d..4526275572 100644
--- a/frontend-modern/src/pages/AIIntelligence.tsx
+++ b/frontend-modern/src/pages/AIIntelligence.tsx
@@ -545,11 +545,11 @@ export function AIIntelligence() {
const intelligenceSummary = createMemo(() => aiIntelligenceStore.intelligenceSummary);
const policyPosture = createMemo(() => intelligenceSummary()?.policy_posture);
- const correlationHighlights = createMemo(
- () => aiIntelligenceStore.correlations?.correlations?.slice(0, 3) ?? [],
- );
const correlationTotal = createMemo(
- () => aiIntelligenceStore.correlations?.count ?? correlationHighlights().length,
+ () =>
+ aiIntelligenceStore.correlations?.count ??
+ aiIntelligenceStore.correlations?.correlations?.length ??
+ 0,
);
// Live in-progress run entry for history list
@@ -1387,10 +1387,10 @@ export function AIIntelligence() {
</dl>
</div>
- <Show when={correlationHighlights().length > 0}>
+ <Show when={(aiIntelligenceStore.correlations?.correlations?.length ?? 0) > 0}>
<ResourceGraphSummary
title="Learned correlations"
- correlations={correlationHighlights()}
+ correlations={aiIntelligenceStore.correlations?.correlations ?? []}
summaryText={`${correlationTotal()} total`}
buildResourceHref={(resourceId) =>
buildInfrastructurePath({ resource: resourceId })
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index eb1b7930a4..9c180eab79 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -390,21 +390,35 @@ describe('AIIntelligence entitlement gating', () => {
getCorrelationsMock.mockResolvedValue({
correlations: [
{
- source_id: 'storage-1',
- source_name: 'Storage 1',
+ source_id: 'storage-2',
+ source_name: 'Storage 2',
source_type: 'storage',
- target_id: 'vm-100',
- target_name: 'VM 100',
+ target_id: 'vm-200',
+ target_name: 'VM 200',
target_type: 'vm',
event_pattern: 'disk_full -> restart',
occurrences: 2,
avg_delay: '1m30s',
- confidence: 0.875,
+ confidence: 0.95,
last_seen: '2026-03-01T00:05:00Z',
description: 'Disk pressure often precedes restarts',
},
+ {
+ source_id: 'storage-1',
+ source_name: 'Storage 1',
+ source_type: 'storage',
+ target_id: 'vm-100',
+ target_name: 'VM 100',
+ target_type: 'vm',
+ event_pattern: 'cpu_high -> restart',
+ occurrences: 1,
+ avg_delay: '3m',
+ confidence: 0.5,
+ last_seen: '2026-03-01T00:03:00Z',
+ description: 'Lower-confidence backup pattern',
+ },
],
- count: 1,
+ count: 2,
});
render(() => <AIIntelligence />);
@@ -413,21 +427,28 @@ describe('AIIntelligence entitlement gating', () => {
expect(screen.getByText('Learned correlations')).toBeInTheDocument();
});
- expect(screen.getByText('1 total')).toBeInTheDocument();
- expect(
- screen.getByRole('link', {
- name: 'Open source resource Storage 1 in Infrastructure',
- }),
- ).toHaveAttribute('href', '/infrastructure?resource=storage-1');
+ expect(screen.getByText('2 total')).toBeInTheDocument();
+ const storage2Link = screen.getByRole('link', {
+ name: 'Open source resource Storage 2 in Infrastructure',
+ });
+ const storage1Link = screen.getByRole('link', {
+ name: 'Open source resource Storage 1 in Infrastructure',
+ });
+ expect(storage2Link).toHaveAttribute('href', '/infrastructure?resource=storage-2');
+ expect(screen.getByRole('link', { name: 'Open target resource VM 200 in Infrastructure' }))
+ .toHaveAttribute('href', '/infrastructure?resource=vm-200');
+ expect(screen.getByRole('link', { name: 'Open target resource VM 100 in Infrastructure' }))
+ .toHaveAttribute('href', '/infrastructure?resource=vm-100');
expect(
- screen.getByRole('link', {
- name: 'Open target resource VM 100 in Infrastructure',
- }),
- ).toHaveAttribute('href', '/infrastructure?resource=vm-100');
+ storage2Link.compareDocumentPosition(storage1Link) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
expect(screen.getByText('Storage 1')).toBeInTheDocument();
expect(screen.getByText('VM 100')).toBeInTheDocument();
+ expect(screen.getByText('Cpu High → Restart')).toBeInTheDocument();
expect(screen.getByText('Disk Full → Restart')).toBeInTheDocument();
- expect(screen.getByText(/2 occurrences · avg delay 2m · 88% confidence/)).toBeInTheDocument();
+ expect(screen.getByText(/2 occurrences .* 95% confidence/)).toBeInTheDocument();
+ expect(screen.getByText(/1 occurrence .* 50% confidence/)).toBeInTheDocument();
expect(screen.getByText('Disk pressure often precedes restarts')).toBeInTheDocument();
});