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.

Preserve Patrol memory analysis scope and qualified fixture controls

pulse-triage[bot]dbceb616c896
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 20e0678d14..ce1a7d1c22 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -39,8 +39,9 @@ current zero and real high pressure both retain their meaning. Other platforms
without Proxmox observations keep their existing selected readings.
Full, quiet and condensed inventory and actual triage seeds preserve these
-qualifications, including unflagged running guests. The no-flag rollup is not a
-health verdict. Native guest runtime status, rather than canonical collection
+qualifications, including unflagged running guests within the existing analysis scope. Guest
+analysis opt-outs do not acquire the new evidence section. The no-flag rollup is
+not a health verdict. Native guest runtime status, rather than canonical collection
status, owns running/paused/stopped eligibility. A snapshot-only alert review
cannot auto-resolve a memory alert from unknown guest pressure; independently
verified current recovery and removed-resource handling remain separate.
diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.go
index 35d1f75d0e..cfaf8690ca 100644
--- a/internal/ai/patrol_ai.go
+++ b/internal/ai/patrol_ai.go
@@ -1153,7 +1153,7 @@ func (p *PatrolService) buildTriageSeedSectionsState(
{priority: 0, name: "findings", content: findingsCtx},
{priority: 0, name: "health_alerts", content: p.seedHealthAndAlertsState(snap, seedSet, cfg, now)},
{priority: 0, name: "scope", content: buildScopeSection(scope, sortedScopedIDs(seedSet))},
- {priority: 1, name: "guest_memory_evidence", content: patrolGuestMemoryEvidenceSection(snap, p.buildScopedSetForRuntime(scope, snap))},
+ {priority: 1, name: "guest_memory_evidence", content: patrolGuestMemoryEvidenceSection(snap, p.buildScopedSetForRuntime(scope, snap), cfg)},
// P2 — triage already preserves the flagged set, so these sections can
// summarize under tighter provider-derived retry budgets.
@@ -1211,7 +1211,7 @@ func (p *PatrolService) buildSeedSectionsState(snap patrolRuntimeState, scope *P
// P1 — always include (typically compact).
{priority: 1, name: "previous_run", content: p.seedPreviousRun(now)},
- {priority: 1, name: "guest_memory_evidence", content: patrolGuestMemoryEvidenceSection(snap, scopedSet)},
+ {priority: 1, name: "guest_memory_evidence", content: patrolGuestMemoryEvidenceSection(snap, scopedSet, cfg)},
// P2 — summarize when needed.
{
diff --git a/internal/ai/patrol_ai_more_test.go b/internal/ai/patrol_ai_more_test.go
index 39d6fe8af2..d54355c684 100644
--- a/internal/ai/patrol_ai_more_test.go
+++ b/internal/ai/patrol_ai_more_test.go
@@ -796,7 +796,7 @@ func TestSeedResourceInventoryState_UsesRuntimeReadStateForNodesAndGuests(t *tes
},
Metrics: &unifiedresources.ResourceMetrics{
CPU: &unifiedresources.MetricValue{Percent: 10},
- Memory: &unifiedresources.MetricValue{Percent: 30},
+ Memory: &unifiedresources.MetricValue{Percent: 30, Observation: models.MemoryObservation{State: "current", Source: "available-field", ObservedAt: now}},
Disk: &unifiedresources.MetricValue{Percent: 20},
},
})
@@ -867,7 +867,7 @@ func TestSeedResourceInventoryState_UsesRuntimeReadStateForNodesAndGuests(t *tes
"# Node Metrics",
"| node-1 | online | 55% | 65% | 40%",
"# Guest Metrics",
- "| vm-1 | VM | node-1 | - | 10% | 30% | 20% | running | - | 2h ago |",
+ fmt.Sprintf("| vm-1 | VM | node-1 | - | 10%% | 30%% (current; source available-field; observed %s; cache-aware guest usage) | 20%% | running | - | 2h ago |", now.UTC().Format(time.RFC3339)),
"# Docker",
"| docker-1 | 2 | 1 | 1 |",
"docker-1/web: health=unhealthy",
diff --git a/internal/ai/patrol_guest_memory.go b/internal/ai/patrol_guest_memory.go
index 87282b73c6..2c1c18e806 100644
--- a/internal/ai/patrol_guest_memory.go
+++ b/internal/ai/patrol_guest_memory.go
@@ -22,7 +22,10 @@ func patrolGuestRuntimeStatus(runtime string, status unifiedresources.ResourceSt
return string(status)
}
-func patrolGuestMemoryEvidenceSection(snap patrolRuntimeState, scopedSet map[string]bool) string {
+func patrolGuestMemoryEvidenceSection(snap patrolRuntimeState, scopedSet map[string]bool, cfg PatrolConfig) string {
+ if !cfg.AnalyzeGuests {
+ return ""
+ }
if gaps := patrolGuestMemoryGaps(patrolGuestInventoryRows(snap, scopedSet, nil)); gaps != "" {
return "# Guest memory evidence\n" + gaps + "\n\n"
}
diff --git a/internal/ai/patrol_guest_memory_reading_test.go b/internal/ai/patrol_guest_memory_reading_test.go
index bc3cb82973..6b24a5b90b 100644
--- a/internal/ai/patrol_guest_memory_reading_test.go
+++ b/internal/ai/patrol_guest_memory_reading_test.go
@@ -43,3 +43,19 @@ func TestPatrolGuestMemoryReadingBoundaries(t *testing.T) {
t.Fatal("collection warning changed native runtime state")
}
}
+
+func TestPatrolGuestMemorySeedScopeAndOptOut(t *testing.T) {
+ at := time.Now().UTC().Add(-time.Minute)
+ snapshot := models.StateSnapshot{VMs: []models.VM{
+ {ID: "included", Name: "included", VMID: 100, Type: "qemu", Status: "running", Memory: patrolMemoryFixture(96, "current", "status-mem", at)},
+ {ID: "excluded", Name: "excluded", VMID: 101, Type: "qemu", Status: "running", Memory: patrolMemoryFixture(96, "current", "status-mem", at)},
+ }}
+ snap := newPatrolRuntimeState(snapshot)
+ if section := patrolGuestMemoryEvidenceSection(snap, nil, PatrolConfig{AnalyzeGuests: false}); section != "" {
+ t.Fatal("guest analysis opt-out acquired memory evidence")
+ }
+ section := patrolGuestMemoryEvidenceSection(snap, map[string]bool{"included": true}, PatrolConfig{AnalyzeGuests: true})
+ if !strings.Contains(section, "included") || strings.Contains(section, "excluded") {
+ t.Fatalf("memory evidence escaped its existing scope: %s", section)
+ }
+}
diff --git a/internal/ai/patrol_triage_test.go b/internal/ai/patrol_triage_test.go
index 6d0dbe0f43..16eabc77c8 100644
--- a/internal/ai/patrol_triage_test.go
+++ b/internal/ai/patrol_triage_test.go
@@ -74,7 +74,7 @@ func TestTriageThresholdChecksState_UsesReadStateWhenLegacySlicesEmpty(t *testin
},
Metrics: &unifiedresources.ResourceMetrics{
CPU: &unifiedresources.MetricValue{Percent: 70},
- Memory: &unifiedresources.MetricValue{Percent: 92},
+ Memory: &unifiedresources.MetricValue{Percent: 92, Observation: models.MemoryObservation{State: "current", Source: "available-field", ObservedAt: time.Now().Add(-time.Minute)}},
Disk: &unifiedresources.MetricValue{Percent: 85},
},
})