Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Keep Patrol service findings out of deleted-resource reconciliation

rcourtman4b8875e9caf6
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 3e9af7538f..c7c6451990 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -493,6 +493,13 @@ The Patrol startup scheduler must preserve that coverage guarantee as well:
`internal/ai/patrol_run.go` may skip the startup full patrol only when recent
run history already includes a successful full Patrol run, not merely because
some recent scoped alert-triggered run exists.
+The Patrol runtime also owns synthetic Patrol service findings canonically.
+Provider-credit and provider-auth failures raised against the synthetic
+`ai-service` Patrol resource are runtime conditions, not inventory resources,
+so the full-run seed/reconcile path must not auto-resolve them as
+`Resource no longer exists in infrastructure` just because `ai-service` is not
+present in the infrastructure snapshot. Those findings stay active until
+Patrol actually succeeds or resolves them for a Patrol-owned reason.
AI chat tool-name labels, pending-tool headers, and assistant status copy now
also route through the shared frontend identifier-label helper, so the chat
surfaces do not keep their own underscore-stripping behavior separate from
diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.go
index 450a2ed6fa..0ffde25fc5 100644
--- a/internal/ai/patrol_ai.go
+++ b/internal/ai/patrol_ai.go
@@ -3297,6 +3297,10 @@ func (p *PatrolService) seedIntelligenceContext(intel seedIntelligence, now time
return sb.String()
}
+func patrolFindingUsesSyntheticRuntimeResource(f *Finding) bool {
+ return f != nil && (f.Key == "ai-patrol-error" || f.ResourceID == "ai-service")
+}
+
// seedFindingsAndContext builds the thresholds, active findings, dismissed findings, and user notes sections.
func (p *PatrolService) seedFindingsAndContextState(scope *PatrolScope, snap patrolRuntimeState) (string, []string) {
var sb strings.Builder
@@ -3327,8 +3331,9 @@ func (p *PatrolService) seedFindingsAndContextState(scope *PatrolScope, snap pat
sb.WriteString("# Active Findings to Re-check\n")
sb.WriteString("Verify whether these findings are still valid. Resolve any that are no longer issues.\n\n")
for _, f := range activeFindings {
- inScopedState := !stateHasScopedResources || scopedResources[f.ResourceID] || scopedResources[f.ResourceName]
- inGlobalState := !stateHasGlobalResources || globalResources[f.ResourceID] || globalResources[f.ResourceName]
+ usesSyntheticRuntimeResource := patrolFindingUsesSyntheticRuntimeResource(f)
+ inScopedState := usesSyntheticRuntimeResource || !stateHasScopedResources || scopedResources[f.ResourceID] || scopedResources[f.ResourceName]
+ inGlobalState := usesSyntheticRuntimeResource || !stateHasGlobalResources || globalResources[f.ResourceID] || globalResources[f.ResourceName]
// Auto-resolve findings only when the resource is gone from the full current state.
// Scoped patrols should skip out-of-scope findings, not resolve them as deleted.
diff --git a/internal/ai/patrol_ai_intelligence_test.go b/internal/ai/patrol_ai_intelligence_test.go
index 2574c48916..9ccde3d8e2 100644
--- a/internal/ai/patrol_ai_intelligence_test.go
+++ b/internal/ai/patrol_ai_intelligence_test.go
@@ -655,6 +655,44 @@ func TestSeedFindingsAndContext_ScopedPatrolSkipsOutOfScopeFindingsWithoutResolv
}
}
+func TestSeedFindingsAndContext_KeepsSyntheticPatrolServiceFindings(t *testing.T) {
+ ps := NewPatrolService(nil, nil)
+
+ serviceFinding := &Finding{
+ ID: generateFindingID("ai-service", "reliability", "ai-patrol-error"),
+ Key: "ai-patrol-error",
+ ResourceID: "ai-service",
+ ResourceName: "Pulse Patrol Service",
+ ResourceType: "service",
+ Title: "Pulse Patrol: Insufficient API credits",
+ Severity: FindingSeverityWarning,
+ Category: FindingCategoryReliability,
+ DetectedAt: time.Now().Add(-2 * time.Hour),
+ LastSeenAt: time.Now().Add(-time.Hour),
+ }
+ ps.findings.Add(serviceFinding)
+
+ node1 := ur.NewNodeView(&ur.Resource{ID: "node-1", Name: "node-1"})
+ ps.SetReadState(&mockReadState{nodes: []*ur.NodeView{&node1}})
+
+ runtime := newPatrolRuntimeState(models.StateSnapshot{
+ Nodes: []models.Node{{ID: "node-1", Name: "node-1"}},
+ })
+ runtime.readState = &mockReadState{nodes: []*ur.NodeView{&node1}}
+
+ output, seeded := ps.seedFindingsAndContextState(&PatrolScope{ResourceIDs: []string{"node-1"}}, runtime)
+
+ if serviceFinding.ResolvedAt != nil {
+ t.Fatalf("expected synthetic Patrol service finding to remain active, got resolved at %v", serviceFinding.ResolvedAt)
+ }
+ if len(seeded) != 1 || seeded[0] != serviceFinding.ID {
+ t.Fatalf("expected synthetic Patrol service finding to stay seeded, got %v", seeded)
+ }
+ if !strings.Contains(output, serviceFinding.Title) {
+ t.Fatalf("expected synthetic Patrol service finding in output, got: %s", output)
+ }
+}
+
func TestSeedFindingsAndContext_ScopedPatrolWithoutRuntimeResourcesOmitsGlobalKnowledge(t *testing.T) {
ps := NewPatrolService(nil, nil)