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
Propagate unified facet counts
rcourtman181dba0548f1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 4ad074faea..7a50c4b7fc 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -122,6 +122,10 @@ That same shared `internal/api/` lifecycle boundary also assumes tenant-scopedresource helpers stay on canonical unified-resource seeds: adjacent fleet andinstall surfaces may not revive raw tenant `StateSnapshot` fallback throughshared API resource wiring once `UnifiedResourceSnapshotForTenant` exists.+That same boundary now also assumes canonical resource payloads preserve+shared facet totals through `facetCounts`, so the resource list and detail+surfaces can keep row summaries aligned without re-inferring totals from+consumer-local slices.That same shared `internal/api/` boundary now also assumes tenant AI servicesstay on canonical Patrol runtime wiring: adjacent fleet and install surfacesmust not revive tenant snapshot-provider bridges through shared AI handlerdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex cc0f50dca0..09b0c7c1fd 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -115,8 +115,9 @@ The API layer already uses contract tests in many places, but every major livecontract should continue moving toward canonical-only runtime shapes.The unified resource API payload now carries the richer domain facets directlythrough the owned backend response: resource objects can expose canonical-`capabilities`, `relationships`, and `recentChanges` in addition to policy and-identity metadata, so the backend payload contract stays aligned with the+`capabilities`, `relationships`, `recentChanges`, and derived `facetCounts`+in addition to policy and identity metadata, so the backend payload contract+stays aligned with thetimeline and control-plane model instead of flattening those fields away.The same resource contract now also exposes dedicated facet endpoints for`/api/resources/{id}/capabilities`, `/api/resources/{id}/relationships`, anddiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex fa32e1bf38..b3e266f454 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -88,7 +88,10 @@ the unified table as well, so PBS and PMG entries must keep the same boundedpresentation and verification surface as the primary fleet rows. The shared`ResourceFacetSummary` component now owns that chip rendering path, so anyfuture summary changes must preserve the same bounded row budget instead of-forking separate table-only presentation logic.+forking separate table-only presentation logic. Row summaries now also prefer+canonical `facetCounts` on each resource when they are available, so the hot+path can stay within the same budget while still reading totals from the+shared resource contract.Governance metadata such as sensitivity and routing scope may be visible inthe table, but it must remain on the same bounded row-windowing and mounted-rowbudget proved by `UnifiedResourceTable.performance.contract.test.tsx` ratherdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex e0d8b13692..7c37189ed7 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -121,10 +121,10 @@ The same shared API runtime now also exposes dedicatedto treat those as adjacent governed API ownership rather than storage/recoverytimeline ownership.The shared unified-resource consumer hook now also preserves `capabilities`,-`relationships`, `recentChanges`, `policy`, and `aiSafeSummary` fields when-storage and recovery surfaces read unified resources, so those pages see the-same control-plane facets as the dedicated resource drawer instead of-flattening them away locally.+`relationships`, `recentChanges`, `facetCounts`, `policy`, and `aiSafeSummary`+fields when storage and recovery surfaces read unified resources, so those+pages see the same control-plane facets as the dedicated resource drawer+instead of flattening them away locally.The frontend storage and recovery surfaces are also first-class runtime entrypoints. `frontend-modern/src/components/Storage/` plusdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 7d12b57495..56f685d2d7 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -176,6 +176,9 @@ performance proof route. The shared resource table now also surfaces compactfacet summary chips for capabilities, relationships, and timeline events, sofacet presentation changes must continue to flow through the same governedresource-row surface rather than inventing a separate ad hoc summary path.+Those row summaries now prefer canonical `facetCounts` on the resource object+when available, so the backend list/read shapes remain the source of truth+instead of forcing the frontend to infer totals only from loaded slices.Those chips now appear on both the primary fleet rows and the PBS/PMG servicerows, so the unified consumer surface must remain consistent across the fulltable instead of diverging by resource class. The same facet summary now alsodiff --git a/frontend-modern/src/api/__tests__/resources.test.ts b/frontend-modern/src/api/__tests__/resources.test.tsindex 4c006e1241..e828e0eace 100644--- a/frontend-modern/src/api/__tests__/resources.test.ts+++ b/frontend-modern/src/api/__tests__/resources.test.ts@@ -65,6 +65,11 @@ describe('ResourceAPI', () => {recentChanges: 3,},});+ expect(result.counts).toStrictEqual({+ capabilities: 1,+ relationships: 1,+ recentChanges: 3,+ });});it('omits invalid timeline query values instead of emitting broken URLs', async () => {diff --git a/frontend-modern/src/api/resources.ts b/frontend-modern/src/api/resources.tsindex 5338b0db92..15ef5c492a 100644--- a/frontend-modern/src/api/resources.ts+++ b/frontend-modern/src/api/resources.ts@@ -2,6 +2,7 @@ import { apiFetchJSON } from '@/utils/apiClient';import type {ResourceCapability,ResourceChange,+ ResourceFacetCounts,ResourceRelationship,} from '@/types/resource';@@ -28,12 +29,6 @@ export interface ResourceTimelineResponse {count: number;}-export interface ResourceFacetCounts {- capabilities: number;- relationships: number;- recentChanges: number;-}-export interface ResourceFacetBundle {capabilities: ResourceCapability[];relationships: ResourceRelationship[];diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsxindex 495f16e8c1..baa61d730f 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx@@ -292,7 +292,9 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {const resourceTimeline = createMemo(() => resourceFacets()?.recentChanges ?? props.resource.recentChanges ?? [],);- const resourceFacetCounts = createMemo(() => resourceFacets()?.counts ?? null);+ const resourceFacetCounts = createMemo(+ () => resourceFacets()?.counts ?? props.resource.facetCounts ?? null,+ );const resourceCapabilityCount = createMemo(() => resourceFacetCounts()?.capabilities ?? resourceCapabilities().length,);diff --git a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsxindex d73467e106..14bf4687b2 100644--- a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx@@ -2,6 +2,7 @@ import { For, Show, createMemo, type Component } from 'solid-js';import type {ResourceCapability,ResourceChange,+ ResourceFacetCounts,ResourceRelationship,} from '@/types/resource';@@ -11,17 +12,11 @@ type FacetBadge = {className: string;};-export interface ResourceFacetSummaryCounts {- capabilities?: number | null;- relationships?: number | null;- recentChanges?: number | null;-}-export interface ResourceFacetSummaryProps {capabilities?: readonly ResourceCapability[] | null;relationships?: readonly ResourceRelationship[] | null;recentChanges?: readonly ResourceChange[] | null;- counts?: ResourceFacetSummaryCounts | null;+ counts?: ResourceFacetCounts | null;class?: string;testId?: string;}@@ -36,7 +31,7 @@ const buildFacetBadges = (capabilities?: readonly ResourceCapability[] | null,relationships?: readonly ResourceRelationship[] | null,recentChanges?: readonly ResourceChange[] | null,- counts?: ResourceFacetSummaryCounts | null,+ counts?: ResourceFacetCounts | null,): FacetBadge[] => {const badges: FacetBadge[] = [];const capabilityCount = counts?.capabilities ?? capabilities?.length ?? 0;diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsxindex 6b533c701c..050429b124 100644--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx@@ -690,6 +690,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (propscapabilities={resource.capabilities}relationships={resource.relationships}recentChanges={resource.recentChanges}+ counts={resource.facetCounts}class="mt-0.5"/></div>@@ -1142,6 +1143,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (propscapabilities={resource.capabilities}relationships={resource.relationships}recentChanges={resource.recentChanges}+ counts={resource.facetCounts}class="mt-0.5"/></div>@@ -1449,6 +1451,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (propscapabilities={resource.capabilities}relationships={resource.relationships}recentChanges={resource.recentChanges}+ counts={resource.facetCounts}class="mt-0.5"/></div>diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsxindex 6ac096a190..4b73b14e2b 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx@@ -153,16 +153,7 @@ describe('UnifiedResourceTable performance contract', () => {relationships: 1,recentChanges: 3,}}- recentChanges={[- {- id: 'change-1',- observedAt: '2026-03-18T12:06:00Z',- resourceId: 'vm:42',- kind: 'restart',- sourceType: 'platform_event',- confidence: 'high',- },- ]}+ recentChanges={[]}/>));@@ -195,16 +186,12 @@ describe('UnifiedResourceTable performance contract', () => {lastSeenAt: new Date().toISOString(),},],- recentChanges: [- {- id: 'change-0',- observedAt: new Date().toISOString(),- resourceId: 'resource-0',- kind: 'state_transition',- sourceType: 'pulse_diff',- confidence: 'high',- },- ],+ facetCounts: {+ capabilities: 1,+ relationships: 1,+ recentChanges: 3,+ },+ recentChanges: [],}: {},);@@ -223,7 +210,7 @@ describe('UnifiedResourceTable performance contract', () => {await waitFor(() => {expect(getByText('Capabilities 1')).toBeInTheDocument();expect(getByText('Relationships 1')).toBeInTheDocument();- expect(getByText('Timeline 1')).toBeInTheDocument();+ expect(getByText('Timeline 3')).toBeInTheDocument();});await waitFor(() => {expect(getBodyRowCount(container)).toBe(PROFILES.S);diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.tsindex e2855ad802..f1bbbff64b 100644--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts@@ -755,6 +755,11 @@ describe('useUnifiedResources', () => {confidence: 'high',},],+ facetCounts: {+ capabilities: 1,+ relationships: 1,+ recentChanges: 1,+ },},],}),@@ -804,6 +809,11 @@ describe('useUnifiedResources', () => {confidence: 'high',},]);+ expect(result!.resources()[0]?.facetCounts).toEqual({+ capabilities: 1,+ relationships: 1,+ recentChanges: 1,+ });dispose();});diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.tsindex aa416bcec8..b7ec36cc97 100644--- a/frontend-modern/src/hooks/useUnifiedResources.ts+++ b/frontend-modern/src/hooks/useUnifiedResources.ts@@ -8,6 +8,7 @@ import type {Resource,ResourceCapability,ResourceChange,+ ResourceFacetCounts,ResourceDiscoveryTarget,ResourceMetricsTarget,ResourcePBSMeta,@@ -308,6 +309,7 @@ type APIResource = {capabilities?: ResourceCapability[];relationships?: ResourceRelationship[];recentChanges?: ResourceChange[];+ facetCounts?: ResourceFacetCounts;physicalDisk?: {devPath?: string;model?: string;@@ -714,6 +716,7 @@ const toResource = (v2: APIResource): Resource => {capabilities: v2.capabilities,relationships: v2.relationships,recentChanges: v2.recentChanges,+ facetCounts: v2.facetCounts,platformData: {sources,sourceStatus: v2.sourceStatus,diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.tsindex 5d0d4bf2ac..73e404db74 100644--- a/frontend-modern/src/types/resource.ts+++ b/frontend-modern/src/types/resource.ts@@ -192,6 +192,12 @@ export interface ResourceCapability {params?: ResourceCapabilityParam[];}+export interface ResourceFacetCounts {+ capabilities: number;+ relationships: number;+ recentChanges: number;+}+export interface ResourceRelationship {sourceId: string;targetId: string;@@ -486,6 +492,7 @@ export interface Resource {capabilities?: ResourceCapability[];relationships?: ResourceRelationship[];recentChanges?: ResourceChange[];+ facetCounts?: ResourceFacetCounts;// Common source facets (optional; not all backends/state payloads include these).// Prefer these over casting `platformData` when available.diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex b099a517a7..7f327781f1 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -3479,6 +3479,11 @@ func TestContract_ResourceListCarriesTimelineAndCapabilityContracts(t *testing.T},},},+ FacetCounts: unifiedresources.ResourceFacetCounts{+ Capabilities: 1,+ Relationships: 1,+ RecentChanges: 1,+ },},},Meta: ResourcesMeta{@@ -3557,7 +3562,12 @@ func TestContract_ResourceListCarriesTimelineAndCapabilityContracts(t *testing.T"reason":"vm started","metadata":{"source":"snapshot"}}- ]+ ],+ "facetCounts":{+ "capabilities":1,+ "relationships":1,+ "recentChanges":1+ }}],"meta":{"page":1,"limit":50,"total":1,"totalPages":1},diff --git a/internal/api/resources.go b/internal/api/resources.goindex 01e58ffcec..17795c5d70 100644--- a/internal/api/resources.go+++ b/internal/api/resources.go@@ -277,11 +277,7 @@ func (h *ResourceHandlers) HandleGetResource(w http.ResponseWriter, r *http.Requjson.NewEncoder(w).Encode(resourceCopy)}-type resourceFacetCountsResponse struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`-}+type resourceFacetCountsResponse = unified.ResourceFacetCountstype resourceFacetBundleResponse struct {ResourceID string `json:"resourceId"`@@ -412,8 +408,8 @@ func (h *ResourceHandlers) HandleGetResourceFacets(w http.ResponseWriter, r *httRelationships: relationships,RecentChanges: recentChanges,Counts: resourceFacetCountsResponse{- Capabilities: len(capabilities),- Relationships: len(relationships),+ Capabilities: resource.FacetCounts.Capabilities,+ Relationships: resource.FacetCounts.Relationships,RecentChanges: changeCount,},})@@ -524,7 +520,7 @@ func (h *ResourceHandlers) HandleGetResourceCapabilities(w http.ResponseWriter,json.NewEncoder(w).Encode(map[string]any{"resourceId": resourceID,"capabilities": capabilities,- "count": len(capabilities),+ "count": resource.FacetCounts.Capabilities,})}@@ -566,7 +562,7 @@ func (h *ResourceHandlers) HandleGetResourceRelationships(w http.ResponseWriter,json.NewEncoder(w).Encode(map[string]any{"resourceId": resourceID,"relationships": relationships,- "count": len(relationships),+ "count": resource.FacetCounts.Relationships,})}diff --git a/internal/api/resources_test.go b/internal/api/resources_test.goindex c3d6e7dab9..18316235e5 100644--- a/internal/api/resources_test.go+++ b/internal/api/resources_test.go@@ -179,6 +179,39 @@ func TestResourceListUsesUnifiedSeedProvider(t *testing.T) {LastSeen: now,UpdatedAt: now,Sources: []unified.DataSource{unified.SourceAgent},+ Capabilities: []unified.ResourceCapability{+ {+ Name: "restart",+ Type: unified.CapabilityTypeCommon,+ Description: "Restart the resource",+ MinimumApprovalLevel: unified.ApprovalAdmin,+ },+ },+ Relationships: []unified.ResourceRelationship{+ {+ SourceID: "agent-seeded",+ TargetID: "node-1",+ Type: unified.RelRunsOn,+ Confidence: 1,+ Active: true,+ Discoverer: "proxmox_adapter",+ ObservedAt: now,+ LastSeenAt: now,+ },+ },+ RecentChanges: []unified.ResourceChange{+ {+ ID: "chg-1",+ ResourceID: "agent-seeded",+ ObservedAt: now,+ Kind: unified.ChangeStateTransition,+ From: "offline",+ To: "online",+ SourceType: unified.SourcePlatformEvent,+ SourceAdapter: unified.AdapterProxmox,+ Confidence: unified.ConfidenceHigh,+ },+ },Identity: unified.ResourceIdentity{Hostnames: []string{"seeded-agent"},},@@ -213,6 +246,9 @@ func TestResourceListUsesUnifiedSeedProvider(t *testing.T) {if strings.TrimSpace(resp.Data[0].AISafeSummary) == "" {t.Fatal("expected aiSafeSummary on seeded resource")}+ if got := resp.Data[0].FacetCounts; got.Capabilities != 1 || got.Relationships != 1 || got.RecentChanges != 1 {+ t.Fatalf("facetCounts = %+v, want 1/1/1", got)+ }}func TestResourceListInvalidatesUnifiedSeedCacheOnFreshnessChange(t *testing.T) {diff --git a/internal/unifiedresources/clone.go b/internal/unifiedresources/clone.goindex c37ec6cf00..f7e5160a49 100644--- a/internal/unifiedresources/clone.go+++ b/internal/unifiedresources/clone.go@@ -40,11 +40,20 @@ func cloneResource(in *Resource) Resource {out.PhysicalDisk = clonePhysicalDiskMeta(in.PhysicalDisk)out.Ceph = cloneCephMeta(in.Ceph)out.TrueNAS = cloneTrueNASData(in.TrueNAS)+ out.FacetCounts = resourceFacetCounts(out)RefreshCanonicalIdentity(&out)RefreshPolicyMetadata(&out)return out}+func resourceFacetCounts(resource Resource) ResourceFacetCounts {+ return ResourceFacetCounts{+ Capabilities: len(resource.Capabilities),+ Relationships: len(resource.Relationships),+ RecentChanges: len(resource.RecentChanges),+ }+}+func cloneParentBySourceMap(in map[DataSource]string) map[DataSource]string {if len(in) == 0 {if in == nil {diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.goindex 7b90ede1e7..689d070866 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -257,6 +257,35 @@ func TestResourceAPIExposesDedicatedFacetReads(t *testing.T) {}}+func TestResourceFacetCountsAreCanonicalResourceFields(t *testing.T) {+ typesData, err := os.ReadFile(filepath.Join("types.go"))+ if err != nil {+ t.Fatalf("failed to read types.go: %v", err)+ }+ typesSource := string(typesData)+ if !strings.Contains(typesSource, "FacetCounts ResourceFacetCounts") {+ t.Fatalf("internal/unifiedresources/types.go must expose Resource.FacetCounts on the canonical resource model")+ }+ if !strings.Contains(typesSource, "json:\"facetCounts,omitempty\"") {+ t.Fatalf("internal/unifiedresources/types.go must keep the facetCounts JSON contract")+ }++ cloneData, err := os.ReadFile(filepath.Join("clone.go"))+ if err != nil {+ t.Fatalf("failed to read clone.go: %v", err)+ }+ cloneSource := string(cloneData)+ requiredSnippets := []string{+ "out.FacetCounts = resourceFacetCounts(out)",+ "func resourceFacetCounts(resource Resource) ResourceFacetCounts",+ }+ for _, snippet := range requiredSnippets {+ if !strings.Contains(cloneSource, snippet) {+ t.Fatalf("internal/unifiedresources/clone.go must derive canonical facet counts via %q", snippet)+ }+ }+}+// TestNoLegacyHostResourceTypeSymbol prevents reintroducing the removed// ResourceTypeHost symbol. v6 code must use ResourceTypeAgent and// CanonicalResourceType() for legacy normalization.diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.goindex c433060485..745cc9a750 100644--- a/internal/unifiedresources/types.go+++ b/internal/unifiedresources/types.go@@ -40,6 +40,7 @@ type Resource struct {Capabilities []ResourceCapability `json:"capabilities,omitempty"`Relationships []ResourceRelationship `json:"relationships,omitempty"`RecentChanges []ResourceChange `json:"recentChanges,omitempty"`+ FacetCounts ResourceFacetCounts `json:"facetCounts,omitempty"`Incidents []ResourceIncident `json:"incidents,omitempty"`IncidentCount int `json:"incidentCount,omitempty"`IncidentCode string `json:"incidentCode,omitempty"`@@ -65,6 +66,14 @@ type Resource struct {TrueNAS *TrueNASData `json:"truenas,omitempty"`}+// ResourceFacetCounts captures the total count of each resource facet that+// may be surfaced in row summaries or detail drawers.+type ResourceFacetCounts struct {+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+}+// DiscoveryTarget describes the canonical discovery request coordinates// for this unified resource.type DiscoveryTarget struct {