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
Use canonical resource timeline in intelligence summary
rcourtman2121e57d74bd
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 1cbf120e66..878500151b 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -156,3 +156,6 @@ The Patrol intelligence seed context now also prefers the canonicalunified-resource timeline before falling back to the patrol-local changedetector, so deterministic patrol context and resource detail context sharethe same change source of truth.+The unified intelligence summary should follow the same rule when it counts+recent activity, so the shared AI summary and the Patrol seed context stay+aligned with the canonical timeline.diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 0a439021df..1fc8579a0d 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -74,3 +74,6 @@ Patrol intelligence seed context should also prefer the canonicalunified-resource timeline before falling back to the patrol-local changedetector so recent-change context stays aligned with the resource timelinethat powers the shared resource API.+Patrol-owned intelligence summaries should keep their recent-change counts+backed by the same canonical timeline when available instead of only counting+Patrol-local detector history.diff --git a/internal/ai/intelligence.go b/internal/ai/intelligence.goindex 8f21579c92..9cc7ad57c6 100644--- a/internal/ai/intelligence.go+++ b/internal/ai/intelligence.go@@ -15,6 +15,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/knowledge""github.com/rcourtman/pulse-go-rewrite/internal/ai/memory""github.com/rcourtman/pulse-go-rewrite/internal/ai/patterns"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")// HealthGrade represents the overall health assessment@@ -139,14 +140,16 @@ type Intelligence struct {mu sync.RWMutex// Core subsystems- findings *FindingsStore- patterns *patterns.Detector- correlations *correlation.Detector- baselines *baseline.Store- incidents *memory.IncidentStore- knowledge *knowledge.Store- changes *memory.ChangeDetector- remediations *memory.RemediationLog+ findings *FindingsStore+ patterns *patterns.Detector+ correlations *correlation.Detector+ baselines *baseline.Store+ incidents *memory.IncidentStore+ knowledge *knowledge.Store+ changes *memory.ChangeDetector+ remediations *memory.RemediationLog+ resourceTimelineStore unifiedresources.ResourceStore+ resourceTimelineStoreOrgID string// State accessstateProvider StateProvider@@ -194,6 +197,15 @@ func (i *Intelligence) SetSubsystems(i.remediations = remediationsLog}+// SetResourceTimelineStore wires the canonical unified-resource timeline used+// for recent change summaries when available.+func (i *Intelligence) SetResourceTimelineStore(store unifiedresources.ResourceStore, orgID string) {+ i.mu.Lock()+ defer i.mu.Unlock()+ i.resourceTimelineStore = store+ i.resourceTimelineStoreOrgID = strings.TrimSpace(orgID)+}+// SetStateProvider sets the state provider for current metricsfunc (i *Intelligence) SetStateProvider(sp StateProvider) {i.mu.Lock()@@ -203,35 +215,47 @@ func (i *Intelligence) SetStateProvider(sp StateProvider) {// GetSummary returns a comprehensive intelligence summaryfunc (i *Intelligence) GetSummary() *IntelligenceSummary {- i.mu.RLock()- defer i.mu.RUnlock()-summary := &IntelligenceSummary{Timestamp: time.Now(),}+ i.mu.RLock()+ findings := i.findings+ patternsDetector := i.patterns+ remediations := i.remediations+ changes := i.changes+ resourceTimelineStore := i.resourceTimelineStore+ i.mu.RUnlock()+// Aggregate findings- if i.findings != nil {- all := i.findings.GetActive(FindingSeverityInfo) // Get all active findings+ if findings != nil {+ all := findings.GetActive(FindingSeverityInfo) // Get all active findingssummary.FindingsCount = i.countFindings(all)summary.TopFindings = i.getTopFindings(all, 5)}// Aggregate predictions- if i.patterns != nil {- predictions := i.patterns.GetPredictions()+ if patternsDetector != nil {+ predictions := patternsDetector.GetPredictions()summary.PredictionsCount = len(predictions)summary.UpcomingRisks = i.getUpcomingRisks(predictions, 5)}// Aggregate recent activity- if i.changes != nil {- recent := i.changes.GetRecentChanges(100, time.Now().Add(-24*time.Hour))+ usedCanonicalRecentChanges := false+ if resourceTimelineStore != nil {+ if recent, err := resourceTimelineStore.GetRecentChanges("", time.Now().Add(-24*time.Hour), 100); err == nil {+ summary.RecentChangesCount = len(recent)+ usedCanonicalRecentChanges = true+ }+ }+ if !usedCanonicalRecentChanges && changes != nil {+ recent := changes.GetRecentChanges(100, time.Now().Add(-24*time.Hour))summary.RecentChangesCount = len(recent)}- if i.remediations != nil {- recent := i.remediations.GetRecentRemediations(5, time.Now().Add(-24*time.Hour))+ if remediations != nil {+ recent := remediations.GetRecentRemediations(5, time.Now().Add(-24*time.Hour))summary.RecentRemediations = recent}diff --git a/internal/ai/intelligence_coverage_test.go b/internal/ai/intelligence_coverage_test.goindex 21a67e1262..ecf9e96db3 100644--- a/internal/ai/intelligence_coverage_test.go+++ b/internal/ai/intelligence_coverage_test.go@@ -11,6 +11,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/memory""github.com/rcourtman/pulse-go-rewrite/internal/ai/patterns""github.com/rcourtman/pulse-go-rewrite/internal/alerts"+ ur "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")func TestIntelligence_formatBaselinesForContext(t *testing.T) {@@ -473,6 +474,29 @@ func TestIntelligence_GetSummary_WithSubsystems(t *testing.T) {}}+func TestIntelligence_GetSummary_UsesCanonicalResourceTimeline(t *testing.T) {+ intel := NewIntelligence(IntelligenceConfig{})+ canonicalStore := ur.NewMemoryStore()+ if err := canonicalStore.RecordChange(ur.ResourceChange{+ ID: "change-1",+ ObservedAt: time.Now().Add(-time.Hour),+ ResourceID: "vm-sum",+ Kind: ur.ChangeConfigUpdate,+ SourceType: ur.SourcePulseDiff,+ SourceAdapter: ur.AdapterOpsAgent,+ Reason: "Config refresh",+ }); err != nil {+ t.Fatalf("record canonical change: %v", err)+ }++ intel.SetResourceTimelineStore(canonicalStore, "org-1")++ summary := intel.GetSummary()+ if summary.RecentChangesCount != 1 {+ t.Fatalf("expected canonical recent change count, got %d", summary.RecentChangesCount)+ }+}+func TestIntelligence_GetResourceIntelligence_WithAllSubsystems(t *testing.T) {intel := NewIntelligence(IntelligenceConfig{})findings := NewFindingsStore()diff --git a/internal/ai/patrol_init.go b/internal/ai/patrol_init.goindex b850502b5f..8d7a9ef124 100644--- a/internal/ai/patrol_init.go+++ b/internal/ai/patrol_init.go@@ -782,6 +782,13 @@ func (p *PatrolService) GetIntelligence() *Intelligence {p.changeDetector,p.remediationLog,)+ if p.aiService != nil {+ p.aiService.mu.RLock()+ store := p.aiService.resourceExportStore+ orgID := p.aiService.resourceExportStoreOrgID+ p.aiService.mu.RUnlock()+ p.intelligence.SetResourceTimelineStore(store, orgID)+ }if p.stateProvider != nil {p.intelligence.SetStateProvider(p.stateProvider)diff --git a/internal/ai/patrol_test.go b/internal/ai/patrol_test.goindex c181e0c400..0011c55753 100644--- a/internal/ai/patrol_test.go+++ b/internal/ai/patrol_test.go@@ -8,6 +8,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/memory""github.com/rcourtman/pulse-go-rewrite/internal/models"+ ur "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")func patrolRuntimeStateForTest(ps *PatrolService, snap models.StateSnapshot) patrolRuntimeState {@@ -984,7 +985,23 @@ func TestPatrolService_GetThresholds(t *testing.T) {}func TestPatrolService_GetIntelligence(t *testing.T) {- ps := NewPatrolService(nil, nil)+ svc := &Service{orgID: "org-1"}+ canonicalStore := ur.NewMemoryStore()+ if err := canonicalStore.RecordChange(ur.ResourceChange{+ ID: "change-1",+ ObservedAt: time.Now().Add(-time.Hour),+ ResourceID: "vm-intel",+ Kind: ur.ChangeConfigUpdate,+ SourceType: ur.SourcePulseDiff,+ SourceAdapter: ur.AdapterOpsAgent,+ Reason: "Config refresh",+ }); err != nil {+ t.Fatalf("record canonical change: %v", err)+ }+ svc.resourceExportStore = canonicalStore+ svc.resourceExportStoreOrgID = "org-1"++ ps := NewPatrolService(svc, nil)ps.stateProvider = &mockStateProvider{}intel := ps.GetIntelligence()@@ -994,6 +1011,10 @@ func TestPatrolService_GetIntelligence(t *testing.T) {if intel != ps.GetIntelligence() {t.Fatal("Expected GetIntelligence to return cached instance")}+ summary := intel.GetSummary()+ if summary.RecentChangesCount != 1 {+ t.Fatalf("expected canonical timeline count, got %d", summary.RecentChangesCount)+ }}func TestPatrolService_Stop(t *testing.T) {