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.

Pin: operator-state-suppressed findings skip autonomous investigation

rcourtmanb822ef17e6d5
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index aa09f43353..f73eaa33d6 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -591,6 +591,19 @@ call (active maintenance window plus the `IntentionallyOffline`
flag) so adding new signals later does not multiply round-trips per
finding.
+A cross-slice consequence worth pinning: operator-state-suppressed
+findings (auto-dismissed with `DismissedReason="expected_behavior"`
+and `operator_state_cause` metadata) are also ineligible for
+autonomous investigation, because `Finding.ShouldInvestigate`
+already gates on `f.DismissedReason != ""`. Investigation budget is
+not spent on findings the operator has told Pulse to stay quiet
+about, regardless of autonomy level. This is delivered by the
+existing chain (Add → auto-dismiss → ShouldInvestigate-false)
+rather than a separate runtime check; the contract test in
+`findings_test.go` pins the relationship so a future refactor of
+either branch cannot silently waste investigation budget on
+operator-suppressed findings.
+
When the projection carries an active maintenance window, the
new-finding path auto-dismisses with reason `expected_behavior`,
attributes the suppression on the lifecycle timeline
diff --git a/internal/ai/findings_test.go b/internal/ai/findings_test.go
index 4030638e87..6e578ec3ee 100644
--- a/internal/ai/findings_test.go
+++ b/internal/ai/findings_test.go
@@ -1817,3 +1817,93 @@ func TestFindingsStore_Add_OperatorStateSuppressionIsOptIn(t *testing.T) {
t.Errorf("default-store finding must remain active; got DismissedReason=%q", got.DismissedReason)
}
}
+
+func TestFindingsStore_OperatorStateSuppressedFindingsDoNotTriggerInvestigation(t *testing.T) {
+ // Cross-slice contract: when slice 31/32's operator-state suppression
+ // fires (maintenance window or intentionally offline), the resulting
+ // auto-dismissed finding must also be ineligible for autonomous
+ // investigation. This is currently delivered by the chain
+ // findings.Add → DismissedReason="expected_behavior" → ShouldInvestigate
+ // returns false on the line `f.DismissedReason != ""` check, but the
+ // relationship is implicit. Pinning it here so a future refactor of
+ // either auto-dismiss or ShouldInvestigate cannot silently waste
+ // investigation budget on operator-suppressed findings.
+
+ cases := []struct {
+ name string
+ signal ResourceOperatorStateProjection
+ wantCause string
+ }{
+ {
+ name: "intentionally_offline",
+ signal: ResourceOperatorStateProjection{
+ IntentionallyOffline: true,
+ },
+ wantCause: "intentionally_offline",
+ },
+ {
+ name: "maintenance_window",
+ signal: ResourceOperatorStateProjection{
+ MaintenanceWindow: &ResourceOperatorStateMaintenanceWindow{
+ StartAt: time.Now().Add(-time.Hour),
+ EndAt: time.Now().Add(time.Hour),
+ },
+ },
+ wantCause: "maintenance_window",
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ store := NewFindingsStore()
+ signal := tc.signal // capture for closure
+ store.SetResourceOperatorStateProvider(
+ ResourceOperatorStateProviderFunc(func(_ string, _ time.Time) (ResourceOperatorStateProjection, bool) {
+ return signal, true
+ }),
+ )
+
+ store.Add(&Finding{
+ ID: "f-suppressed",
+ ResourceID: "vm:101",
+ Severity: FindingSeverityWarning,
+ Title: "CPU saturated",
+ })
+
+ got := store.Get("f-suppressed")
+ if got == nil {
+ t.Fatal("finding must be persisted even when auto-dismissed")
+ }
+ if got.DismissedReason != "expected_behavior" {
+ t.Fatalf("auto-dismiss must run; got DismissedReason=%q", got.DismissedReason)
+ }
+
+ // The cross-slice contract: an auto-dismissed finding must
+ // not be investigated. The autonomy level is irrelevant
+ // here — even at "full" autonomy, investigation must skip
+ // operator-suppressed findings because the operator has
+ // already told Pulse to stay quiet.
+ for _, autonomy := range []string{"approval", "assisted", "full"} {
+ if got.ShouldInvestigate(autonomy) {
+ t.Errorf("ShouldInvestigate(%q) must be false on operator-suppressed finding (cause=%s)", autonomy, tc.wantCause)
+ }
+ }
+
+ // Sanity-check the lifecycle attribution still names the cause
+ // — protects against the auto-dismiss branch silently changing
+ // to a generic 'dismissed' that other tooling might
+ // mis-categorize as operator-driven rather than operator-state
+ // driven.
+ foundCause := false
+ for _, ev := range got.Lifecycle {
+ if ev.Type == "dismissed" && ev.Metadata["operator_state_cause"] == tc.wantCause {
+ foundCause = true
+ break
+ }
+ }
+ if !foundCause {
+ t.Errorf("lifecycle must carry operator_state_cause=%s metadata", tc.wantCause)
+ }
+ })
+ }
+}