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.

test(ai): wire typed planners in control projection fixtures

pulse-triage[bot]7f703bc41a1b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 5f478d1831..f079a832fd 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -8369,3 +8369,13 @@ 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.
+
+Service control-setting, execution-mode and Assistant projection fixtures must
+install a typed planner whenever they expect planning to be available; a mock
+agent transport alone does not model that capability. Provider projection must
+not invoke the planner merely to list tools. The read-only projection control
+must include an installed planner so it tests policy rather than accidentally
+passing because capability wiring is absent. Surface regressions also remove
+the planner while retaining execute authority and transport, and assert control
+is absent in both provider tools and the surface contract. These are offline
+fixture and policy proofs, not hosted-model or installed acceptance.
diff --git a/internal/ai/chat/service_test.go b/internal/ai/chat/service_test.go
index 0dacfcc51b..d5b995b979 100644
--- a/internal/ai/chat/service_test.go
+++ b/internal/ai/chat/service_test.go
@@ -593,10 +593,11 @@ func TestService_AbortSession_UsesRegisteredActiveLoops(t *testing.T) {
func TestService_SettersAndUpdateControlSettings(t *testing.T) {
service := NewService(Config{
AIConfig: &config.AIConfig{ControlLevel: config.ControlLevelReadOnly},
- // Agent server makes pulse_control eligible when control is enabled.
+ // Control policy is tested with canonical planning wired below.
AgentServer: &mockAgentServer{},
StateProvider: &mockStateProvider{},
})
+ service.SetTypedActionPlanner(&gateTestPlanner{})
require.NotNil(t, service.executor)
// In read-only mode, pulse_control is not available
@@ -630,6 +631,7 @@ func TestService_ToolsForExecutionMode_ExposesGovernedTools(t *testing.T) {
StateProvider: &mockStateProvider{},
AgentServer: &mockAgentServer{},
})
+ service.SetTypedActionPlanner(&gateTestPlanner{})
// After tool consolidation: pulse_control handles commands and guest control,
// pulse_docker handles Docker operations
require.True(t, hasTool(service.executor.ListTools(), "pulse_control"))
@@ -648,6 +650,7 @@ func TestService_ToolsForExecutionMode_InteractiveAddsQuestionTool(t *testing.T)
StateProvider: &mockStateProvider{},
AgentServer: &mockAgentServer{},
})
+ service.SetTypedActionPlanner(&gateTestPlanner{})
require.True(t, hasTool(service.executor.ListTools(), "pulse_control"))
require.True(t, hasTool(service.executor.ListTools(), "pulse_docker"))
require.True(t, hasTool(service.executor.ListTools(), "pulse_query"))
diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.go
index f960f3cc89..35d974c0be 100644
--- a/internal/ai/chat/service_tooling_test.go
+++ b/internal/ai/chat/service_tooling_test.go
@@ -234,10 +234,11 @@ func TestAssistantPromptQualifiesForLocalInventoryCount(t *testing.T) {
func TestAssistantSurfaceToolContractUsesRuntimeAssistantProjection(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{
- StateProvider: fakeStateProvider{},
- AgentServer: fakeAgentServer{},
- ReadState: &fakeCanonicalReadState{},
- ControlLevel: tools.ControlLevelControlled,
+ StateProvider: fakeStateProvider{},
+ TypedActionPlanner: &gateTestPlanner{},
+ AgentServer: fakeAgentServer{},
+ ReadState: &fakeCanonicalReadState{},
+ ControlLevel: tools.ControlLevelControlled,
})
svc := &Service{
executor: exec,
@@ -272,6 +273,13 @@ func TestAssistantSurfaceToolContractUsesRuntimeAssistantProjection(t *testing.T
t.Fatalf("execute-authorized controlled surface missing governed infrastructure control: %#v", executeAuthorized.ToolNames)
}
+ // Execute authority cannot substitute for an installed planner.
+ svc.SetTypedActionPlanner(nil)
+ unavailable := svc.AssistantSurfaceToolContract(WithExecuteAuthority(context.Background(), true))
+ if stringSliceContains(unavailable.ToolNames, agentcapabilities.PulseControlToolName) {
+ t.Fatalf("planner-less surface exposed control: %#v", unavailable.ToolNames)
+ }
+
svc.SetAutonomousMode(true)
autonomous := svc.AssistantSurfaceToolContract(context.Background())
if stringSliceContains(autonomous.NativeToolNames, agentcapabilities.PulseQuestionToolName) ||
@@ -285,9 +293,10 @@ func TestAssistantSurfaceToolContractUsesRuntimeAssistantProjection(t *testing.T
func TestToolsForExecutionMode_AutonomousNonPatrolExposesGovernedTools(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{
- StateProvider: fakeStateProvider{},
- AgentServer: fakeAgentServer{},
- ControlLevel: tools.ControlLevelControlled,
+ StateProvider: fakeStateProvider{},
+ TypedActionPlanner: &gateTestPlanner{},
+ AgentServer: fakeAgentServer{},
+ ControlLevel: tools.ControlLevelControlled,
})
svc := &Service{executor: exec}
diff --git a/internal/ai/tools/provider_projection_test.go b/internal/ai/tools/provider_projection_test.go
index 3e7ae1faa0..35610e4f94 100644
--- a/internal/ai/tools/provider_projection_test.go
+++ b/internal/ai/tools/provider_projection_test.go
@@ -1,14 +1,25 @@
package tools
import (
+ "context"
"os"
"strings"
"testing"
"github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"
"github.com/rcourtman/pulse-go-rewrite/internal/agentexec"
+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
)
+// Projection requires planning availability but must not invoke the planner.
+func projectionTestPlanner(t *testing.T) TypedActionPlanner {
+ t.Helper()
+ return typedActionPlannerFunc(func(context.Context, string, unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ t.Fatal("tool projection must not plan or execute")
+ return nil, nil
+ })
+}
+
func providerToolNameSet(list []agentcapabilities.ProviderTool) map[string]bool {
set := make(map[string]bool, len(list))
for _, tool := range list {
@@ -28,9 +39,10 @@ func providerToolByName(list []agentcapabilities.ProviderTool, name string) (age
func TestPulseToolExecutorAssistantProviderToolsUsesRuntimeAvailability(t *testing.T) {
exec := NewPulseToolExecutor(ExecutorConfig{
- ReadState: &fakeReadState{},
- AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
- ControlLevel: ControlLevelControlled,
+ ReadState: &fakeReadState{},
+ TypedActionPlanner: projectionTestPlanner(t),
+ AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
+ ControlLevel: ControlLevelControlled,
})
projected := exec.AssistantProviderTools(agentcapabilities.AssistantProviderToolOptions{IncludeQuestionTool: true})
@@ -141,9 +153,10 @@ func TestPulseToolExecutorAssistantProviderToolsHonorsInteractionMode(t *testing
func TestPulseToolExecutorAssistantProviderToolsHonorsControlLevel(t *testing.T) {
exec := NewPulseToolExecutor(ExecutorConfig{
- ReadState: &fakeReadState{},
- AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
- ControlLevel: ControlLevelReadOnly,
+ ReadState: &fakeReadState{},
+ TypedActionPlanner: projectionTestPlanner(t),
+ AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
+ ControlLevel: ControlLevelReadOnly,
})
names := providerToolNameSet(exec.AssistantProviderTools(agentcapabilities.AssistantProviderToolOptions{}))
@@ -157,9 +170,10 @@ func TestPulseToolExecutorAssistantProviderToolsHonorsControlLevel(t *testing.T)
func TestPulseToolExecutorAssistantSurfaceToolContractUsesRuntimeProjection(t *testing.T) {
exec := NewPulseToolExecutor(ExecutorConfig{
- ReadState: &fakeReadState{},
- AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
- ControlLevel: ControlLevelControlled,
+ ReadState: &fakeReadState{},
+ TypedActionPlanner: projectionTestPlanner(t),
+ AgentServer: &mockAgentServer{agents: []agentexec.ConnectedAgent{{AgentID: "agent-1", Hostname: "node-1"}}},
+ ControlLevel: ControlLevelControlled,
})
contract := exec.AssistantSurfaceToolContract(agentcapabilities.AssistantProviderToolOptions{IncludeQuestionTool: true})
@@ -199,3 +213,35 @@ func TestPulseToolExecutorAssistantSurfaceToolContractUsesRuntimeProjection(t *t
t.Fatalf("Assistant surface contract must not duplicate MCP capability names: %+v", contract.CapabilityNames)
}
}
+
+// Retired execution transports alone must not advertise canonical planning on
+// either provider-facing projection, even when execution authority is enabled.
+func TestAssistantProjectionsRequireTypedPlanner(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ planner TypedActionPlanner
+ want bool
+ }{
+ {name: "transport_only"},
+ {name: "typed_planner", planner: projectionTestPlanner(t), want: true},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ exec := NewPulseToolExecutor(ExecutorConfig{
+ ReadState: &fakeReadState{},
+ AgentServer: &mockAgentServer{},
+ TypedActionPlanner: tc.planner,
+ ControlLevel: ControlLevelControlled,
+ })
+ opts := agentcapabilities.AssistantProviderToolOptions{}
+ names := providerToolNameSet(exec.AssistantProviderTools(opts))
+ contract := exec.AssistantSurfaceToolContract(opts)
+ found := false
+ for _, name := range contract.ToolNames {
+ found = found || name == agentcapabilities.PulseControlToolName
+ }
+ if names[agentcapabilities.PulseControlToolName] != tc.want || found != tc.want {
+ t.Fatalf("provider control=%v surface control=%v want=%v", names[agentcapabilities.PulseControlToolName], found, tc.want)
+ }
+ })
+ }
+}