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 timelines in incident context
rcourtman27dc24b6fd3a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 2cd8b49d4b..94f8c1ae4b 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -139,6 +139,10 @@ context should come from the shared resource store first so AI prompts reflectthe same change record that powers the resource API, with patrol-local changedetectors only serving as fallback coverage when the canonical store is notavailable.+Resource-only incident context should follow the same rule: if an alert+timeline is absent, the incident prompt path should fall back to the canonical+unified-resource timeline rather than depending only on patrol-local change+memory.The same runtime boundary now also owns durable action execution auditing.`internal/ai/chat/service.go` initializes the unified-resource audit store ondiff --git a/internal/ai/coverage_increase_test.go b/internal/ai/coverage_increase_test.goindex ad4c3f7f19..96777c80cf 100644--- a/internal/ai/coverage_increase_test.go+++ b/internal/ai/coverage_increase_test.go@@ -419,7 +419,48 @@ func TestService_BuildIncidentContext(t *testing.T) {t.Logf("Resource context: %s", ctx)}- // Case 4: both empty+ // Case 4: canonical resource timeline fallback+ canonicalStore := unifiedresources.NewMemoryStore()+ if err := canonicalStore.RecordChange(unifiedresources.ResourceChange{+ ID: "change-incident-1",+ ObservedAt: time.Now().Add(-time.Hour),+ ResourceID: "res1",+ Kind: unifiedresources.ChangeConfigUpdate,+ From: "old",+ To: "new",+ SourceType: unifiedresources.SourcePulseDiff,+ SourceAdapter: unifiedresources.AdapterOpsAgent,+ Confidence: unifiedresources.ConfidenceMedium,+ RelatedResources: []string{"related-1"},+ Reason: "Config refresh",+ }); err != nil {+ t.Fatalf("record canonical change: %v", err)+ }+ s.mu.Lock()+ s.orgID = "org-1"+ s.resourceExportStore = canonicalStore+ s.resourceExportStoreOrgID = s.orgID+ s.mu.Unlock()++ ctx = s.buildIncidentContext("res1", "")+ if !strings.Contains(ctx, "Recent Changes") {+ t.Fatalf("expected canonical recent changes in incident context, got %q", ctx)+ }+ if !strings.Contains(ctx, "Config update") {+ t.Fatalf("expected canonical change kind in incident context, got %q", ctx)+ }+ if !strings.Contains(ctx, "agent:ops-helper") {+ t.Fatalf("expected canonical adapter provenance in incident context, got %q", ctx)+ }+ if !strings.Contains(ctx, "related-1") {+ t.Fatalf("expected canonical related resource in incident context, got %q", ctx)+ }+ s.mu.Lock()+ s.resourceExportStore = nil+ s.resourceExportStoreOrgID = ""+ s.mu.Unlock()++ // Case 5: both emptyctx = s.buildIncidentContext("", "")if ctx != "" {t.Error("Expected empty context when both IDs are empty")diff --git a/internal/ai/service.go b/internal/ai/service.goindex 157a88b3f0..4b0cb8d7c4 100644--- a/internal/ai/service.go+++ b/internal/ai/service.go@@ -4494,17 +4494,30 @@ func (s *Service) buildIncidentContext(resourceID, alertIdentifier string) strinstore := s.incidentStores.mu.RUnlock()- if store == nil {- return ""+ var sections []string++ if store != nil {+ if alertIdentifier != "" {+ if text := store.FormatForAlert(alertIdentifier, 8); text != "" {+ sections = append(sections, text)+ }+ } else if resourceID != "" {+ if text := store.FormatForResource(resourceID, 4); text != "" {+ sections = append(sections, text)+ }+ }}- if alertIdentifier != "" {- return store.FormatForAlert(alertIdentifier, 8)+ if alertIdentifier == "" && resourceID != "" {+ if recentChanges := s.buildRecentResourceChangesContext(resourceID); recentChanges != "" {+ sections = append(sections, recentChanges)+ }}- if resourceID != "" {- return store.FormatForResource(resourceID, 4)++ if len(sections) == 0 {+ return ""}- return ""+ return strings.Join(sections, "")}// RecordIncidentAnalysis stores an AI analysis event for an alert.