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.

Expose resource graph context

rcourtmane55d57e63011
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 11d3141e9a..e222017033 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -174,6 +174,10 @@ runtime uses for prompt export and context rendering.
The resource-intelligence payload used by the resource drawer also carries
the same canonical policy posture snapshot, so the detail surface can show
governed posture context without inventing a second posture contract.
+That same resource-intelligence payload also carries dependency and
+dependent graph context from unified-resource correlations, so the drawer
+can show canonical graph relationships without reconstructing them from the
+relationship timeline alone.
The shared AI resource and infrastructure prompt contexts should also surface
the same canonical recent changes section before any patrol-local fallback so
the model sees the same timeline entries that power the resource API and
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 9aa252b7e0..bb92e81aaf 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -174,6 +174,10 @@ The same API contract now also owns the dedicated frontend resource facet
client in `frontend-modern/src/api/resources.ts`, which fetches the governed
capability, relationship, and timeline surfaces from `internal/api/resources.go`
instead of teaching the drawer or list views to reconstruct them inline.
+The same AI resource-intelligence payload now also carries dependency and
+dependent graph arrays, so the drawer can render canonical graph context from
+the shared AI contract instead of inferring it from the relationship facet
+payload alone.
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 038f00685d..6ddbf4b42f 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -95,6 +95,10 @@ runtime derives from unified resources.
The resource drawer now carries the same canonical posture snapshot through
the resource-intelligence payload, so the resource-level AI card can show the
org posture context without introducing a separate posture endpoint.
+That same resource-intelligence payload also carries canonical dependency and
+dependent graph context, so the resource drawer can surface relationship
+reachability directly from the AI contract instead of inventing a second
+graph summary.
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/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 10a8198e5d..22a87ffcce 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -296,6 +296,8 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
},
{ initialValue: null as ResourceIntelligence | null },
);
+ const resourceDependencies = createMemo(() => resourceIntelligence()?.dependencies ?? []);
+ const resourceDependents = createMemo(() => resourceIntelligence()?.dependents ?? []);
const policyPosture = createMemo(() => resourceIntelligence()?.policy_posture);
const timelineFacetRequest = createMemo(() => {
const id = resourceFacetId();
@@ -952,6 +954,71 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
)}
</Show>
+ <Show when={resourceDependencies().length > 0 || resourceDependents().length > 0}>
+ <div class="rounded border border-border-subtle bg-base px-2 py-1.5">
+ <div class="text-[10px] uppercase tracking-wide text-muted">
+ Graph context
+ </div>
+ <div class="mt-0.5 text-[11px] text-base-content">
+ {resourceDependencies().length} dependencies ·{' '}
+ {resourceDependents().length} dependents
+ </div>
+ <Show when={resourceDependencies().length > 0}>
+ <div class="mt-2">
+ <div class="text-[9px] uppercase tracking-wide text-muted">
+ Depends on
+ </div>
+ <div class="mt-1 flex flex-wrap gap-1">
+ <For each={resourceDependencies().slice(0, 3)}>
+ {(dependency) => {
+ const href = buildInfrastructureResourceHref(dependency);
+ return href ? (
+ <a
+ class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px] text-blue-700 hover:underline dark:text-blue-300"
+ href={href}
+ aria-label={`Open dependency resource ${dependency} in Infrastructure`}
+ >
+ {dependency}
+ </a>
+ ) : (
+ <span class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px]">
+ {dependency}
+ </span>
+ );
+ }}
+ </For>
+ </div>
+ </div>
+ </Show>
+ <Show when={resourceDependents().length > 0}>
+ <div class="mt-2">
+ <div class="text-[9px] uppercase tracking-wide text-muted">
+ Used by
+ </div>
+ <div class="mt-1 flex flex-wrap gap-1">
+ <For each={resourceDependents().slice(0, 3)}>
+ {(dependent) => {
+ const href = buildInfrastructureResourceHref(dependent);
+ return href ? (
+ <a
+ class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px] text-blue-700 hover:underline dark:text-blue-300"
+ href={href}
+ aria-label={`Open dependent resource ${dependent} in Infrastructure`}
+ >
+ {dependent}
+ </a>
+ ) : (
+ <span class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px]">
+ {dependent}
+ </span>
+ );
+ }}
+ </For>
+ </div>
+ </div>
+ </Show>
+ </div>
+ </Show>
</div>
</div>
)}
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
index 593d743edb..d2a3b06c99 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
@@ -54,6 +54,8 @@ vi.mock('@/api/ai', () => ({
reason: 'Updated canonical config',
},
],
+ dependencies: ['storage-1'],
+ dependents: ['vm-child'],
policy_posture: {
total_resources: 2,
sensitivity_counts: {
@@ -303,7 +305,7 @@ describe('ResourceDetailDrawer runtime and identity cards', () => {
it('surfaces canonical AI intelligence for the resource overview', async () => {
const resource = baseResource({});
- const { getByText } = render(() => <ResourceDetailDrawer resource={resource} />);
+ const { getByRole, getByText } = render(() => <ResourceDetailDrawer resource={resource} />);
await waitFor(() => {
expect(getByText('AI Intelligence')).toBeInTheDocument();
@@ -316,6 +318,18 @@ describe('ResourceDetailDrawer runtime and identity cards', () => {
expect(getByText('2 governed resources')).toBeInTheDocument();
expect(getByText('Public')).toBeInTheDocument();
expect(getByText('Cloud Summary')).toBeInTheDocument();
+ expect(getByText('Graph context')).toBeInTheDocument();
+ expect(getByText('1 dependencies · 1 dependents')).toBeInTheDocument();
+ expect(
+ getByRole('link', {
+ name: 'Open dependency resource storage-1 in Infrastructure',
+ }),
+ ).toHaveAttribute('href', expect.stringContaining('/infrastructure?resource=storage-1'));
+ expect(
+ getByRole('link', {
+ name: 'Open dependent resource vm-child in Infrastructure',
+ }),
+ ).toHaveAttribute('href', expect.stringContaining('/infrastructure?resource=vm-child'));
const latestChange = getByText('Latest canonical change').parentElement;
expect(latestChange).not.toBeNull();
expect(latestChange).toHaveTextContent('Config update');
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 900ba4f6c5..9d194a9e75 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -443,6 +443,7 @@ describe('AIIntelligence entitlement gating', () => {
expect(screen.getByText('Cloud Summary')).toBeInTheDocument();
expect(screen.getByText('Local Only')).toBeInTheDocument();
expect(screen.getByText('Hostname 2')).toBeInTheDocument();
+ expect(screen.getByText('IP Address 1')).toBeInTheDocument();
});
it('treats a selected zero-finding run as an empty snapshot and uses effective scope ids', async () => {
diff --git a/frontend-modern/src/types/aiIntelligence.ts b/frontend-modern/src/types/aiIntelligence.ts
index 8ae74636cb..22046692bf 100644
--- a/frontend-modern/src/types/aiIntelligence.ts
+++ b/frontend-modern/src/types/aiIntelligence.ts
@@ -112,6 +112,8 @@ export interface ResourceIntelligence {
resource_name?: string;
resource_type?: string;
health: IntelligenceHealthScore;
+ dependencies?: string[];
+ dependents?: string[];
recent_changes?: ResourceChange[];
policy_posture?: IntelligencePolicyPostureSummary;
note_count: number;
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 5bd1cf468f..fe5b448035 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -18,6 +18,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/ai"
"github.com/rcourtman/pulse-go-rewrite/internal/ai/approval"
"github.com/rcourtman/pulse-go-rewrite/internal/ai/chat"
+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/correlation"
"github.com/rcourtman/pulse-go-rewrite/internal/ai/memory"
"github.com/rcourtman/pulse-go-rewrite/internal/alerts"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
@@ -297,12 +298,47 @@ func TestContract_ResourceIntelligenceIncludesRecentChanges(t *testing.T) {
}); err != nil {
t.Fatalf("record canonical change: %v", err)
}
+ correlationDetector := correlation.NewDetector(correlation.Config{
+ MinOccurrences: 1,
+ CorrelationWindow: 2 * time.Hour,
+ RetentionWindow: 24 * time.Hour,
+ })
+ correlationBase := observedAt.Add(-10 * time.Minute)
+ correlationDetector.RecordEvent(correlation.Event{
+ ResourceID: "storage-1",
+ ResourceName: "storage-1",
+ ResourceType: "storage",
+ EventType: correlation.EventDiskFull,
+ Timestamp: correlationBase,
+ })
+ correlationDetector.RecordEvent(correlation.Event{
+ ResourceID: "vm-100",
+ ResourceName: "vm-100",
+ ResourceType: "vm",
+ EventType: correlation.EventRestart,
+ Timestamp: correlationBase.Add(1 * time.Minute),
+ })
+ correlationDetector.RecordEvent(correlation.Event{
+ ResourceID: "storage-1",
+ ResourceName: "storage-1",
+ ResourceType: "storage",
+ EventType: correlation.EventDiskFull,
+ Timestamp: correlationBase.Add(2 * time.Minute),
+ })
+ correlationDetector.RecordEvent(correlation.Event{
+ ResourceID: "vm-100",
+ ResourceName: "vm-100",
+ ResourceType: "vm",
+ EventType: correlation.EventRestart,
+ Timestamp: correlationBase.Add(3 * time.Minute),
+ })
svc.SetUnifiedResourceProvider(&stubUnifiedResourceProvider{
resources: []unifiedresources.Resource{
{ID: "public-1", Type: unifiedresources.ResourceTypeVM, Tags: []string{"public"}},
{ID: "internal-1", Type: unifiedresources.ResourceTypeAgent, Agent: &unifiedresources.AgentData{Hostname: "agent-1"}},
},
})
+ setUnexportedField(t, svc.GetPatrolService(), "correlationDetector", correlationDetector)
setUnexportedField(t, svc, "resourceExportStore", canonicalStore)
setUnexportedField(t, svc.GetPatrolService(), "aiService", svc)
@@ -334,6 +370,13 @@ func TestContract_ResourceIntelligenceIncludesRecentChanges(t *testing.T) {
if got := int(policyPosture["total_resources"].(float64)); got != 2 {
t.Fatalf("expected total_resources=2, got %d", got)
}
+ dependencies, ok := payload["dependencies"].([]interface{})
+ if !ok {
+ t.Fatalf("expected dependencies array in response, got %T", payload["dependencies"])
+ }
+ if len(dependencies) == 0 {
+ t.Fatal("expected at least one dependency in response")
+ }
}
func TestContract_IntelligenceSummaryIncludesRecentChanges(t *testing.T) {