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 restart evidence in Patrol scope

rcourtman3f94a8f3020a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 4b7671d57d..9ef833e2df 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5716,10 +5716,12 @@ The exact scoped inventory is the authoritative resource set. Patrol must call
for all lifecycle decisions, avoiding duplicate reads and their extra provider
turns on both healthy and faulted runs.
On a quiet deterministic triage with a current exact scoped inventory showing
-the scoped resources running and healthy and no active alerts or findings, the
-model uses the supplied snapshot as sufficient calm-day evidence and does not
-spend platform or inventory tool calls merely reconfirming the same state. A
-concrete snapshot signal or active finding may still justify a targeted read;
+the scoped resources running and healthy, no container restart evidence, and no
+active alerts or findings, the model uses the supplied snapshot as sufficient
+calm-day evidence and does not spend platform or inventory tool calls merely
+reconfirming the same state. Exact scoped app-container rows carry the canonical
+restart count from normal collection. A non-zero count is a concrete signal
+that prevents the calm-day shortcut and may justify a targeted current read;
quiet triage is not a deterministic replacement for model-owned assessment.
Provider-facing `pulse_docker` calls are host-scoped: every advertised action
requires a Docker host name or ID in the structured schema, matching the
diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.go
index 36abe9d564..da17e2792e 100644
--- a/internal/ai/patrol_ai.go
+++ b/internal/ai/patrol_ai.go
@@ -1286,7 +1286,7 @@ Pulse has assembled deterministic evidence before this turn. The flagged items a
Your job is to assess the provided evidence and decide which items, if any, require attention. Available evidence sources include historical metrics, logs, backup/replication/RAID details, and resource configuration.
-When deterministic triage is quiet, the current exact scoped inventory shows the scoped resources running and healthy, and there are no active alerts or findings, treat the supplied snapshot as sufficient for a calm-day assessment. Call patrol_get_findings exactly once, then return the all-clear without using platform or inventory tools merely to reconfirm the same healthy state. A quiet result does not prohibit a targeted read when the snapshot, surrounding evidence, or an active finding contains a concrete signal that needs investigation.
+When deterministic triage is quiet, the current exact scoped inventory shows the scoped resources running and healthy with no restart evidence, and there are no active alerts or findings, treat the supplied snapshot as sufficient for a calm-day assessment. Call patrol_get_findings exactly once, then return the all-clear without using platform or inventory tools merely to reconfirm the same healthy state. A quiet result does not prohibit a targeted read when the snapshot, surrounding evidence, or an active finding contains a concrete signal that needs investigation. A non-zero container restart count is such a signal: assess it and use a targeted current read when needed rather than returning the calm-day all-clear.
## Direct Provider-State Flags
@@ -2043,6 +2043,7 @@ type patrolDockerHostRow struct {
type patrolAppContainerRow struct {
id, name, status string
health string
+ restartCount int
cpu, memory float64
}
@@ -2356,12 +2357,13 @@ func patrolAppContainerRows(snap patrolRuntimeState, scopedSet map[string]bool)
continue
}
rows = append(rows, patrolAppContainerRow{
- id: cv.ID(),
- name: cv.Name(),
- status: strings.TrimSpace(cv.ContainerState()),
- health: strings.TrimSpace(cv.Health()),
- cpu: cv.CPUPercent(),
- memory: cv.MemoryPercent(),
+ id: cv.ID(),
+ name: cv.Name(),
+ status: strings.TrimSpace(cv.ContainerState()),
+ health: strings.TrimSpace(cv.Health()),
+ restartCount: cv.RestartCount(),
+ cpu: cv.CPUPercent(),
+ memory: cv.MemoryPercent(),
})
}
return rows
@@ -2378,12 +2380,13 @@ func patrolAppContainerRows(snap patrolRuntimeState, scopedSet map[string]bool)
continue
}
rows = append(rows, patrolAppContainerRow{
- id: container.ID,
- name: container.Name,
- status: container.State,
- health: container.Health,
- cpu: container.CPUPercent,
- memory: container.MemoryPercent,
+ id: container.ID,
+ name: container.Name,
+ status: container.State,
+ health: container.Health,
+ restartCount: container.RestartCount,
+ cpu: container.CPUPercent,
+ memory: container.MemoryPercent,
})
}
}
@@ -2953,15 +2956,15 @@ func (p *PatrolService) seedResourceInventoryState(snap patrolRuntimeState, scop
containerRows := patrolAppContainerRows(snap, scopedSet)
if len(containerRows) > 0 {
sb.WriteString("# Scoped App Containers\n")
- sb.WriteString("| Name | Resource ID | State | Health | CPU | Memory |\n")
- sb.WriteString("|------|-------------|-------|--------|-----|--------|\n")
+ sb.WriteString("| Name | Resource ID | State | Health | Restarts | CPU | Memory |\n")
+ sb.WriteString("|------|-------------|-------|--------|----------|-----|--------|\n")
for _, row := range containerRows {
health := strings.TrimSpace(row.health)
if health == "" {
health = "not reported"
}
- sb.WriteString(fmt.Sprintf("| %s | %s | %s | %s | %.0f%% | %.0f%% |\n",
- row.name, row.id, row.status, health, row.cpu, row.memory))
+ sb.WriteString(fmt.Sprintf("| %s | %s | %s | %s | %d | %.0f%% | %.0f%% |\n",
+ row.name, row.id, row.status, health, row.restartCount, row.cpu, row.memory))
}
sb.WriteString("\n")
}
diff --git a/internal/ai/patrol_ai_more_test.go b/internal/ai/patrol_ai_more_test.go
index 6b43c10253..69e26b402d 100644
--- a/internal/ai/patrol_ai_more_test.go
+++ b/internal/ai/patrol_ai_more_test.go
@@ -344,6 +344,7 @@ func TestGetPatrolSystemPromptForTriage_IncludesQuietRunEfficiencyContract(t *te
"treat the supplied snapshot as sufficient for a calm-day assessment",
"without using platform or inventory tools merely to reconfirm the same healthy state",
"does not prohibit a targeted read",
+ "A non-zero container restart count is such a signal",
} {
if !strings.Contains(prompt, want) {
t.Fatalf("triage patrol system prompt missing %q", want)
diff --git a/internal/ai/patrol_triage_test.go b/internal/ai/patrol_triage_test.go
index 963ebd9f11..8fcedca976 100644
--- a/internal/ai/patrol_triage_test.go
+++ b/internal/ai/patrol_triage_test.go
@@ -397,6 +397,7 @@ func TestTriageContainerHealthChecksState_UsesReadState(t *testing.T) {
Docker: &unifiedresources.DockerData{
ContainerState: "running",
Health: "unhealthy",
+ RestartCount: 4,
},
})
state := patrolRuntimeState{readState: &mockReadState{dockerCtrs: []*unifiedresources.DockerContainerView{&unhealthy}}}
@@ -418,7 +419,7 @@ func TestTriageContainerHealthChecksState_UsesReadState(t *testing.T) {
for _, expected := range []string{
"Container health check reported unhealthy while running",
"# Scoped App Containers",
- "| faulty | app-container:tower:faulty | running | unhealthy |",
+ "| faulty | app-container:tower:faulty | running | unhealthy | 4 |",
} {
if !strings.Contains(seed, expected) {
t.Fatalf("expected exact app-container evidence %q in triage seed, got:\n%s", expected, seed)