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.

feat(ai): Wire operational memory into router startup

rcourtmanc63d7828a0fd
diff --git a/internal/ai/service.go b/internal/ai/service.go
index 8f2fde9191..246c2c81c4 100644
--- a/internal/ai/service.go
+++ b/internal/ai/service.go
@@ -219,6 +219,28 @@ func (s *Service) SetBaselineStore(store *BaselineStore) {
}
}
+// SetChangeDetector sets the change detector for operational memory
+func (s *Service) SetChangeDetector(detector *ChangeDetector) {
+ s.mu.RLock()
+ patrol := s.patrolService
+ s.mu.RUnlock()
+
+ if patrol != nil {
+ patrol.SetChangeDetector(detector)
+ }
+}
+
+// SetRemediationLog sets the remediation log for tracking fix attempts
+func (s *Service) SetRemediationLog(remLog *RemediationLog) {
+ s.mu.RLock()
+ patrol := s.patrolService
+ s.mu.RUnlock()
+
+ if patrol != nil {
+ patrol.SetRemediationLog(remLog)
+ }
+}
+
// StartPatrol starts the background patrol service
func (s *Service) StartPatrol(ctx context.Context) {
s.mu.RLock()
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 93761dd1cf..60cf3f12e6 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -105,6 +105,16 @@ func (h *AISettingsHandler) SetBaselineStore(store *ai.BaselineStore) {
h.aiService.SetBaselineStore(store)
}
+// SetChangeDetector sets the change detector for operational memory
+func (h *AISettingsHandler) SetChangeDetector(detector *ai.ChangeDetector) {
+ h.aiService.SetChangeDetector(detector)
+}
+
+// SetRemediationLog sets the remediation log for tracking fix attempts
+func (h *AISettingsHandler) SetRemediationLog(remLog *ai.RemediationLog) {
+ h.aiService.SetRemediationLog(remLog)
+}
+
// StopPatrol stops the background AI patrol service
func (h *AISettingsHandler) StopPatrol() {
h.aiService.StopPatrol()
diff --git a/internal/api/router.go b/internal/api/router.go
index dd5182f415..c035596993 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1436,6 +1436,28 @@ func (r *Router) StartPatrol(ctx context.Context) {
}
}
}
+
+ // Initialize operational memory (change detection and remediation logging)
+ dataDir := ""
+ if r.persistence != nil {
+ dataDir = r.persistence.DataDir()
+ }
+
+ changeDetector := ai.NewChangeDetector(ai.ChangeDetectorConfig{
+ MaxChanges: 1000,
+ DataDir: dataDir,
+ })
+ if changeDetector != nil {
+ r.aiSettingsHandler.SetChangeDetector(changeDetector)
+ }
+
+ remediationLog := ai.NewRemediationLog(ai.RemediationLogConfig{
+ MaxRecords: 500,
+ DataDir: dataDir,
+ })
+ if remediationLog != nil {
+ r.aiSettingsHandler.SetRemediationLog(remediationLog)
+ }
r.aiSettingsHandler.StartPatrol(ctx)
}