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.

Align Patrol quiet-run tool contracts

rcourtman739b0c92d493
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8d2cd16688..297097178d 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5711,6 +5711,15 @@ The exact scoped inventory is the authoritative resource set. Patrol must call
`patrol_get_findings` once near the beginning of a run and reuse that snapshot
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;
+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
+executor contract and preventing invalid hostless Swarm-state calls.
Persisted Patrol tool inputs must retain complete structured finding calls up
to the bounded 16 KiB record limit so normal evidence-rich findings remain
deterministically replayable. If any captured input is nevertheless incomplete
diff --git a/internal/ai/patrol_ai.go b/internal/ai/patrol_ai.go
index a0fe5b4107..36abe9d564 100644
--- a/internal/ai/patrol_ai.go
+++ b/internal/ai/patrol_ai.go
@@ -1286,6 +1286,8 @@ 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.
+
## Direct Provider-State Flags
The deterministic triage table and exact scoped inventory are current evidence collected through Pulse's normal provider paths. When they show a direct failed health check, failed backup, or broken replication state, treat detection as complete: call patrol_get_findings, then report or assess the confirmed symptom from the seed evidence. Do not call pulse_query, pulse_discovery, pulse_read, or broad inventory tools before recording that symptom. Root-cause investigation is a separate follow-up; unavailable logs must not consume the reporting turn.
diff --git a/internal/ai/patrol_ai_more_test.go b/internal/ai/patrol_ai_more_test.go
index 45d5574855..6b43c10253 100644
--- a/internal/ai/patrol_ai_more_test.go
+++ b/internal/ai/patrol_ai_more_test.go
@@ -336,6 +336,21 @@ func TestGetPatrolSystemPrompt_IncludesTrustScaffoldingGuidance(t *testing.T) {
}
}
+func TestGetPatrolSystemPromptForTriage_IncludesQuietRunEfficiencyContract(t *testing.T) {
+ ps := NewPatrolService(&Service{cfg: &config.AIConfig{PatrolAutonomyLevel: config.PatrolAutonomyMonitor}}, nil)
+ prompt := ps.getPatrolSystemPromptForTriage()
+
+ for _, want := range []string{
+ "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",
+ } {
+ if !strings.Contains(prompt, want) {
+ t.Fatalf("triage patrol system prompt missing %q", want)
+ }
+ }
+}
+
func TestRunAIAnalysis_EarlyErrors(t *testing.T) {
t.Run("nil service", func(t *testing.T) {
ps := NewPatrolService(nil, nil)
diff --git a/internal/ai/tools/docker_updates_test.go b/internal/ai/tools/docker_updates_test.go
index c775196dcf..7b704866d3 100644
--- a/internal/ai/tools/docker_updates_test.go
+++ b/internal/ai/tools/docker_updates_test.go
@@ -66,6 +66,24 @@ func TestExecuteCheckDockerUpdates(t *testing.T) {
assert.Contains(t, result.Content[0].Text, "Failed to trigger update check")
}
+func TestPulseDockerToolSchemaRequiresHostForEveryAdvertisedAction(t *testing.T) {
+ exec := NewPulseToolExecutor(ExecutorConfig{})
+
+ var dockerTool Tool
+ for _, tool := range exec.registry.ListTools(exec.invocationPolicy()) {
+ if tool.Name == "pulse_docker" {
+ dockerTool = tool
+ break
+ }
+ }
+
+ require.Equal(t, "pulse_docker", dockerTool.Name)
+ assert.Contains(t, dockerTool.InputSchema.Required, "action")
+ assert.Contains(t, dockerTool.InputSchema.Required, "host")
+ assert.Contains(t, dockerTool.Description, "Every advertised action requires")
+ assert.Contains(t, dockerTool.InputSchema.Properties["host"].Description, "Required")
+}
+
func TestExecuteCheckDockerUpdates_RetriesTransientError(t *testing.T) {
origSleep := dockerUpdateQueueSleepFn
dockerUpdateQueueSleepFn = func(context.Context, time.Duration) error { return nil }
diff --git a/internal/ai/tools/tools_docker.go b/internal/ai/tools/tools_docker.go
index 53d06a349c..db3d22055e 100644
--- a/internal/ai/tools/tools_docker.go
+++ b/internal/ai/tools/tools_docker.go
@@ -53,13 +53,13 @@ func (e *PulseToolExecutor) registerDockerTools() {
e.registry.registerBuiltin(RegisteredTool{
Definition: Tool{
Name: agentcapabilities.PulseDockerToolName,
- Description: `Read Docker update posture and Swarm state. Container control is planned through pulse_control using a canonical resource capability. Container updates remain unavailable until durable delivery and compensation contracts are complete.`,
+ Description: `Read host-scoped Docker update posture and Swarm state. Every advertised action requires the Docker host name or ID; use the host identity from the current resource context. Container control is planned through pulse_control using a canonical resource capability. Container updates remain unavailable until durable delivery and compensation contracts are complete.`,
InputSchema: InputSchema{
Type: "object",
Properties: map[string]PropertySchema{
"action": {
Type: "string",
- Description: "Docker action to perform",
+ Description: "Docker action to perform; every action is scoped to the required host",
Enum: []string{"updates", "check_updates", "services", "tasks", "swarm"},
},
"container": {
@@ -68,7 +68,7 @@ func (e *PulseToolExecutor) registerDockerTools() {
},
"host": {
Type: "string",
- Description: "Docker host name or ID",
+ Description: "Required Docker host name or ID for every action",
},
"operation": {
Type: "string",
@@ -84,7 +84,7 @@ func (e *PulseToolExecutor) registerDockerTools() {
Description: "Filter by stack name (for services)",
},
},
- Required: []string{"action"},
+ Required: []string{"action", "host"},
},
},
Handler: func(ctx context.Context, exec *PulseToolExecutor, args map[string]interface{}) (CallToolResult, error) {