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.

Canonicalize app container health check findings

rcourtman31f89bb430e9
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index fec3494581..47423dac16 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -3563,9 +3563,10 @@ resolve canonical/source IDs and unique aliases before collection, reject
1. Update this contract when canonical AI runtime or transport entry points move, including transport-level provider request-shape changes such as OpenAI-compatible `tool_choice` handling, runtime-failure classification splits (for example separating tool-choice request rejection, no tool-capable endpoint, and generic model-level lack of tool support into distinct causes), Patrol-specific verification surfaces such as `POST /api/ai/patrol/preflight` that exercise the full chat-completions path with a minimal tool definition rather than only listing models, Patrol-preflight cache observability where the AI Service caches the most recent preflight outcome (success, soft warning, or classified failure) and the AI settings response surfaces it as `patrol_preflight` so the UI can hydrate a "last verified" indicator without forcing operators to re-run preflight on every page load, the auto-trigger contract on `HandleUpdateAISettings` where the save handler runs `TriggerPatrolPreflightAsync` only when the change actually moved Patrol transport (model swap, provider key for that model changed, or assistant just enabled with a Patrol model) so routine settings saves do not burn provider tokens, the startup-seed contract where the AI Service handler dispatches the same async preflight on Pulse boot when assistant is enabled and a Patrol model is configured so the cache is populated for the first `/api/settings/ai` poll after a restart instead of blanking back to "never verified", the readiness-integration contract where the `tools` check in the Patrol readiness payload consults the cached preflight and surfaces the classified evidence (success, soft warning, or failure with classified summary plus "last preflight <age>") for the configured provider+model when available (falling back to the static `PatrolToolReadinessForModel` classifier only when the cache is empty or holds a result for a different model), the preflight-runtime-recovery contract where a successful Patrol preflight with an observed tool call resolves the synthetic Patrol runtime failure finding while failed or no-tool-call preflights leave it active, the stateless-Patrol-input contract where `ExecutePatrolStream` must pass only the current run's user prompt into the agentic loop rather than reloading the persisted `patrol-main` session history (so a prior run that ended with orphan `tool_calls` cannot poison every subsequent run with malformed conversation structure), and the deterministic-resolve-gate contract where the `patrol_resolve_finding` tool adapter rejects LLM-driven resolves of event/persistent category findings (`backup`, `reliability`, `security`, `general`) when a deterministic verifier exists for the finding's key and that verifier either still detects the failure signal **or returns an inconclusive result** — preventing the LLM from optimistically resolving a finding its current investigation simply didn't re-surface, which was the source of the "Backup failed" flap (detected → auto-resolved → re-detected ten times in a day before this gate). The fail-closed-on-inconclusive policy treats verifier errors (timeouts, executor unavailability, transport faults) as "we don't know" rather than "go ahead": resolution of an event/persistent finding is effectively permanent (next detection registers as a regression and inflates counters), so the safe default is to refuse and require either a successful re-verification or operator action. The gate has a symmetric counterpart, the verified stale-resolve contract: `reconcileStaleFindings` (`internal/ai/patrol_ai.go`) may auto-resolve an event/persistent finding that was seeded but neither re-reported nor resolved ONLY when the finding's key has a deterministic verifier and that verifier affirmatively confirms the failure signal is gone — absence of a re-report remains insufficient evidence for these categories, "still present" or inconclusive verification leaves the finding active (the same fail-closed default), and verifications are capped per reconcile pass (`maxVerifiedStaleResolvesPerRun`) with deferred candidates logged and retried on the next successful full patrol. Without this counterpart the lifecycle was asymmetric: a genuinely fixed backup or recovered service stayed an active finding indefinitely unless the LLM happened to call `patrol_resolve_finding`. `hasDeterministicVerifierForKey` (`internal/ai/patrol_findings.go`) is the single source of truth for which keys have verifiers, consulted by both the gate and the reconcile pass, and must stay aligned with the dispatch switch in `verifyFixDeterministically` (it previously listed two of the seven dispatch keys, silently skipping verification that existed). Finding keys normalize onto the canonical verifier vocabulary in `normalizeFindingKey` via an alias map of unambiguous directional synonyms (`high-cpu` → `cpu-high`, `high-memory` → `memory-high`, `high-disk` → `disk-high`) so deduplication and deterministic verification meet on one key, and the `patrol_report_finding` key guidance (`internal/ai/tools/tools_patrol.go`) teaches the canonical vocabulary; semantically distinct keys (`pbs-job-failed`, `node-offline`) must not be aliased onto verifier keys whose resource model they do not match, the assessment-recovery contract where the overall-health "Recent Patrol errors" coverage factor in `summarizeRecentPatrolCoverage` suppresses the score penalty once three consecutive trailing successful full Patrol runs exist at the most-recent end of the recent-runs window — so the grade reflects current reality after a Patrol-affecting bug is fixed rather than dragging stale failures forward for the ~9 hours it takes scheduled runs to age them out of the trailing-10 ratio, the orphan-tool-call-repair contract where `convertToProviderMessages` injects synthetic is_error tool result messages for any `tool_call_id` in an assistant message that has no matching downstream tool result, so a chat session that ended mid-tool-call (network drop, ctx timeout, browser crash) cannot poison its next message with the structural-violation error the provider rejects — the synthetic content is marked is_error=true and explains the interruption so the model can retry the call or proceed without the data, and the patrol-session-bound contract where `ExecutePatrolStream` calls `SessionStore.TrimMessages` after persisting each run's messages to cap the patrol-main session at 200 messages (roughly two recent runs' worth) — without the bound the file grew unbounded at every scheduled run, reaching 16 MB and 3,593 messages within a month and making every `AddMessage` rewrite linearly more expensive; the canonical Patrol forensic log is the `PatrolRunRecord` history surfaced at `/api/ai/patrol/runs`, not the chat-session-shaped file
Container-health finding variants such as `app-container-unhealthy`,
- `container-health-unhealthy`, `container-health-failing`,
- `container-unhealthy`, and `failing-health-check` must normalize to the
- canonical `health-check-failed` key before finding identity is generated.
+ `app-container-health-check-failed`, `container-health-unhealthy`,
+ `container-health-failing`, `container-unhealthy`, and
+ `failing-health-check` must normalize to the canonical
+ `health-check-failed` key before finding identity is generated.
Existing-finding reconfirmation therefore converges on one durable issue
even when the model changes an unambiguous key spelling between runs.
2. Keep AI runtime and shared API proof routing aligned in `registry.json`
diff --git a/internal/ai/patrol_findings.go b/internal/ai/patrol_findings.go
index 0d09366661..db91579ed6 100644
--- a/internal/ai/patrol_findings.go
+++ b/internal/ai/patrol_findings.go
@@ -1346,19 +1346,20 @@ func (p *PatrolService) dispatchPatrolInvestigations(result *AIAnalysisResult) {
// and pbs-job-failed is NOT backup-failed; mapping those would point the
// verifier at the wrong resource model.
var findingKeyAliases = map[string]string{
- "app-container-unhealthy": "health-check-failed",
- "container-health-check-failed": "health-check-failed",
- "container-health-failed": "health-check-failed",
- "container-health-failing": "health-check-failed",
- "container-health-unhealthy": "health-check-failed",
- "container-unhealthy": "health-check-failed",
- "failing-health-check": "health-check-failed",
- "health-check-failing": "health-check-failed",
- "healthcheck-failed": "health-check-failed",
- "high-cpu": "cpu-high",
- "high-memory": "memory-high",
- "high-disk": "disk-high",
- "unhealthy-container": "health-check-failed",
+ "app-container-health-check-failed": "health-check-failed",
+ "app-container-unhealthy": "health-check-failed",
+ "container-health-check-failed": "health-check-failed",
+ "container-health-failed": "health-check-failed",
+ "container-health-failing": "health-check-failed",
+ "container-health-unhealthy": "health-check-failed",
+ "container-unhealthy": "health-check-failed",
+ "failing-health-check": "health-check-failed",
+ "health-check-failing": "health-check-failed",
+ "healthcheck-failed": "health-check-failed",
+ "high-cpu": "cpu-high",
+ "high-memory": "memory-high",
+ "high-disk": "disk-high",
+ "unhealthy-container": "health-check-failed",
}
func normalizeFindingKey(key string) string {
diff --git a/internal/ai/patrol_findings_additional_test.go b/internal/ai/patrol_findings_additional_test.go
index 93ac4c6970..b23e7f8ee4 100644
--- a/internal/ai/patrol_findings_additional_test.go
+++ b/internal/ai/patrol_findings_additional_test.go
@@ -1734,7 +1734,7 @@ func TestPatrolFindingAdapterCanonicalizesContainerHealthKeyVariantsAcrossRuns(t
t.Fatalf("first report = (%q, %t, %v), want a new finding", findingID, isNew, err)
}
- for _, variant := range []string{"container-health-failing", "app-container-unhealthy", "container-health-unhealthy"} {
+ for _, variant := range []string{"container-health-failing", "app-container-unhealthy", "app-container-health-check-failed", "container-health-unhealthy"} {
secondInput := firstInput
secondInput.Key = variant
secondInput.Title = "Container health is failing while running"
diff --git a/internal/ai/patrol_reconcile_test.go b/internal/ai/patrol_reconcile_test.go
index e8dc88facd..3db6560b99 100644
--- a/internal/ai/patrol_reconcile_test.go
+++ b/internal/ai/patrol_reconcile_test.go
@@ -448,19 +448,20 @@ func TestReconcileStaleFindings_VerificationCapDefersExcessCandidates(t *testing
func TestNormalizeFindingKey_CanonicalAliases(t *testing.T) {
cases := map[string]string{
- "high-cpu": "cpu-high",
- "High_Memory": "memory-high",
- "high disk": "disk-high",
- "cpu-high": "cpu-high",
- "backup-stale": "backup-stale",
- "app-container-unhealthy": "health-check-failed",
- "container-health-failing": "health-check-failed",
- "container-health-check-failed": "health-check-failed",
- "container-health-unhealthy": "health-check-failed",
- "healthcheck-failed": "health-check-failed",
- "failing-health-check": "health-check-failed",
- "container-unhealthy": "health-check-failed",
- "unhealthy-container": "health-check-failed",
+ "app-container-health-check-failed": "health-check-failed",
+ "high-cpu": "cpu-high",
+ "High_Memory": "memory-high",
+ "high disk": "disk-high",
+ "cpu-high": "cpu-high",
+ "backup-stale": "backup-stale",
+ "app-container-unhealthy": "health-check-failed",
+ "container-health-failing": "health-check-failed",
+ "container-health-check-failed": "health-check-failed",
+ "container-health-unhealthy": "health-check-failed",
+ "healthcheck-failed": "health-check-failed",
+ "failing-health-check": "health-check-failed",
+ "container-unhealthy": "health-check-failed",
+ "unhealthy-container": "health-check-failed",
// Non-aliased keys pass through normalization unchanged.
"pbs-job-failed": "pbs-job-failed",
}