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
Fail closed on Patrol runtime finding controls
rcourtman5e33851092ba
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex e62cb53a8b..868a1ec50f 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -514,6 +514,11 @@ so the full-run seed/reconcile path must not auto-resolve them as`Resource no longer exists in infrastructure` just because `ai-service` is notpresent in the infrastructure snapshot. Those findings stay active untilPatrol actually succeeds or resolves them for a Patrol-owned reason.+Because those findings represent Patrol blindness rather than operator-triaged+infrastructure noise, the Patrol runtime must also reject manual acknowledge,+snooze, dismiss, resolve, and suppress actions against synthetic `ai-service`+runtime findings. The canonical recovery path is to correct AI/provider+configuration and let Patrol re-evaluate the runtime condition on the next run.The shared findings lifecycle must also treat a regressed issue as a new activeoccurrence. When a resolved finding reappears, `internal/ai/findings.go` mustclear any stale acknowledgement timestamp from the prior occurrence instead ofdiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 964b49a7bb..536fbbd484 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -175,6 +175,12 @@ for Patrol-owned runtime findings as well. Expanded runtime-finding rows shouldoffer the same direct `Open AI Settings` action that the top assessment uses,instead of falling back to only generic acknowledge, snooze, or dismisscontrols.+That same contract must fail closed on manual lifecycle controls too. Patrol+runtime findings are Patrol-owned impairment signals, not ordinary estate+findings, so the findings list must not offer generic acknowledge, snooze,+dismiss, resolve, or suppress controls for them. The correct operator path is+to fix AI/provider configuration and rerun Patrol, optionally adding context+notes, rather than hiding the runtime issue.The summary recency chip must follow the same governed scope distinction. Whenthe latest completed activity was only a scoped run, the summary should labelthat timestamp as `Last activity` instead of `Last patrol`; `Last full patrol`diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsxindex 6b0befb611..016d65de8a 100644--- a/frontend-modern/src/components/AI/FindingsPanel.tsx+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx@@ -43,6 +43,7 @@ import {getFindingStatusLabel,getFindingSourceBadgeClasses,getFindingSourceLabel,+ getFindingManualControlsPresentation,getFindingPrimaryActionPresentation,getFindingSubjectPresentation,getPatrolFindingClassification,@@ -408,6 +409,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {const recency = getFindingRecencyPresentation(finding);const patrolFindingClassification = getPatrolFindingClassification(finding);const subject = getFindingSubjectPresentation(finding);+ const manualControls = getFindingManualControlsPresentation(finding);return (<div@@ -588,7 +590,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {{/* Actions */}<div class="flex items-center gap-1 shrink-0"><Show when={finding.status === 'active'}>- <Show when={!finding.acknowledgedAt}>+ <Show when={manualControls.acknowledge && !finding.acknowledgedAt}><buttontype="button"onClick={(e) => handleAcknowledge(finding, e)}@@ -606,38 +608,42 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {</svg></button></Show>- <button- type="button"- onClick={(e) => handleSnooze(finding, 24, e)}- class="p-1 text-slate-400 hover:text-muted"- title="Snooze 24h"- disabled={actionLoading() === finding.id}- >- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </button>- <button- type="button"- onClick={(e) => handleStartDismiss(finding, 'will_fix_later', e)}- class="p-1 text-slate-400 hover:text-muted"- title="Dismiss"- disabled={actionLoading() === finding.id}- >- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M6 18L18 6M6 6l12 12"- />- </svg>- </button>+ <Show when={manualControls.snooze}>+ <button+ type="button"+ onClick={(e) => handleSnooze(finding, 24, e)}+ class="p-1 text-slate-400 hover:text-muted"+ title="Snooze 24h"+ disabled={actionLoading() === finding.id}+ >+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"+ />+ </svg>+ </button>+ </Show>+ <Show when={manualControls.dismiss}>+ <button+ type="button"+ onClick={(e) => handleStartDismiss(finding, 'will_fix_later', e)}+ class="p-1 text-slate-400 hover:text-muted"+ title="Dismiss"+ disabled={actionLoading() === finding.id}+ >+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M6 18L18 6M6 6l12 12"+ />+ </svg>+ </button>+ </Show></Show>{/* Expand indicator */}<svg@@ -839,7 +845,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {<Show when={finding.status === 'active'}><div class="mt-3 flex flex-wrap gap-2 text-xs">- <Show when={!finding.acknowledgedAt}>+ <Show when={manualControls.acknowledge && !finding.acknowledgedAt}><buttontype="button"onClick={(e) => handleAcknowledge(finding, e)}@@ -849,54 +855,62 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {Acknowledge</button></Show>- <button- type="button"- onClick={(e) => handleSnooze(finding, 1, e)}- class="px-2 py-1 rounded border border-border hover:bg-surface-hover"- disabled={actionLoading() === finding.id}- >- Snooze 1h- </button>- <button- type="button"- onClick={(e) => handleSnooze(finding, 24, e)}- class="px-2 py-1 rounded border border-border hover:bg-surface-hover"- disabled={actionLoading() === finding.id}- >- Snooze 24h- </button>- <button- type="button"- onClick={(e) => handleSnooze(finding, 168, e)}- class="px-2 py-1 rounded border border-border hover:bg-surface-hover"- disabled={actionLoading() === finding.id}- >- Snooze 7d- </button>- <button- type="button"- onClick={(e) => handleStartDismiss(finding, 'not_an_issue', e)}- class="px-2 py-1 rounded border border-border text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900"- disabled={actionLoading() === finding.id}- >- Dismiss: Not an issue- </button>- <button- type="button"- onClick={(e) => handleStartDismiss(finding, 'expected_behavior', e)}- class="px-2 py-1 rounded border border-border hover:bg-surface-hover"- disabled={actionLoading() === finding.id}- >- Dismiss: Expected- </button>- <button- type="button"- onClick={(e) => handleStartDismiss(finding, 'will_fix_later', e)}- class="px-2 py-1 rounded border border-border hover:bg-surface-hover"- disabled={actionLoading() === finding.id}- >- Dismiss: Later- </button>+ <Show when={manualControls.snooze}>+ <>+ <button+ type="button"+ onClick={(e) => handleSnooze(finding, 1, e)}+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover"+ disabled={actionLoading() === finding.id}+ >+ Snooze 1h+ </button>+ <button+ type="button"+ onClick={(e) => handleSnooze(finding, 24, e)}+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover"+ disabled={actionLoading() === finding.id}+ >+ Snooze 24h+ </button>+ <button+ type="button"+ onClick={(e) => handleSnooze(finding, 168, e)}+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover"+ disabled={actionLoading() === finding.id}+ >+ Snooze 7d+ </button>+ </>+ </Show>+ <Show when={manualControls.dismiss}>+ <>+ <button+ type="button"+ onClick={(e) => handleStartDismiss(finding, 'not_an_issue', e)}+ class="px-2 py-1 rounded border border-border text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900"+ disabled={actionLoading() === finding.id}+ >+ Dismiss: Not an issue+ </button>+ <button+ type="button"+ onClick={(e) => handleStartDismiss(finding, 'expected_behavior', e)}+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover"+ disabled={actionLoading() === finding.id}+ >+ Dismiss: Expected+ </button>+ <button+ type="button"+ onClick={(e) => handleStartDismiss(finding, 'will_fix_later', e)}+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover"+ disabled={actionLoading() === finding.id}+ >+ Dismiss: Later+ </button>+ </>+ </Show></div></Show>{/* Inline dismiss confirmation */}diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.tsindex 3ac6b6d3d4..6851669825 100644--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts@@ -6,6 +6,7 @@ import {formatFindingLifecycleType,formatFindingLoopState,getFindingEmptyStateCopy,+ getFindingManualControlsPresentation,getFindingPrimaryActionPresentation,getFindingSubjectPresentation,getPatrolFindingClassification,@@ -245,6 +246,36 @@ describe('aiFindingPresentation', () => {});});+ describe('findingManualControlsPresentation', () => {+ it('disables generic feedback controls for patrol runtime findings', () => {+ expect(+ getFindingManualControlsPresentation({+ resourceId: 'ai-service',+ resourceName: 'Pulse Patrol Service',+ title: 'Pulse Patrol: Insufficient API credits',+ }),+ ).toEqual({+ acknowledge: false,+ snooze: false,+ dismiss: false,+ });+ });++ it('keeps generic feedback controls for infrastructure findings', () => {+ expect(+ getFindingManualControlsPresentation({+ resourceId: 'vm-101',+ resourceName: 'db-01',+ title: 'Disk nearly full',+ }),+ ).toEqual({+ acknowledge: true,+ snooze: true,+ dismiss: true,+ });+ });+ });+describe('filterPresentation', () => {it('builds canonical filter options', () => {expect(@@ -300,6 +331,13 @@ describe('aiFindingPresentation', () => {expect(findingsPanelSource).toContain("href={action().href}");});+ it('routes generic finding controls through the shared manual-controls helper', () => {+ expect(findingsPanelSource).toContain('getFindingManualControlsPresentation(finding)');+ expect(findingsPanelSource).toContain('manualControls.acknowledge');+ expect(findingsPanelSource).toContain('manualControls.snooze');+ expect(findingsPanelSource).toContain('manualControls.dismiss');+ });+it('only shows the sort control when there are multiple Patrol findings to sort', () => {expect(findingsPanelSource).toContain('<Show when={patrolFindings().length > 1}>');expect(findingsPanelSource).toContain('<option value="severity">By Severity</option>');diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.tsindex 3b43204c08..7d428e3301 100644--- a/frontend-modern/src/utils/aiFindingPresentation.ts+++ b/frontend-modern/src/utils/aiFindingPresentation.ts@@ -216,6 +216,12 @@ export interface FindingPrimaryActionPresentation {href: string;}+export interface FindingManualControlsPresentation {+ acknowledge: boolean;+ snooze: boolean;+ dismiss: boolean;+}+export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string): string =>FINDING_SOURCE_LABELS[source] || source;@@ -306,6 +312,21 @@ export const getFindingPrimaryActionPresentation = (return undefined;};+export const getFindingManualControlsPresentation = (+ finding: Pick<UnifiedFinding, 'resourceId' | 'resourceName' | 'title'>,+): FindingManualControlsPresentation =>+ isPatrolRuntimeFinding(finding)+ ? {+ acknowledge: false,+ snooze: false,+ dismiss: false,+ }+ : {+ acknowledge: true,+ snooze: true,+ dismiss: true,+ };+export const getFindingRecencyPresentation = (finding: Pick<UnifiedFinding, 'status' | 'detectedAt' | 'lastSeenAt'>,): FindingRecencyPresentation => {diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.goindex 0ffde25fc5..5434f95c12 100644--- a/internal/ai/patrol_ai.go+++ b/internal/ai/patrol_ai.go@@ -3297,10 +3297,6 @@ func (p *PatrolService) seedIntelligenceContext(intel seedIntelligence, now timereturn sb.String()}-func patrolFindingUsesSyntheticRuntimeResource(f *Finding) bool {- return f != nil && (f.Key == "ai-patrol-error" || f.ResourceID == "ai-service")-}-// seedFindingsAndContext builds the thresholds, active findings, dismissed findings, and user notes sections.func (p *PatrolService) seedFindingsAndContextState(scope *PatrolScope, snap patrolRuntimeState) (string, []string) {var sb strings.Builderdiff --git a/internal/ai/patrol_findings.go b/internal/ai/patrol_findings.goindex cc1397ea0a..fefa68ad2b 100644--- a/internal/ai/patrol_findings.go+++ b/internal/ai/patrol_findings.go@@ -20,6 +20,22 @@ import ("github.com/rs/zerolog/log")+const (+ patrolRuntimeFindingKey = "ai-patrol-error"+ patrolRuntimeResourceID = "ai-service"+)++func patrolFindingUsesSyntheticRuntimeResource(f *Finding) bool {+ return f != nil && (f.Key == patrolRuntimeFindingKey || f.ResourceID == patrolRuntimeResourceID)+}++func patrolRuntimeFindingManualActionError(action string) error {+ return fmt.Errorf(+ "Patrol runtime findings cannot be %s manually; update AI settings and rerun Patrol",+ action,+ )+}+// recordFinding stores a finding, syncs it to the unified store, and triggers follow-up actions.func (p *PatrolService) recordFinding(f *Finding) bool {if p == nil || p.findings == nil || f == nil {@@ -42,7 +58,7 @@ func (p *PatrolService) recordFinding(f *Finding) bool {// Generate remediation plan for actionable findings// Skip internal error findings (not actionable by users)- if !(stored.Key == "ai-patrol-error" || stored.ResourceID == "ai-service") {+ if !patrolFindingUsesSyntheticRuntimeResource(stored) {p.generateRemediationPlan(stored)}@@ -74,6 +90,22 @@ func (p *PatrolService) recordFinding(f *Finding) bool {return isNew}+// RejectManualActionForRuntimeFinding fails closed when a manual lifecycle action targets+// a Patrol-owned runtime finding such as the synthetic ai-service provider/runtime error.+func (p *PatrolService) RejectManualActionForRuntimeFinding(findingID string, action string) error {+ if p == nil || p.findings == nil {+ return fmt.Errorf("finding not found: %s", findingID)+ }+ finding := p.findings.Get(findingID)+ if finding == nil {+ return fmt.Errorf("finding not found: %s", findingID)+ }+ if patrolFindingUsesSyntheticRuntimeResource(finding) {+ return patrolRuntimeFindingManualActionError(action)+ }+ return nil+}+func (p *PatrolService) setBlockedReason(reason string) {if reason == "" {return@@ -547,6 +579,9 @@ func (p *PatrolService) DismissFinding(findingID string, reason string, note strif finding == nil {return fmt.Errorf("finding not found: %s", findingID)}+ if patrolFindingUsesSyntheticRuntimeResource(finding) {+ return patrolRuntimeFindingManualActionError("dismissed")+ }// Dismiss the finding:// - "not_an_issue" creates permanent suppression (true false positive)diff --git a/internal/ai/patrol_findings_additional_test.go b/internal/ai/patrol_findings_additional_test.goindex 267545aa43..42e7f372bb 100644--- a/internal/ai/patrol_findings_additional_test.go+++ b/internal/ai/patrol_findings_additional_test.go@@ -4,6 +4,7 @@ import ("context""errors""fmt"+ "strings""testing""time"@@ -89,6 +90,37 @@ func TestPatrolService_DismissFinding(t *testing.T) {}}+func TestPatrolService_DismissFinding_RejectsPatrolRuntimeFinding(t *testing.T) {+ ps := NewPatrolService(nil, nil)+ f := &Finding{+ ID: "runtime-1",+ Key: patrolRuntimeFindingKey,+ Severity: FindingSeverityWarning,+ Category: FindingCategoryReliability,+ ResourceID: patrolRuntimeResourceID,+ ResourceName: "Pulse Patrol Service",+ ResourceType: "service",+ Title: "Pulse Patrol: Insufficient API credits",+ }+ ps.findings.Add(f)++ err := ps.DismissFinding("runtime-1", "not_an_issue", "ignore it")+ if err == nil {+ t.Fatal("expected Patrol runtime finding dismissal to be rejected")+ }+ if got := err.Error(); !strings.Contains(got, "cannot be dismissed manually") {+ t.Fatalf("unexpected error: %q", got)+ }++ stored := ps.findings.Get("runtime-1")+ if stored == nil {+ t.Fatal("expected runtime finding to remain present")+ }+ if stored.DismissedReason != "" {+ t.Fatalf("expected runtime finding to remain active, got dismissed reason %q", stored.DismissedReason)+ }+}+func TestPatrolFindingCreatorAdapter_IsActionable(t *testing.T) {ps := NewPatrolService(nil, nil)diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.goindex 4cf674871f..bac1d51f26 100644--- a/internal/api/ai_handlers.go+++ b/internal/api/ai_handlers.go@@ -5182,6 +5182,12 @@ func (h *AISettingsHandler) HandleAcknowledgeFinding(w http.ResponseWriter, r *hhttp.Error(w, "Finding not found", http.StatusNotFound)return}+ if foundInPatrol {+ if err := patrol.RejectManualActionForRuntimeFinding(req.FindingID, "acknowledged"); err != nil {+ http.Error(w, err.Error(), http.StatusConflict)+ return+ }+ }// Acknowledge in patrol findings if it exists thereif foundInPatrol {@@ -5302,6 +5308,12 @@ func (h *AISettingsHandler) HandleSnoozeFinding(w http.ResponseWriter, r *http.Rhttp.Error(w, "Finding not found or already resolved", http.StatusNotFound)return}+ if foundInPatrol {+ if err := patrol.RejectManualActionForRuntimeFinding(req.FindingID, "snoozed"); err != nil {+ http.Error(w, err.Error(), http.StatusConflict)+ return+ }+ }// Snooze in patrol findings if it exists thereif foundInPatrol {@@ -5384,6 +5396,10 @@ func (h *AISettingsHandler) HandleResolveFinding(w http.ResponseWriter, r *http.http.Error(w, "Finding not found or already resolved", http.StatusNotFound)return}+ if err := patrol.RejectManualActionForRuntimeFinding(req.FindingID, "resolved"); err != nil {+ http.Error(w, err.Error(), http.StatusConflict)+ return+ }// Capture details before actiondetectedAt := finding.DetectedAt@@ -5569,6 +5585,12 @@ func (h *AISettingsHandler) HandleDismissFinding(w http.ResponseWriter, r *http.http.Error(w, "Finding not found", http.StatusNotFound)return}+ if foundInPatrol {+ if err := patrol.RejectManualActionForRuntimeFinding(req.FindingID, "dismissed"); err != nil {+ http.Error(w, err.Error(), http.StatusConflict)+ return+ }+ }// Dismiss in patrol findings if it exists thereif foundInPatrol {@@ -5666,6 +5688,10 @@ func (h *AISettingsHandler) HandleSuppressFinding(w http.ResponseWriter, r *httphttp.Error(w, "Finding not found", http.StatusNotFound)return}+ if err := patrol.RejectManualActionForRuntimeFinding(req.FindingID, "suppressed"); err != nil {+ http.Error(w, err.Error(), http.StatusConflict)+ return+ }// Capture details before actiondetectedAt := finding.DetectedAtdiff --git a/internal/api/ai_handlers_patrol_actions_additional_test.go b/internal/api/ai_handlers_patrol_actions_additional_test.goindex ba3f73f138..70d045b100 100644--- a/internal/api/ai_handlers_patrol_actions_additional_test.go+++ b/internal/api/ai_handlers_patrol_actions_additional_test.go@@ -77,6 +77,43 @@ func addUnifiedFinding(store *unified.UnifiedStore, id string, detectedAt time.Treturn finding}+func addPatrolRuntimeFinding(t *testing.T, patrol *ai.PatrolService, id string, detectedAt time.Time) *ai.Finding {+ t.Helper()++ finding := &ai.Finding{+ ID: id,+ Key: "ai-patrol-error",+ Severity: ai.FindingSeverityWarning,+ Category: ai.FindingCategoryReliability,+ Title: "Pulse Patrol: Insufficient API credits",+ Description: "Patrol could not complete because provider credits are exhausted",+ ResourceID: "ai-service",+ ResourceName: "Pulse Patrol Service",+ ResourceType: "service",+ DetectedAt: detectedAt,+ LastSeenAt: detectedAt,+ }+ patrol.GetFindings().Add(finding)+ return finding+}++func addUnifiedRuntimeFinding(store *unified.UnifiedStore, id string, detectedAt time.Time) *unified.UnifiedFinding {+ finding := &unified.UnifiedFinding{+ ID: id,+ Source: unified.SourceAIPatrol,+ Severity: unified.SeverityWarning,+ Category: unified.CategoryReliability,+ ResourceID: "ai-service",+ ResourceName: "Pulse Patrol Service",+ ResourceType: "service",+ Title: "Pulse Patrol: Insufficient API credits",+ Description: "Patrol could not complete because provider credits are exhausted",+ DetectedAt: detectedAt,+ }+ store.AddFromAI(finding)+ return finding+}+type stubQuickstartCreditManager struct {remaining int}@@ -476,6 +513,116 @@ func TestHandleSuppressFinding_SetsSuppressed(t *testing.T) {}}+func TestHandlePatrolRuntimeFindingActions_AreRejected(t *testing.T) {+ handler, patrol, unifiedStore, learningStore := setupAIHandlerWithPatrol(t)++ detectedAt := time.Now().Add(-30 * time.Minute)+ addPatrolRuntimeFinding(t, patrol, "finding-runtime", detectedAt)+ addUnifiedRuntimeFinding(unifiedStore, "finding-runtime", detectedAt)++ tests := []struct {+ name string+ path string+ body string+ handler func(http.ResponseWriter, *http.Request)+ wantPhrase string+ }{+ {+ name: "acknowledge",+ path: "/api/ai/patrol/acknowledge",+ body: `{"finding_id":"finding-runtime"}`,+ handler: handler.HandleAcknowledgeFinding,+ wantPhrase: "cannot be acknowledged manually",+ },+ {+ name: "snooze",+ path: "/api/ai/patrol/snooze",+ body: `{"finding_id":"finding-runtime","duration_hours":24}`,+ handler: handler.HandleSnoozeFinding,+ wantPhrase: "cannot be snoozed manually",+ },+ {+ name: "resolve",+ path: "/api/ai/patrol/resolve",+ body: `{"finding_id":"finding-runtime"}`,+ handler: handler.HandleResolveFinding,+ wantPhrase: "cannot be resolved manually",+ },+ {+ name: "dismiss",+ path: "/api/ai/patrol/dismiss",+ body: `{"finding_id":"finding-runtime","reason":"expected_behavior","note":"ignore"}`,+ handler: handler.HandleDismissFinding,+ wantPhrase: "cannot be dismissed manually",+ },+ {+ name: "suppress",+ path: "/api/ai/patrol/suppress",+ body: `{"finding_id":"finding-runtime"}`,+ handler: handler.HandleSuppressFinding,+ wantPhrase: "cannot be suppressed manually",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ req := httptest.NewRequest(http.MethodPost, tt.path, strings.NewReader(tt.body))+ rec := httptest.NewRecorder()++ tt.handler(rec, req)++ if rec.Code != http.StatusConflict {+ t.Fatalf("status = %d, want 409", rec.Code)+ }+ if !strings.Contains(rec.Body.String(), tt.wantPhrase) {+ t.Fatalf("expected response to contain %q, got %q", tt.wantPhrase, rec.Body.String())+ }+ })+ }++ patrolFinding := patrol.GetFindings().Get("finding-runtime")+ if patrolFinding == nil {+ t.Fatal("expected runtime finding to remain present")+ }+ if patrolFinding.AcknowledgedAt != nil {+ t.Fatal("expected runtime finding to remain unacknowledged")+ }+ if patrolFinding.SnoozedUntil != nil {+ t.Fatal("expected runtime finding to remain unsnoozed")+ }+ if patrolFinding.ResolvedAt != nil {+ t.Fatal("expected runtime finding to remain unresolved")+ }+ if patrolFinding.DismissedReason != "" {+ t.Fatalf("expected runtime finding to remain undismissed, got %q", patrolFinding.DismissedReason)+ }+ if patrolFinding.Suppressed {+ t.Fatal("expected runtime finding to remain unsuppressed")+ }++ unifiedFinding := unifiedStore.Get("finding-runtime")+ if unifiedFinding == nil {+ t.Fatal("expected unified runtime finding to remain present")+ }+ if unifiedFinding.AcknowledgedAt != nil {+ t.Fatal("expected unified runtime finding to remain unacknowledged")+ }+ if unifiedFinding.SnoozedUntil != nil {+ t.Fatal("expected unified runtime finding to remain unsnoozed")+ }+ if unifiedFinding.ResolvedAt != nil {+ t.Fatal("expected unified runtime finding to remain unresolved")+ }+ if unifiedFinding.DismissedReason != "" {+ t.Fatalf("expected unified runtime finding to remain undismissed, got %q", unifiedFinding.DismissedReason)+ }++ stats := learningStore.GetStatistics()+ if stats.TotalFeedbackRecords != 0 {+ t.Fatalf("feedback records = %d, want 0", stats.TotalFeedbackRecords)+ }+}+func TestHandleGetFindingsHistory_StartTimeFilter(t *testing.T) {handler, patrol, _, _ := setupAIHandlerWithPatrol(t)