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
Centralize root cause relationship model
rcourtman1b13ba999ef9
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex b6e1de58dd..4c2bd382bd 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -153,6 +153,10 @@ detectors only serving as fallback coverage when the canonical store is notavailable. When that patrol-local fallback is used, it must render through theshared memory change presentation helper so the same heading, scope prefix, andchange-type labels are reused instead of being rebuilt ad hoc in AI-local code.+The AI correlation root-cause engine also consumes the canonical unified-+resource relationship model directly, so cross-resource reasoning stays aligned+with the same graph edges that back the resource API instead of maintaining a+parallel relationship vocabulary inside AI correlation.AI-facing policy metadata must also be cloned through the shared unified-resource policy helper so chat and tools consumers do not maintain their ownpolicy copy logic. Chat mention prefetch now calls that shared helper directlydiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 126d4d419c..b37d72bb7e 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -440,6 +440,10 @@ The AI runtime now also uses the canonical policy presentation helpers tosurface those routing and redaction labels in shared context output, so thesame policy model is reflected in prompt summaries instead of beingre-described independently per surface.+The AI correlation root-cause engine also consumes the canonical unified-+resource relationship model directly, so graph reasoning and relationship+scoring stay on the same owned edge vocabulary instead of keeping a separate+AI-local relationship struct.Those helpers now own the canonical redaction-hint order and count-to-labelprojection, so the AI summary and any other backend policy posture surface donot re-sort redaction labels locally.diff --git a/internal/ai/correlation/rootcause.go b/internal/ai/correlation/rootcause.goindex cc52532e02..a668e145c4 100644--- a/internal/ai/correlation/rootcause.go+++ b/internal/ai/correlation/rootcause.go@@ -9,30 +9,25 @@ import ("strings""sync""time"++ unifiedresources "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")-// RelationshipType describes how resources are related-type RelationshipType string+// RelationshipType and ResourceRelationship are aliases to the canonical+// unified-resource graph model so root-cause correlation consumes the same+// edge vocabulary as the rest of the platform.+type RelationshipType = unifiedresources.RelationshipType++type ResourceRelationship = unifiedresources.ResourceRelationshipconst (- RelationshipRunsOn RelationshipType = "runs_on" // VM runs on Node- RelationshipUsesStorage RelationshipType = "uses_storage" // VM uses Storage- RelationshipUsesNetwork RelationshipType = "uses_network" // Guest uses Network- RelationshipContains RelationshipType = "contains" // Node contains VMs- RelationshipBackedBy RelationshipType = "backed_by" // Storage backed by disks- RelationshipHosted RelationshipType = "hosted" // Container hosted on Docker- RelationshipDepends RelationshipType = "depends_on" // Generic dependency+ RelationshipRunsOn = unifiedresources.RelRunsOn+ RelationshipDepends = unifiedresources.RelDependsOn+ RelationshipMountedTo = unifiedresources.RelMountedTo+ RelationshipExposedBy = unifiedresources.RelExposedBy+ RelationshipOwnedBy = unifiedresources.RelOwnedBy)-// ResourceRelationship describes a relationship between two resources-type ResourceRelationship struct {- SourceID string `json:"source_id"`- SourceType string `json:"source_type"`- TargetID string `json:"target_id"`- TargetType string `json:"target_type"`- Relationship RelationshipType `json:"relationship"`-}-// RelatedEvent represents an event on a related resourcetype RelatedEvent struct {ResourceID string `json:"resource_id"`@@ -245,19 +240,7 @@ func (e *RootCauseEngine) scoreAsRootCause(candidate *RelatedEvent, trigger Rela// Check if there's a direct relationshipfor _, rel := range relationships {if rel.SourceID == candidate.ResourceID || rel.TargetID == candidate.ResourceID {- // Strong relationship types- switch rel.Relationship {- case RelationshipRunsOn:- score += 0.4 // VM problems often caused by host- case RelationshipUsesStorage:- score += 0.35 // Storage issues propagate- case RelationshipBackedBy:- score += 0.3- case RelationshipContains:- score += 0.25- default:- score += 0.2- }+ score += relationshipScore(rel.Type)break}}@@ -292,6 +275,23 @@ func (e *RootCauseEngine) scoreAsRootCause(candidate *RelatedEvent, trigger Relareturn score}+func relationshipScore(t RelationshipType) float64 {+ switch t {+ case unifiedresources.RelRunsOn:+ return 0.4+ case unifiedresources.RelMountedTo:+ return 0.35+ case unifiedresources.RelDependsOn:+ return 0.3+ case unifiedresources.RelOwnedBy:+ return 0.25+ case unifiedresources.RelExposedBy:+ return 0.2+ default:+ return 0.2+ }+}+// buildCausalChain builds a chain of causation from root cause to triggerfunc (e *RootCauseEngine) buildCausalChain(rootCause *RelatedEvent, trigger RelatedEvent, related []RelatedEvent, relationships []ResourceRelationship) []string {chain := make([]string, 0)diff --git a/internal/ai/correlation/rootcause_additional_test.go b/internal/ai/correlation/rootcause_additional_test.goindex e8a4a1cec9..7ff526d9d3 100644--- a/internal/ai/correlation/rootcause_additional_test.go+++ b/internal/ai/correlation/rootcause_additional_test.go@@ -46,7 +46,7 @@ func TestRootCauseEngine_AnalyzeAndFormat(t *testing.T) {triggerTime := time.Now()topology := &stubTopologyProvider{relationships: []ResourceRelationship{- {SourceID: "node-1", TargetID: "vm-1", Relationship: RelationshipRunsOn},+ {SourceID: "node-1", TargetID: "vm-1", Type: RelationshipRunsOn},},types: map[string]string{"node-1": "node",@@ -115,7 +115,7 @@ func TestRootCauseEngine_ScoringAndHelpers(t *testing.T) {trigger := RelatedEvent{ResourceID: "vm-1", ResourceType: "vm", Metric: "cpu", Timestamp: time.Now()}candidate := RelatedEvent{ResourceID: "node-1", ResourceType: "node", Metric: "cpu", Timestamp: time.Now().Add(-30 * time.Second)}- relationships := []ResourceRelationship{{SourceID: "node-1", TargetID: "vm-1", Relationship: RelationshipRunsOn}}+ relationships := []ResourceRelationship{{SourceID: "node-1", TargetID: "vm-1", Type: RelationshipRunsOn}}score := engine.scoreAsRootCause(&candidate, trigger, relationships)if score <= 0 {diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.goindex d0fd5d4ee6..71c4c1d2a3 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -385,6 +385,26 @@ func TestExportDecisionHelpersCanonicalInUnifiedResources(t *testing.T) {}}+func TestRootCauseEngineUsesCanonicalRelationshipModel(t *testing.T) {+ data, err := os.ReadFile(filepath.Join("..", "ai", "correlation", "rootcause.go"))+ if err != nil {+ t.Fatalf("failed to read rootcause.go: %v", err)+ }+ source := string(data)+ requiredSnippets := []string{+ "type RelationshipType = unifiedresources.RelationshipType",+ "type ResourceRelationship = unifiedresources.ResourceRelationship",+ "GetRelationships(resourceID string) []ResourceRelationship",+ "score += relationshipScore(rel.Type)",+ "func relationshipScore(t RelationshipType) float64",+ }+ for _, snippet := range requiredSnippets {+ if !strings.Contains(source, snippet) {+ t.Fatalf("internal/ai/correlation/rootcause.go must pin canonical relationship snippet %q", snippet)+ }+ }+}+func TestResourceDisplayNameUsedByInfrastructureConsumers(t *testing.T) {requiredSnippets := map[string][]string{filepath.Join("..", "monitoring", "connected_infrastructure.go"): {