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
Reject empty and blocked Patrol evidence
rcourtman991b3cad358d
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 283b0b3a74..c22a11af1c 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -67,9 +67,12 @@ model has received at least one successful structured result from an advertisedevidence tool. Until then, core withholds proposal authority while leavingevidence-tool selection model-owned. Failed, policy-blocked, loop-blocked, andotherwise rejected calls still consume the bounded evidence-attempt budget but-cannot satisfy grounding. If that budget is exhausted without a successful-result, the run fails closed before proposal or completed-investigation-persistence. An unset attempt ceiling does not weaken that rule: reaching the+cannot satisfy grounding. Transport success alone is insufficient: the result+must contain non-empty evidence content and must not carry the shared legacy or+structured policy-block/approval markers. If that budget is exhausted without+a successful result, the run fails closed before proposal or+completed-investigation persistence. An unset attempt ceiling does not weaken+that rule: reaching theindependent model-turn limit with no successful result fails closed before thegeneric final-summary fallback. The side-effect-free action-capability lookup is planningmetadata, not infrastructure evidence: it neither consumes the evidence budget@@ -7478,7 +7481,9 @@ authority or a zero-evidence manifest fails before inference. Runtimecompletion and proposal authority additionallyrequire at least one of those evidence calls to succeed; attempted calls remainvisible for budget accounting and forensics, but failed or blocked results are-not grounding. This keeps focused Patrol+not grounding. Blank tool results and machine-readable policy or approval+blocks are also non-grounding even when an adapter fails to set `is_error`.+This keeps focused Patrolusable with smaller local models without replacing model judgment with adiagnostic script or weakening proposal, policy, approval, execution, orverification boundaries.diff --git a/internal/ai/chat/agentic.go b/internal/ai/chat/agentic.goindex 990edb7fe0..9abddecaca 100644--- a/internal/ai/chat/agentic.go+++ b/internal/ai/chat/agentic.go@@ -2389,6 +2389,8 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif firstToolResultText == "" {firstToolResultText = resultText}+ successfulInvestigationEvidence := isPatrolInvestigationExecution(a.currentExecutionProfile()) &&+ isSuccessfulInvestigationEvidenceResult(tc.Name, resultText, isError)// Track pending recovery for strict resolution blocks// (FSM blocks are tracked above; strict resolution blocks come from the executor)@@ -2503,7 +2505,7 @@ func (a *AgenticLoop) executeWithTools(ctx context.Context, sessionID string, meif !isError {anyToolSucceededThisTurn = true- if isPatrolInvestigationExecution(a.currentExecutionProfile()) && isInvestigationEvidenceTool(tc.Name) {+ if successfulInvestigationEvidence {a.successfulEvidenceCalls++}if isPatrolDetectionExecution(a.currentExecutionProfile()) && tc.Name == agentcapabilities.PatrolGetFindingsToolName {diff --git a/internal/ai/chat/agentic_additional_test.go b/internal/ai/chat/agentic_additional_test.goindex 2d62b6f2e8..2269e51b99 100644--- a/internal/ai/chat/agentic_additional_test.go+++ b/internal/ai/chat/agentic_additional_test.go@@ -10,10 +10,23 @@ import ("time""github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"+ "github.com/rcourtman/pulse-go-rewrite/internal/agentexec""github.com/rcourtman/pulse-go-rewrite/internal/ai/providers""github.com/rcourtman/pulse-go-rewrite/internal/ai/tools")+type policyBlockedEvidenceAgentServer struct{}++func (policyBlockedEvidenceAgentServer) GetConnectedAgents() []agentexec.ConnectedAgent {+ return []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "host-1"}}+}++func (policyBlockedEvidenceAgentServer) ExecuteCommand(context.Context, string, agentexec.ExecuteCommandPayload) (*agentexec.CommandResultPayload, error) {+ return &agentexec.CommandResultPayload{+ Stdout: agentcapabilities.PolicyBlockedToolMarker("uptime", "blocked by policy"),+ }, nil+}+func TestRequiresOrderedPatrolFindingLifecycleExecution(t *testing.T) {tests := []struct {name string@@ -159,6 +172,83 @@ func TestInvestigationEvidenceBudgetHelpers(t *testing.T) {}}+func TestSuccessfulInvestigationEvidenceResultRejectsEmptyAndBlockedOutcomes(t *testing.T) {+ policyResponse := agentcapabilities.NewToolJSONResultWithIsError(agentcapabilities.NewToolBlockedError(+ agentcapabilities.ErrCodePolicyBlocked,+ "blocked by policy",+ nil,+ ), false)++ tests := []struct {+ name string+ tool string+ content string+ isError bool+ want bool+ }{+ {name: "canonical evidence", tool: agentcapabilities.PulseQueryToolName, content: `{"items":[]}`, want: true},+ {name: "non evidence tool", tool: agentcapabilities.PulseAlertsToolName, content: `{"alerts":[]}`},+ {name: "error result", tool: agentcapabilities.PulseQueryToolName, content: "query failed", isError: true},+ {name: "empty result", tool: agentcapabilities.PulseQueryToolName},+ {name: "whitespace result", tool: agentcapabilities.PulseQueryToolName, content: " \n\t "},+ {name: "legacy policy block", tool: agentcapabilities.PulseQueryToolName, content: " \n" + agentcapabilities.PolicyBlockedToolMarker("query", "blocked by policy")},+ {name: "structured policy block", tool: agentcapabilities.PulseQueryToolName, content: agentcapabilities.ToolResultText(policyResponse)},+ {name: "approval request", tool: agentcapabilities.PulseQueryToolName, content: agentcapabilities.ApprovalRequiredToolMarker("query", "call-1", "approval required", "approval-1", "Approve it.")},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := isSuccessfulInvestigationEvidenceResult(tt.tool, tt.content, tt.isError); got != tt.want {+ t.Fatalf("isSuccessfulInvestigationEvidenceResult(%q, %q, %v) = %v, want %v", tt.tool, tt.content, tt.isError, got, tt.want)+ }+ })+ }+}++func TestAgenticLoopPatrolInvestigationPolicyBlockedEvidenceDoesNotUnlockProposal(t *testing.T) {+ t.Setenv("PULSE_STRICT_RESOLUTION", "false")+ provider := &stubStreamingProvider{}+ providerCalls := 0+ provider.chatStream = func(_ context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {+ providerCalls+++ if providerToolIsAdvertised(req.Tools, agentcapabilities.PatrolProposeActionToolName) {+ t.Fatalf("proposal authority exposed before grounded evidence: %+v", req.Tools)+ }+ callback(providers.StreamEvent{Type: "done", Data: providers.DoneEvent{ToolCalls: []providers.ToolCall{{+ ID: "policy-blocked-evidence", Name: agentcapabilities.PulseReadToolName,+ Input: map[string]interface{}{"action": "exec", "command": "uptime", "target_host": "host-1"},+ }}}})+ return nil+ }++ executor := tools.NewPulseToolExecutor(tools.ExecutorConfig{AgentServer: policyBlockedEvidenceAgentServer{}})+ executor.ApplyExecutionProfile(tools.ProfilePatrolInvestigation)+ loop := NewAgenticLoop(provider, executor, "system")+ loop.SetExecutionProfile(tools.ProfilePatrolInvestigation)+ loop.SetMaxEvidenceCalls(1)+ loop.SetMaxTurns(3)++ result, err := loop.ExecuteWithTools(+ context.Background(),+ "policy-blocked-evidence",+ []Message{{Role: "user", Content: "investigate"}},+ []providers.Tool{{Name: agentcapabilities.PulseReadToolName}, {Name: agentcapabilities.PatrolProposeActionToolName}},+ func(StreamEvent) {},+ )+ if err == nil || !strings.Contains(err.Error(), "without a successful structured evidence result") {+ t.Fatalf("ExecuteWithTools error = %v, want fail-closed grounding error", err)+ }+ if providerCalls != 1 || loop.GetTotalEvidenceCalls() != 1 || loop.successfulEvidenceCalls != 0 {+ t.Fatalf("provider/evidence counts = %d/%d/%d, want 1/1/0", providerCalls, loop.GetTotalEvidenceCalls(), loop.successfulEvidenceCalls)+ }+ if len(result) == 0 || result[len(result)-1].ToolResult == nil {+ t.Fatalf("policy-blocked evidence result missing from transcript: %+v", result)+ }+ blocked := result[len(result)-1].ToolResult+ if blocked.IsError || !agentcapabilities.HasPolicyBlockedToolMarker(blocked.Content) {+ t.Fatalf("test requires a transport-success policy block, got %+v", blocked)+ }+}+func TestAgenticLoopPatrolInvestigationRepairsToolFreeStart(t *testing.T) {provider := &stubStreamingProvider{}var requests []providers.ChatRequestdiff --git a/internal/ai/chat/agentic_investigation_budget.go b/internal/ai/chat/agentic_investigation_budget.goindex 8aaa9320e0..0d25b92c0e 100644--- a/internal/ai/chat/agentic_investigation_budget.go+++ b/internal/ai/chat/agentic_investigation_budget.go@@ -2,6 +2,7 @@ package chatimport ("fmt"+ "strings""github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities""github.com/rcourtman/pulse-go-rewrite/internal/ai/providers"@@ -45,6 +46,23 @@ func isInvestigationEvidenceTool(name string) bool {return agentcapabilities.IsPatrolInfrastructureEvidenceToolName(name)}+func isSuccessfulInvestigationEvidenceResult(name, content string, isError bool) bool {+ content = strings.TrimSpace(content)+ if !isInvestigationEvidenceTool(name) || isError || content == "" {+ return false+ }+ if agentcapabilities.HasPolicyBlockedToolMarker(content) || agentcapabilities.HasApprovalRequiredToolMarker(content) {+ return false+ }+ if code, ok := agentcapabilities.ToolResultErrorCode(content); ok {+ switch code {+ case agentcapabilities.ErrCodePolicyBlocked, agentcapabilities.ErrCodeApprovalRequired:+ return false+ }+ }+ return true+}+func investigationEvidenceTools(available []providers.Tool) []providers.Tool {filtered := make([]providers.Tool, 0, len(available))for _, tool := range available {