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.

fix(ai): advertise lifecycle control from planner availability

pulse-triage[bot]fd2327d3cf4a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 135c6a3c75..5f478d1831 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -8350,3 +8350,22 @@ Acceptance requires each target's actual approval-required tool receipt, not
final prose. This fixture changes no production behaviour and proves no hosted
acceptance until the fixed-source, credential-contained execution has actually
completed.
+
+#### Plan-only capability exposure
+
+The available tool list and rendered governance manifest advertise
+`pulse_control` only when the canonical typed-action planner and read state are
+installed, subject to the existing control-level policy. Agent command transport
+and native app execution providers are neither prerequisites nor substitutes for
+that planner. Read-only sessions still hide control. Discovery, capability
+validation, approval and execution remain distinct; advertising planning grants
+no execution authority.
+
+The offline lifecycle fixture checks the offered provider-neutral tools and
+rendered manifest before returning scripted calls, and the loopback gateway
+checks actual wire tool names. A scripted call to an unoffered tool is not
+capability acceptance. Availability regressions cover planner-only operation,
+read-only policy, missing state and executor-only configurations. Search probes
+retain the existing normalised literal matching: wildcard strings do not expand,
+while a broader literal query can find the five synthetic targets. That read
+proof does not establish model-owned recovery or permit broadening action scope.
diff --git a/internal/ai/chat/hosted_lifecycle_diagnostic_test.go b/internal/ai/chat/hosted_lifecycle_diagnostic_test.go
index fd029fe800..26d9014515 100644
--- a/internal/ai/chat/hosted_lifecycle_diagnostic_test.go
+++ b/internal/ai/chat/hosted_lifecycle_diagnostic_test.go
@@ -161,6 +161,12 @@ func TestLifecycleDiagnosticFixture(t *testing.T) {
backend.chatStream = func(_ context.Context, req providers.ChatRequest, cb providers.StreamCallback) error {
turn++
require.Equal(t, 2048, req.MaxTokens)
+ names := map[string]bool{}
+ for _, tool := range req.Tools {
+ names[tool.Name] = true
+ }
+ require.True(t, names["pulse_control"], "scripted calls must be offered to a real provider")
+ require.Contains(t, req.System, "pulse_control")
require.Equal(t, diagnosticModel, req.Model)
require.Contains(t, req.System, "first-party in-app Pulse Intelligence")
require.Contains(t, req.System, "QEMU guest agent")
@@ -249,6 +255,14 @@ func TestLifecycleDiagnosticGatewayWire(t *testing.T) {
if req["max_tokens"] != float64(2048) && req["max_completion_tokens"] != float64(2048) {
t.Error("missing token cap")
}
+ offered := map[string]bool{}
+ for _, raw := range req["tools"].([]any) {
+ tool := raw.(map[string]any)["function"].(map[string]any)
+ offered[tool["name"].(string)] = true
+ }
+ if !offered["pulse_control"] || !offered["pulse_query"] {
+ t.Error("gateway must receive query and plan tools")
+ }
mu.Lock()
turn++
n := turn
@@ -293,3 +307,33 @@ func TestLifecycleDiagnosticGatewayWire(t *testing.T) {
}
}
}
+
+// The hosted model's wildcard queries are not interpreted as globs. A literal
+// broader query can discover the same five targets; this is not model recovery
+// acceptance and must not silently broaden a lifecycle action's target set.
+func TestLifecycleDiagnosticLiteralSearch(t *testing.T) {
+ vms := make([]unifiedresources.Resource, 0, 5)
+ for i := 1; i <= 5; i++ {
+ vms = append(vms, gateTestProxmoxVM(fmt.Sprintf("win-%02d", i), 100+i))
+ }
+ e := tools.NewPulseToolExecutor(tools.ExecutorConfig{
+ StateProvider: &mockStateProvider{}, UnifiedResourceProvider: plainTextResourceTestProvider(vms...),
+ })
+ for _, tc := range []struct {
+ query string
+ total int
+ }{
+ {"win-0?", 0}, {"win-0*", 0}, {"win-0", 5}, {"win-01", 1},
+ } {
+ t.Run(tc.query, func(t *testing.T) {
+ result, err := e.ExecuteTool(context.Background(), "pulse_query", map[string]interface{}{"action": "search", "query": tc.query, "type": "vm", "limit": 5})
+ require.NoError(t, err)
+ require.False(t, result.IsError, result.Content)
+ var payload struct {
+ Total int `json:"total"`
+ }
+ require.NoError(t, json.Unmarshal([]byte(result.Content[0].Text), &payload))
+ require.Equal(t, tc.total, payload.Total)
+ })
+ }
+}
diff --git a/internal/ai/tools/control_resource_test.go b/internal/ai/tools/control_resource_test.go
index b8b6d6998e..68e615e73c 100644
--- a/internal/ai/tools/control_resource_test.go
+++ b/internal/ai/tools/control_resource_test.go
@@ -36,13 +36,15 @@ func (s *stubAppContainerActionProvider) ExecuteAction(_ context.Context, req Ap
return &result, nil
}
-func TestPulseToolExecutor_ListTools_IncludesPulseControlForNativeAppProvider(t *testing.T) {
+func TestPulseToolExecutor_ListTools_IncludesPulseControlForNativeAppPlanner(t *testing.T) {
provider := newTrueNASUnifiedQueryProvider(t)
executor := NewPulseToolExecutor(ExecutorConfig{
- UnifiedResourceProvider: provider,
- ReadState: provider.ResourceRegistry,
- AppContainerActionProvider: &stubAppContainerActionProvider{},
- ControlLevel: ControlLevelControlled,
+ UnifiedResourceProvider: provider,
+ ReadState: provider.ResourceRegistry,
+ TypedActionPlanner: typedActionPlannerFunc(func(context.Context, string, unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ return nil, nil
+ }),
+ ControlLevel: ControlLevelControlled,
})
tools := executor.ListTools()
@@ -54,15 +56,17 @@ func TestPulseToolExecutor_ListTools_IncludesPulseControlForNativeAppProvider(t
}
}
if !found {
- t.Fatalf("expected pulse_control to be available with native app action provider, got %+v", tools)
+ t.Fatalf("expected pulse_control to be available with native app planner, got %+v", tools)
}
}
func TestPulseToolExecutor_ListTools_PulseControlDescriptionStaysCapabilityBounded(t *testing.T) {
executor := NewPulseToolExecutor(ExecutorConfig{
StateProvider: &mockStateProvider{},
- AgentServer: &mockAgentServer{},
- ControlLevel: ControlLevelControlled,
+ TypedActionPlanner: typedActionPlannerFunc(func(context.Context, string, unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ return nil, nil
+ }),
+ ControlLevel: ControlLevelControlled,
})
tools := executor.ListTools()
@@ -166,3 +170,37 @@ type typedActionPlannerFunc func(context.Context, string, unifiedresources.Actio
func (f typedActionPlannerFunc) PlanTypedAction(ctx context.Context, orgID string, req unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
return f(ctx, orgID, req)
}
+
+// Tool exposure follows the plan-only lifecycle boundary, not an execution
+// transport. Read-only policy must still hide it even when planning is wired.
+func TestPulseControlAvailabilityUsesPlanner(t *testing.T) {
+ planner := typedActionPlannerFunc(func(context.Context, string, unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ t.Fatal("listing tools must not plan or execute")
+ return nil, nil
+ })
+ for _, tc := range []struct {
+ name string
+ cfg ExecutorConfig
+ want bool
+ }{
+ {"planner", ExecutorConfig{StateProvider: &mockStateProvider{}, TypedActionPlanner: planner, ControlLevel: ControlLevelControlled}, true},
+ {"read_only", ExecutorConfig{StateProvider: &mockStateProvider{}, TypedActionPlanner: planner, ControlLevel: ControlLevelReadOnly}, false},
+ {"no_state", ExecutorConfig{TypedActionPlanner: planner, ControlLevel: ControlLevelControlled}, false},
+ {"agent_only", ExecutorConfig{StateProvider: &mockStateProvider{}, AgentServer: &mockAgentServer{}, ControlLevel: ControlLevelControlled}, false},
+ {"app_executor_only", ExecutorConfig{StateProvider: &mockStateProvider{}, AppContainerActionProvider: &stubAppContainerActionProvider{}, ControlLevel: ControlLevelControlled}, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ e := NewPulseToolExecutor(tc.cfg)
+ offered, governed := false, false
+ for _, tool := range e.ListTools() {
+ offered = offered || tool.Name == "pulse_control"
+ }
+ for _, tool := range e.ListToolGovernance() {
+ governed = governed || tool.Name == "pulse_control"
+ }
+ if offered != tc.want || governed != tc.want {
+ t.Fatalf("offered=%v governed=%v want=%v", offered, governed, tc.want)
+ }
+ })
+ }
+}
diff --git a/internal/ai/tools/executor.go b/internal/ai/tools/executor.go
index aab46e51f3..22e13678af 100644
--- a/internal/ai/tools/executor.go
+++ b/internal/ai/tools/executor.go
@@ -1211,7 +1211,9 @@ func (e *PulseToolExecutor) isToolAvailable(name string) bool {
case agentcapabilities.PulseReadToolName:
return e.agentServer != nil || (e.appContainerReadProvider != nil && e.hasReadState())
case agentcapabilities.PulseControlToolName:
- return (e.agentServer != nil || e.appContainerActionProvider != nil) && e.hasReadState()
+ // Control only creates canonical plans. Execution transports neither
+ // enable planning nor substitute for the installed lifecycle planner.
+ return e.typedActionPlanner != nil && e.hasReadState()
case agentcapabilities.PulseFileEditToolName:
return e.agentServer != nil
case agentcapabilities.PulseDiscoveryToolName: