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
feat(patrol): reconcile actionable findings on activation
rcourtman1164d3730248
diff --git a/docs/PRIVACY.md b/docs/PRIVACY.mdindex 93105db73c..39cc563582 100644--- a/docs/PRIVACY.md+++ b/docs/PRIVACY.md@@ -178,6 +178,12 @@ Every field is listed below with the reason it exists. Nothing else is included| Pulse Intelligence approved action decisions 30d | `1` | Count approved governed action decisions in the current 30-day telemetry window without sending approvers, reasons, command text, targets, or action IDs || Pulse Intelligence approved action attempts 30d | `1` | Count approved governed action attempts in the current 30-day telemetry window without sending action output, command text, or verification detail || Pulse Intelligence approved action successes 30d | `1` | Count approved governed actions that completed successfully in the current 30-day telemetry window without sending action output, command text, resource IDs, actors, reasons, or verification detail |+| Pulse Intelligence Patrol action plans 30d | `2` | Count governed action plans proposed from Patrol investigations in the current 30-day telemetry window without sending action IDs, finding IDs, investigation IDs, command text, resource IDs, or plan details |+| Pulse Intelligence Patrol approval requests 30d | `2` | Count approval-gated Patrol-origin actions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol rejected action decisions 30d | `1` | Count rejected Patrol-origin action decisions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol approved action decisions 30d | `1` | Count approved Patrol-origin action decisions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol approved action attempts 30d | `1` | Count approved Patrol-origin action attempts in the current 30-day telemetry window without sending action IDs, finding IDs, command text, output, resources, or verification detail |+| Pulse Intelligence Patrol approved action successes 30d | `1` | Count approved Patrol-origin actions that completed successfully in the current 30-day telemetry window without sending action IDs, finding IDs, command text, output, resources, actors, reasons, or verification detail || Pulse Intelligence approved action failures (pre-dispatch) 30d | `1` | Count approved governed actions refused before dispatch (for example an expired or drifted plan) in the current 30-day telemetry window without sending action output, command text, resource IDs, actors, or reasons || Pulse Intelligence approved action failures (execution) 30d | `1` | Count approved governed actions whose dispatched execution failed in the current 30-day telemetry window without sending action output, error text, command text, resource IDs, or actors || Pulse Intelligence approved action failures (unverified) 30d | `1` | Count approved governed actions that executed but whose outcome verification was not confirmed in the current 30-day telemetry window without sending verification evidence, action output, command text, resource IDs, or actors |diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 695cbaf23e..07388d1d90 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -5125,6 +5125,20 @@ about the next move — it does not need a separate read to getthe situated picture, and it can avoid proposing fixes theoperator has locked the resource against.+An effective autonomy transition out of `monitor` also reconciles findings+that were detected while Patrol was in Watch Only. The API publishes the+persisted autonomy mutation first, then+`PatrolService.ReconcileActionableFindingBacklog` selects active+warning/critical findings through the same `ShouldInvestigate` admission used+by scheduled and alert-triggered work. The activation pass is bounded to three+concurrent starts minus the orchestrator's current running count, orders+critical findings before warnings and older findings before newer ones, and+leaves remaining work to ordinary Patrol runs. It must not run for a no-op+save, a transition into Watch Only, an unavailable orchestrator, or an+effective mode still clamped to `monitor`; activation must never create an+unbounded model-work burst or bypass suppression, snooze, cooldown, attempt,+terminal-outcome, operator-state, and concurrency gates.+`ResourceOperatorStateProjection` carries `NeverAutoRemediate`and `Criticality` alongside `IntentionallyOffline` and `MaintenanceWindow` so theinvestigation read path and the suppression read path share adiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 752145ca7b..e7be5ffba2 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -2899,7 +2899,9 @@ a new API state machine, queue contract, or verification-accounting field.content-free `internal/telemetry.Ping` payload shape exposed by the systemsettings preview route, including Pulse Intelligence loop booleans, Assistantand Patrol counters, operations-loop workflow starter counts, governed-action- counters including approved/rejected action decisions, and external-agent/MCP aggregate, adapter-origin, and+ counters including approved/rejected action decisions, Patrol-origin plan,+ approval, decision, approved-attempt, and approved-success counters, and+ external-agent/MCP aggregate, adapter-origin, andcapability-class counters, so browser preview, privacy disclosure, andoutbound heartbeat JSON do not drift into separate contracts.Operations-loop starter fields may count only the canonical@@ -8676,6 +8678,12 @@ owners must not rely on that 402 as normal control flow for stale local state:when the current entitlement locks safe remediation, they submit `monitor` evenif older persisted settings or a previous entitlement left `approval`,`assisted`, or `full` in memory.+After a successful persisted update whose effective mode actually crosses from+`monitor` to `approval`, `assisted`, or eligible `full`, the shared API mutation+boundary invokes the bounded Patrol actionable-finding reconciliation pass.+The pass runs only after `ApplyPatrolAutonomyConfig` has published the new+runtime authority; failed writes, Community clamps, repeated paid-mode saves,+budget-only edits, and demotions must not start backlog work.The Patrol header and configuration-dialog presentation for that API boundarymust compose the shared`frontend-modern/src/components/shared/FilterButtonGroup.tsx` selector: thediff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex e78fb6feec..974b5885ba 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -387,6 +387,12 @@ or historical proof/counting for resolved-only work.run history so the next Patrol operator step is visible without waiting for alater poll or page reload. Locked Community/runtime saves and repeated no-op selections mustnot record paid starter activity.+ That successful server-side transition out of Watch Only also starts one+ bounded reconciliation pass over already-active actionable findings, so the+ next Patrol step can appear without waiting for the issue to be detected+ again. The backend owns this behavior and retains the normal eligibility and+ concurrency gates; the browser marker remains entry-point telemetry only and+ must not become a second investigation trigger.The same journey may count a generic Patrol run or recency timestamp asreadiness to start, but it must not advance the current operator state untilit has issue-backed Patrol evidence: an active or resolved finding,diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex 59df4ad00f..dca1d33214 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -1204,7 +1204,9 @@ new-finding/investigation/resolved-finding/autofix counts, external-agent/MCPreadiness and recent-use booleans including the adapter-origin `pulse-mcp`recent-use boolean, action-plan counts, approval-request counts,rejected-action-decision counts, approved-action-decision counts,-approved-action-attempt counts, and approved-action-success counts. Those fields may measure whether Patrol,+approved-action-attempt counts, approved-action-success counts, and the+source-specific Patrol-origin subset of plan, approval request, rejected or+approved decision, approved attempt, and approved success counts. Those fields may measure whether Patrol,Assistant, external agents, approvals, and governed actions form an adoptedgoverned operation, whether an operator entered the guided Patrol-controlstarter, which source carried the stage, whether the Patrol control journeydiff --git a/frontend-modern/public/docs/PRIVACY.md b/frontend-modern/public/docs/PRIVACY.mdindex 93105db73c..39cc563582 100644--- a/frontend-modern/public/docs/PRIVACY.md+++ b/frontend-modern/public/docs/PRIVACY.md@@ -178,6 +178,12 @@ Every field is listed below with the reason it exists. Nothing else is included| Pulse Intelligence approved action decisions 30d | `1` | Count approved governed action decisions in the current 30-day telemetry window without sending approvers, reasons, command text, targets, or action IDs || Pulse Intelligence approved action attempts 30d | `1` | Count approved governed action attempts in the current 30-day telemetry window without sending action output, command text, or verification detail || Pulse Intelligence approved action successes 30d | `1` | Count approved governed actions that completed successfully in the current 30-day telemetry window without sending action output, command text, resource IDs, actors, reasons, or verification detail |+| Pulse Intelligence Patrol action plans 30d | `2` | Count governed action plans proposed from Patrol investigations in the current 30-day telemetry window without sending action IDs, finding IDs, investigation IDs, command text, resource IDs, or plan details |+| Pulse Intelligence Patrol approval requests 30d | `2` | Count approval-gated Patrol-origin actions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol rejected action decisions 30d | `1` | Count rejected Patrol-origin action decisions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol approved action decisions 30d | `1` | Count approved Patrol-origin action decisions in the current 30-day telemetry window without sending action IDs, finding IDs, approvers, reasons, command text, or targets |+| Pulse Intelligence Patrol approved action attempts 30d | `1` | Count approved Patrol-origin action attempts in the current 30-day telemetry window without sending action IDs, finding IDs, command text, output, resources, or verification detail |+| Pulse Intelligence Patrol approved action successes 30d | `1` | Count approved Patrol-origin actions that completed successfully in the current 30-day telemetry window without sending action IDs, finding IDs, command text, output, resources, actors, reasons, or verification detail || Pulse Intelligence approved action failures (pre-dispatch) 30d | `1` | Count approved governed actions refused before dispatch (for example an expired or drifted plan) in the current 30-day telemetry window without sending action output, command text, resource IDs, actors, or reasons || Pulse Intelligence approved action failures (execution) 30d | `1` | Count approved governed actions whose dispatched execution failed in the current 30-day telemetry window without sending action output, error text, command text, resource IDs, or actors || Pulse Intelligence approved action failures (unverified) 30d | `1` | Count approved governed actions that executed but whose outcome verification was not confirmed in the current 30-day telemetry window without sending verification evidence, action output, command text, resource IDs, or actors |diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.tsindex 384dec00aa..58e4ac06ed 100644--- a/frontend-modern/src/api/__tests__/settings.test.ts+++ b/frontend-modern/src/api/__tests__/settings.test.ts@@ -143,6 +143,12 @@ const mockTelemetryPreviewPayload = {pulse_intelligence_approved_action_decisions_30d: 0,pulse_intelligence_approved_action_attempts_30d: 0,pulse_intelligence_approved_action_successes_30d: 0,+ pulse_intelligence_patrol_action_plans_30d: 0,+ pulse_intelligence_patrol_approval_requests_30d: 0,+ pulse_intelligence_patrol_rejected_action_decisions_30d: 0,+ pulse_intelligence_patrol_approved_action_decisions_30d: 0,+ pulse_intelligence_patrol_approved_action_attempts_30d: 0,+ pulse_intelligence_patrol_approved_action_successes_30d: 0,pulse_intelligence_approved_action_failures_pre_dispatch_30d: 0,pulse_intelligence_approved_action_failures_execution_30d: 0,pulse_intelligence_approved_action_failures_unverified_30d: 0,diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.tsindex 9da1094a3c..ac64366062 100644--- a/frontend-modern/src/api/settings.ts+++ b/frontend-modern/src/api/settings.ts@@ -144,6 +144,12 @@ export interface TelemetryPingPreview {pulse_intelligence_approved_action_decisions_30d: number;pulse_intelligence_approved_action_attempts_30d: number;pulse_intelligence_approved_action_successes_30d: number;+ pulse_intelligence_patrol_action_plans_30d: number;+ pulse_intelligence_patrol_approval_requests_30d: number;+ pulse_intelligence_patrol_rejected_action_decisions_30d: number;+ pulse_intelligence_patrol_approved_action_decisions_30d: number;+ pulse_intelligence_patrol_approved_action_attempts_30d: number;+ pulse_intelligence_patrol_approved_action_successes_30d: number;pulse_intelligence_approved_action_failures_pre_dispatch_30d: number;pulse_intelligence_approved_action_failures_execution_30d: number;pulse_intelligence_approved_action_failures_unverified_30d: number;diff --git a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.tsindex 8b07ee1a07..231ee28abf 100644--- a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts@@ -149,6 +149,12 @@ const buildTelemetryPreviewPayload = (pulse_intelligence_approved_action_decisions_30d: 0,pulse_intelligence_approved_action_attempts_30d: 0,pulse_intelligence_approved_action_successes_30d: 0,+ pulse_intelligence_patrol_action_plans_30d: 0,+ pulse_intelligence_patrol_approval_requests_30d: 0,+ pulse_intelligence_patrol_rejected_action_decisions_30d: 0,+ pulse_intelligence_patrol_approved_action_decisions_30d: 0,+ pulse_intelligence_patrol_approved_action_attempts_30d: 0,+ pulse_intelligence_patrol_approved_action_successes_30d: 0,pulse_intelligence_approved_action_failures_pre_dispatch_30d: 0,pulse_intelligence_approved_action_failures_execution_30d: 0,pulse_intelligence_approved_action_failures_unverified_30d: 0,diff --git a/internal/ai/patrol_activation_reconcile_test.go b/internal/ai/patrol_activation_reconcile_test.gonew file mode 100644index 0000000000..d310539c36--- /dev/null+++ b/internal/ai/patrol_activation_reconcile_test.go@@ -0,0 +1,70 @@+package ai++import (+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+)++func TestReconcileActionableFindingBacklogIsBoundedAndPrioritizesCriticalFindings(t *testing.T) {+ persistence := config.NewConfigPersistence(t.TempDir())+ service := NewService(persistence, nil)+ service.cfg = &config.AIConfig{Enabled: true, PatrolAutonomyLevel: config.PatrolAutonomyApproval}+ patrol := NewPatrolService(service, nil)+ orchestrator := newIntegrationOrchestrator(true)+ patrol.SetInvestigationOrchestrator(orchestrator)++ now := time.Now().UTC()+ for _, finding := range []*Finding{+ {ID: "warning-old", Severity: FindingSeverityWarning, ResourceID: "vm-1", DetectedAt: now.Add(-5 * time.Hour)},+ {ID: "critical-new", Severity: FindingSeverityCritical, ResourceID: "vm-2", DetectedAt: now.Add(-time.Hour)},+ {ID: "warning-new", Severity: FindingSeverityWarning, ResourceID: "vm-3", DetectedAt: now.Add(-30 * time.Minute)},+ {ID: "critical-old", Severity: FindingSeverityCritical, ResourceID: "vm-4", DetectedAt: now.Add(-4 * time.Hour)},+ {ID: "warning-middle", Severity: FindingSeverityWarning, ResourceID: "vm-5", DetectedAt: now.Add(-2 * time.Hour)},+ {ID: "info", Severity: FindingSeverityInfo, ResourceID: "vm-6", DetectedAt: now.Add(-6 * time.Hour)},+ } {+ patrol.findings.Add(finding)+ }++ if got := patrol.ReconcileActionableFindingBacklog(); got != maxPatrolActivationBacklogInvestigations {+ t.Fatalf("ReconcileActionableFindingBacklog() = %d, want %d", got, maxPatrolActivationBacklogInvestigations)+ }+ patrol.investigationWg.Wait()++ started := map[string]bool{}+ for len(orchestrator.investigateCh) > 0 {+ started[<-orchestrator.investigateCh] = true+ }+ for _, id := range []string{"critical-old", "critical-new", "warning-old"} {+ if !started[id] {+ t.Errorf("expected prioritized finding %q to start, got %v", id, started)+ }+ }+ for _, id := range []string{"warning-middle", "warning-new", "info"} {+ if started[id] {+ t.Errorf("unexpected backlog finding %q started, got %v", id, started)+ }+ }+}++func TestReconcileActionableFindingBacklogDoesNothingInWatchOnly(t *testing.T) {+ persistence := config.NewConfigPersistence(t.TempDir())+ service := NewService(persistence, nil)+ service.cfg = &config.AIConfig{Enabled: true, PatrolAutonomyLevel: config.PatrolAutonomyMonitor}+ patrol := NewPatrolService(service, nil)+ orchestrator := newIntegrationOrchestrator(true)+ patrol.SetInvestigationOrchestrator(orchestrator)+ patrol.findings.Add(&Finding{+ ID: "warning", Severity: FindingSeverityWarning, ResourceID: "vm-1", DetectedAt: time.Now().UTC(),+ })++ if got := patrol.ReconcileActionableFindingBacklog(); got != 0 {+ t.Fatalf("ReconcileActionableFindingBacklog() = %d, want 0", got)+ }+ select {+ case id := <-orchestrator.investigateCh:+ t.Fatalf("Watch Only started investigation %q", id)+ default:+ }+}diff --git a/internal/ai/patrol_findings.go b/internal/ai/patrol_findings.goindex bd076d93ba..d95c2be798 100644--- a/internal/ai/patrol_findings.go+++ b/internal/ai/patrol_findings.go@@ -1618,9 +1618,68 @@ func (p *PatrolService) retryTimedOutInvestigations() {}}+// maxPatrolActivationBacklogInvestigations bounds the one-time catch-up that+// runs when Patrol moves out of Watch Only. Existing findings can be numerous;+// activation must not turn that backlog into an unbounded burst of model work.+const maxPatrolActivationBacklogInvestigations = 3++// ReconcileActionableFindingBacklog starts a bounded, deterministic set of+// investigations for findings that were detected while Patrol was in Watch+// Only. Normal patrol runs continue to own subsequent retry and discovery.+func (p *PatrolService) ReconcileActionableFindingBacklog() int {+ if p == nil || p.findings == nil {+ return 0+ }+ p.mu.RLock()+ orchestrator := p.investigationOrchestrator+ aiService := p.aiService+ p.mu.RUnlock()+ if orchestrator == nil || aiService == nil || aiService.GetConfig() == nil ||+ aiService.GetEffectivePatrolAutonomyLevel() == "monitor" {+ return 0+ }++ available := maxPatrolActivationBacklogInvestigations - orchestrator.GetRunningCount()+ if available <= 0 {+ return 0+ }+ findings := p.findings.GetActive(FindingSeverityWarning)+ sort.SliceStable(findings, func(i, j int) bool {+ if findings[i].Severity != findings[j].Severity {+ return findings[i].Severity == FindingSeverityCritical+ }+ if !findings[i].DetectedAt.Equal(findings[j].DetectedAt) {+ return findings[i].DetectedAt.Before(findings[j].DetectedAt)+ }+ return findings[i].ID < findings[j].ID+ })++ started := 0+ for _, finding := range findings {+ if started >= available {+ break+ }+ if p.maybeInvestigateFinding(finding) {+ started+++ }+ }+ if started > 0 {+ log.Info().Int("started", started).Int("eligible_backlog", len(findings)).+ Msg("AI Patrol: Reconciled actionable findings after autonomy activation")+ }+ return started+}+// MaybeInvestigateFinding checks if a finding should be investigated and triggers investigation if so// This is called both during scheduled patrol runs and when alert-triggered findings are createdfunc (p *PatrolService) MaybeInvestigateFinding(f *Finding) {+ p.maybeInvestigateFinding(f)+}++func (p *PatrolService) maybeInvestigateFinding(f *Finding) bool {+ if p == nil || f == nil {+ return false+ }p.mu.RLock()orchestrator := p.investigationOrchestratoraiService := p.aiService@@ -1628,21 +1687,21 @@ func (p *PatrolService) MaybeInvestigateFinding(f *Finding) {// No orchestrator configuredif orchestrator == nil {- return+ return false}// Get autonomy level from AI configif aiService == nil {- return+ return false}if aiService.GetConfig() == nil {- return+ return false}autonomyLevel := aiService.GetEffectivePatrolAutonomyLevel()// Check if finding should be investigatedif !f.ShouldInvestigate(autonomyLevel) {- return+ return false}// Check if we can start another investigation (concurrency limit)@@ -1650,7 +1709,7 @@ func (p *PatrolService) MaybeInvestigateFinding(f *Finding) {log.Debug().Str("finding_id", f.ID).Msg("Cannot start investigation: max concurrent investigations reached")- return+ return false}// Convert Finding to shared finding type for the investigation orchestrator@@ -1788,6 +1847,7 @@ func (p *PatrolService) MaybeInvestigateFinding(f *Finding) {Str("resource", f.ResourceName).Str("autonomy_level", autonomyLevel).Msg("Triggered autonomous investigation for finding")+ return true}// PublishFindingLifecycleUpdate projects a reconciled action outcome to thediff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.goindex 2f55b9638a..2dc5cc7455 100644--- a/internal/api/ai_handlers.go+++ b/internal/api/ai_handlers.go@@ -8074,6 +8074,7 @@ func (h *AISettingsHandler) mutatePatrolAutopilotConfig(ctx context.Context, mutif persistence == nil || service == nil {return fmt.Errorf("Pulse Patrol config persistence unavailable")}+ activationTransition := falsewrite := func() error {current, err := h.loadAIConfig(ctx)if err != nil {@@ -8087,18 +8088,40 @@ func (h *AISettingsHandler) mutatePatrolAutopilotConfig(ctx context.Context, mutif err != nil || !changed {return err}+ policy := h.currentPatrolAutopilotServerPolicy()+ orgID := strings.TrimSpace(GetOrgID(ctx))+ if orgID == "" {+ orgID = "default"+ }+ previousEffective, _ := current.GetEffectivePatrolAutonomyWithPolicy(orgID, policy)+ nextEffective, _ := next.GetEffectivePatrolAutonomyWithPolicy(orgID, policy)if err := persistence.SaveAIConfig(*next); err != nil {return err}- return service.ApplyPatrolAutonomyConfig(next)+ if err := service.ApplyPatrolAutonomyConfig(next); err != nil {+ return err+ }+ activationTransition = previousEffective == config.PatrolAutonomyMonitor && nextEffective != config.PatrolAutonomyMonitor+ return nil}h.stateMu.RLock()coordinator := h.policyMutationh.stateMu.RUnlock()+ var err errorif coordinator != nil {- return coordinator(write)+ err = coordinator(write)+ } else {+ err = write()}- return write()+ if err != nil {+ return err+ }+ if activationTransition {+ if patrol := service.GetPatrolService(); patrol != nil {+ patrol.ReconcileActionableFindingBacklog()+ }+ }+ return nil}func patrolAutonomyResponseForConfig(cfg *config.AIConfig, orgID string, policy unifiedresources.PatrolAutopilotServerPolicy, hasAutoFix bool) PatrolAutonomyResponse {diff --git a/internal/api/ai_handlers_investigation_additional_test.go b/internal/api/ai_handlers_investigation_additional_test.goindex f292100617..e0dbbc94c7 100644--- a/internal/api/ai_handlers_investigation_additional_test.go+++ b/internal/api/ai_handlers_investigation_additional_test.go@@ -315,6 +315,7 @@ func TestPatrolOutcomeForActionAuditPreservesInconclusiveVerification(t *testingtype stubInvestigationOrchestrator struct {session *ai.InvestigationSession+ investigateCh chan stringreinvestigateCh chan reinvestigateCalllastAutonomy stringlastReinvestigate string@@ -326,6 +327,9 @@ type reinvestigateCall struct {}func (s *stubInvestigationOrchestrator) InvestigateFinding(ctx context.Context, finding *ai.InvestigationFinding, autonomyLevel string) error {+ if s.investigateCh != nil {+ s.investigateCh <- finding.ID+ }return nil}diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.goindex a096ab7015..2bfc13debf 100644--- a/internal/api/ai_handlers_test.go+++ b/internal/api/ai_handlers_test.go@@ -248,6 +248,48 @@ func TestAISettingsHandler_PatrolAutonomyMonitorOnlyAllowsMonitor(t *testing.T)require.Contains(t, premiumRec.Body.String(), "limited to Monitor")}+func TestMutatePatrolAutopilotConfigReconcilesBacklogOnlyWhenLeavingMonitor(t *testing.T) {+ tmp := t.TempDir()+ persistence := config.NewConfigPersistence(tmp)+ aiCfg := config.NewDefaultAIConfig()+ aiCfg.Enabled = true+ aiCfg.PatrolAutonomyLevel = config.PatrolAutonomyMonitor+ require.NoError(t, persistence.SaveAIConfig(*aiCfg))++ handler := newTestAISettingsHandler(&config.Config{DataPath: tmp}, persistence, nil)+ service := handler.GetAIService(context.Background())+ require.NotNil(t, service)+ service.SetStateProvider(&stubStateProvider{})+ patrol := service.GetPatrolService()+ require.NotNil(t, patrol)+ patrol.GetFindings().Add(&ai.Finding{+ ID: "backlog-warning", Severity: ai.FindingSeverityWarning,+ ResourceID: "vm-100", DetectedAt: time.Now().Add(-time.Hour),+ })+ orchestrator := &stubInvestigationOrchestrator{investigateCh: make(chan string, 2)}+ patrol.SetInvestigationOrchestrator(orchestrator)++ setApproval := func(cfg *config.AIConfig, _ unifiedresources.PatrolAutopilotServerPolicy) (bool, error) {+ changed := cfg.PatrolAutonomyLevel != config.PatrolAutonomyApproval+ cfg.PatrolAutonomyLevel = config.PatrolAutonomyApproval+ return changed, nil+ }+ require.NoError(t, handler.mutatePatrolAutopilotConfig(context.Background(), setApproval))+ select {+ case findingID := <-orchestrator.investigateCh:+ require.Equal(t, "backlog-warning", findingID)+ case <-time.After(time.Second):+ t.Fatal("leaving Watch Only did not reconcile the actionable finding backlog")+ }++ require.NoError(t, handler.mutatePatrolAutopilotConfig(context.Background(), setApproval))+ select {+ case findingID := <-orchestrator.investigateCh:+ t.Fatalf("no-op paid-mode save retriggered finding %q", findingID)+ case <-time.After(50 * time.Millisecond):+ }+}+func TestAISettingsProvidersProjectionCarriesSuggestedModelWireShape(t *testing.T) {payload, err := json.Marshal(aiProviderDefinitionResponses(nil))require.NoError(t, err)diff --git a/internal/api/telemetry_pulse_intelligence.go b/internal/api/telemetry_pulse_intelligence.goindex d6447f2185..0fd125e1ba 100644--- a/internal/api/telemetry_pulse_intelligence.go+++ b/internal/api/telemetry_pulse_intelligence.go@@ -91,8 +91,15 @@ func (r *Router) GetPulseIntelligenceActionTelemetry(since time.Time) telemetry.recordsByID[actionID] = record}snapshot.ActionPlans30d+++ patrolOrigin := isPatrolActionOrigin(record.Origin)+ if patrolOrigin {+ snapshot.PatrolActionPlans30d+++ }if pulseIntelligenceActionRequiresApproval(record) {snapshot.ApprovalRequests30d+++ if patrolOrigin {+ snapshot.PatrolApprovalRequests30d+++ }}if pulseIntelligenceActionWasRejected(record) {if actionID := strings.TrimSpace(record.ID); actionID != "" {@@ -119,12 +126,34 @@ func (r *Router) GetPulseIntelligenceActionTelemetry(since time.Time) telemetry.snapshot.ApprovedActionDecisions30d += len(approvedDecisionIDs)snapshot.ApprovedActionAttempts30d += len(approvedAttemptIDs)snapshot.ApprovedActionSuccesses30d += len(approvedSuccessIDs)+ snapshot.PatrolRejectedActionDecisions30d += pulseIntelligencePatrolOriginActionCount(store, rejectedDecisionIDs, recordsByID)+ snapshot.PatrolApprovedActionDecisions30d += pulseIntelligencePatrolOriginActionCount(store, approvedDecisionIDs, recordsByID)+ snapshot.PatrolApprovedActionAttempts30d += pulseIntelligencePatrolOriginActionCount(store, approvedAttemptIDs, recordsByID)+ snapshot.PatrolApprovedActionSuccesses30d += pulseIntelligencePatrolOriginActionCount(store, approvedSuccessIDs, recordsByID)accumulatePulseIntelligenceApprovedActionOutcomes(&snapshot, store, orgID, approvedAttemptIDs, approvedSuccessIDs, recordsByID, time.Now().UTC())}return snapshot}+func pulseIntelligencePatrolOriginActionCount(store unifiedresources.ResourceStore, actionIDs map[string]struct{}, recordsByID map[string]unifiedresources.ActionAuditRecord) int {+ count := 0+ for actionID := range actionIDs {+ record, ok := recordsByID[actionID]+ if !ok && store != nil {+ fetched, found, err := store.GetActionAudit(actionID)+ if err == nil && found {+ record = fetched+ ok = true+ }+ }+ if ok && isPatrolActionOrigin(record.Origin) {+ count+++ }+ }+ return count+}+// pulseIntelligenceStuckExecutingThreshold separates an in-flight dispatch// from an abandoned one. The longest legitimate typed dispatch transport wait// is 30 minutes, so an executing record untouched for longer is stuck.diff --git a/internal/api/telemetry_pulse_intelligence_test.go b/internal/api/telemetry_pulse_intelligence_test.goindex b06c26ab72..e610929d54 100644--- a/internal/api/telemetry_pulse_intelligence_test.go+++ b/internal/api/telemetry_pulse_intelligence_test.go@@ -400,6 +400,15 @@ func TestGetPulseIntelligenceActionTelemetry_CountsOnlyIndependentPatrolFindingRif got.ApprovedActionAttempts30d != 3 || got.ApprovedActionSuccesses30d != 3 {t.Fatalf("attempts/successes = %d/%d, want 3/3", got.ApprovedActionAttempts30d, got.ApprovedActionSuccesses30d)}+ if got.PatrolActionPlans30d != 2 || got.PatrolApprovalRequests30d != 2 {+ t.Fatalf("Patrol-origin plans/approval requests = %d/%d, want 2/2", got.PatrolActionPlans30d, got.PatrolApprovalRequests30d)+ }+ if got.PatrolRejectedActionDecisions30d != 0 || got.PatrolApprovedActionDecisions30d != 2 {+ t.Fatalf("Patrol-origin rejected/approved decisions = %d/%d, want 0/2", got.PatrolRejectedActionDecisions30d, got.PatrolApprovedActionDecisions30d)+ }+ if got.PatrolApprovedActionAttempts30d != 2 || got.PatrolApprovedActionSuccesses30d != 2 {+ t.Fatalf("Patrol-origin attempts/successes = %d/%d, want 2/2", got.PatrolApprovedActionAttempts30d, got.PatrolApprovedActionSuccesses30d)+ }if got.VerifiedFindingResolutions30d != 1 {t.Fatalf("VerifiedFindingResolutions30d = %d, want 1", got.VerifiedFindingResolutions30d)}diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.goindex 4e4117d61a..0126b46878 100644--- a/internal/telemetry/telemetry.go+++ b/internal/telemetry/telemetry.go@@ -165,7 +165,10 @@ const (// saves a connection, concentrated three to one in container deployments,// and nothing recorded whether those installs tried to reach a node and// failed or never attempted one at all.- TelemetrySchemaVersion = 11+ // Schema v12 adds Patrol-origin action funnel counters so detection and+ // investigation activity can be separated from proposal, decision,+ // execution, and successful completion without exporting action identity.+ TelemetrySchemaVersion = 12)type installIDRecord struct {@@ -353,6 +356,12 @@ type Ping struct {PulseIntelligenceApprovedActionDecisions30d int `json:"pulse_intelligence_approved_action_decisions_30d"`PulseIntelligenceApprovedActionAttempts30d int `json:"pulse_intelligence_approved_action_attempts_30d"`PulseIntelligenceApprovedActionSuccesses30d int `json:"pulse_intelligence_approved_action_successes_30d"`+ PulseIntelligencePatrolActionPlans30d int `json:"pulse_intelligence_patrol_action_plans_30d"`+ PulseIntelligencePatrolApprovalRequests30d int `json:"pulse_intelligence_patrol_approval_requests_30d"`+ PulseIntelligencePatrolRejectedActionDecisions30d int `json:"pulse_intelligence_patrol_rejected_action_decisions_30d"`+ PulseIntelligencePatrolApprovedActionDecisions30d int `json:"pulse_intelligence_patrol_approved_action_decisions_30d"`+ PulseIntelligencePatrolApprovedActionAttempts30d int `json:"pulse_intelligence_patrol_approved_action_attempts_30d"`+ PulseIntelligencePatrolApprovedActionSuccesses30d int `json:"pulse_intelligence_patrol_approved_action_successes_30d"`// Cause-coded approved-action failure counters. Together with successes// and still-in-flight attempts these partition the attempt count, so the@@ -501,6 +510,12 @@ type Snapshot struct {PulseIntelligenceApprovedActionDecisions30d intPulseIntelligenceApprovedActionAttempts30d intPulseIntelligenceApprovedActionSuccesses30d int+ PulseIntelligencePatrolActionPlans30d int+ PulseIntelligencePatrolApprovalRequests30d int+ PulseIntelligencePatrolRejectedActionDecisions30d int+ PulseIntelligencePatrolApprovedActionDecisions30d int+ PulseIntelligencePatrolApprovedActionAttempts30d int+ PulseIntelligencePatrolApprovedActionSuccesses30d intPulseIntelligenceApprovedActionFailuresPreDispatch30d intPulseIntelligenceApprovedActionFailuresExecution30d intPulseIntelligenceApprovedActionFailuresUnverified30d int@@ -525,12 +540,18 @@ type Snapshot struct {// failure-cause fields carry only closed machine reason codes, never command// text, resource identifiers, or output.type PulseIntelligenceActionSnapshot struct {- ActionPlans30d int- ApprovalRequests30d int- RejectedActionDecisions30d int- ApprovedActionDecisions30d int- ApprovedActionAttempts30d int- ApprovedActionSuccesses30d int+ ActionPlans30d int+ ApprovalRequests30d int+ RejectedActionDecisions30d int+ ApprovedActionDecisions30d int+ ApprovedActionAttempts30d int+ ApprovedActionSuccesses30d int+ PatrolActionPlans30d int+ PatrolApprovalRequests30d int+ PatrolRejectedActionDecisions30d int+ PatrolApprovedActionDecisions30d int+ PatrolApprovedActionAttempts30d int+ PatrolApprovedActionSuccesses30d int// ApprovedActionFailuresPreDispatch30d counts approved attempts refused// terminally before dispatch (plan drift, expiry, emergency stop, policy@@ -1109,6 +1130,12 @@ func applySnapshot(base Ping, fn SnapshotFunc) Ping {ping.PulseIntelligenceApprovedActionDecisions30d = s.PulseIntelligenceApprovedActionDecisions30dping.PulseIntelligenceApprovedActionAttempts30d = s.PulseIntelligenceApprovedActionAttempts30dping.PulseIntelligenceApprovedActionSuccesses30d = s.PulseIntelligenceApprovedActionSuccesses30d+ ping.PulseIntelligencePatrolActionPlans30d = s.PulseIntelligencePatrolActionPlans30d+ ping.PulseIntelligencePatrolApprovalRequests30d = s.PulseIntelligencePatrolApprovalRequests30d+ ping.PulseIntelligencePatrolRejectedActionDecisions30d = s.PulseIntelligencePatrolRejectedActionDecisions30d+ ping.PulseIntelligencePatrolApprovedActionDecisions30d = s.PulseIntelligencePatrolApprovedActionDecisions30d+ ping.PulseIntelligencePatrolApprovedActionAttempts30d = s.PulseIntelligencePatrolApprovedActionAttempts30d+ ping.PulseIntelligencePatrolApprovedActionSuccesses30d = s.PulseIntelligencePatrolApprovedActionSuccesses30dping.PulseIntelligenceApprovedActionFailuresPreDispatch30d = s.PulseIntelligenceApprovedActionFailuresPreDispatch30dping.PulseIntelligenceApprovedActionFailuresExecution30d = s.PulseIntelligenceApprovedActionFailuresExecution30dping.PulseIntelligenceApprovedActionFailuresUnverified30d = s.PulseIntelligenceApprovedActionFailuresUnverified30ddiff --git a/pkg/server/telemetry_pulse_intelligence.go b/pkg/server/telemetry_pulse_intelligence.goindex 0da61eca99..524958afe1 100644--- a/pkg/server/telemetry_pulse_intelligence.go+++ b/pkg/server/telemetry_pulse_intelligence.go@@ -37,6 +37,12 @@ func applyPulseIntelligenceTelemetrySnapshot(snap.PulseIntelligenceApprovedActionDecisions30d = actionSnapshot.ApprovedActionDecisions30dsnap.PulseIntelligenceApprovedActionAttempts30d = actionSnapshot.ApprovedActionAttempts30dsnap.PulseIntelligenceApprovedActionSuccesses30d = actionSnapshot.ApprovedActionSuccesses30d+ snap.PulseIntelligencePatrolActionPlans30d = actionSnapshot.PatrolActionPlans30d+ snap.PulseIntelligencePatrolApprovalRequests30d = actionSnapshot.PatrolApprovalRequests30d+ snap.PulseIntelligencePatrolRejectedActionDecisions30d = actionSnapshot.PatrolRejectedActionDecisions30d+ snap.PulseIntelligencePatrolApprovedActionDecisions30d = actionSnapshot.PatrolApprovedActionDecisions30d+ snap.PulseIntelligencePatrolApprovedActionAttempts30d = actionSnapshot.PatrolApprovedActionAttempts30d+ snap.PulseIntelligencePatrolApprovedActionSuccesses30d = actionSnapshot.PatrolApprovedActionSuccesses30dsnap.PulseIntelligenceApprovedActionFailuresPreDispatch30d = actionSnapshot.ApprovedActionFailuresPreDispatch30dsnap.PulseIntelligenceApprovedActionFailuresExecution30d = actionSnapshot.ApprovedActionFailuresExecution30dsnap.PulseIntelligenceApprovedActionFailuresUnverified30d = actionSnapshot.ApprovedActionFailuresUnverified30ddiff --git a/pkg/server/telemetry_pulse_intelligence_test.go b/pkg/server/telemetry_pulse_intelligence_test.goindex 62713abf1e..df7b74addf 100644--- a/pkg/server/telemetry_pulse_intelligence_test.go+++ b/pkg/server/telemetry_pulse_intelligence_test.go@@ -116,6 +116,12 @@ func TestApplyPulseIntelligenceTelemetrySnapshot_AggregatesContentFreeLoopCountsApprovedActionDecisions30d: 1,ApprovedActionAttempts30d: 1,ApprovedActionSuccesses30d: 1,+ PatrolActionPlans30d: 6,+ PatrolApprovalRequests30d: 5,+ PatrolRejectedActionDecisions30d: 1,+ PatrolApprovedActionDecisions30d: 4,+ PatrolApprovedActionAttempts30d: 3,+ PatrolApprovedActionSuccesses30d: 2,ApprovedActionInFlight30d: 2,ApprovedActionUnclassified30d: 3,ApprovedActionRefusalsPlanStale30d: 4,@@ -176,6 +182,12 @@ func TestApplyPulseIntelligenceTelemetrySnapshot_AggregatesContentFreeLoopCountssnap.PulseIntelligenceApprovedActionDecisions30d != 1 ||snap.PulseIntelligenceApprovedActionAttempts30d != 1 ||snap.PulseIntelligenceApprovedActionSuccesses30d != 1 ||+ snap.PulseIntelligencePatrolActionPlans30d != 6 ||+ snap.PulseIntelligencePatrolApprovalRequests30d != 5 ||+ snap.PulseIntelligencePatrolRejectedActionDecisions30d != 1 ||+ snap.PulseIntelligencePatrolApprovedActionDecisions30d != 4 ||+ snap.PulseIntelligencePatrolApprovedActionAttempts30d != 3 ||+ snap.PulseIntelligencePatrolApprovedActionSuccesses30d != 2 ||snap.PulseIntelligenceApprovedActionInFlight30d != 2 ||snap.PulseIntelligenceApprovedActionUnclassified30d != 3 ||snap.PulseIntelligenceApprovedActionRefusalsPlanStale30d != 4 ||diff --git a/scripts/telemetry_adoption_report.py b/scripts/telemetry_adoption_report.pyindex 9696507c5d..f92494403a 100644--- a/scripts/telemetry_adoption_report.py+++ b/scripts/telemetry_adoption_report.py@@ -319,6 +319,12 @@ PULSE_INTELLIGENCE_COUNT_FIELDS = (("pulse_intelligence_approved_action_decisions_30d", "Approved action decisions 30d"),("pulse_intelligence_approved_action_attempts_30d", "Approved action attempts 30d"),("pulse_intelligence_approved_action_successes_30d", "Approved action successes 30d"),+ ("pulse_intelligence_patrol_action_plans_30d", "Patrol-origin action plans 30d"),+ ("pulse_intelligence_patrol_approval_requests_30d", "Patrol-origin approval requests 30d"),+ ("pulse_intelligence_patrol_rejected_action_decisions_30d", "Patrol-origin rejected action decisions 30d"),+ ("pulse_intelligence_patrol_approved_action_decisions_30d", "Patrol-origin approved action decisions 30d"),+ ("pulse_intelligence_patrol_approved_action_attempts_30d", "Patrol-origin approved action attempts 30d"),+ ("pulse_intelligence_patrol_approved_action_successes_30d", "Patrol-origin approved action successes 30d"),("pulse_intelligence_approved_action_failures_pre_dispatch_30d","Approved action failures (pre-dispatch refusal) 30d",@@ -628,6 +634,39 @@ PULSE_INTELLIGENCE_OUTCOME_COHORTS = ((),("pulse_intelligence_approved_action_successes_30d",),),+ (+ "patrol_action_plan_30d",+ "Patrol-origin action plan 30d",+ (),+ ("pulse_intelligence_patrol_action_plans_30d",),+ ),+ (+ "patrol_approval_request_30d",+ "Patrol-origin approval request 30d",+ (),+ ("pulse_intelligence_patrol_approval_requests_30d",),+ ),+ (+ "patrol_action_decision_30d",+ "Patrol-origin action decision 30d",+ (),+ (+ "pulse_intelligence_patrol_rejected_action_decisions_30d",+ "pulse_intelligence_patrol_approved_action_decisions_30d",+ ),+ ),+ (+ "patrol_action_attempt_30d",+ "Patrol-origin approved action attempt 30d",+ (),+ ("pulse_intelligence_patrol_approved_action_attempts_30d",),+ ),+ (+ "patrol_action_success_30d",+ "Patrol-origin approved action success 30d",+ (),+ ("pulse_intelligence_patrol_approved_action_successes_30d",),+ ),)PULSE_INTELLIGENCE_OPERATION_SIGNAL_GROUPS = {"configured": (@@ -711,6 +750,17 @@ PULSE_INTELLIGENCE_OPERATION_SIGNAL_GROUPS = {"pulse_intelligence_approved_action_attempts_30d",),),+ "patrol_action": (+ (),+ (+ "pulse_intelligence_patrol_action_plans_30d",+ "pulse_intelligence_patrol_approval_requests_30d",+ "pulse_intelligence_patrol_rejected_action_decisions_30d",+ "pulse_intelligence_patrol_approved_action_decisions_30d",+ "pulse_intelligence_patrol_approved_action_attempts_30d",+ "pulse_intelligence_patrol_approved_action_successes_30d",+ ),+ ),"approved_execution": (("pulse_intelligence_approved_execution_loop_30d",