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
Make Patrol report confirmed health failures
rcourtmanf6a289f72d14
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 114d909935..23331d0034 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -78,6 +78,20 @@ the same investigate, approval, execution, and verification boundaries enforcedby the orchestrator. Prompt copy must not fall back to the legacy`patrol_auto_fix` boolean or the retired "observe only" / "auto-fix mode"framing.+Patrol's Watch evidence contract treats a direct provider-reported failed+health check, failed backup, or broken replication state as sufficient evidence+for the confirmed operational symptom. The model reports that symptom even when+an agent or native log adapter cannot supply optional root-cause evidence,+uses warning/reliability for a failed health check unless evidence establishes+a critical consequence, states that the root cause remains unknown, and must+not fabricate one. Scoped+triage seed context contains both deterministic flags and the explicitly scoped+resource inventory, including exact app-container health, rather than reducing+the model's evidence to whichever resources the deterministic pass happened to+flag. Quick scoped checks have a strict three-turn model budget: active-finding+inspection, report or assessment, and final summary. A capability-unavailable+read result is terminal for that capability within the run and must not trigger+retries or broad inventory scans.Patrol finding storage must consolidate equivalent active storage-capacitysiblings before they reach browser surfaces: a broader storage risk and ageneric usage/capacity finding for the same normalized storage identity are onediff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.goindex 2fd40d32e8..4771500091 100644--- a/internal/ai/patrol_ai.go+++ b/internal/ai/patrol_ai.go@@ -7,6 +7,7 @@ import ("context""encoding/json""fmt"+ "maps""regexp""sort""strconv"@@ -955,6 +956,16 @@ func computePatrolMaxTurns(resourceCount int, scope *PatrolScope) int {}func computeTriageMaxTurns(flagCount int, scope *PatrolScope) int {+ // A quick Patrol run is an intentionally narrow check of already-scoped+ // resources. The seed contains the current resource evidence, leaving one+ // turn to inspect active findings, one to report/assess, and one to finish.+ // Giving quick runs the full adaptive budget encourages broad rediscovery+ // and can multiply the same large tool schema across otherwise redundant+ // provider calls.+ if scope != nil && scope.Depth == PatrolDepthQuick {+ return 3+ }+const (triageBaseTurns = 5triageTurnsPerFlag = 3@@ -969,12 +980,6 @@ func computeTriageMaxTurns(flagCount int, scope *PatrolScope) int {if turns > triageMaxTurns {turns = triageMaxTurns}- if scope != nil && scope.Depth == PatrolDepthQuick {- if turns > 20 {- turns = 20- }- }-return turns}@@ -1168,7 +1173,7 @@ You have access to the following tools to investigate infrastructure:- pulse_pmg — Proxmox Mail Gateway status, mail stats, queues**Deep Investigation:**-- pulse_read — Read-only command execution, file reads, log tailing+- pulse_read — Read-only command execution, file reads, and log tailing when a command-capable agent or native log adapter is available for the resource- pulse_discovery — Read or refresh discovered service details, config paths, ports, and bind mounts- pulse_knowledge — User notes, incidents, event correlations@@ -1193,6 +1198,8 @@ The seed context includes service identity (from discovery) and reachability dat- Resource configuration details that could explain misconfiguration.- Mail queue or spam-volume data if mail flow looks abnormal.+A direct provider-reported failed health check, failed backup, or broken replication state is already confirmed evidence of an operational symptom. Report that symptom even when logs or command execution are unavailable. Use warning/reliability for a failed health check unless the evidence establishes a critical consequence. State that the root cause is unknown and recommend the next safe diagnostic step; never invent a root cause. Missing optional root-cause evidence must not suppress a confirmed symptom-level finding.+**Step 3 — Report or assess findings.** Report new confirmed issues with patrol_report_finding. For every active finding returned by patrol_get_findings, call patrol_assess_finding exactly once with present, resolved, or uncertain and current evidence. Do not silently skip a known finding: omission is not evidence that it cleared. patrol_resolve_finding remains available for compatibility, but patrol_assess_finding is the complete existing-finding verdict.Always call patrol_get_findings before reporting, assessing, or resolving findings.@@ -1201,6 +1208,8 @@ The snapshot eliminates routine data gathering. When a notable signal needs curr## Efficiency Rules- Do NOT call the same tool with the same parameters twice in a single patrol run.- Keep track of what you've already checked. If you've already retrieved metrics for a resource, use the data you have.+- Once direct resource evidence confirms an actionable symptom, report it before pursuing optional root-cause detail.+- If a tool reports that a resource lacks the required agent or native capability, do not retry that capability or replace it with a broad inventory scan. Continue with the evidence already available.## Severity & Thresholds@@ -1340,9 +1349,14 @@ func (p *PatrolService) buildTriageSeedSectionsState(if triage == nil {triage = &TriageResult{}}- flaggedSet := triage.FlaggedIDs- if flaggedSet == nil {- flaggedSet = map[string]bool{}+ seedSet := p.buildScopedSetForRuntime(scope, snap)+ if seedSet == nil {+ seedSet = make(map[string]bool, len(triage.FlaggedIDs))+ } else {+ seedSet = maps.Clone(seedSet)+ }+ for id := range triage.FlaggedIDs {+ seedSet[id] = true}findingsCtx, seededFindingIDs := p.seedFindingsAndContextState(scope, snap)@@ -1352,8 +1366,8 @@ func (p *PatrolService) buildTriageSeedSectionsState(// P0 — always include.{priority: 0, name: "triage_overview", content: formatTriageOverviewSection(triage)},{priority: 0, name: "findings", content: findingsCtx},- {priority: 0, name: "health_alerts", content: p.seedHealthAndAlertsState(snap, flaggedSet, cfg, now)},- {priority: 0, name: "scope", content: buildScopeSection(scope, sortedScopedIDs(flaggedSet))},+ {priority: 0, name: "health_alerts", content: p.seedHealthAndAlertsState(snap, seedSet, cfg, now)},+ {priority: 0, name: "scope", content: buildScopeSection(scope, sortedScopedIDs(seedSet))},// P2 — triage already preserves the flagged set, so these sections can// summarize under tighter provider-derived retry budgets.@@ -1366,8 +1380,8 @@ func (p *PatrolService) buildTriageSeedSectionsState({priority: 2,name: "flagged_inventory",- content: p.seedResourceInventoryState(snap, flaggedSet, cfg, now, false, guestIntel),- summary: p.seedResourceInventorySummaryState(snap, flaggedSet, cfg, now, guestIntel),+ content: p.seedResourceInventoryState(snap, seedSet, cfg, now, false, guestIntel),+ summary: p.seedResourceInventorySummaryState(snap, seedSet, cfg, now, guestIntel),},// P3 — healthy rollup is useful context but lowest-value on retries.@@ -2020,6 +2034,7 @@ type patrolDockerHostRow struct {type patrolAppContainerRow struct {id, name, status string+ health stringcpu, memory float64}@@ -2336,6 +2351,7 @@ func patrolAppContainerRows(snap patrolRuntimeState, scopedSet map[string]bool)id: cv.ID(),name: cv.Name(),status: strings.TrimSpace(cv.ContainerState()),+ health: strings.TrimSpace(cv.Health()),cpu: cv.CPUPercent(),memory: cv.MemoryPercent(),})@@ -2357,6 +2373,7 @@ func patrolAppContainerRows(snap patrolRuntimeState, scopedSet map[string]bool)id: container.ID,name: container.Name,status: container.State,+ health: container.Health,cpu: container.CPUPercent,memory: container.MemoryPercent,})@@ -2920,6 +2937,27 @@ func (p *PatrolService) seedResourceInventoryState(snap patrolRuntimeState, scop}sb.WriteString("\n")}++ // Full unscoped runs retain the compact host rollup above. Scoped and+ // triage runs also carry exact app-container evidence so a child resource+ // does not disappear merely because its parent host is outside the set.+ if scopedSet != nil {+ containerRows := patrolAppContainerRows(snap, scopedSet)+ if len(containerRows) > 0 {+ sb.WriteString("# Scoped App Containers\n")+ sb.WriteString("| Name | Resource ID | State | Health | CPU | Memory |\n")+ sb.WriteString("|------|-------------|-------|--------|-----|--------|\n")+ for _, row := range containerRows {+ health := strings.TrimSpace(row.health)+ if health == "" {+ health = "not reported"+ }+ sb.WriteString(fmt.Sprintf("| %s | %s | %s | %s | %.0f%% | %.0f%% |\n",+ row.name, row.id, row.status, health, row.cpu, row.memory))+ }+ sb.WriteString("\n")+ }+ }}// --- Storage Pools ---diff --git a/internal/ai/patrol_triage.go b/internal/ai/patrol_triage.goindex 0cb98a5f46..be3591d6b2 100644--- a/internal/ai/patrol_triage.go+++ b/internal/ai/patrol_triage.go@@ -71,6 +71,7 @@ func (p *PatrolService) runDeterministicTriageState(flags = append(flags, triageAnomalyChecks(intel)...)flags = append(flags, triageBackupChecksState(snap, scopedSet)...)flags = append(flags, triageDiskHealthChecksState(snap, scopedSet)...)+ flags = append(flags, triageContainerHealthChecksState(snap, scopedSet)...)flags = append(flags, triageAlertChecksState(snap, scopedSet)...)flags = append(flags, triageConnectivityChecksState(snap, guestIntel, scopedSet)...)flags = append(flags, triageRecentChanges(intel)...)@@ -100,6 +101,36 @@ func (p *PatrolService) runDeterministicTriageState(}}+func triageContainerHealthChecksState(snap patrolRuntimeState, scopedSet map[string]bool) []TriageFlag {+ rows := patrolAppContainerRows(snap, scopedSet)+ flags := make([]TriageFlag, 0)+ for _, row := range rows {+ if !strings.EqualFold(strings.TrimSpace(row.status), "running") || !triageContainerHealthFailed(row.health) {+ continue+ }++ health := strings.TrimSpace(row.health)+ flags = append(flags, TriageFlag{+ ResourceID: row.id,+ ResourceName: triageResourceName(row.name, row.id),+ ResourceType: "app-container",+ Category: "health",+ Severity: "warning",+ Reason: fmt.Sprintf("Container health check reported %s while running", health),+ })+ }+ return flags+}++func triageContainerHealthFailed(health string) bool {+ switch strings.ToLower(strings.TrimSpace(health)) {+ case "unhealthy", "failed", "failing", "error", "critical", "degraded":+ return true+ default:+ return false+ }+}+func triageThresholdChecksState(snap patrolRuntimeState, scopedSet map[string]bool, thresholds PatrolThresholds) []TriageFlag {flags := make([]TriageFlag, 0)for _, n := range patrolNodeInventoryRows(snap, scopedSet) {diff --git a/internal/ai/patrol_triage_integration_test.go b/internal/ai/patrol_triage_integration_test.goindex 1d2615dccb..678e7d5865 100644--- a/internal/ai/patrol_triage_integration_test.go+++ b/internal/ai/patrol_triage_integration_test.go@@ -86,6 +86,31 @@ func TestBuildTriageSeedContext_FlaggedOnly(t *testing.T) {}}+func TestBuildTriageSeedContext_UnionsExplicitScopeWithFlags(t *testing.T) {+ ps := NewPatrolService(nil, nil)+ state := triageIntegrationState(10)+ triage := triageIntegrationResult(state, map[string]bool{"qemu/102": true})+ scope := &PatrolScope{+ ResourceIDs: []string{"qemu/107"},+ Depth: PatrolDepthQuick,+ }++ seed, _ := ps.buildTriageSeedContextState(triage, patrolRuntimeStateForTest(ps, state), scope, nil)+ for _, expected := range []string{"vm-02", "vm-07"} {+ if !strings.Contains(seed, expected) {+ t.Fatalf("expected flagged or explicitly scoped resource %q in triage seed, got:\n%s", expected, seed)+ }+ }+ for _, unexpected := range []string{"vm-00", "vm-03", "vm-09"} {+ if strings.Contains(seed, unexpected) {+ t.Fatalf("did not expect unrelated resource %q in triage seed, got:\n%s", unexpected, seed)+ }+ }+ if !strings.Contains(seed, "Effective scope: 2 resources (qemu/102, qemu/107)") {+ t.Fatalf("expected scope section to describe the complete evidence set, got:\n%s", seed)+ }+}+func TestBuildTriageSeedContext_SmallOutput(t *testing.T) {ps := NewPatrolService(nil, nil)state := triageIntegrationState(40)@@ -130,8 +155,10 @@ func TestComputeTriageMaxTurns(t *testing.T) {}quickScope := &PatrolScope{Depth: PatrolDepthQuick}- if got := computeTriageMaxTurns(15, quickScope); got != 20 {- t.Fatalf("quick scope expected 20-turn cap, got %d", got)+ for _, flagCount := range []int{0, 1, 15, 100} {+ if got := computeTriageMaxTurns(flagCount, quickScope); got != 3 {+ t.Fatalf("quick scope with %d flags: expected strict 3-turn budget, got %d", flagCount, got)+ }}}@@ -156,6 +183,16 @@ func TestGetPatrolSystemPromptForTriage(t *testing.T) {if strings.Contains(prompt, "Your job is to find issues that simple threshold-based alerts CANNOT catch") {t.Fatalf("expected standard opening to be replaced in triage prompt, got:\n%s", prompt)}+ for _, required := range []string{+ "failed health check",+ "Report that symptom even when logs or command execution are unavailable",+ "root cause is unknown",+ "do not retry that capability",+ } {+ if !strings.Contains(prompt, required) {+ t.Fatalf("expected confirmed-symptom evidence contract %q in prompt, got:\n%s", required, prompt)+ }+ }}func triageIntegrationState(vmCount int) models.StateSnapshot {diff --git a/internal/ai/patrol_triage_test.go b/internal/ai/patrol_triage_test.goindex e95631031c..963ebd9f11 100644--- a/internal/ai/patrol_triage_test.go+++ b/internal/ai/patrol_triage_test.go@@ -359,6 +359,73 @@ func TestTriageDiskHealthChecksState_UsesPhysicalDiskFallback(t *testing.T) {}}+func TestTriageContainerHealthChecksState_FlagsConfirmedFailureOnly(t *testing.T) {+ state := patrolRuntimeState{+ DockerHosts: []models.DockerHost{{+ ID: "docker-host-1",+ Hostname: "tower",+ Containers: []models.DockerContainer{+ {ID: "app-container:tower:faulty", Name: "faulty", State: "running", Health: "unhealthy"},+ {ID: "app-container:tower:healthy", Name: "healthy", State: "running", Health: "healthy"},+ {ID: "app-container:tower:starting", Name: "starting", State: "running", Health: "starting"},+ {ID: "app-container:tower:stopped", Name: "stopped", State: "exited", Health: "unhealthy"},+ },+ }},+ }++ flags := triageContainerHealthChecksState(state, nil)+ if len(flags) != 1 {+ t.Fatalf("expected one confirmed container-health failure, got %#v", flags)+ }+ flag := flags[0]+ if flag.ResourceID != "app-container:tower:faulty" || flag.ResourceName != "faulty" || flag.ResourceType != "app-container" {+ t.Fatalf("expected exact app-container identity, got %#v", flag)+ }+ if flag.Category != "health" || flag.Severity != "warning" || !strings.Contains(flag.Reason, "reported unhealthy while running") {+ t.Fatalf("expected grounded warning health flag, got %#v", flag)+ }+}++func TestTriageContainerHealthChecksState_UsesReadState(t *testing.T) {+ parentID := "docker-host-1"+ unhealthy := unifiedresources.NewDockerContainerView(&unifiedresources.Resource{+ ID: "app-container:tower:faulty",+ Name: "faulty",+ Type: unifiedresources.ResourceTypeAppContainer,+ Status: unifiedresources.StatusOnline,+ ParentID: &parentID,+ Docker: &unifiedresources.DockerData{+ ContainerState: "running",+ Health: "unhealthy",+ },+ })+ state := patrolRuntimeState{readState: &mockReadState{dockerCtrs: []*unifiedresources.DockerContainerView{&unhealthy}}}++ flags := triageContainerHealthChecksState(state, map[string]bool{"app-container:tower:faulty": true})+ if len(flags) != 1 || flags[0].ResourceID != "app-container:tower:faulty" {+ t.Fatalf("expected read-state container health failure, got %#v", flags)+ }++ ps := NewPatrolService(nil, nil)+ triage := &TriageResult{+ Flags: flags,+ FlaggedIDs: map[string]bool{flags[0].ResourceID: true},+ }+ seed, _ := ps.buildTriageSeedContextState(triage, state, &PatrolScope{+ ResourceIDs: []string{flags[0].ResourceID},+ Depth: PatrolDepthQuick,+ }, nil)+ for _, expected := range []string{+ "Container health check reported unhealthy while running",+ "# Scoped App Containers",+ "| faulty | app-container:tower:faulty | running | unhealthy |",+ } {+ if !strings.Contains(seed, expected) {+ t.Fatalf("expected exact app-container evidence %q in triage seed, got:\n%s", expected, seed)+ }+ }+}+func TestTriageAlertChecks(t *testing.T) {state := patrolRuntimeState{ActiveAlerts: []models.Alert{diff --git a/internal/ai/tools/tools_patrol.go b/internal/ai/tools/tools_patrol.goindex 340b1256d0..11b91094b9 100644--- a/internal/ai/tools/tools_patrol.go+++ b/internal/ai/tools/tools_patrol.go@@ -17,7 +17,7 @@ func (e *PulseToolExecutor) registerPatrolTools() {Name: agentcapabilities.PatrolReportFindingToolName,Description: `Report an infrastructure finding discovered during patrol investigation.-Call this tool to create a structured finding after you have gathered sufficient evidence via investigation tools.+Call this tool to create a structured finding after you have gathered sufficient evidence. A provider-reported failed health check, failed backup, or broken replication state is sufficient evidence for the confirmed symptom even when optional logs or command execution are unavailable. Use warning/reliability for a failed health check unless the evidence establishes a critical consequence. Report the symptom and state that its root cause is unknown; do not fabricate a cause or suppress the finding while searching for one.The finding will be validated against current metrics and deduplicated automatically.Returns: {"ok": true, "finding_id": "...", "is_new": true/false} on success.`,diff --git a/internal/ai/tools/tools_patrol_test.go b/internal/ai/tools/tools_patrol_test.goindex 95923d2c00..add50a5cc0 100644--- a/internal/ai/tools/tools_patrol_test.go+++ b/internal/ai/tools/tools_patrol_test.go@@ -757,6 +757,7 @@ func TestPatrolToolsRegistered(t *testing.T) {})found := map[string]bool{}var resolveTool Tool+ var reportTool Toolfor _, tool := range tools {if tool.Name == "patrol_report_finding" || tool.Name == "patrol_assess_finding" || tool.Name == "patrol_resolve_finding" || tool.Name == "patrol_get_findings" {found[tool.Name] = true@@ -764,6 +765,9 @@ func TestPatrolToolsRegistered(t *testing.T) {if tool.Name == "patrol_resolve_finding" {resolveTool = tool}+ if tool.Name == "patrol_report_finding" {+ reportTool = tool+ }}assert.True(t, found["patrol_report_finding"], "patrol_report_finding should be registered")@@ -775,6 +779,9 @@ func TestPatrolToolsRegistered(t *testing.T) {assert.Contains(t, resolveTool.InputSchema.Required, agentcapabilities.ReasonArgumentName)assert.Contains(t, resolveTool.InputSchema.Properties, agentcapabilities.FindingIDArgumentName)assert.Contains(t, resolveTool.InputSchema.Properties, agentcapabilities.ReasonArgumentName)+ require.NotEmpty(t, reportTool.Name)+ assert.Contains(t, reportTool.Description, "failed health check")+ assert.Contains(t, reportTool.Description, "root cause is unknown")}func TestPatrolToolsAvailability(t *testing.T) {diff --git a/internal/ai/tools/tools_read.go b/internal/ai/tools/tools_read.goindex 39f17d3041..827b94f98d 100644--- a/internal/ai/tools/tools_read.go+++ b/internal/ai/tools/tools_read.go@@ -17,7 +17,7 @@ func (e *PulseToolExecutor) registerReadTools() {e.registry.registerBuiltin(RegisteredTool{Definition: Tool{Name: agentcapabilities.PulseReadToolName,- Description: `Execute read-only operations on infrastructure (exec, file, find, tail, logs). Rejects write commands. Use target_host for agent-routed reads, or resource_id for API-backed native resource logs such as supported TrueNAS app-containers. When Pulse has attached resource context, use target_host="current_resource" or resource_id="current_resource" for the attached resource instead of copying redacted identifiers.`,+ Description: `Execute read-only operations on infrastructure (exec, file, find, tail, logs). Rejects write commands. Agent-routed actions require a command-capable agent; resource_id logs require a supported native log adapter. Use target_host for agent-routed reads, or resource_id for API-backed native resource logs such as supported TrueNAS app-containers. When Pulse has attached resource context, use target_host="current_resource" or resource_id="current_resource" for the attached resource instead of copying redacted identifiers. If the tool reports that the required capability is unavailable, do not retry the same capability; continue with provider evidence already available.`,InputSchema: InputSchema{Type: "object",Properties: map[string]PropertySchema{diff --git a/internal/ai/tools/tools_read_test.go b/internal/ai/tools/tools_read_test.goindex a1745a64a1..b7ae40b043 100644--- a/internal/ai/tools/tools_read_test.go+++ b/internal/ai/tools/tools_read_test.go@@ -289,6 +289,15 @@ func TestPulseToolExecutor_ListTools_IncludesPulseReadForNativeAppReadProvider(ttools := exec.ListTools()assert.True(t, containsTool(tools, "pulse_read"))+ for _, tool := range tools {+ if tool.Name != "pulse_read" {+ continue+ }+ assert.Contains(t, tool.Description, "require a command-capable agent")+ assert.Contains(t, tool.Description, "do not retry the same capability")+ return+ }+ t.Fatal("pulse_read tool definition was not projected")}func TestExecuteReadLogs_TrueNASAppUsesNativeReadProvider(t *testing.T) {