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.

persist remind_at and remind_count on will_fix_later findings

rcourtman183bf5b617ad
diff --git a/internal/ai/findings.go b/internal/ai/findings.go
index 4dba20225e..814306b5e0 100644
--- a/internal/ai/findings.go
+++ b/internal/ai/findings.go
@@ -186,6 +186,12 @@ type Finding struct {
// "you said you'd fix this on <date>, it's still happening." Only
// populated for reason == "will_fix_later".
RemindAt *time.Time `json:"remind_at,omitempty"`
+ // RemindCount counts how many times a will_fix_later commitment has
+ // surfaced past its RemindAt deadline. Incremented next to each
+ // "reminded" lifecycle event (both the re-detection path and the
+ // proactive sweep). Survives the clear of RemindAt so the curator UI
+ // can show "reminded 3x".
+ RemindCount int `json:"remind_count,omitempty"`
// Investigation fields - tracks autonomous AI investigation of findings
InvestigationSessionID string `json:"investigation_session_id,omitempty"` // Chat session ID if being investigated
@@ -230,6 +236,7 @@ type findingJSON struct {
TimesRaised int `json:"times_raised"`
Suppressed bool `json:"suppressed"`
RemindAt *time.Time `json:"remind_at,omitempty"`
+ RemindCount int `json:"remind_count,omitempty"`
InvestigationSessionID string `json:"investigation_session_id,omitempty"`
InvestigationStatus string `json:"investigation_status,omitempty"`
InvestigationOutcome string `json:"investigation_outcome,omitempty"`
@@ -274,6 +281,7 @@ func (f Finding) MarshalJSON() ([]byte, error) {
TimesRaised: f.TimesRaised,
Suppressed: f.Suppressed,
RemindAt: f.RemindAt,
+ RemindCount: f.RemindCount,
InvestigationSessionID: f.InvestigationSessionID,
InvestigationStatus: f.InvestigationStatus,
InvestigationOutcome: f.InvestigationOutcome,
@@ -323,6 +331,7 @@ func (f *Finding) UnmarshalJSON(data []byte) error {
TimesRaised: payload.TimesRaised,
Suppressed: payload.Suppressed,
RemindAt: payload.RemindAt,
+ RemindCount: payload.RemindCount,
InvestigationSessionID: payload.InvestigationSessionID,
InvestigationStatus: payload.InvestigationStatus,
InvestigationOutcome: payload.InvestigationOutcome,
@@ -1354,6 +1363,7 @@ func (s *FindingsStore) Add(f *Finding) bool {
if prevRemindAt != nil {
meta["remind_at"] = prevRemindAt.Format(time.RFC3339)
}
+ existing.RemindCount++
s.appendLifecycleLocked(existing, "reminded", "will_fix_later remind-at deadline passed; re-surfacing finding", string(FindingLoopStateDismissed), string(FindingLoopStateDetected), meta)
}
if operatorStateLifted {
diff --git a/internal/ai/findings_persistence.go b/internal/ai/findings_persistence.go
index 91e6a98368..28eb09bb9e 100644
--- a/internal/ai/findings_persistence.go
+++ b/internal/ai/findings_persistence.go
@@ -62,6 +62,8 @@ func findingsToRecords(findings map[string]*Finding) map[string]*config.AIFindin
UserNote: f.UserNote,
TimesRaised: f.TimesRaised,
Suppressed: f.Suppressed,
+ RemindAt: f.RemindAt,
+ RemindCount: f.RemindCount,
// Investigation fields
InvestigationSessionID: f.InvestigationSessionID,
InvestigationStatus: f.InvestigationStatus,
@@ -119,6 +121,8 @@ func recordsToFindings(records map[string]*config.AIFindingRecord) map[string]*F
UserNote: r.UserNote,
TimesRaised: r.TimesRaised,
Suppressed: r.Suppressed,
+ RemindAt: r.RemindAt,
+ RemindCount: r.RemindCount,
// Investigation fields
InvestigationSessionID: r.InvestigationSessionID,
InvestigationStatus: r.InvestigationStatus,
diff --git a/internal/ai/findings_remind_persistence_test.go b/internal/ai/findings_remind_persistence_test.go
new file mode 100644
index 0000000000..a290716490
--- /dev/null
+++ b/internal/ai/findings_remind_persistence_test.go
@@ -0,0 +1,69 @@
+package ai
+
+import (
+ "testing"
+ "time"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+)
+
+// TestFindingsPersistenceAdapter_PreservesRemindAt locks the will_fix_later
+// commitment loop's persistence: RemindAt and RemindCount must survive a
+// save/load cycle. Before this guard, RemindAt was dropped on the floor at
+// persistence time, so every restart silently forgot every operator
+// "fix later" promise and the deadline never re-surfaced the finding.
+func TestFindingsPersistenceAdapter_PreservesRemindAt(t *testing.T) {
+ tmp := t.TempDir()
+ persistence := config.NewConfigPersistence(tmp)
+ adapter := NewFindingsPersistenceAdapter(persistence)
+
+ now := time.Now().UTC().Truncate(time.Second)
+ remindAt := now.Add(72 * time.Hour)
+
+ original := &Finding{
+ ID: "finding-will-fix-1",
+ Key: "storage-growth-high",
+ Severity: FindingSeverityWarning,
+ Category: FindingCategoryCapacity,
+ ResourceID: "node1-storage",
+ ResourceName: "tank",
+ ResourceType: "storage",
+ Node: "node1",
+ Title: "Storage growth trending toward full",
+ Description: "Pool tank approaching threshold",
+ Source: "ai-analysis",
+ DetectedAt: now.Add(-2 * time.Hour),
+ LastSeenAt: now,
+ DismissedReason: DismissReasonWillFixLater,
+ UserNote: "Will run cleanup playbook next maintenance window",
+ TimesRaised: 1,
+ RemindAt: &remindAt,
+ RemindCount: 2,
+ }
+
+ if err := adapter.SaveFindings(map[string]*Finding{original.ID: original}); err != nil {
+ t.Fatalf("save: %v", err)
+ }
+
+ loaded, err := adapter.LoadFindings()
+ if err != nil {
+ t.Fatalf("load: %v", err)
+ }
+
+ got := loaded[original.ID]
+ if got == nil {
+ t.Fatalf("finding %q not found after load", original.ID)
+ }
+ if got.DismissedReason != DismissReasonWillFixLater {
+ t.Errorf("DismissedReason: got %q, want %q", got.DismissedReason, DismissReasonWillFixLater)
+ }
+ if got.RemindAt == nil {
+ t.Fatal("RemindAt was dropped on persistence roundtrip")
+ }
+ if !got.RemindAt.Equal(remindAt) {
+ t.Errorf("RemindAt mismatch: got %v, want %v", got.RemindAt, remindAt)
+ }
+ if got.RemindCount != 2 {
+ t.Errorf("RemindCount mismatch: got %d, want 2", got.RemindCount)
+ }
+}
diff --git a/internal/config/persistence.go b/internal/config/persistence.go
index 47fe76bbc8..eabee56308 100644
--- a/internal/config/persistence.go
+++ b/internal/config/persistence.go
@@ -2231,10 +2231,12 @@ type AIFindingRecord struct {
SnoozedUntil *time.Time `json:"snoozed_until,omitempty"`
AlertIdentifier string `json:"-"`
// User feedback fields - enables persistence of dismissal state
- DismissedReason string `json:"dismissed_reason,omitempty"`
- UserNote string `json:"user_note,omitempty"`
- TimesRaised int `json:"times_raised"`
- Suppressed bool `json:"suppressed"`
+ DismissedReason string `json:"dismissed_reason,omitempty"`
+ UserNote string `json:"user_note,omitempty"`
+ TimesRaised int `json:"times_raised"`
+ Suppressed bool `json:"suppressed"`
+ RemindAt *time.Time `json:"remind_at,omitempty"`
+ RemindCount int `json:"remind_count,omitempty"`
// Investigation fields - tracks autonomous AI investigation of findings
InvestigationSessionID string `json:"investigation_session_id,omitempty"`