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
Auto-acknowledge new findings during operator-set maintenance windows
rcourtmancf2e61ea22a1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex a96162f0cb..f9f7cdc4ff 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -917,6 +917,15 @@ profile and assignment columns, but embedded table framing must route through## Current State+The findings runtime now consumes operator-set per-resource state+through a provider adapter wired in `internal/api/router.go` at+startup: when a resource is in an operator-set maintenance window,+new findings against it are auto-acknowledged at creation time so a+scheduled-maintenance window does not flood notifications during the+window. The agent runtime keeps the operator commitment honored across+restarts because the underlying state lives in the durable+`resource_operator_state` SQLite table.+The `/api/resources/{id}/operator-state` GET / PUT / DELETE handlers in`internal/api/resources_operator_state.go` are the canonical operatorsurface for setting per-resource intent (intentionally offline, neverdiff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 5495014aed..f5cf93ffdf 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -580,6 +580,19 @@ runtime cost control, and shared AI transport surfaces.## Current State+The findings store now consults a `ResourceOperatorStateProvider`+during the new-finding path. The interface lives in `internal/ai` to+avoid an import cycle with `internal/unifiedresources`; the API layer+wires the adapter at startup, projecting+`unified.ResourceOperatorState` into the narrow+`ActiveMaintenanceWindow` shape the findings runtime needs. When the+provider reports an active maintenance window, the new-finding path+auto-dismisses with reason `expected_behavior`, attributes the+suppression on the lifecycle timeline (`operator_state_cause:+maintenance_window`), and persists the finding for audit history.+Deployments without a provider keep the original new-finding behavior+— suppression is opt-in.+This subsystem now makes Pulse Assistant and Patrol backend runtime ownershipexplicit inside the current architecture lane instead of leaving thosesurfaces implicit inside broad architecture or generic API ownership. A laterdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 77069b6c9a..288b893ccf 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1343,6 +1343,16 @@ the canonical monitored-system blocked payload.## Current State+The router wires the operator-state adapter into the findings runtime+at startup: `internal/api/router.go` calls+`patrol.GetFindings().SetResourceOperatorStateProvider(...)` with a+`ResourceOperatorStateProviderFunc` closure that reads the unified+store and projects `state.IsInMaintenanceAt` into the+`ActiveMaintenanceWindow` shape `internal/ai` consumes. This keeps+`internal/ai` free of an `internal/unifiedresources` import while+giving the findings runtime per-resource maintenance suppression+without each org needing a separate adapter declaration.+`/api/resources/{id}/operator-state` is the canonical surface foroperator-set per-resource intent (intentionally offline, neverauto-remediate, maintenance window, criticality hint). GET requiresdiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 6816592818..e69317d1e1 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -1175,3 +1175,17 @@ and Explain entry points. Investigation evidence and rollback plansare intentionally omitted from the clipboard shape — those areconversation context for the Assistant flow, not "share thisfinding" context for chat or tickets.+The findings store also consumes per-resource operator-set state via+the narrow `ResourceOperatorStateProvider` interface installed by+`SetResourceOperatorStateProvider`. The API layer wires an adapter+that projects `unified.ResourceOperatorState` into the+`ActiveMaintenanceWindow` projection so `internal/ai` does not need+to import `internal/unifiedresources`. When a new finding is raised+against a resource currently in an operator-set maintenance window,+the new-finding path auto-dismisses it as `expected_behavior`,+populates `AcknowledgedAt`, writes a `UserNote` naming the window+and reason, and emits a `dismissed` lifecycle event with the+`operator_state_cause: maintenance_window` metadata so the timeline+can attribute the suppression to its source. Default deployments+without a provider behave identically to before — operator-state+suppression is opt-in.diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex f41248a677..740d7ff082 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -506,6 +506,14 @@ shell clickable behind another overlay.## Current State+The new-finding hot path now consults a per-resource operator-state+provider when one is wired (slice 31). The provider call is gated on+`f.ResourceID != ""` and a non-nil provider so deployments without+the feature wired pay no extra work; the provider implementation+itself is a single SQLite point lookup keyed on `canonical_id`, no+join, no scan. Maintenance-window suppression therefore adds at most+one read per new finding, not per existing-finding update.+Summary cards for Infrastructure, Storage, Workloads, and Recovery now surfacehealth-state counts (offline, degraded, alerting) instead of raw online/offlinesplits. `InfrastructureSummary.tsx` and `infrastructureSummaryModel.ts` adddiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex a7e9c32b17..0febf8ec36 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -947,6 +947,12 @@ bypass the API fail-closed execution gate.## Current State+The findings runtime reads operator-set state through the same+durable `resource_operator_state` SQLite table on every+new-finding-add. A maintenance window persisted before a process+restart still suppresses new findings after the agent reloads — the+operator commitment survives without needing a re-entry on startup.+The `resource_operator_state` SQLite table introduced by theunified-resources store keeps operator-set per-resource intent(intentionally offline, never auto-remediate, maintenance window,diff --git a/internal/ai/findings.go b/internal/ai/findings.goindex 67c58734a1..5358f41e41 100644--- a/internal/ai/findings.go+++ b/internal/ai/findings.go@@ -664,6 +664,46 @@ type FindingsStore struct {lastSaveError error // Last error from save operationonSaveError func(err error) // Optional callback for save errorslastSaveTime time.Time // Last successful save time+ // Optional resource-operator-state provider — when set, the store+ // consults it during Add for per-resource maintenance windows and+ // other operator-set intent, auto-acknowledging new findings whose+ // resource is in a maintenance window. Nil-safe; an unset provider+ // disables operator-state-driven suppression.+ resourceOperatorStateProvider ResourceOperatorStateProvider+}++// ResourceOperatorStateMaintenanceWindow describes the maintenance+// window an operator set on a resource. The findings store consults+// this through ResourceOperatorStateProvider; the package layout puts+// the canonical type in `internal/unifiedresources` to avoid an import+// cycle, so this is the projected shape the findings runtime needs.+type ResourceOperatorStateMaintenanceWindow struct {+ StartAt time.Time+ EndAt time.Time+ Reason string+}++// ResourceOperatorStateProvider is the narrow interface the findings+// store consumes for per-resource operator intent. Implementations+// adapt the unified-resources `ResourceOperatorState` shape into the+// projection that the findings runtime needs (currently just the+// active maintenance window). Returning ok=false means "no active+// operator state for this resource" and the store falls through to+// the default new-finding path.+type ResourceOperatorStateProvider interface {+ ActiveMaintenanceWindow(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool)+}++// ResourceOperatorStateProviderFunc is a function adapter so wire-up+// code in the API layer can pass a closure without declaring a struct.+type ResourceOperatorStateProviderFunc func(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool)++// ActiveMaintenanceWindow implements ResourceOperatorStateProvider.+func (f ResourceOperatorStateProviderFunc) ActiveMaintenanceWindow(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {+ if f == nil {+ return ResourceOperatorStateMaintenanceWindow{}, false+ }+ return f(canonicalID, now)}// NewFindingsStore creates a new findings store@@ -677,6 +717,17 @@ func NewFindingsStore() *FindingsStore {}}+// SetResourceOperatorStateProvider installs the per-resource+// operator-state provider that the findings store consults during Add.+// Wired by the API layer at startup so the store can stay in+// `internal/ai` without importing `internal/unifiedresources`. Pass+// nil to disable operator-state-driven suppression (the default).+func (s *FindingsStore) SetResourceOperatorStateProvider(p ResourceOperatorStateProvider) {+ s.mu.Lock()+ defer s.mu.Unlock()+ s.resourceOperatorStateProvider = p+}+// SetPersistence sets the persistence layer and loads existing findingsfunc (s *FindingsStore) SetPersistence(p FindingsPersistence) error {s.mu.Lock()@@ -1115,6 +1166,32 @@ func (s *FindingsStore) Add(f *Finding) bool {s.syncLoopStateLocked(f)s.appendLifecycleLocked(f, "detected", "Detected by Pulse Patrol", "", f.LoopState, nil)+ // Operator-state suppression: when the resource is currently in a+ // maintenance window the operator set, auto-dismiss the finding as+ // expected_behavior with a reason that names the window. The+ // finding still lands in durable history (so the operator can+ // audit what tripped during the window) but does not surface as+ // active. Severity escalation paths still wake it later if the+ // underlying condition stays after the window closes.+ if provider := s.resourceOperatorStateProvider; provider != nil && f.ResourceID != "" {+ if window, ok := provider.ActiveMaintenanceWindow(f.ResourceID, time.Now()); ok {+ now := time.Now()+ f.DismissedReason = "expected_behavior"+ f.AcknowledgedAt = &now+ noteParts := []string{fmt.Sprintf("Resource is in operator-set maintenance window until %s.", window.EndAt.Format(time.RFC3339))}+ if reason := strings.TrimSpace(window.Reason); reason != "" {+ noteParts = append(noteParts, "Reason: "+reason)+ }+ f.UserNote = strings.Join(noteParts, " ")+ s.appendLifecycleLocked(f, "dismissed", "Auto-acknowledged: resource in maintenance window", f.LoopState, string(FindingLoopStateDismissed), map[string]string{+ "reason": "expected_behavior",+ "operator_state_cause": "maintenance_window",+ "maintenance_end_at": window.EndAt.Format(time.RFC3339),+ })+ s.syncLoopStateLocked(f)+ }+ }+s.findings[f.ID] = fs.byResource[f.ResourceID] = append(s.byResource[f.ResourceID], f.ID)if f.IsActive() {diff --git a/internal/ai/findings_test.go b/internal/ai/findings_test.goindex 2a639e184c..ea1336f4ce 100644--- a/internal/ai/findings_test.go+++ b/internal/ai/findings_test.go@@ -1609,3 +1609,114 @@ func TestFinding_RemindAt_RoundTripsThroughJSON(t *testing.T) {t.Errorf("RemindAt round-trip mismatch: got %v want %v", roundTripped.RemindAt, when)}}++func TestFindingsStore_Add_AutoAcknowledgesDuringMaintenanceWindow(t *testing.T) {+ // When the operator has set a maintenance window covering the+ // finding's resource, the new-finding path must auto-dismiss the+ // finding with reason "expected_behavior" and record a lifecycle+ // event naming the maintenance window. The finding still lands in+ // durable history (so the operator can audit what tripped during+ // the window) but does not surface as active.+ store := NewFindingsStore()+ now := time.Now()+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, queriedAt time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {+ if canonicalID != "vm:101" {+ return ResourceOperatorStateMaintenanceWindow{}, false+ }+ return ResourceOperatorStateMaintenanceWindow{+ StartAt: now.Add(-time.Hour),+ EndAt: now.Add(time.Hour),+ Reason: "Q3 storage upgrade",+ }, true+ })+ store.SetResourceOperatorStateProvider(provider)++ store.Add(&Finding{+ ID: "f1",+ ResourceID: "vm:101",+ Severity: FindingSeverityWarning,+ Title: "CPU saturated",+ })++ got := store.Get("f1")+ if got == nil {+ t.Fatal("finding must be persisted even when auto-dismissed; durable history matters")+ }+ if got.DismissedReason != "expected_behavior" {+ t.Errorf("expected DismissedReason=expected_behavior; got %q", got.DismissedReason)+ }+ if got.AcknowledgedAt == nil {+ t.Error("AcknowledgedAt must be populated for auto-dismissed findings")+ }+ if !strings.Contains(got.UserNote, "operator-set maintenance window") {+ t.Errorf("UserNote should explain the maintenance suppression; got %q", got.UserNote)+ }+ if !strings.Contains(got.UserNote, "Q3 storage upgrade") {+ t.Errorf("UserNote should include the operator's reason; got %q", got.UserNote)+ }+ // Lifecycle must record the auto-dismiss with the canonical+ // operator_state_cause metadata so the timeline can attribute the+ // suppression to its source.+ foundMaintenanceEvent := false+ for _, ev := range got.Lifecycle {+ if ev.Type == "dismissed" && ev.Metadata["operator_state_cause"] == "maintenance_window" {+ foundMaintenanceEvent = true+ break+ }+ }+ if !foundMaintenanceEvent {+ t.Error("expected a 'dismissed' lifecycle event with operator_state_cause=maintenance_window")+ }+}++func TestFindingsStore_Add_DoesNotAutoAcknowledgeOutsideMaintenanceWindow(t *testing.T) {+ // A provider that reports no active window must not affect the+ // new-finding default path — the finding lands as active. Pin this+ // so the suppression branch can't drift into "always suppress when+ // provider is set".+ store := NewFindingsStore()+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {+ return ResourceOperatorStateMaintenanceWindow{}, false+ })+ store.SetResourceOperatorStateProvider(provider)++ store.Add(&Finding{+ ID: "f-active",+ ResourceID: "vm:101",+ Severity: FindingSeverityWarning,+ Title: "CPU saturated",+ })++ got := store.Get("f-active")+ if got == nil {+ t.Fatal("expected finding to be persisted")+ }+ if got.DismissedReason != "" {+ t.Errorf("finding must remain active when provider reports no window; got DismissedReason=%q", got.DismissedReason)+ }+ if !got.IsActive() {+ t.Error("finding must report IsActive=true outside maintenance windows")+ }+}++func TestFindingsStore_Add_OperatorStateSuppressionIsOptIn(t *testing.T) {+ // The default store (no provider wired) must behave exactly as+ // before — slice 31 must not regress the existing new-finding+ // path for any deployment that hasn't opted in to the+ // operator-state feature yet.+ store := NewFindingsStore()+ store.Add(&Finding{+ ID: "f-default",+ ResourceID: "vm:101",+ Severity: FindingSeverityWarning,+ Title: "CPU saturated",+ })++ got := store.Get("f-default")+ if got == nil {+ t.Fatal("expected finding to be persisted on default store")+ }+ if got.DismissedReason != "" {+ t.Errorf("default-store finding must remain active; got DismissedReason=%q", got.DismissedReason)+ }+}diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex d43e310e86..aacf439759 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -13233,6 +13233,35 @@ func assertJSONSnapshot(t *testing.T, got []byte, want string) {}}+// TestContract_FindingsResourceOperatorStateProviderIsWired pins the+// startup wiring that gives the findings runtime access to+// per-resource operator-set state via the API layer's adapter. The+// router must call SetResourceOperatorStateProvider with a closure+// that reads the unified store's GetResourceOperatorState and+// projects IsInMaintenanceAt into the ActiveMaintenanceWindow shape;+// regressions here would silently disable maintenance-window+// auto-acknowledgement without breaking any unit tests because the+// behavior is opt-in.+func TestContract_FindingsResourceOperatorStateProviderIsWired(t *testing.T) {+ source, err := os.ReadFile("router.go")+ if err != nil {+ t.Fatalf("read router.go: %v", err)+ }+ src := string(source)+ if !strings.Contains(src, "SetResourceOperatorStateProvider(") {+ t.Error("router.go must call SetResourceOperatorStateProvider on the findings store at startup")+ }+ if !strings.Contains(src, "ResourceOperatorStateProviderFunc(") {+ t.Error("router.go must use the ai.ResourceOperatorStateProviderFunc adapter so the closure satisfies the provider interface")+ }+ if !strings.Contains(src, "IsInMaintenanceAt(now)") {+ t.Error("router.go must gate the projection on state.IsInMaintenanceAt so a stale window does not return as active")+ }+ if !strings.Contains(src, "GetResourceOperatorState(canonicalID)") {+ t.Error("router.go must read state from the unified store's canonical accessor")+ }+}+// TestContract_ResourceOperatorStateUrlCanonicalIDWinsOverBody pins the// security-relevant decision that the URL path's canonical_id always// wins over any body-supplied value on PUTdiff --git a/internal/api/router.go b/internal/api/router.goindex ff66b3cbc7..b0c8e3b079 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -1750,6 +1750,36 @@ func (r *Router) startPatrolForContext(ctx context.Context, orgID string) bool {patrol.SetUnifiedFindingResolver(func(findingID string) {unifiedStore.Resolve(findingID)})+ // Wire per-resource operator-state into the findings runtime so+ // new findings raised against a resource currently in a+ // maintenance window get auto-acknowledged with reason+ // "expected_behavior". The adapter projects+ // `unified.ResourceOperatorState` into the narrow+ // `ResourceOperatorStateProvider` shape the findings store+ // consumes — keeps `internal/ai` clear of an+ // `internal/unifiedresources` import.+ patrol.GetFindings().SetResourceOperatorStateProvider(+ ai.ResourceOperatorStateProviderFunc(+ func(canonicalID string, now time.Time) (ai.ResourceOperatorStateMaintenanceWindow, bool) {+ orgStore, lookupErr := r.resourceHandlers.getStore(orgID)+ if lookupErr != nil {+ return ai.ResourceOperatorStateMaintenanceWindow{}, false+ }+ state, found, fetchErr := orgStore.GetResourceOperatorState(canonicalID)+ if fetchErr != nil || !found {+ return ai.ResourceOperatorStateMaintenanceWindow{}, false+ }+ if !state.IsInMaintenanceAt(now) {+ return ai.ResourceOperatorStateMaintenanceWindow{}, false+ }+ return ai.ResourceOperatorStateMaintenanceWindow{+ StartAt: *state.MaintenanceStartAt,+ EndAt: *state.MaintenanceEndAt,+ Reason: state.MaintenanceReason,+ }, true+ },+ ),+ )// Wire push notifications: patrol findings → relay client (best-effort)patrol.SetPushNotifyCallback(func(n relay.PushNotificationPayload) {