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 provenance counts in facet summaries
rcourtman74e530168822
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex c618ce92bf..4d837e6275 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -143,6 +143,11 @@ That same shared facet bundle now also carries grouped `recentChangeKinds`counts by canonical change kind, so the lifecycle-adjacent detail surfaces canreport restart, anomaly, relationship, and capability distribution withoutrebuilding timeline math in the browser.+That same shared facet bundle now also carries grouped+`recentChangeSourceTypes` counts by canonical source type, so the+lifecycle-adjacent detail surfaces can distinguish platform events, pulse+diffs, heuristics, user actions, and agent actions without re-inferencing the+provenance 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 d5bab325f9..1983f948b0 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -131,6 +131,11 @@ The same facet bundle contract now also returns grouped `recentChangeKinds`counts by canonical `ChangeKind`, so the shared drawer and summary chips canshow the distribution of restarts, anomalies, state transitions, and othertimeline classes without guessing from the loaded slice.+The same facet bundle contract now also returns grouped+`recentChangeSourceTypes` counts by canonical source type, so the shared+drawer and summary chips can distinguish platform events, pulse diffs,+heuristics, user actions, and agent actions without inventing frontend-local+provenance 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 e04cc6fc32..f13f13a3e2 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -120,6 +120,11 @@ consume now also carries grouped `recentChangeKinds` counts by canonical changekind, so storage and recovery surfaces can show the distribution of restarts,anomalies, relationships, and capability changes without re-deriving their owntimeline breakdowns.+That same shared facet bundle now also carries grouped+`recentChangeSourceTypes` counts by canonical source type, so storage and+recovery surfaces can separate platform events, pulse diffs, heuristics,+user actions, and agent actions without inferring provenance 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 356616fc7c..3407ae755b 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -121,6 +121,10 @@ The same facet bundle now also returns grouped recent-change counts bycanonical change kind, so the detail drawer can surface the distribution ofstate transitions, restarts, config updates, anomalies, relationships, andcapabilities without recomputing timeline history in the browser.+That same facet bundle now also returns grouped recent-change provenance+counts by source type, so the detail drawer can distinguish platform events,+pulse diffs, heuristics, user actions, and agent actions without re-deriving+adapter provenance 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 118c7905a6..645f1b7b61 100644--- a/frontend-modern/src/api/__tests__/resources.test.ts+++ b/frontend-modern/src/api/__tests__/resources.test.ts@@ -44,6 +44,10 @@ describe('ResourceAPI', () => {metric_anomaly: 2,restart: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },},} as any);@@ -74,6 +78,10 @@ describe('ResourceAPI', () => {metric_anomaly: 2,restart: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },},});expect(result.counts).toStrictEqual({@@ -84,6 +92,10 @@ describe('ResourceAPI', () => {metric_anomaly: 2,restart: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },});});diff --git a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsxindex 99d2740117..90f8896223 100644--- a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx@@ -73,6 +73,52 @@ const recentChangeKindLabels: Record<},};+type RecentChangeSourceType =+ | 'platform_event'+ | 'pulse_diff'+ | 'heuristic'+ | 'user_action'+ | 'agent_action';++const recentChangeSourceTypeOrder: RecentChangeSourceType[] = [+ 'platform_event',+ 'pulse_diff',+ 'heuristic',+ 'user_action',+ 'agent_action',+];++const recentChangeSourceTypeLabels: Record<+ RecentChangeSourceType,+ { label: string; plural: string; className: string }+> = {+ platform_event: {+ label: 'Platform event',+ plural: 'Platform events',+ className: 'bg-sky-100 text-sky-700 dark:bg-sky-900 dark:text-sky-300',+ },+ pulse_diff: {+ label: 'Pulse diff',+ plural: 'Pulse diffs',+ className: 'bg-violet-100 text-violet-700 dark:bg-violet-900 dark:text-violet-300',+ },+ heuristic: {+ label: 'Heuristic',+ plural: 'Heuristics',+ className: 'bg-fuchsia-100 text-fuchsia-700 dark:bg-fuchsia-900 dark:text-fuchsia-300',+ },+ user_action: {+ label: 'User action',+ plural: 'User actions',+ className: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300',+ },+ agent_action: {+ label: 'Agent action',+ plural: 'Agent actions',+ 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,@@ -122,6 +168,24 @@ const buildFacetBadges = (}}+ const sourceTypeCounts = counts?.recentChangeSourceTypes;+ if (sourceTypeCounts) {+ for (const sourceType of recentChangeSourceTypeOrder) {+ const count = sourceTypeCounts[sourceType];+ if (!count || count <= 0) continue;+ const sourceTypeLabel = recentChangeSourceTypeLabels[sourceType];+ badges.push({+ label: `${sourceTypeLabel.label} ${count}`,+ title: countLabel(+ count,+ sourceTypeLabel.label.toLowerCase(),+ sourceTypeLabel.plural.toLowerCase(),+ ),+ className: `${badgeBase} ${sourceTypeLabel.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 84efc8bb88..59667e4053 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx@@ -110,6 +110,10 @@ describe('ResourceDetailDrawer history tab', () => {restart: 2,metric_anomaly: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },},});@@ -130,6 +134,8 @@ describe('ResourceDetailDrawer history tab', () => {expect(screen.getByText('Timeline 3')).toBeInTheDocument();expect(screen.getByText('Restart 2')).toBeInTheDocument();expect(screen.getByText('Anomaly 1')).toBeInTheDocument();+ expect(screen.getByText('Platform event 1')).toBeInTheDocument();+ expect(screen.getByText('Pulse diff 2')).toBeInTheDocument();});it('renders resource capability, relationship, and timeline facets', async () => {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 082f9722cf..0c27c68828 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@@ -156,6 +156,10 @@ describe('UnifiedResourceTable performance contract', () => {restart: 2,metric_anomaly: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },}}recentChanges={[]}/>@@ -166,6 +170,8 @@ describe('UnifiedResourceTable performance contract', () => {expect(getByText('Timeline 3')).toBeInTheDocument();expect(getByText('Restart 2')).toBeInTheDocument();expect(getByText('Anomaly 1')).toBeInTheDocument();+ expect(getByText('Platform event 1')).toBeInTheDocument();+ expect(getByText('Pulse diff 2')).toBeInTheDocument();});it('renders facet summary badges without changing the Profile S row budget', async () => {@@ -200,6 +206,10 @@ describe('UnifiedResourceTable performance contract', () => {restart: 2,metric_anomaly: 1,},+ recentChangeSourceTypes: {+ platform_event: 1,+ pulse_diff: 2,+ },},recentChanges: [],}diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.tsindex 2b13eef56b..e8a03ab23f 100644--- a/frontend-modern/src/types/resource.ts+++ b/frontend-modern/src/types/resource.ts@@ -192,6 +192,7 @@ export interface ResourceFacetCounts {relationships: number;recentChanges: number;recentChangeKinds?: Partial<Record<ResourceChangeKind, number>>;+ recentChangeSourceTypes?: Partial<Record<ResourceChangeSourceType, number>>;}export interface ResourceRelationship {diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 9763d58e4f..b1035a91bd 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -3936,10 +3936,11 @@ 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"`+ 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"`} `json:"counts"`}{ResourceID: "vm:42",@@ -3987,15 +3988,20 @@ 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"`+ 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: 1,Relationships: 1,RecentChanges: 3,RecentChangeKinds: map[unifiedresources.ChangeKind]int{unifiedresources.ChangeRestart: 1, unifiedresources.ChangeAnomaly: 2},+ RecentChangeSourceTypes: map[unifiedresources.ChangeSourceType]int{+ unifiedresources.SourcePlatformEvent: 1,+ unifiedresources.SourcePulseDiff: 2,+ },},}@@ -4050,6 +4056,10 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {"recentChangeKinds":{"metric_anomaly":2,"restart":1+ },+ "recentChangeSourceTypes":{+ "platform_event":1,+ "pulse_diff":2}}}`diff --git a/internal/api/resources.go b/internal/api/resources.goindex db0b7b7a44..40427990f2 100644--- a/internal/api/resources.go+++ b/internal/api/resources.go@@ -500,6 +500,11 @@ func (h *ResourceHandlers) HandleGetResourceFacets(w http.ResponseWriter, r *htthttp.Error(w, sanitizeErrorForClient(err, "Internal server error"), http.StatusInternalServerError)return}+ sourceTypeCounts, err := store.CountRecentChangesBySourceTypeFiltered(resourceID, since, filters)+ if err != nil {+ http.Error(w, sanitizeErrorForClient(err, "Internal server error"), http.StatusInternalServerError)+ return+ }capabilities := resource.Capabilitiesif capabilities == nil {@@ -517,10 +522,11 @@ 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,+ Capabilities: resource.FacetCounts.Capabilities,+ Relationships: resource.FacetCounts.Relationships,+ RecentChanges: changeCount,+ RecentChangeKinds: changeKindCounts,+ RecentChangeSourceTypes: sourceTypeCounts,},})}diff --git a/internal/api/resources_test.go b/internal/api/resources_test.goindex ab93b15951..7395bbd0d0 100644--- a/internal/api/resources_test.go+++ b/internal/api/resources_test.go@@ -986,10 +986,11 @@ 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"`+ 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"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1004,6 +1005,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeKinds; len(got) != 2 || got[unified.ChangeRestart] != 1 || got[unified.ChangeAnomaly] != 2 {t.Fatalf("unexpected recent change kind counts: %#v", got)}+ 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.Relationships[0].Metadata["cluster"]; got != "pve-prod" {t.Fatalf("unexpected relationship metadata: %#v", payload.Relationships[0].Metadata)}@@ -1145,10 +1149,11 @@ 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"`+ 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"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1160,6 +1165,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeKinds; len(got) != 1 || got[unified.ChangeRestart] != 1 {t.Fatalf("unexpected filtered facet kind counts: %#v", got)}+ if got := payload.Counts.RecentChangeSourceTypes; len(got) != 1 || got[unified.SourcePlatformEvent] != 1 {+ t.Fatalf("unexpected filtered facet source type counts: %#v", got)+ }if payload.RecentChanges[0].ID != "chg-42" {t.Fatalf("unexpected filtered facets change: %#v", payload.RecentChanges[0])}@@ -1177,10 +1185,11 @@ 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"`+ 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"`} `json:"counts"`}if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {@@ -1192,6 +1201,9 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {if got := payload.Counts.RecentChangeKinds; len(got) != 1 || got[unified.ChangeAnomaly] != 1 {t.Fatalf("unexpected adapter-filtered facet kind counts: %#v", got)}+ if got := payload.Counts.RecentChangeSourceTypes; len(got) != 1 || got[unified.SourcePulseDiff] != 1 {+ t.Fatalf("unexpected adapter-filtered facet source type 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 0347e9488f..6aa86b812f 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -249,6 +249,7 @@ func TestResourceAPIExposesDedicatedFacetReads(t *testing.T) {"GetRecentChangesFiltered(resourceID, since, limit, filters)","CountRecentChangesFiltered(resourceID, since, filters)","CountRecentChangesByKindFiltered(resourceID, since, filters)",+ "CountRecentChangesBySourceTypeFiltered(resourceID, since, filters)","sourceAdapter","invalid sourceAdapter value","strings.HasSuffix(r.URL.Path, \"/facets\")",@@ -325,9 +326,12 @@ 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") {+ t.Fatalf("internal/unifiedresources/types.go must expose grouped timeline source-type 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 e5b6f85f1d..dc2dfd3c7e 100644--- a/internal/unifiedresources/store.go+++ b/internal/unifiedresources/store.go@@ -31,6 +31,8 @@ type ResourceStore interface {CountRecentChangesFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (int, error)CountRecentChangesByKind(canonicalID string, since time.Time) (map[ChangeKind]int, error)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)RecordActionAudit(record ActionAuditRecord) errorGetActionAudits(canonicalID string, since time.Time, limit int) ([]ActionAuditRecord, error)RecordActionLifecycleEvent(event ActionLifecycleEvent) error@@ -826,6 +828,41 @@ func (s *SQLiteResourceStore) CountRecentChangesByKindFiltered(canonicalID strinreturn counts, nil}+func (s *SQLiteResourceStore) CountRecentChangesBySourceType(canonicalID string, since time.Time) (map[ChangeSourceType]int, error) {+ return s.CountRecentChangesBySourceTypeFiltered(canonicalID, since, ResourceChangeFilters{})+}++func (s *SQLiteResourceStore) CountRecentChangesBySourceTypeFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceType]int, error) {+ query, args := buildRecentChangeCountQuery(canonicalID, since, filters, "SELECT COALESCE(source_type, ''), COUNT(*) FROM resource_changes")+ query += ` GROUP BY source_type`++ 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 type: %w", err)+ }+ defer rows.Close()++ counts := make(map[ChangeSourceType]int)+ for rows.Next() {+ var sourceType string+ var count int+ if err := rows.Scan(&sourceType, &count); err != nil {+ return nil, fmt.Errorf("scan resource change source type count row: %w", err)+ }+ if sourceType == "" {+ continue+ }+ counts[ChangeSourceType(sourceType)] = count+ }+ if err := rows.Err(); err != nil {+ return nil, fmt.Errorf("iterate resource change source type count rows: %w", err)+ }+ return counts, nil+}+func (s *SQLiteResourceStore) RecordActionAudit(record ActionAuditRecord) error {s.mu.Lock()defer s.mu.Unlock()@@ -1207,6 +1244,33 @@ func (m *MemoryStore) CountRecentChangesByKindFiltered(canonicalID string, sincereturn counts, nil}+func (m *MemoryStore) CountRecentChangesBySourceType(canonicalID string, since time.Time) (map[ChangeSourceType]int, error) {+ return m.CountRecentChangesBySourceTypeFiltered(canonicalID, since, ResourceChangeFilters{})+}++func (m *MemoryStore) CountRecentChangesBySourceTypeFiltered(canonicalID string, since time.Time, filters ResourceChangeFilters) (map[ChangeSourceType]int, error) {+ m.mu.RLock()+ defer m.mu.RUnlock()+ canonicalID = CanonicalResourceID(canonicalID)+ counts := make(map[ChangeSourceType]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.SourceType]+++ }+ 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 2d433cfa9c..b5bcf38264 100644--- a/internal/unifiedresources/store_test.go+++ b/internal/unifiedresources/store_test.go@@ -732,6 +732,76 @@ func TestCountRecentChangesByKind_RespectsFilters(t *testing.T) {}}+func TestCountRecentChangesBySourceType_RespectsFilters(t *testing.T) {+ store := newTestStore(t)+ base := time.Date(2026, 3, 18, 12, 0, 0, 0, time.UTC)+ changes := []ResourceChange{+ {+ ID: "chg-source-1",+ ResourceID: "vm:1",+ ObservedAt: base.Add(-30 * time.Minute),+ Kind: ChangeStateTransition,+ SourceType: SourcePlatformEvent,+ SourceAdapter: AdapterProxmox,+ Confidence: ConfidenceHigh,+ },+ {+ ID: "chg-source-2",+ ResourceID: "vm:1",+ ObservedAt: base.Add(-20 * time.Minute),+ Kind: ChangeAnomaly,+ SourceType: SourcePulseDiff,+ SourceAdapter: AdapterDocker,+ Confidence: ConfidenceMedium,+ },+ {+ ID: "chg-source-3",+ ResourceID: "vm:1",+ ObservedAt: base.Add(-10 * time.Minute),+ Kind: ChangeAnomaly,+ SourceType: SourcePulseDiff,+ SourceAdapter: AdapterProxmox,+ Confidence: ConfidenceLow,+ },+ {+ ID: "chg-source-4",+ ResourceID: "vm:2",+ ObservedAt: base.Add(-5 * time.Minute),+ Kind: ChangeCapability,+ SourceType: SourceAgentAction,+ SourceAdapter: AdapterDocker,+ Confidence: ConfidenceLow,+ },+ }+ for _, change := range changes {+ if err := store.RecordChange(change); err != nil {+ t.Fatalf("RecordChange(%s): %v", change.ID, err)+ }+ }++ counts, err := store.CountRecentChangesBySourceType("vm:1", base.Add(-35*time.Minute))+ if err != nil {+ t.Fatalf("CountRecentChangesBySourceType vm:1: %v", err)+ }+ wantCounts := map[ChangeSourceType]int{+ SourcePlatformEvent: 1,+ SourcePulseDiff: 2,+ }+ if !reflect.DeepEqual(counts, wantCounts) {+ t.Fatalf("CountRecentChangesBySourceType vm:1 = %#v, want %#v", counts, wantCounts)+ }++ filteredCounts, err := store.CountRecentChangesBySourceTypeFiltered("vm:1", base.Add(-35*time.Minute), ResourceChangeFilters{+ SourceAdapters: []ChangeSourceAdapter{AdapterProxmox},+ })+ if err != nil {+ t.Fatalf("CountRecentChangesBySourceTypeFiltered source adapters: %v", err)+ }+ 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})+ }+}+func TestGetRecentChanges_RespectsFilters(t *testing.T) {store := newTestStore(t)base := time.Date(2026, 3, 18, 12, 0, 0, 0, time.UTC)diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.goindex c044324ced..0b4abb54b2 100644--- a/internal/unifiedresources/types.go+++ b/internal/unifiedresources/types.go@@ -69,10 +69,11 @@ 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"`+ 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"`}// DiscoveryTarget describes the canonical discovery request coordinates