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
Tier patrol-coverage health impact by recent-error ratio
rcourtmana343ba01269c
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 6ed3764193..33c8a671a4 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -580,6 +580,17 @@ runtime cost control, and shared AI transport surfaces.## Current State+The overall health score (`calculateOverallHealth` in+`internal/ai/intelligence.go`) tiers the "recent Patrol errors" coverage+factor by the ratio of errored runs to relevant runs in the scoring+window. Above 50% of recent runs erroring is a `-30` impact and is+described as "Most recent Patrol runs encountered errors"; above 25%+is `-20`; otherwise the original `-10` light-tier description applies.+This prevents the score chip from showing grade A while the same+assessment surface warns the operator that coverage is incomplete or+recent runs failed, which previously happened whenever one successful+manual run sat among many failed startup runs.+Stale-finding auto-resolve (`reconcileStaleFindings` in`internal/ai/patrol_ai.go`) is gated on the category whitelist exposed by`CategorySupportsStaleAutoResolve` in `internal/ai/findings.go`. Onlydiff --git a/internal/ai/intelligence.go b/internal/ai/intelligence.goindex 830c745328..929b9d23f3 100644--- a/internal/ai/intelligence.go+++ b/internal/ai/intelligence.go@@ -1114,10 +1114,31 @@ func summarizeRecentPatrolCoverage(impact: 20,}, truecase recentErrors > 0:+ // Tier the impact by error ratio so the score actually reflects how+ // unreliable recent runs have been. The previous flat 10-point impact+ // could not separate "1 error in 10 runs" (mostly healthy) from+ // "8 errors in 10 runs" (mostly broken) — both produced grade A and+ // contradicted the "recent Patrol runs encountered errors" warning+ // the same factor surfaces. Dominant-error periods now drop the+ // score out of the A band so the grade and the warning agree.+ ratio := float64(recentErrors) / float64(len(relevant))+ var impact float64+ var description string+ switch {+ case ratio > 0.5:+ impact = 30+ description = fmt.Sprintf("Most recent Patrol runs encountered errors (%d of %d); the current health summary is not reliable until coverage stabilizes.", recentErrors, len(relevant))+ case ratio > 0.25:+ impact = 20+ description = fmt.Sprintf("Recent Patrol runs encountered errors (%d of %d), so the current health summary may be incomplete.", recentErrors, len(relevant))+ default:+ impact = 10+ description = "Recent Patrol runs encountered errors, so the current health summary may be incomplete."+ }return patrolCoverageFactor{name: "Recent Patrol errors",- description: "Recent Patrol runs encountered errors, so the current health summary may be incomplete.",- impact: 10,+ description: description,+ impact: impact,}, truedefault:return patrolCoverageFactor{}, falsediff --git a/internal/ai/intelligence_coverage_test.go b/internal/ai/intelligence_coverage_test.goindex 9ced00685d..841b480282 100644--- a/internal/ai/intelligence_coverage_test.go+++ b/internal/ai/intelligence_coverage_test.go@@ -1,6 +1,7 @@package aiimport (+ "fmt""reflect""strings""testing"@@ -153,6 +154,98 @@ func TestIntelligence_getTopFindings_Empty(t *testing.T) {}}+// When most recent runs error but at least one successful full run exists, the+// score model must drop out of grade A. The previous flat 10-point penalty+// produced grade A even with 8 of 9 recent runs failing — the user saw+// "Coverage incomplete, recent runs errored" alongside an "A 95/100" chip.+// Tiering by error ratio aligns the grade with the warning.+func TestIntelligence_GetSummary_DominantRecentErrorsDropOutOfGradeA(t *testing.T) {+ intel := NewIntelligence(IntelligenceConfig{})+ runHistory := NewPatrolRunHistoryStore(20)+ now := time.Now()+ // One successful full patrol — keeps hasSuccessfulFullRun=true so we land+ // on the tiered case-4 branch instead of the no-successful-run branches.+ runHistory.Add(PatrolRunRecord{+ ID: "manual-ok",+ Type: "patrol",+ TriggerReason: "manual",+ CompletedAt: now.Add(-2 * time.Hour),+ ErrorCount: 0,+ Status: "healthy",+ ResourcesChecked: 50,+ })+ // Eight subsequent startup runs all errored — the dominant-error case+ // observed in the wild that previously still produced grade A.+ for i := 0; i < 8; i++ {+ runHistory.Add(PatrolRunRecord{+ ID: fmt.Sprintf("startup-error-%d", i),+ Type: "patrol",+ TriggerReason: "startup",+ CompletedAt: now.Add(-time.Duration(60-i*5) * time.Minute),+ ErrorCount: 1,+ Status: "error",+ ResourcesChecked: 58,+ })+ }+ intel.SetRunHistoryStore(runHistory)++ summary := intel.GetSummary()+ if summary.OverallHealth.Grade == HealthGradeA {+ t.Fatalf("expected non-A grade when most recent runs errored, got %s (score %f)",+ summary.OverallHealth.Grade, summary.OverallHealth.Score)+ }+ var coverageFactor *HealthFactor+ for i := range summary.OverallHealth.Factors {+ if summary.OverallHealth.Factors[i].Category == "coverage" {+ coverageFactor = &summary.OverallHealth.Factors[i]+ break+ }+ }+ if coverageFactor == nil {+ t.Fatal("expected coverage factor in overall health")+ }+ if !strings.Contains(coverageFactor.Description, "Most recent Patrol runs encountered errors") {+ t.Fatalf("expected dominant-error description, got %q", coverageFactor.Description)+ }+}++// A single error among many successful runs should still warn but not punish+// the grade out of A — the "occasional error" case stays at the lighter 10-pt+// penalty so a transient single failure doesn't flip the headline.+func TestIntelligence_GetSummary_OccasionalRecentErrorStaysInGradeA(t *testing.T) {+ intel := NewIntelligence(IntelligenceConfig{})+ runHistory := NewPatrolRunHistoryStore(20)+ now := time.Now()+ for i := 0; i < 9; i++ {+ runHistory.Add(PatrolRunRecord{+ ID: fmt.Sprintf("patrol-ok-%d", i),+ Type: "patrol",+ TriggerReason: "scheduled",+ CompletedAt: now.Add(-time.Duration(60-i*5) * time.Minute),+ ErrorCount: 0,+ Status: "healthy",+ ResourcesChecked: 50,+ })+ }+ runHistory.Add(PatrolRunRecord{+ ID: "patrol-error-1",+ Type: "patrol",+ TriggerReason: "scheduled",+ CompletedAt: now.Add(-2 * time.Minute),+ ErrorCount: 1,+ Status: "error",+ ResourcesChecked: 58,+ })+ intel.SetRunHistoryStore(runHistory)++ summary := intel.GetSummary()+ // Light tier: -10 penalty against a 100 starting score = 90, still grade A.+ if summary.OverallHealth.Grade != HealthGradeA {+ t.Fatalf("expected grade A for 1-error-in-10, got %s (score %f)",+ summary.OverallHealth.Grade, summary.OverallHealth.Score)+ }+}+func TestIntelligence_GetSummary_DegradesWhenRecentPatrolCoverageIsScopedAndErroring(t *testing.T) {intel := NewIntelligence(IntelligenceConfig{})runHistory := NewPatrolRunHistoryStore(10)