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.

wire update-safety watcher into PatrolService and seed demo

rcourtman5821b6c810b4
diff --git a/internal/ai/demo.go b/internal/ai/demo.go
index b425a1e447..08fd80b4f4 100644
--- a/internal/ai/demo.go
+++ b/internal/ai/demo.go
@@ -142,6 +142,23 @@ func (p *PatrolService) InjectDemoFindings() {
TimesRaised: 3,
Source: "patrol",
},
+ {
+ ID: "demo-update-safety-warning",
+ Key: UpdateSafetyFindingPrefix + ":docker-host-1/homeassistant",
+ Severity: FindingSeverityWarning,
+ Category: FindingCategoryReliability,
+ Title: "Container \"homeassistant\" image updated",
+ Description: "Image digest changed. Container homeassistant was updated to a new image and has restarted 2 times in the verification window.",
+ ResourceID: "docker-host-1/homeassistant",
+ ResourceName: "homeassistant",
+ ResourceType: "app-container",
+ Node: "docker-host-1",
+ Evidence: "prior_digest=sha256:abc123def456 new_digest=sha256:789xyz012uvw restart_count=2",
+ DetectedAt: now.Add(-3 * time.Minute),
+ LastSeenAt: now.Add(-1 * time.Minute),
+ TimesRaised: 2,
+ Source: updateSafetySource,
+ },
}
// Add findings to the store
diff --git a/internal/ai/demo_test.go b/internal/ai/demo_test.go
index a229e223c5..6ac4fd6b28 100644
--- a/internal/ai/demo_test.go
+++ b/internal/ai/demo_test.go
@@ -32,8 +32,8 @@ func TestPatrolService_InjectDemoFindings(t *testing.T) {
service.InjectDemoFindings()
findings := service.findings.GetAll(nil)
- if len(findings) != 5 {
- t.Fatalf("expected 5 demo findings, got %d", len(findings))
+ if len(findings) != 6 {
+ t.Fatalf("expected 6 demo findings, got %d", len(findings))
}
if service.runHistoryStore.Count() != 13 {
t.Fatalf("expected 13 demo run history entries, got %d", service.runHistoryStore.Count())
diff --git a/internal/ai/patrol.go b/internal/ai/patrol.go
index c3d4a4b1a0..65601b69b1 100644
--- a/internal/ai/patrol.go
+++ b/internal/ai/patrol.go
@@ -462,7 +462,8 @@ type PatrolService struct {
// same resource so a noisy host surfaces as one storm finding rather
// than several concurrent per-symptom rows. Owned for the service
// lifetime; in-memory only, no goroutine.
- stormThrottler *findingStormThrottler
+ stormThrottler *findingStormThrottler
+ updateSafetyWatcher *UpdateSafetyWatcher
// ReadState provides typed read-only views over resource state (VMs, nodes, hosts, etc.).
// This is injected separately from stateProvider since stateProvider also contains
// non-resource telemetry (alerts, backups, connection health) that isn't modeled as resources yet.
@@ -685,5 +686,6 @@ func NewPatrolService(aiService *Service, stateProvider StateProvider) *PatrolSe
// router seam.
p.stormThrottler = newFindingStormThrottler()
p.findings.SetStormThrottler(p.stormThrottler)
+ p.updateSafetyWatcher = newUpdateSafetyWatcher()
return p
}
diff --git a/internal/ai/patrol_run.go b/internal/ai/patrol_run.go
index edff0b8c47..2ea1591792 100644
--- a/internal/ai/patrol_run.go
+++ b/internal/ai/patrol_run.go
@@ -409,6 +409,20 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
runStats.trueNASChecked +
runStats.kubernetesChecked
+ // Run update-safety watcher on every patrol cycle regardless of LLM availability.
+ // Direct FindingsStore.Add bypasses push-notification (MVP: not an emergency).
+ if cfg.AnalyzeDocker && p.updateSafetyWatcher != nil {
+ updateEmit, updateResolve := p.updateSafetyWatcher.Observe(state.DockerHosts, time.Now())
+ for _, f := range updateEmit {
+ if !p.findings.Add(f) {
+ log.Debug().Str("finding_id", f.ID).Msg("AI Patrol: update-safety finding already in store")
+ }
+ }
+ for _, s := range updateResolve {
+ p.findings.ResolveWithReason(s.DedupKey, s.Reason)
+ }
+ }
+
// Determine if we can run LLM analysis (requires AI service + circuit breaker not open)
aiServiceEnabled := p.aiService != nil && p.aiService.IsEnabled()
canRunLLM := aiServiceEnabled && llmAllowed