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
Expose adapter provenance counts in facet summaries
rcourtman261d4e858613
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 4d837e6275..e00b696169 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -148,6 +148,11 @@ That same shared facet bundle now also carries groupedlifecycle-adjacent detail surfaces can distinguish platform events, pulsediffs, heuristics, user actions, and agent actions without re-inferencing theprovenance mix in the browser.+That same shared facet bundle now also carries grouped+`recentChangeSourceAdapters` counts by canonical source adapter, so the+lifecycle-adjacent detail surfaces can distinguish Docker, Proxmox, TrueNAS,+and ops-helper provenance without re-inferencing the integration mix in the+browser.Timeline entries surfaced through that same boundary also preserve`relatedResources` graph context for non-relationship changes, so adjacentfleet and install surfaces can link the affected neighbors without trying todiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 1983f948b0..9be461cf13 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -136,6 +136,10 @@ The same facet bundle contract now also returns groupeddrawer and summary chips can distinguish platform events, pulse diffs,heuristics, user actions, and agent actions without inventing frontend-localprovenance heuristics.+The same facet bundle contract now also returns grouped+`recentChangeSourceAdapters` counts by canonical source adapter, so the+shared drawer and summary chips can distinguish Docker, Proxmox, TrueNAS, and+ops-helper provenance without inventing frontend-local integration heuristics.Canonical timeline entries now also preserve graph context in`relatedResources`, so the history surface can explain which neighboringresources moved with restart, anomaly, config, state transition, anddiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex f13f13a3e2..dde8744f16 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -125,6 +125,10 @@ That same shared facet bundle now also carries groupedrecovery surfaces can separate platform events, pulse diffs, heuristics,user actions, and agent actions without inferring provenance from the loadedslice.+That same shared facet bundle now also carries grouped+`recentChangeSourceAdapters` counts by canonical source adapter, so storage+and recovery surfaces can separate Docker, Proxmox, TrueNAS, and ops-helper+provenance without inferring integration origin from the loaded slice.Those same resource timeline records also preserve `relatedResources` graphcontext for non-relationship changes, so storage and recovery views can stilllink neighboring resources when the timeline entry is a restart, anomaly, ordiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 3407ae755b..fad1700824 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -125,6 +125,10 @@ That same facet bundle now also returns grouped recent-change provenancecounts by source type, so the detail drawer can distinguish platform events,pulse diffs, heuristics, user actions, and agent actions without re-derivingadapter provenance from the loaded slice.+That same facet bundle now also returns grouped recent-change adapter counts+by source adapter, so the detail drawer can distinguish Docker, Proxmox,+TrueNAS, and ops-helper provenance without re-deriving integration origin+from the loaded slice.That same shared store now also persists append-only action lifecycle, actionaudit, and export audit records, giving the control-plane verbs a durable homediff --git a/frontend-modern/src/api/__tests__/resources.test.ts b/frontend-modern/src/api/__tests__/resources.test.tsindex 645f1b7b61..d8b78b17ea 100644--- a/frontend-modern/src/api/__tests__/resources.test.ts+++ b/frontend-modern/src/api/__tests__/resources.test.ts@@ -48,6 +48,10 @@ describe('ResourceAPI', () => {platform_event: 1,pulse_diff: 2,},+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },},} as any);@@ -82,6 +86,10 @@ describe('ResourceAPI', () => {platform_event: 1,pulse_diff: 2,},+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },},});expect(result.counts).toStrictEqual({@@ -96,6 +104,10 @@ describe('ResourceAPI', () => {platform_event: 1,pulse_diff: 2,},+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },});});diff --git a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsxindex 90f8896223..a69919f13a 100644--- a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx@@ -4,6 +4,7 @@ import type {ResourceChange,ResourceChangeKind,ResourceFacetCounts,+ ResourceFacetSourceAdapter,ResourceRelationship,} from '@/types/resource';@@ -119,6 +120,39 @@ const recentChangeSourceTypeLabels: Record<},};+const recentChangeSourceAdapterOrder: ResourceFacetSourceAdapter[] = [+ 'docker_adapter',+ 'proxmox_adapter',+ 'truenas_adapter',+ 'agent:ops-helper',+];++const recentChangeSourceAdapterLabels: Record<+ ResourceFacetSourceAdapter,+ { label: string; plural: string; className: string }+> = {+ docker_adapter: {+ label: 'Docker adapter',+ plural: 'Docker adapters',+ className: 'bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300',+ },+ proxmox_adapter: {+ label: 'Proxmox adapter',+ plural: 'Proxmox adapters',+ className: 'bg-sky-100 text-sky-700 dark:bg-sky-900 dark:text-sky-300',+ },+ truenas_adapter: {+ label: 'TrueNAS adapter',+ plural: 'TrueNAS adapters',+ className: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300',+ },+ 'agent:ops-helper': {+ label: 'Ops helper',+ plural: 'Ops helpers',+ className: 'bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300',+ },+};+const buildFacetBadges = (capabilities?: readonly ResourceCapability[] | null,relationships?: readonly ResourceRelationship[] | null,@@ -186,6 +220,24 @@ const buildFacetBadges = (}}+ const sourceAdapterCounts = counts?.recentChangeSourceAdapters;+ if (sourceAdapterCounts) {+ for (const sourceAdapter of recentChangeSourceAdapterOrder) {+ const count = sourceAdapterCounts[sourceAdapter];+ if (!count || count <= 0) continue;+ const sourceAdapterLabel = recentChangeSourceAdapterLabels[sourceAdapter];+ badges.push({+ label: `${sourceAdapterLabel.label} ${count}`,+ title: countLabel(+ count,+ sourceAdapterLabel.label.toLowerCase(),+ sourceAdapterLabel.plural.toLowerCase(),+ ),+ className: `${badgeBase} ${sourceAdapterLabel.className}`,+ });+ }+ }+return badges;};diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsxindex 59667e4053..c0bc88ff74 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx@@ -114,6 +114,10 @@ describe('ResourceDetailDrawer history tab', () => {platform_event: 1,pulse_diff: 2,},+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },},});@@ -136,6 +140,8 @@ describe('ResourceDetailDrawer history tab', () => {expect(screen.getByText('Anomaly 1')).toBeInTheDocument();expect(screen.getByText('Platform event 1')).toBeInTheDocument();expect(screen.getByText('Pulse diff 2')).toBeInTheDocument();+ expect(screen.getByText('Docker adapter 2')).toBeInTheDocument();+ expect(screen.getByText('Proxmox adapter 1')).toBeInTheDocument();});it('renders resource capability, relationship, and timeline facets', async () => {@@ -203,6 +209,10 @@ describe('ResourceDetailDrawer history tab', () => {restart: 2,metric_anomaly: 1,},+ recentChangeSourceAdapters: {+ docker_adapter: 1,+ proxmox_adapter: 2,+ },},});@@ -306,6 +316,10 @@ describe('ResourceDetailDrawer history tab', () => {restart: 1,metric_anomaly: 1,},+ recentChangeSourceAdapters: {+ docker_adapter: 1,+ proxmox_adapter: 1,+ },},};const filteredFacetBundle = {@@ -442,6 +456,10 @@ describe('ResourceDetailDrawer history tab', () => {restart: 1,metric_anomaly: 1,},+ recentChangeSourceAdapters: {+ docker_adapter: 1,+ proxmox_adapter: 1,+ },},}).mockResolvedValueOnce({@@ -488,6 +506,9 @@ describe('ResourceDetailDrawer history tab', () => {recentChangeKinds: {metric_anomaly: 1,},+ recentChangeSourceAdapters: {+ docker_adapter: 1,+ },},});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 0c27c68828..07d79101d0 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@@ -160,6 +160,10 @@ describe('UnifiedResourceTable performance contract', () => {platform_event: 1,pulse_diff: 2,},+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },}}recentChanges={[]}/>@@ -172,6 +176,8 @@ describe('UnifiedResourceTable performance contract', () => {expect(getByText('Anomaly 1')).toBeInTheDocument();expect(getByText('Platform event 1')).toBeInTheDocument();expect(getByText('Pulse diff 2')).toBeInTheDocument();+ expect(getByText('Docker adapter 2')).toBeInTheDocument();+ expect(getByText('Proxmox adapter 1')).toBeInTheDocument();});it('renders facet summary badges without changing the Profile S row budget', async () => {@@ -206,13 +212,17 @@ describe('UnifiedResourceTable performance contract', () => {restart: 2,metric_anomaly: 1,},- recentChangeSourceTypes: {- platform_event: 1,- pulse_diff: 2,- },+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,},- recentChanges: [],- }+ recentChangeSourceAdapters: {+ docker_adapter: 2,+ proxmox_adapter: 1,+ },+ },+ recentChanges: [],+ }: {},);const { container, getByText } = render(() => (diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.tsindex e8a03ab23f..3d95047861 100644--- a/frontend-modern/src/types/resource.ts+++ b/frontend-modern/src/types/resource.ts@@ -167,6 +167,12 @@ export type ResourceChangeSourceAdapter =| 'agent:ops-helper'| string;+export type ResourceFacetSourceAdapter =+ | 'docker_adapter'+ | 'proxmox_adapter'+ | 'truenas_adapter'+ | 'agent:ops-helper';+export interface ResourceCapabilityParam {name: string;type: string;@@ -193,6 +199,7 @@ export interface ResourceFacetCounts {recentChanges: number;recentChangeKinds?: Partial<Record<ResourceChangeKind, number>>;recentChangeSourceTypes?: Partial<Record<ResourceChangeSourceType, number>>;+ recentChangeSourceAdapters?: Partial<Record<ResourceFacetSourceAdapter, number>>;}export interface ResourceRelationship {diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex b1035a91bd..ec0164ce29 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -3936,11 +3936,12 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {Relationships []unifiedresources.ResourceRelationship `json:"relationships"`RecentChanges []unifiedresources.ResourceChange `json:"recentChanges"`Counts struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`- RecentChangeKinds map[unifiedresources.ChangeKind]int `json:"recentChangeKinds"`- RecentChangeSourceTypes map[unifiedresources.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[unifiedresources.ChangeKind]int `json:"recentChangeKinds"`+ RecentChangeSourceTypes map[unifiedresources.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ RecentChangeSourceAdapters map[unifiedresources.ChangeSourceAdapter]int `json:"recentChangeSourceAdapters"`} `json:"counts"`}{ResourceID: "vm:42",@@ -3988,11 +3989,12 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {},},Counts: struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`- RecentChangeKinds map[unifiedresources.ChangeKind]int `json:"recentChangeKinds"`- RecentChangeSourceTypes map[unifiedresources.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[unifiedresources.ChangeKind]int `json:"recentChangeKinds"`+ RecentChangeSourceTypes map[unifiedresources.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ RecentChangeSourceAdapters map[unifiedresources.ChangeSourceAdapter]int `json:"recentChangeSourceAdapters"`}{Capabilities: 1,Relationships: 1,@@ -4002,6 +4004,10 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {unifiedresources.SourcePlatformEvent: 1,unifiedresources.SourcePulseDiff: 2,},+ RecentChangeSourceAdapters: map[unifiedresources.ChangeSourceAdapter]int{+ unifiedresources.AdapterProxmox: 1,+ unifiedresources.AdapterDocker: 2,+ },},}@@ -4060,6 +4066,10 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {"recentChangeSourceTypes":{"platform_event":1,"pulse_diff":2+ },+ "recentChangeSourceAdapters":{+ "docker_adapter":2,+ "proxmox_adapter":1}}}`diff --git a/internal/api/resources.go b/internal/api/resources.goindex 40427990f2..0c0f78159a 100644--- a/internal/api/resources.go+++ b/internal/api/resources.go@@ -505,6 +505,11 @@ func (h *ResourceHandlers) HandleGetResourceFacets(w http.ResponseWriter, r *htthttp.Error(w, sanitizeErrorForClient(err, "Internal server error"), http.StatusInternalServerError)return}+ sourceAdapterCounts, err := store.CountRecentChangesBySourceAdapterFiltered(resourceID, since, filters)+ if err != nil {+ http.Error(w, sanitizeErrorForClient(err, "Internal server error"), http.StatusInternalServerError)+ return+ }capabilities := resource.Capabilitiesif capabilities == nil {@@ -522,11 +527,12 @@ func (h *ResourceHandlers) HandleGetResourceFacets(w http.ResponseWriter, r *httRelationships: relationships,RecentChanges: recentChanges,Counts: resourceFacetCountsResponse{- Capabilities: resource.FacetCounts.Capabilities,- Relationships: resource.FacetCounts.Relationships,- RecentChanges: changeCount,- RecentChangeKinds: changeKindCounts,- RecentChangeSourceTypes: sourceTypeCounts,+ Capabilities: resource.FacetCounts.Capabilities,+ Relationships: resource.FacetCounts.Relationships,+ RecentChanges: changeCount,+ RecentChangeKinds: changeKindCounts,+ RecentChangeSourceTypes: sourceTypeCounts,+ RecentChangeSourceAdapters: sourceAdapterCounts,},})}diff --git a/internal/api/resources_test.go b/internal/api/resources_test.goindex 7395bbd0d0..0c94cd5e51 100644--- a/internal/api/resources_test.go+++ b/internal/api/resources_test.go@@ -986,11 +986,12 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {Relationships []unified.ResourceRelationship `json:"relationships"`RecentChanges []unified.ResourceChange `json:"recentChanges"`Counts struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`- RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`- RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`+ RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ RecentChangeSourceAdapters map[unified.ChangeSourceAdapter]int `json:"recentChangeSourceAdapters"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1008,6 +1009,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeSourceTypes; len(got) != 2 || got[unified.SourcePlatformEvent] != 1 || got[unified.SourcePulseDiff] != 2 {t.Fatalf("unexpected recent change source type counts: %#v", got)}+ if got := payload.Counts.RecentChangeSourceAdapters; len(got) != 2 || got[unified.AdapterProxmox] != 2 || got[unified.AdapterDocker] != 1 {+ t.Fatalf("unexpected recent change source adapter counts: %#v", got)+ }if got := payload.Relationships[0].Metadata["cluster"]; got != "pve-prod" {t.Fatalf("unexpected relationship metadata: %#v", payload.Relationships[0].Metadata)}@@ -1149,11 +1153,12 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {RecentChanges []unified.ResourceChange `json:"recentChanges"`Relationships []unified.ResourceRelationship `json:"relationships"`Counts struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`- RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`- RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`+ RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ RecentChangeSourceAdapters map[unified.ChangeSourceAdapter]int `json:"recentChangeSourceAdapters"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1168,6 +1173,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeSourceTypes; len(got) != 1 || got[unified.SourcePlatformEvent] != 1 {t.Fatalf("unexpected filtered facet source type counts: %#v", got)}+ if got := payload.Counts.RecentChangeSourceAdapters; len(got) != 1 || got[unified.AdapterProxmox] != 1 {+ t.Fatalf("unexpected filtered facet source adapter counts: %#v", got)+ }if payload.RecentChanges[0].ID != "chg-42" {t.Fatalf("unexpected filtered facets change: %#v", payload.RecentChanges[0])}@@ -1185,11 +1193,12 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {RecentChanges []unified.ResourceChange `json:"recentChanges"`Relationships []unified.ResourceRelationship `json:"relationships"`Counts struct {- Capabilities int `json:"capabilities"`- Relationships int `json:"relationships"`- RecentChanges int `json:"recentChanges"`- RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`- RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[unified.ChangeKind]int `json:"recentChangeKinds"`+ RecentChangeSourceTypes map[unified.ChangeSourceType]int `json:"recentChangeSourceTypes"`+ RecentChangeSourceAdapters map[unified.ChangeSourceAdapter]int `json:"recentChangeSourceAdapters"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1204,6 +1213,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeSourceTypes; len(got) != 1 || got[unified.SourcePulseDiff] != 1 {t.Fatalf("unexpected adapter-filtered facet source type counts: %#v", got)}+ if got := payload.Counts.RecentChangeSourceAdapters; len(got) != 1 || got[unified.AdapterDocker] != 1 {+ t.Fatalf("unexpected adapter-filtered facet source adapter counts: %#v", got)+ }if payload.RecentChanges[0].ID != "chg-42-extra-2" {t.Fatalf("unexpected adapter-filtered facets change: %#v", payload.RecentChanges[0])}diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.goindex 6aa86b812f..698d4bd3b1 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -326,12 +326,15 @@ func TestResourceFacetCountsAreCanonicalResourceFields(t *testing.T) {if !strings.Contains(typesSource, "json:\"facetCounts,omitempty\"") {t.Fatalf("internal/unifiedresources/types.go must keep the facetCounts JSON contract")}- if !strings.Contains(typesSource, "RecentChangeKinds map[ChangeKind]int") {+ if !strings.Contains(typesSource, "RecentChangeKinds map[ChangeKind]int") {t.Fatalf("internal/unifiedresources/types.go must expose grouped timeline counts on the canonical facet model")}- if !strings.Contains(typesSource, "RecentChangeSourceTypes map[ChangeSourceType]int") {+ if !strings.Contains(typesSource, "RecentChangeSourceTypes map[ChangeSourceType]int") {t.Fatalf("internal/unifiedresources/types.go must expose grouped timeline source-type counts on the canonical facet model")}+ if !strings.Contains(typesSource, "RecentChangeSourceAdapters map[ChangeSourceAdapter]int") {+ t.Fatalf("internal/unifiedresources/types.go must expose grouped timeline source-adapter counts on the canonical facet model")+ }cloneData, err := os.ReadFile(filepath.Join("clone.go"))if err != nil {diff --git a/internal/unifiedresources/store.go b/internal/unifiedresources/store.goindex dc2dfd3c7e..9caedc06c4 100644--- a/internal/unifiedresources/store.go+++ b/internal/unifiedresources/store.go@@ -33,6 +33,8 @@ type ResourceStore interface {CountRecentChangesByKindFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeKind]int, error)CountRecentChangesBySourceType(canonicalID string, since time.Time) (map[ChangeSourceType]int, error)CountRecentChangesBySourceTypeFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceType]int, error)+ CountRecentChangesBySourceAdapter(canonicalID string, since time.Time) (map[ChangeSourceAdapter]int, error)+ CountRecentChangesBySourceAdapterFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceAdapter]int, error)RecordActionAudit(record ActionAuditRecord) errorGetActionAudits(canonicalID string, since time.Time, limit int) ([]ActionAuditRecord, error)RecordActionLifecycleEvent(event ActionLifecycleEvent) error@@ -863,6 +865,41 @@ func (s *SQLiteResourceStore) CountRecentChangesBySourceTypeFiltered(canonicalIDreturn counts, nil}+func (s *SQLiteResourceStore) CountRecentChangesBySourceAdapter(canonicalID string, since time.Time) (map[ChangeSourceAdapter]int, error) {+ return s.CountRecentChangesBySourceAdapterFiltered(canonicalID, since, ResourceChangeFilters{})+}++func (s *SQLiteResourceStore) CountRecentChangesBySourceAdapterFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceAdapter]int, error) {+ query, args := buildRecentChangeCountQuery(canonicalID, since, filters, "SELECT COALESCE(source_adapter, ''), COUNT(*) FROM resource_changes")+ query += ` GROUP BY source_adapter`++ s.mu.Lock()+ defer s.mu.Unlock()++ rows, err := s.db.Query(query, args...)+ if err != nil {+ return nil, fmt.Errorf("query resource change counts by source adapter: %w", err)+ }+ defer rows.Close()++ counts := make(map[ChangeSourceAdapter]int)+ for rows.Next() {+ var sourceAdapter string+ var count int+ if err := rows.Scan(&sourceAdapter, &count); err != nil {+ return nil, fmt.Errorf("scan resource change source adapter count row: %w", err)+ }+ if sourceAdapter == "" {+ continue+ }+ counts[ChangeSourceAdapter(sourceAdapter)] = count+ }+ if err := rows.Err(); err != nil {+ return nil, fmt.Errorf("iterate resource change source adapter count rows: %w", err)+ }+ return counts, nil+}+func (s *SQLiteResourceStore) RecordActionAudit(record ActionAuditRecord) error {s.mu.Lock()defer s.mu.Unlock()@@ -1271,6 +1308,33 @@ func (m *MemoryStore) CountRecentChangesBySourceTypeFiltered(canonicalID string,return counts, nil}+func (m *MemoryStore) CountRecentChangesBySourceAdapter(canonicalID string, since time.Time) (map[ChangeSourceAdapter]int, error) {+ return m.CountRecentChangesBySourceAdapterFiltered(canonicalID, since, ResourceChangeFilters{})+}++func (m *MemoryStore) CountRecentChangesBySourceAdapterFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceAdapter]int, error) {+ m.mu.RLock()+ defer m.mu.RUnlock()+ canonicalID = CanonicalResourceID(canonicalID)+ counts := make(map[ChangeSourceAdapter]int)+ for _, change := range m.changes {+ if canonicalID != "" && CanonicalResourceID(change.ResourceID) != canonicalID {+ continue+ }+ if !since.IsZero() && change.ObservedAt.Before(since) {+ continue+ }+ if !filters.matches(change) {+ continue+ }+ counts[change.SourceAdapter]+++ }+ if len(counts) == 0 {+ return nil, nil+ }+ return counts, nil+}+func buildRecentChangeCountQuery(canonicalID string, since time.Time, filters ResourceChangeFilters, selectClause string) (string, []any) {query := selectClauseargs := []any{}diff --git a/internal/unifiedresources/store_test.go b/internal/unifiedresources/store_test.goindex b5bcf38264..f4578ae4d1 100644--- a/internal/unifiedresources/store_test.go+++ b/internal/unifiedresources/store_test.go@@ -800,6 +800,28 @@ func TestCountRecentChangesBySourceType_RespectsFilters(t *testing.T) {if !reflect.DeepEqual(filteredCounts, map[ChangeSourceType]int{SourcePlatformEvent: 1, SourcePulseDiff: 1}) {t.Fatalf("CountRecentChangesBySourceTypeFiltered source adapters = %#v, want %#v", filteredCounts, map[ChangeSourceType]int{SourcePlatformEvent: 1, SourcePulseDiff: 1})}++ adapterCounts, err := store.CountRecentChangesBySourceAdapter("vm:1", base.Add(-35*time.Minute))+ if err != nil {+ t.Fatalf("CountRecentChangesBySourceAdapter vm:1: %v", err)+ }+ wantAdapterCounts := map[ChangeSourceAdapter]int{+ AdapterDocker: 1,+ AdapterProxmox: 2,+ }+ if !reflect.DeepEqual(adapterCounts, wantAdapterCounts) {+ t.Fatalf("CountRecentChangesBySourceAdapter vm:1 = %#v, want %#v", adapterCounts, wantAdapterCounts)+ }++ filteredAdapterCounts, err := store.CountRecentChangesBySourceAdapterFiltered("vm:1", base.Add(-35*time.Minute), ResourceChangeFilters{+ SourceTypes: []ChangeSourceType{SourcePulseDiff},+ })+ if err != nil {+ t.Fatalf("CountRecentChangesBySourceAdapterFiltered source types: %v", err)+ }+ if !reflect.DeepEqual(filteredAdapterCounts, map[ChangeSourceAdapter]int{AdapterDocker: 1, AdapterProxmox: 1}) {+ t.Fatalf("CountRecentChangesBySourceAdapterFiltered source types = %#v, want %#v", filteredAdapterCounts, map[ChangeSourceAdapter]int{AdapterDocker: 1, AdapterProxmox: 1})+ }}func TestGetRecentChanges_RespectsFilters(t *testing.T) {diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.goindex 0b4abb54b2..169a3af102 100644--- a/internal/unifiedresources/types.go+++ b/internal/unifiedresources/types.go@@ -69,11 +69,12 @@ type Resource struct {// 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"`- RecentChangeKinds map[ChangeKind]int `json:"recentChangeKinds,omitempty"`- RecentChangeSourceTypes map[ChangeSourceType]int `json:"recentChangeSourceTypes,omitempty"`+ Capabilities int `json:"capabilities"`+ Relationships int `json:"relationships"`+ RecentChanges int `json:"recentChanges"`+ RecentChangeKinds map[ChangeKind]int `json:"recentChangeKinds,omitempty"`+ RecentChangeSourceTypes map[ChangeSourceType]int `json:"recentChangeSourceTypes,omitempty"`+ RecentChangeSourceAdapters map[ChangeSourceAdapter]int `json:"recentChangeSourceAdapters,omitempty"`}// DiscoveryTarget describes the canonical discovery request coordinates