Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Clear Patrol runtime issue after scoped success

rcourtmanf13a89db624c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 96946de0a4..68b8ad1cb0 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -1268,6 +1268,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 not
present in the infrastructure snapshot. Those findings stay active until
Patrol actually succeeds or resolves them for a Patrol-owned reason.
+That success boundary includes provider-backed scoped Patrol runs. A successful
+scoped run proves that Patrol can currently reach the selected provider/model
+and complete tool-backed analysis, so it must clear the synthetic
+`ai-service` runtime failure just as a successful full Patrol run does, without
+loosening ordinary scoped finding reconciliation for infrastructure issues.
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`
@@ -1304,6 +1309,11 @@ Patrol. Reasoning-backed provider turns that return tool calls with
`reasoning_content` must preserve that reasoning state on the following
tool-result turn when the provider requires it, so Assistant and Patrol can
complete multi-turn tool use against live BYOK providers.
+Readiness classification for the same provider path must be model-aware, not
+provider-only. Known live-proven DeepSeek V4 tool-capable models may report
+Patrol readiness as ready; unknown DeepSeek aliases may still warn until
+proved, and known reasoning-only families must continue to fail closed before
+Patrol work is admitted.
That same browser-owned chat read model must keep target normalization helper-
driven. Assistant shells may still derive legacy VM identifiers or display
labels for read-only targeting, but they must do so through shared helpers and
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 54863fc0d8..e6ca4e8e2a 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -503,6 +503,12 @@ provider protocol fragments such as `tool_choice`, `reasoning_content`, raw
endpoint URLs, credential hints, or model-internal error strings do not leak
through run history while the operator still receives an actionable recovery
summary.
+The Patrol surface must not keep presenting runtime-warning or runtime-issue
+copy after a successful provider-backed Patrol run proves the selected
+provider/model can run tool-backed analysis. Scoped success may still leave
+estate coverage incomplete, but it must clear stale Patrol runtime impairment
+state and suppress provider-only readiness warnings for live-proven
+tool-capable models.
That same shared finding-presentation helper should also own Patrol finding
subject labels, so Patrol-owned synthetic service findings render as
`Patrol runtime` rather than leaking backend resource internals like
diff --git a/internal/ai/patrol_readiness.go b/internal/ai/patrol_readiness.go
index d1fbaae87f..4ea57b9bc0 100644
--- a/internal/ai/patrol_readiness.go
+++ b/internal/ai/patrol_readiness.go
@@ -77,6 +77,8 @@ func EvaluatePatrolConfigReadiness(cfg *config.AIConfig) PatrolConfigReadiness {
func PatrolToolReadinessForModel(provider, model string) (string, PatrolFailureCause, string) {
normalizedModel := strings.ToLower(strings.TrimSpace(model))
switch {
+ case provider == config.AIProviderDeepSeek && patrolDeepSeekModelSupportsTools(normalizedModel):
+ return PatrolReadinessReady, PatrolFailureCauseNone, "The selected DeepSeek model supports Patrol's tool-backed analysis contract."
case strings.Contains(normalizedModel, "deepseek-r1") ||
strings.Contains(normalizedModel, "/r1") ||
strings.Contains(normalizedModel, ":r1") ||
@@ -94,6 +96,11 @@ func PatrolToolReadinessForModel(provider, model string) (string, PatrolFailureC
}
}
+func patrolDeepSeekModelSupportsTools(normalizedModel string) bool {
+ model := strings.TrimPrefix(normalizedModel, string(config.AIProviderDeepSeek)+":")
+ return model == "deepseek-v4-flash" || model == "deepseek-v4-pro"
+}
+
func patrolConfigReadiness(provider, model, status string, cause PatrolFailureCause, summary string) PatrolConfigReadiness {
if cause == "" {
cause = PatrolFailureCauseNone
diff --git a/internal/ai/patrol_readiness_test.go b/internal/ai/patrol_readiness_test.go
index d3aecf949b..646531374f 100644
--- a/internal/ai/patrol_readiness_test.go
+++ b/internal/ai/patrol_readiness_test.go
@@ -71,6 +71,16 @@ func TestEvaluatePatrolConfigReadiness_AssignsStableCause(t *testing.T) {
cfg.PatrolModel = "ollama:llama3.2"
},
},
+ {
+ name: "deepseek v4 flash ready",
+ wantCause: PatrolFailureCauseNone,
+ wantReady: true,
+ configure: func(cfg *config.AIConfig) {
+ cfg.Enabled = true
+ cfg.DeepSeekAPIKey = "sk-test"
+ cfg.PatrolModel = "deepseek:deepseek-v4-flash"
+ },
+ },
{
name: "ready",
wantCause: PatrolFailureCauseNone,
diff --git a/internal/ai/patrol_run.go b/internal/ai/patrol_run.go
index 1beb89e6e9..106920d0bf 100644
--- a/internal/ai/patrol_run.go
+++ b/internal/ai/patrol_run.go
@@ -298,6 +298,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
errorSummary string
errorDetail string
aiAnalysis *AIAnalysisResult // Stores the AI's analysis for the run record
+ runtimeResolved bool
}
var newFindings []*Finding
@@ -405,14 +406,8 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
runStats.triageFlags = aiResult.TriageFlags
runStats.triageSkippedLLM = aiResult.TriageSkippedLLM
- // Auto-resolve previous patrol error finding if this run succeeded
- errorFindingID := generateFindingID("ai-service", "reliability", "ai-patrol-error")
- if existing := p.findings.Get(errorFindingID); existing != nil && !existing.IsResolved() {
- p.findings.Resolve(errorFindingID, true) // auto-resolved
- if resolver := p.unifiedFindingResolver; resolver != nil {
- resolver(errorFindingID)
- }
- log.Info().Msg("AI Patrol: Auto-resolved previous patrol error finding after successful run")
+ if !aiResult.TriageSkippedLLM {
+ runStats.runtimeResolved = p.resolvePatrolRuntimeFailureFinding("full_patrol_success")
}
// Findings are already recorded via patrol_report_finding tool calls.
@@ -437,6 +432,9 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge
var resolvedCount int
if runStats.aiAnalysis != nil {
resolvedCount = len(runStats.aiAnalysis.ResolvedIDs)
+ if runStats.runtimeResolved {
+ resolvedCount++
+ }
// Auto-resolve stale findings: active findings that were presented to the LLM
// in seed context but were neither re-reported nor explicitly resolved.
@@ -687,6 +685,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
errorSummary string
errorDetail string
aiAnalysis *AIAnalysisResult
+ runtimeResolved bool
}
// Get current state
@@ -818,6 +817,9 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
runStats.rejectedFindings = aiResult.RejectedFindings
runStats.triageFlags = aiResult.TriageFlags
runStats.triageSkippedLLM = aiResult.TriageSkippedLLM
+ if !aiResult.TriageSkippedLLM {
+ runStats.runtimeResolved = p.resolvePatrolRuntimeFailureFinding("scoped_patrol_success")
+ }
// Findings are already recorded via patrol_report_finding tool calls.
for _, f := range aiResult.Findings {
@@ -866,6 +868,13 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
findingsSummaryStr = fmt.Sprintf("Analysis incomplete (%d errors)", runStats.errors)
}
}
+ resolvedFindings := 0
+ if runStats.aiAnalysis != nil {
+ resolvedFindings = len(runStats.aiAnalysis.ResolvedIDs)
+ if runStats.runtimeResolved {
+ resolvedFindings++
+ }
+ }
runRecord := PatrolRunRecord{
ID: runID,
@@ -894,6 +903,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)
NewFindings: runStats.newFindings,
ExistingFindings: runStats.existingFindings,
RejectedFindings: runStats.rejectedFindings,
+ ResolvedFindings: resolvedFindings,
FindingsSummary: findingsSummaryStr,
FindingIDs: runStats.findingIDs,
ErrorCount: runStats.errors,
diff --git a/internal/ai/patrol_runtime_failure.go b/internal/ai/patrol_runtime_failure.go
index 0fcabe75cc..f78e75f719 100644
--- a/internal/ai/patrol_runtime_failure.go
+++ b/internal/ai/patrol_runtime_failure.go
@@ -5,6 +5,8 @@ import (
"regexp"
"strings"
"time"
+
+ "github.com/rs/zerolog/log"
)
const patrolRuntimeFailureDetailLimit = 2000
@@ -249,3 +251,20 @@ func newPatrolRuntimeFailureFinding(failure patrolRuntimeFailure, now time.Time)
LastSeenAt: now,
}
}
+
+func (p *PatrolService) resolvePatrolRuntimeFailureFinding(reason string) bool {
+ if p == nil || p.findings == nil {
+ return false
+ }
+ errorFindingID := generateFindingID(patrolRuntimeResourceID, "reliability", patrolRuntimeFindingKey)
+ if existing := p.findings.Get(errorFindingID); existing == nil || existing.IsResolved() {
+ return false
+ }
+
+ p.findings.Resolve(errorFindingID, true)
+ if resolver := p.unifiedFindingResolver; resolver != nil {
+ resolver(errorFindingID)
+ }
+ log.Info().Str("reason", reason).Msg("AI Patrol: Auto-resolved previous patrol runtime finding after successful provider-backed run")
+ return true
+}
diff --git a/internal/ai/patrol_runtime_failure_test.go b/internal/ai/patrol_runtime_failure_test.go
index 9c2dacd5b0..205bda6c9c 100644
--- a/internal/ai/patrol_runtime_failure_test.go
+++ b/internal/ai/patrol_runtime_failure_test.go
@@ -261,3 +261,59 @@ func TestRunScopedPatrolRecordsStructuredRuntimeFailure(t *testing.T) {
t.Fatalf("unexpected runtime finding title %q", finding.Title)
}
}
+
+func TestRunScopedPatrolResolvesPreviousRuntimeFailureOnSuccess(t *testing.T) {
+ svc := NewService(config.NewConfigPersistence(t.TempDir()), nil)
+ svc.cfg = &config.AIConfig{Enabled: true, PatrolModel: "deepseek:deepseek-v4-flash", DeepSeekAPIKey: "sk-test"}
+ svc.provider = &mockProvider{}
+ var patrolStreamCalled bool
+ svc.SetChatService(&mockChatService{
+ executor: tools.NewPulseToolExecutor(tools.ExecutorConfig{}),
+ executePatrolStreamFunc: func(ctx context.Context, req PatrolExecuteRequest, callback ChatStreamCallback) (*PatrolStreamResponse, error) {
+ patrolStreamCalled = true
+ return &PatrolStreamResponse{Content: "scoped patrol completed without provider errors"}, nil
+ },
+ })
+
+ ps := NewPatrolService(svc, &mockStateProvider{
+ state: models.StateSnapshot{
+ Nodes: []models.Node{{ID: "node-1", Name: "pve-1", Status: "online", CPU: 0.95}},
+ },
+ })
+ ps.SetConfig(PatrolConfig{
+ Enabled: true,
+ Interval: time.Hour,
+ AnalyzeNodes: true,
+ })
+ runtimeFinding := newPatrolRuntimeFailureFinding(patrolRuntimeFailureFromError(errors.New("provider connection failed")), time.Now().Add(-time.Hour))
+ ps.recordFinding(runtimeFinding)
+
+ ps.runScopedPatrol(context.Background(), PatrolScope{
+ ResourceIDs: []string{"node-1"},
+ Reason: TriggerReasonManual,
+ NoStream: true,
+ })
+
+ if !patrolStreamCalled {
+ t.Fatal("expected scoped patrol success to exercise the provider-backed patrol stream")
+ }
+
+ finding := ps.findings.Get(runtimeFinding.ID)
+ if finding == nil {
+ t.Fatal("expected runtime finding to remain available as resolved history")
+ }
+ if !finding.IsResolved() {
+ t.Fatalf("expected successful scoped patrol to auto-resolve runtime finding, got resolved_at=%v", finding.ResolvedAt)
+ }
+
+ runs := ps.runHistoryStore.GetRecent(1)
+ if len(runs) != 1 {
+ t.Fatalf("expected one scoped patrol run, got %d", len(runs))
+ }
+ if runs[0].ErrorCount != 0 {
+ t.Fatalf("expected successful scoped run without runtime errors, got %d", runs[0].ErrorCount)
+ }
+ if runs[0].ResolvedFindings != 1 {
+ t.Fatalf("expected scoped run to record resolved runtime finding, got %d", runs[0].ResolvedFindings)
+ }
+}
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 711a219fac..686abb2440 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -280,6 +280,20 @@ func TestAISettingsHandler_PatrolReadinessBranches(t *testing.T) {
aiCfg.AnthropicAPIKey = "test-key"
},
},
+ {
+ name: "deepseek v4 flash is ready",
+ patrolAvailable: true,
+ wantStatus: patrolReadinessReady,
+ wantReady: true,
+ wantCheckID: "tools",
+ wantCheck: patrolReadinessReady,
+ wantSummary: "ready to run",
+ configure: func(aiCfg *config.AIConfig) {
+ aiCfg.Enabled = true
+ aiCfg.Model = "deepseek:deepseek-v4-flash"
+ aiCfg.DeepSeekAPIKey = "test-key"
+ },
+ },
{
name: "deepseek aliases warn instead of silently ready",
patrolAvailable: true,