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.

Populate Patrol runtime-failure findings with Impact

rcourtman744b861614ab
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index c5fa957bbe..96cdeaf57f 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -235,7 +235,18 @@ runtime cost control, and shared AI transport surfaces.
the model. The TS API client must keep its `InvestigationRecord` and
`InvestigationRecordTrigger` mirrors aligned with the Go struct,
including the `trigger.cause` string, so frontend handoff context does
- not lose backend-attributed failure cause. When `/api/ai/chat` receives `finding_id`, the
+ not lose backend-attributed failure cause. Detection-time finding
+ creation may author `Finding.Impact` directly so the
+ consequence-if-ignored statement is set at finding birth rather than
+ waiting for an AI investigation to derive it;
+ `BuildFindingInvestigationRecord` then propagates `Finding.Impact`
+ into `InvestigationRecord.Impact` without transformation, and the AI
+ engine must not synthesize impact text from severity or category when
+ the finding source has not authored one. The Patrol runtime-failure
+ classifier (`internal/ai/patrol_runtime_failure.go`) is the canonical
+ example: it stamps a constant impact string on every runtime-failure
+ cause because the operational consequence of a non-running Patrol is
+ invariant across causes, and only the recommendation varies. When `/api/ai/chat` receives `finding_id`, the
runtime must enrich the provider turn from that durable record while
preserving the user's authored prompt as the persisted conversation
message; the model-only handoff may persist as session metadata so
diff --git a/internal/ai/findings.go b/internal/ai/findings.go
index 83b8d9b903..686a2d8512 100644
--- a/internal/ai/findings.go
+++ b/internal/ai/findings.go
@@ -114,6 +114,7 @@ type Finding struct {
Node string `json:"node,omitempty"`
Title string `json:"title"`
Description string `json:"description"`
+ Impact string `json:"impact,omitempty"` // Operator-facing consequence-if-ignored statement
Recommendation string `json:"recommendation,omitempty"`
Evidence string `json:"evidence,omitempty"` // data/commands that led to this finding
Source string `json:"source,omitempty"` // "ai-analysis" for LLM findings, empty for rule-based
@@ -159,6 +160,7 @@ type findingJSON struct {
Node string `json:"node,omitempty"`
Title string `json:"title"`
Description string `json:"description"`
+ Impact string `json:"impact,omitempty"`
Recommendation string `json:"recommendation,omitempty"`
Evidence string `json:"evidence,omitempty"`
Source string `json:"source,omitempty"`
@@ -200,6 +202,7 @@ func (f Finding) MarshalJSON() ([]byte, error) {
Node: f.Node,
Title: f.Title,
Description: f.Description,
+ Impact: f.Impact,
Recommendation: f.Recommendation,
Evidence: f.Evidence,
Source: f.Source,
@@ -246,6 +249,7 @@ func (f *Finding) UnmarshalJSON(data []byte) error {
Node: payload.Node,
Title: payload.Title,
Description: payload.Description,
+ Impact: payload.Impact,
Recommendation: payload.Recommendation,
Evidence: payload.Evidence,
Source: payload.Source,
diff --git a/internal/ai/investigation_records.go b/internal/ai/investigation_records.go
index a05eaed58a..5374bae45c 100644
--- a/internal/ai/investigation_records.go
+++ b/internal/ai/investigation_records.go
@@ -40,6 +40,7 @@ func BuildFindingInvestigationRecord(f *Finding, session *InvestigationSession)
Outcome: aicontracts.InvestigationOutcome(strings.TrimSpace(f.InvestigationOutcome)),
Evidence: investigationRecordEvidenceForFinding(f),
Conclusion: strings.TrimSpace(f.Description),
+ Impact: strings.TrimSpace(f.Impact),
RecommendedAction: strings.TrimSpace(f.Recommendation),
Verification: investigationRecordVerificationNotes(aicontracts.InvestigationOutcome(strings.TrimSpace(f.InvestigationOutcome))),
ToolsUsed: []string{},
diff --git a/internal/ai/investigation_records_test.go b/internal/ai/investigation_records_test.go
index 418a6c2c94..117b728573 100644
--- a/internal/ai/investigation_records_test.go
+++ b/internal/ai/investigation_records_test.go
@@ -21,6 +21,7 @@ func TestBuildFindingInvestigationRecord_FromSession(t *testing.T) {
Node: "pve-1",
Title: "High CPU",
Description: "CPU above threshold",
+ Impact: "Workload stalls until CPU pressure clears.",
Recommendation: "Reduce CPU pressure",
Evidence: "cpu=96%",
Source: "ai-analysis",
@@ -90,8 +91,8 @@ func TestBuildFindingInvestigationRecord_FromSession(t *testing.T) {
if record.ApprovalID != "approval-1" {
t.Fatalf("approval ID = %q", record.ApprovalID)
}
- if record.Impact != "" {
- t.Fatalf("expected empty default impact, got %q", record.Impact)
+ if record.Impact != "Workload stalls until CPU pressure clears." {
+ t.Fatalf("expected finding impact to propagate to record, got %q", record.Impact)
}
if record.Rollback == nil || len(record.Rollback) != 0 {
t.Fatalf("expected normalized empty rollback slice, got %#v", record.Rollback)
diff --git a/internal/ai/patrol_runtime_failure.go b/internal/ai/patrol_runtime_failure.go
index b36915c80a..bebb8e4653 100644
--- a/internal/ai/patrol_runtime_failure.go
+++ b/internal/ai/patrol_runtime_failure.go
@@ -55,11 +55,18 @@ type patrolRuntimeFailure struct {
Summary string
Cause PatrolFailureCause
Description string
+ Impact string
Recommendation string
Detail string
Evidence string
}
+// patrolRuntimeFailureImpact is the shared consequence-if-ignored statement
+// for any Patrol runtime failure. The cause varies but the operational
+// consequence is constant: while Patrol is not analyzing, alerts continue
+// to fire without enrichment.
+const patrolRuntimeFailureImpact = "While Patrol cannot analyze, alerts continue to fire without evidence or recommended actions, and AI Intelligence summaries cannot refresh."
+
type PatrolRuntimeFailureDiagnostic struct {
Title string
Summary string
@@ -92,6 +99,7 @@ func patrolRuntimeFailureFromError(err error) patrolRuntimeFailure {
Summary: "Provider analysis error",
Cause: PatrolFailureCauseProviderConnection,
Description: "Pulse Patrol reached the configured provider, but the provider did not complete the Patrol analysis request.",
+ Impact: patrolRuntimeFailureImpact,
Recommendation: "Review the Patrol provider settings, selected model, and provider logs, then rerun Patrol after the provider path is healthy.",
Detail: detail,
}
@@ -253,6 +261,7 @@ func newPatrolRuntimeFailureFinding(failure patrolRuntimeFailure, now time.Time)
ResourceType: "service",
Title: failure.Title,
Description: failure.Description,
+ Impact: failure.Impact,
Recommendation: failure.Recommendation,
Evidence: failure.Evidence,
FailureCause: string(failure.Cause),
diff --git a/internal/ai/patrol_runtime_failure_test.go b/internal/ai/patrol_runtime_failure_test.go
index 636a809b31..bf7641cf47 100644
--- a/internal/ai/patrol_runtime_failure_test.go
+++ b/internal/ai/patrol_runtime_failure_test.go
@@ -13,6 +13,34 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/models"
)
+func TestPatrolRuntimeFailureFromError_PopulatesImpactForAllCauses(t *testing.T) {
+ cases := []struct {
+ name string
+ err error
+ }{
+ {"tool_calling_unsupported", errors.New(`API error (404): No endpoints found that support the provided 'tool_choice' value`)},
+ {"model_unavailable", errors.New(`model "qwen3.5:2b" is not available`)},
+ {"provider_billing", errors.New(`API error (402): insufficient balance`)},
+ {"provider_rate_limited", errors.New(`API error (429): rate limit exceeded`)},
+ {"provider_auth", errors.New(`API error (401): unauthorized`)},
+ {"provider_not_configured", errors.New(`provider not configured`)},
+ {"provider_connection", errors.New(`failed to connect: i/o timeout`)},
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ failure := patrolRuntimeFailureFromError(tc.err)
+ if failure.Impact != patrolRuntimeFailureImpact {
+ t.Fatalf("expected shared runtime-failure impact, got %q", failure.Impact)
+ }
+ finding := newPatrolRuntimeFailureFinding(failure, time.Now())
+ if finding.Impact != patrolRuntimeFailureImpact {
+ t.Fatalf("expected finding impact to inherit from failure, got %q", finding.Impact)
+ }
+ })
+ }
+}
+
func TestPatrolRuntimeFailureFromError_ClassifiesToolCallingUnsupported(t *testing.T) {
err := errors.New(`agentic patrol failed: API error (404): {"error":{"message":"No endpoints found that support the provided 'tool_choice' value."}}`)