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.

Enforce the canonical mutation plane

rcourtmanf510b990955c
diff --git a/.github/workflows/canonical-governance.yml b/.github/workflows/canonical-governance.yml
index d04419ad38..b4c702c998 100644
--- a/.github/workflows/canonical-governance.yml
+++ b/.github/workflows/canonical-governance.yml
@@ -115,6 +115,9 @@ jobs:
- name: Run registry audit
run: python3 scripts/release_control/registry_audit.py --check
+ - name: Run canonical mutation registry audits
+ run: go test ./internal/mutationregistry ./internal/ai/tools -run 'Test(EveryRegisteredMutationHasDisposition|InfrastructureAPIRoutesResolveToRegistry|TransportCommandCatalogsResolveToRegistry|PatrolJobRegistrationResolvesToRegistry|RuntimeCandidateAuditNegativeFixtures|RegisteredModelMutationSchemasResolveToClosedRegistry|RetiredMutationAliasesCannotShadowExtensions)' -count=1
+
- name: Run contract audit
run: python3 scripts/release_control/contract_audit.py --check
diff --git a/cmd/mutation-registry-audit/main.go b/cmd/mutation-registry-audit/main.go
new file mode 100644
index 0000000000..41996050ee
--- /dev/null
+++ b/cmd/mutation-registry-audit/main.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/mutationregistry"
+)
+
+func main() {
+ check := flag.Bool("check", false, "validate the closed mutation registry")
+ format := flag.String("format", "json", "output format (json)")
+ flag.Parse()
+ if *check {
+ if err := mutationregistry.Validate(); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+ }
+ if *format != "json" {
+ fmt.Fprintf(os.Stderr, "unsupported format %q\n", *format)
+ os.Exit(2)
+ }
+ encoder := json.NewEncoder(os.Stdout)
+ encoder.SetIndent("", " ")
+ if err := encoder.Encode(mutationregistry.Entries()); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+}
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 6b8190cb56..251c723bf3 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -7536,7 +7536,7 @@
},
{
"id": "action-governance-auditability-post-rc-hardening",
- "summary": "Track broader action-governance hardening beyond the current canonical action-audit and resource-scoped action-history floor, including richer provider dry-runs, enterprise policy execution, multi-actor or MFA approval chains, and deeper safe-execution contracts for future controlled operations.",
+ "summary": "Track governed residuals behind the closed canonical mutation registry: Task 07 owns durable delivery/reconnect before Docker update, Docker runtime stop, Kubernetes scale/restart/delete, or native-provider transport can activate; Task 10 owns terminal truth, verification, compensation, and rollback representation; Task 12 owns the final L1/governance verdict and administrative-exception review. Raw model command, file write, arbitrary pod exec, legacy run_command, /api/ai/run-command, and enterprise command remediation are retired with no replacement or executable historical authority.",
"owner": "project-owner",
"status": "planned",
"recorded_at": "2026-04-25",
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f2400005a0..7720a2a6db 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1748,6 +1748,14 @@ Agent` secondary handoff against the live setup wizard instead of relying
## Current State
+### Canonical mutation-plane dependency
+
+Agent deployment remains an explicit Pulse-administrative exception in the
+closed mutation registry. Agent command transports do not originate authority:
+typed host update/storage cleanup and executor-owned resource commands may run
+only after committed action-lifecycle authority, while raw model command and
+unowned delivery paths remain denied.
+
Agent dispatch begins only after the canonical action store wins and commits
the transition to `executing`. Concurrent replay, another SQLite connection,
or a process restart cannot obtain a second executor admission for that action.
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 219d1c976d..585915b7bd 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5733,3 +5733,27 @@ eligibility, or a Patrol mode below the capability's class leave the action
pending rather than converting a valid proposal into an investigation failure.
An idempotent resubmission returns the existing action disposition and must not
execute a terminal action twice.
+
+### Canonical mutation registry boundary
+
+Assistant infrastructure mutations are classified by the generated
+`internal/mutationregistry` registry before handler execution. The only active
+model-originated mutation is `pulse_control type=resource`, which submits a
+typed capability request to the shared action-lifecycle planner and never
+contacts infrastructure directly. Retired tool names and compatibility aliases
+cannot be registered or shadowed by extensions. Docker update/control,
+Kubernetes scale/restart/delete, arbitrary exec, raw command, and file writes
+are omitted from offered schemas and denied if fabricated.
+
+The registry audits enumerate actual registered tool discriminator values and
+bind mechanically discovered API, job, and transport candidates to one registry
+disposition. Transport lifecycle entries must name non-transport lifecycle
+authority and committed authority before delivery. Task 07 owns durable
+delivery/reconnect and Task 10 owns terminal truth/compensation; incomplete
+Docker, Kubernetes/native-provider, delivery, and rollback paths remain
+`retired_denied`, not parallel executors.
+
+Enterprise command-remediation records are readable historical imports only.
+Production code contains no command or rollback execution algorithm; exported
+approve/execute/rollback interfaces and HTTP endpoints are permanently inert
+even when a command executor is injected.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 82f095bed6..761ff27a96 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -7314,3 +7314,35 @@ and execution-result writes are conditional state transitions whose event and
record update commit together. Only the successful execution-start CAS winner
may call the executor; a concurrent or post-restart duplicate returns the
current executing or terminal record without another admission.
+
+### Canonical mutation plane
+
+`internal/mutationregistry/manifest.json` is the generated closed registry for
+runtime-reachable customer-infrastructure mutations and explicit Pulse
+administrative exceptions. Every entry declares origin, resource/capability,
+disposition, lifecycle executor (when executable), approval floor, delivery,
+verification, rollback, and residual owner. Infrastructure execution is valid
+only through `internal/actionlifecycle`; retired entries fail before transport.
+
+Executable audits derive candidates from the constructed Assistant tool
+registry and its schema discriminators, registered infrastructure HTTP route
+namespaces, Patrol broker registration, and actual agent/Docker transport
+constant catalogs. Unknown candidates, duplicate alias classification, retired
+alias extension shadowing, and transport without prior durable lifecycle
+authority fail `go test ./...` CI. The HTTP scanner's governed limitation is
+exact: it covers `/api/actions/`, `/api/agents/docker/`, `/api/updates/`,
+`/api/ai/remediation/`, and `/api/ai/run-command`; general settings and metadata
+CRUD are not claimed as customer-infrastructure mutation enumeration.
+
+Raw command/file write/arbitrary pod exec, direct Docker update/control, and
+enterprise command remediation are retired compatibility surfaces. Enterprise
+`remediation.json` remains readable history, but approve, execute, and rollback
+return `command_remediation_retired`/`ErrLegacyRemediationRetired` before any
+injected executor. Task 07 owns durable delivery/reconnect, Task 10 owns truth
+and compensation, and Task 12 owns the final governance verdict.
+The Pulse registry cannot assign ownership to sibling-repository paths; the
+exact residual unowned by `registry.json` is
+`pulse-enterprise/internal/remediation/engine.go` and
+`pulse-enterprise/internal/aiautofix/remediation_handlers.go`. Their contract is
+enforced by enterprise inertness/static tests and remains a Task 12 governance
+input rather than being hidden behind an invalid cross-repo registry path.
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index bda15692b4..dba1dd52ab 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -789,6 +789,13 @@ shell clickable behind another overlay.
## Current State
+### Canonical mutation-plane dependency
+
+Router wiring now exposes only typed action planning for model-originated
+infrastructure changes. The mutation registry audits run in governance CI and
+must remain bounded to static construction/catalog scans; they introduce no
+request-path enumeration or per-request registry traversal.
+
The router's shared browser-cookie writer is request-local security policy. It
must not add per-request persistence reads, network work, or background fan-out;
all login and CSRF call sites consume the already-derived in-memory policy.
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 8746cda8c7..8e3400bf21 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1506,7 +1506,8 @@
"cmd/pulse-mcp/",
"frontend-modern/src/components/AI/Chat/",
"internal/agentcapabilities/",
- "internal/ai/"
+ "internal/ai/",
+ "internal/mutationregistry/"
],
"owned_files": [
"cmd/pulse-mcp/main.go",
@@ -1543,6 +1544,21 @@
"exact_files": [],
"require_explicit_path_policy_coverage": true,
"path_policies": [
+ {
+ "id": "canonical-mutation-registry",
+ "label": "closed canonical mutation registry and runtime candidate audit proof",
+ "match_prefixes": [
+ "internal/mutationregistry/"
+ ],
+ "match_files": [],
+ "allow_same_subsystem_tests": true,
+ "test_prefixes": [
+ "internal/mutationregistry/"
+ ],
+ "exact_files": [
+ "internal/ai/tools/mutation_registry_audit_test.go"
+ ]
+ },
{
"id": "pulse-mcp-adapter",
"label": "Pulse MCP adapter proof",
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index 0a633e7774..cb9a390504 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -464,6 +464,13 @@ the `white_label` branding entitlement.
## Current State
+### Canonical mutation-plane dependency
+
+Raw command, file-write, arbitrary pod-exec, and legacy remediation authority
+are retired before handler or transport execution. Extension aliases cannot
+shadow retired names, and transport delivery must name committed lifecycle
+authority rather than accepting model-supplied command or rollback text.
+
Unified Agent Pulse transports share one fail-closed TLS policy across host,
Docker/Podman, Kubernetes, remote configuration, commands, and self-update.
Custom CA bundles and SHA-256 leaf-certificate pins are runtime trust inputs,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 55c5ea811d..42b6b57a98 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1691,6 +1691,13 @@ must not treat starter
## Current State
+### Canonical mutation-plane dependency
+
+Infrastructure rollback is a declared lifecycle property, not executable model
+or legacy remediation text. Task 10 owns compensation/truth representation;
+until that contract is complete, affected Docker, Kubernetes, and native
+provider mutations remain fail-closed denied.
+
Storage and recovery consumers inherit create-once action identity, monotonic
terminal state, and exactly-one executor admission from the shared lifecycle.
They must not retry an `executing` action as a new dispatch after restart;
diff --git a/internal/agentcapabilities/errors.go b/internal/agentcapabilities/errors.go
index dbdf7e6bdb..48e7ab217b 100644
--- a/internal/agentcapabilities/errors.go
+++ b/internal/agentcapabilities/errors.go
@@ -32,6 +32,7 @@ const (
AgentErrCodeActionQueueUnavailable = "action_queue_unavailable"
AgentErrCodeActionQueueQueryFailed = "action_queue_query_failed"
AgentErrCodeActionQueueEncodeFailed = "action_queue_encode_failed"
+ AgentErrCodeRawCommandRetired = "raw_command_retired"
)
// ErrorEnvelope is the stable failure shape emitted by Pulse Intelligence
diff --git a/internal/agentcapabilities/invocation.go b/internal/agentcapabilities/invocation.go
index de5494bec8..0dab73b160 100644
--- a/internal/agentcapabilities/invocation.go
+++ b/internal/agentcapabilities/invocation.go
@@ -194,10 +194,6 @@ var registryInvocationDescriptors = map[string]InvocationDescriptor{
"pods": {Kind: ToolCallKindRead, Mutation: MutationNone},
"deployments": {Kind: ToolCallKindRead, Mutation: MutationNone},
"logs": {Kind: ToolCallKindRead, Mutation: MutationNone},
- "scale": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
- "restart": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
- "delete_pod": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
- "exec": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
},
},
PulseDockerToolName: {
@@ -212,8 +208,6 @@ var registryInvocationDescriptors = map[string]InvocationDescriptor{
// is read for workflow purposes too (write would drive the
// FSM into verification for a non-mutating refresh).
"check_updates": {Kind: ToolCallKindRead, Mutation: MutationNone},
- "control": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
- "update": {Kind: ToolCallKindWrite, Mutation: MutationInfrastructure},
},
},
PulseKnowledgeToolName: {
diff --git a/internal/agentcapabilities/invocation_test.go b/internal/agentcapabilities/invocation_test.go
index 7cc24a6145..d8168cdf9f 100644
--- a/internal/agentcapabilities/invocation_test.go
+++ b/internal/agentcapabilities/invocation_test.go
@@ -118,10 +118,10 @@ func TestInvocationDescriptorForReturnsIsolatedCopies(t *testing.T) {
if !ok {
t.Fatal("docker descriptor missing")
}
- first.Cases["update"] = InvocationClass{Kind: ToolCallKindRead, Mutation: MutationNone}
+ first.Cases["updates"] = InvocationClass{Kind: ToolCallKindWrite, Mutation: MutationInfrastructure}
second, _ := InvocationDescriptorFor(PulseDockerToolName)
- if got := second.Cases["update"]; got.Mutation != MutationInfrastructure {
+ if got := second.Cases["updates"]; got.Mutation != MutationNone {
t.Fatalf("mutating a returned descriptor leaked into the canonical table: %#v", got)
}
diff --git a/internal/agentcapabilities/schema.go b/internal/agentcapabilities/schema.go
index 409d3268fe..ce3609d2a9 100644
--- a/internal/agentcapabilities/schema.go
+++ b/internal/agentcapabilities/schema.go
@@ -232,10 +232,8 @@ func NewPulseQuestionProviderTool() ProviderTool {
}
const (
- // LegacyAssistantRunCommandToolName is the compatibility alias still used by
- // the older native Assistant service. New registry-backed chat uses
- // pulse_control with type=command, but the alias vocabulary remains shared so
- // provider schemas, execution, and approval handling cannot drift.
+ // LegacyAssistantRunCommandToolName is retained only to recognize and deny
+ // old persisted/provider calls. It is never projected to a model.
LegacyAssistantRunCommandToolName = "run_command"
// LegacyAssistantFetchURLToolName is the compatibility alias for the older
// native Assistant URL fetch helper.
@@ -259,37 +257,11 @@ const (
// schema copies.
func LegacyAssistantUtilityProviderTools() []ProviderTool {
return ProjectProviderTools([]Tool{
- legacyAssistantRunCommandTool(),
legacyAssistantFetchURLTool(),
legacyAssistantSetResourceURLTool(),
})
}
-func legacyAssistantRunCommandTool() Tool {
- return Tool{
- Name: LegacyAssistantRunCommandToolName,
- Description: "Execute a shell command. By default runs on the current target (container/VM), but set run_on_host=true for Proxmox host commands. IMPORTANT: For targets on different nodes, specify target_host to route to the correct PVE node.",
- InputSchema: InputSchema{
- Type: "object",
- Properties: map[string]PropertySchema{
- LegacyAssistantCommandArgumentName: {
- Type: "string",
- Description: "The shell command to execute (e.g., 'ps aux --sort=-%mem | head -20')",
- },
- LegacyAssistantRunOnHostArgumentName: {
- Type: "boolean",
- Description: "If true, run on the Proxmox/Docker host instead of inside the container/VM. Use for pct/qm commands like 'pct resize 101 rootfs +10G'. When true, you should also set target_host.",
- },
- LegacyAssistantTargetHostArgumentName: {
- Type: "string",
- Description: "Optional hostname of the specific host/node to run the command on. Use this to explicitly route pct/qm/docker commands to the correct host node or Docker host. Check the 'node' or 'Host Node' field in the target's context.",
- },
- },
- Required: []string{LegacyAssistantCommandArgumentName},
- },
- }
-}
-
func legacyAssistantFetchURLTool() Tool {
return Tool{
Name: LegacyAssistantFetchURLToolName,
diff --git a/internal/agentcapabilities/schema_test.go b/internal/agentcapabilities/schema_test.go
index 6e31ca52f8..f0dd35756a 100644
--- a/internal/agentcapabilities/schema_test.go
+++ b/internal/agentcapabilities/schema_test.go
@@ -327,8 +327,8 @@ func TestProjectPulseAssistantProviderToolsUsesSurfaceAffordances(t *testing.T)
func TestLegacyAssistantUtilityProviderToolsOwnCompatibilitySchemas(t *testing.T) {
tools := LegacyAssistantUtilityProviderTools()
- if len(tools) != 3 {
- t.Fatalf("legacy Assistant utility tools = %+v, want three compatibility tools", tools)
+ if len(tools) != 2 {
+ t.Fatalf("legacy Assistant utility tools = %+v, want two non-command compatibility tools", tools)
}
byName := map[string]ProviderTool{}
@@ -336,19 +336,8 @@ func TestLegacyAssistantUtilityProviderToolsOwnCompatibilitySchemas(t *testing.T
byName[tool.Name] = tool
}
- runCommand := byName[LegacyAssistantRunCommandToolName]
- if !reflect.DeepEqual(runCommand.InputSchema["required"], []string{LegacyAssistantCommandArgumentName}) {
- t.Fatalf("run_command required = %#v, want command", runCommand.InputSchema["required"])
- }
- runProps := runCommand.InputSchema["properties"].(map[string]interface{})
- for _, field := range []string{
- LegacyAssistantCommandArgumentName,
- LegacyAssistantRunOnHostArgumentName,
- LegacyAssistantTargetHostArgumentName,
- } {
- if _, ok := runProps[field]; !ok {
- t.Fatalf("run_command schema missing %q: %#v", field, runProps)
- }
+ if _, ok := byName[LegacyAssistantRunCommandToolName]; ok {
+ t.Fatal("retired run_command alias must not be projected to providers")
}
fetchURL := byName[LegacyAssistantFetchURLToolName]
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index d2b0baadc7..1e82af4fae 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -64,6 +64,7 @@ type (
KnowledgeStoreProvider = tools.KnowledgeStoreProvider
AssistantDiscoveryProvider = tools.DiscoveryProvider
AssistantUnifiedResourceProvider = tools.UnifiedResourceProvider
+ AssistantTypedActionPlanner = tools.TypedActionPlanner
)
// Config holds service configuration
@@ -3520,6 +3521,17 @@ func (s *Service) SetUnifiedResourceProvider(provider AssistantUnifiedResourcePr
}
}
+// SetTypedActionPlanner routes model-proposed resource actions into the
+// shared lifecycle planner. Approval and execution remain on canonical action
+// surfaces.
+func (s *Service) SetTypedActionPlanner(planner AssistantTypedActionPlanner) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if s.executor != nil {
+ s.executor.SetTypedActionPlanner(planner)
+ }
+}
+
func (s *Service) SetReadState(readState unifiedresources.ReadState) {
s.mu.Lock()
defer s.mu.Unlock()
diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.go
index 90ea7d836a..34f3b65599 100644
--- a/internal/ai/chat/service_execute_additional_test.go
+++ b/internal/ai/chat/service_execute_additional_test.go
@@ -1754,6 +1754,7 @@ func TestService_ExecuteStream_RequestAutonomousOverrideClampsToolExecutor(t *te
approvalRequiredMode := false
approvalSeen := false
+ retirementSeen := false
err = svc.ExecuteStream(ctx, ExecuteRequest{
SessionID: "sess-request-override",
Prompt: "check disk space",
@@ -1765,13 +1766,19 @@ func TestService_ExecuteStream_RequestAutonomousOverrideClampsToolExecutor(t *te
approvalSeen = true
cancel()
}
+ if event.Type == "tool_end" {
+ retirementSeen = true
+ }
})
- if err == nil || !strings.Contains(err.Error(), "context canceled") {
- t.Fatalf("expected request to stop while waiting for approval, got %v", err)
+ if err != nil {
+ t.Fatalf("expected retired command call to return a tool denial, got %v", err)
+ }
+ if approvalSeen {
+ t.Fatal("retired raw command must not create an approval")
}
- if !approvalSeen {
- t.Fatal("expected approval_needed event from request-local approval mode")
+ if !retirementSeen {
+ t.Fatal("expected retired raw command result")
}
if got := agentServer.calls.Load(); got != 0 {
t.Fatalf("expected command not to execute before approval, got %d executions", got)
diff --git a/internal/ai/chat/service_tooling_test.go b/internal/ai/chat/service_tooling_test.go
index 869c641265..ae042ac1be 100644
--- a/internal/ai/chat/service_tooling_test.go
+++ b/internal/ai/chat/service_tooling_test.go
@@ -296,8 +296,11 @@ func TestToolsForExecutionMode_AutonomousNonPatrolExposesGovernedTools(t *testin
if !set["pulse_storage"] {
t.Fatalf("expected storage tool to be exposed without prompt keyword routing")
}
- if !set["pulse_control"] || !set["pulse_file_edit"] || !set["pulse_docker"] {
- t.Fatalf("expected autonomous non-patrol mode to expose governed write tools")
+ if !set["pulse_control"] || !set["pulse_docker"] {
+ t.Fatalf("expected autonomous non-patrol mode to expose typed planning and read tools")
+ }
+ if set["pulse_file_edit"] {
+ t.Fatal("retired file mutation tool must not be exposed")
}
if set[pulseQuestionToolName] {
t.Fatalf("expected autonomous mode to exclude the interactive clarification tool")
@@ -321,7 +324,7 @@ func TestBuildSystemPrompt_DoesNotClaimGenericVMControl(t *testing.T) {
if !strings.Contains(prompt, "Not every VM or container supports control") {
t.Fatalf("expected system prompt to call out read-only resource platforms, got %q", prompt)
}
- if !strings.Contains(prompt, "control only resources that explicitly support shared Pulse actions") {
+ if !strings.Contains(prompt, "Plans shared Pulse resource actions; approval and execution stay on the canonical action lifecycle") {
t.Fatalf("expected system prompt to describe capability-bound pulse_control usage, got %q", prompt)
}
if !strings.Contains(prompt, "## AVAILABLE TOOL GOVERNANCE") {
@@ -584,38 +587,19 @@ func testRunCommandToolDefinition() tools.Tool {
func TestExecuteCommand_SuccessAndExitCode(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
- exec.RegisterTool(tools.RegisteredTool{
- Invocation: tools.StaticInvocation(agentcapabilities.ToolCallKindRead, agentcapabilities.MutationNone),
- Definition: testRunCommandToolDefinition(),
- Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
- return tools.NewTextResult("Command failed (exit code 7): boom"), nil
- },
- })
-
svc := &Service{executor: exec}
output, code, err := svc.ExecuteCommand(context.Background(), "uptime", "")
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
- if code != 7 {
- t.Fatalf("expected exit code 7, got %d", code)
+ if err == nil || code != 1 {
+ t.Fatalf("expected retired command error with exit code 1, got output=%q code=%d err=%v", output, code, err)
}
- if !strings.Contains(output, "Command failed") {
- t.Fatalf("expected command output, got: %s", output)
+ if !strings.Contains(output, "retired and denied") {
+ t.Fatalf("expected retirement output, got: %s", output)
}
}
func TestExecuteCommand_ErrorAndApprovalPaths(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
- exec.RegisterTool(tools.RegisteredTool{
- Invocation: tools.StaticInvocation(agentcapabilities.ToolCallKindRead, agentcapabilities.MutationNone),
- Definition: testRunCommandToolDefinition(),
- Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
- return tools.NewErrorResult(context.Canceled), nil
- },
- })
-
svc := &Service{executor: exec}
_, code, err := svc.ExecuteCommand(context.Background(), "uptime", "")
@@ -623,51 +607,17 @@ func TestExecuteCommand_ErrorAndApprovalPaths(t *testing.T) {
t.Fatalf("expected error with exit code 1")
}
- // Registry entries are append-only, so the approval scenario uses a
- // fresh executor instead of swapping the handler in place.
- approvalExec := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
- approvalExec.RegisterTool(tools.RegisteredTool{
- Invocation: tools.StaticInvocation(agentcapabilities.ToolCallKindRead, agentcapabilities.MutationNone),
- Definition: testRunCommandToolDefinition(),
- Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
- return tools.NewTextResult("APPROVAL_REQUIRED: requires approval"), nil
- },
- })
- svc = &Service{executor: approvalExec}
-
- _, _, err = svc.ExecuteCommand(context.Background(), "uptime", "")
- if err == nil {
- t.Fatalf("expected approval error")
- }
}
func TestExecuteCommandUsesSharedResultTextProjection(t *testing.T) {
exec := tools.NewPulseToolExecutor(tools.ExecutorConfig{})
- exec.RegisterTool(tools.RegisteredTool{
- Invocation: tools.StaticInvocation(agentcapabilities.ToolCallKindRead, agentcapabilities.MutationNone),
- Definition: testRunCommandToolDefinition(),
- Handler: func(ctx context.Context, exec *tools.PulseToolExecutor, args map[string]interface{}) (tools.CallToolResult, error) {
- return tools.CallToolResult{
- Content: []tools.Content{
- {Type: "text", Text: "stdout"},
- {Type: "resource", URI: "file://ignored"},
- {Type: "text"},
- {Type: "text", Text: "stderr"},
- },
- }, nil
- },
- })
-
svc := &Service{executor: exec}
output, code, err := svc.ExecuteCommand(context.Background(), "uptime", "")
- if err != nil {
- t.Fatalf("ExecuteCommand: %v", err)
- }
- if code != 0 {
- t.Fatalf("exit code = %d, want 0", code)
+ if err == nil || code != 1 {
+ t.Fatalf("expected retired command denial, output=%q code=%d err=%v", output, code, err)
}
- if output != "stdout\nstderr" {
- t.Fatalf("output = %q, want shared result text projection", output)
+ if !strings.Contains(output, "retired and denied") {
+ t.Fatalf("output = %q, want retirement response", output)
}
}
diff --git a/internal/ai/service.go b/internal/ai/service.go
index 5752012862..41797f65ad 100644
--- a/internal/ai/service.go
+++ b/internal/ai/service.go
@@ -3096,11 +3096,12 @@ func (s *Service) legacyAssistantInvocationPolicy() aitools.InvocationPolicy {
level = aitools.ControlLevel(cfg.GetControlLevel())
}
return aitools.InvocationPolicy{
- ControlLevel: level,
- HasExecuteAuthority: true,
- ExecuteAuthorityBound: true,
- PulseStateAllowlist: map[string]bool{},
- Profile: aitools.ProfileInteractiveAssistant,
+ ControlLevel: level,
+ HasExecuteAuthority: true,
+ ExecuteAuthorityBound: true,
+ DenyInfrastructureMutations: true,
+ PulseStateAllowlist: map[string]bool{},
+ Profile: aitools.ProfileInteractiveAssistant,
}
}
diff --git a/internal/ai/tools/adapters.go b/internal/ai/tools/adapters.go
index f7c7b8fd09..62d5c5ec7b 100644
--- a/internal/ai/tools/adapters.go
+++ b/internal/ai/tools/adapters.go
@@ -833,21 +833,7 @@ func (a *UpdatesToolAdapter) TriggerUpdateCheck(hostID string) (DockerCommandSta
// UpdateContainer implements UpdatesProvider
func (a *UpdatesToolAdapter) UpdateContainer(hostID, containerID, containerName string) (DockerCommandStatus, error) {
- if a.commands == nil {
- return DockerCommandStatus{}, fmt.Errorf("monitor not available")
- }
-
- cmdStatus, err := a.commands.QueueDockerContainerUpdateCommand(hostID, containerID, containerName)
- if err != nil {
- return DockerCommandStatus{}, err
- }
-
- return DockerCommandStatus{
- ID: cmdStatus.ID,
- Type: cmdStatus.Type,
- Status: cmdStatus.Status,
- Message: cmdStatus.Message,
- }, nil
+ return DockerCommandStatus{}, fmt.Errorf("Docker container updates are retired until canonical lifecycle delivery and compensation are available")
}
// GetCommandStatus implements UpdatesProvider
diff --git a/internal/ai/tools/adapters_test.go b/internal/ai/tools/adapters_test.go
index 5b66515504..32eb70df28 100644
--- a/internal/ai/tools/adapters_test.go
+++ b/internal/ai/tools/adapters_test.go
@@ -2,6 +2,7 @@ package tools
import (
"errors"
+ "strings"
"testing"
"time"
@@ -540,8 +541,8 @@ func TestUpdatesToolAdapter(t *testing.T) {
runner.updateErr = nil
runner.updateStatus = models.DockerHostCommandStatus{ID: "cmd2", Type: "update", Status: "queued"}
status, err = adapter.UpdateContainer("host1", "c1", "nginx")
- if err != nil || status.ID != "cmd2" {
- t.Fatalf("unexpected update status: %+v err=%v", status, err)
+ if err == nil || !strings.Contains(err.Error(), "retired") || status.ID != "" {
+ t.Fatalf("expected retired update denial: %+v err=%v", status, err)
}
if _, ok := adapter.GetCommandStatus("cmd2"); ok {
diff --git a/internal/ai/tools/control_resource_test.go b/internal/ai/tools/control_resource_test.go
index 43df531720..0fffc73809 100644
--- a/internal/ai/tools/control_resource_test.go
+++ b/internal/ai/tools/control_resource_test.go
@@ -5,7 +5,6 @@ import (
"encoding/json"
"strings"
"testing"
- "time"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
)
@@ -71,13 +70,13 @@ func TestPulseToolExecutor_ListTools_PulseControlDescriptionStaysCapabilityBound
if tool.Name != "pulse_control" {
continue
}
- if !strings.Contains(tool.Description, "explicitly advertise shared Pulse actions") {
+ if !strings.Contains(tool.Description, "explicitly advertises the requested capability") {
t.Fatalf("expected pulse_control description to stay capability-bounded, got %q", tool.Description)
}
- if !strings.Contains(tool.Description, "read-only") {
- t.Fatalf("expected pulse_control description to warn about read-only resources, got %q", tool.Description)
+ if !strings.Contains(tool.Description, "never executes commands") {
+ t.Fatalf("expected pulse_control description to name the command-free boundary, got %q", tool.Description)
}
- if action := tool.InputSchema.Properties["action"].Description; !strings.Contains(action, "resolved resource's shared action set") {
+ if action := tool.InputSchema.Properties["action"].Description; !strings.Contains(action, "Advertised resource capability") {
t.Fatalf("expected pulse_control action schema to describe shared action gating, got %q", action)
}
return
@@ -109,6 +108,16 @@ func TestExecuteControlResource_TrueNASAppUsesNativeActionProvider(t *testing.T)
ReadState: provider.ResourceRegistry,
AppContainerActionProvider: actionProvider,
ActionAuditStore: store,
+ TypedActionPlanner: typedActionPlannerFunc(func(_ context.Context, _ string, req unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ return &unifiedresources.ActionPlan{
+ ActionID: "action-1",
+ RequestID: req.RequestID,
+ Allowed: true,
+ RequiresApproval: true,
+ ApprovalPolicy: unifiedresources.ApprovalAdmin,
+ PlanHash: "hash-1",
+ }, nil
+ }),
})
executor.SetResolvedContext(resolved)
@@ -135,35 +144,17 @@ func TestExecuteControlResource_TrueNASAppUsesNativeActionProvider(t *testing.T)
if err := json.Unmarshal([]byte(result.Content[0].Text), &payload); err != nil {
t.Fatalf("decode result payload: %v", err)
}
- if payload["platform"] != "truenas" {
- t.Fatalf("expected truenas platform, got %+v", payload)
- }
- if payload["action"] != "restart" || payload["status"] != "running" {
- t.Fatalf("unexpected action payload: %+v", payload)
+ if payload["action_id"] != "action-1" || payload["capability"] != "restart" {
+ t.Fatalf("expected canonical action plan, got %+v", payload)
}
- if len(actionProvider.calls) != 1 {
- t.Fatalf("expected one native app action call, got %+v", actionProvider.calls)
- }
- call := actionProvider.calls[0]
- if call.OrgID != "default" || call.ProviderUID != "nextcloud" || call.Host != "truenas-main" || call.Action != "restart" {
- t.Fatalf("unexpected native app action request: %+v", call)
+ if len(actionProvider.calls) != 0 {
+ t.Fatalf("model planning must not call the native provider, got %+v", actionProvider.calls)
}
+}
- audits, err := store.GetActionAudits("", time.Time{}, 10)
- if err != nil {
- t.Fatalf("GetActionAudits() error = %v", err)
- }
- if len(audits) != 1 {
- t.Fatalf("expected one action audit, got %+v", audits)
- }
- if audits[0].Request.CapabilityName != "pulse_control" {
- t.Fatalf("unexpected capability name: %+v", audits[0].Request)
- }
- if got := audits[0].Request.Params["action"]; got != "restart" {
- t.Fatalf("expected audited action restart, got %+v", audits[0].Request.Params)
- }
- if got := audits[0].Request.Params["platform"]; got != "truenas" {
- t.Fatalf("expected audited platform truenas, got %+v", audits[0].Request.Params)
- }
+type typedActionPlannerFunc func(context.Context, string, unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error)
+
+func (f typedActionPlannerFunc) PlanTypedAction(ctx context.Context, orgID string, req unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error) {
+ return f(ctx, orgID, req)
}
diff --git a/internal/ai/tools/control_test.go b/internal/ai/tools/control_test.go
index 13847c4f22..500a44f4d9 100644
--- a/internal/ai/tools/control_test.go
+++ b/internal/ai/tools/control_test.go
@@ -94,11 +94,8 @@ func TestPulseToolExecutor_ExecuteControlGuest(t *testing.T) {
"action": "stop",
})
assert.NoError(t, err)
- resp := mustParseJSONMapControl(t, result.Content[0].Text)
- assert.Equal(t, true, resp["success"])
- if v, ok := resp["verification"].(map[string]interface{}); ok {
- assert.Equal(t, true, v["ok"])
- }
+ assert.Contains(t, result.Content[0].Text, "retired and denied")
+ agentSrv.AssertNotCalled(t, "ExecuteCommand", mock.Anything, mock.Anything, mock.Anything)
}
func TestPulseToolExecutor_ExecuteControlDocker(t *testing.T) {
@@ -149,9 +146,6 @@ func TestPulseToolExecutor_ExecuteControlDocker(t *testing.T) {
"operation": "restart",
})
assert.NoError(t, err)
- resp := mustParseJSONMapControl(t, result.Content[0].Text)
- assert.Equal(t, true, resp["success"])
- if v, ok := resp["verification"].(map[string]interface{}); ok {
- assert.Equal(t, true, v["ok"])
- }
+ assert.Contains(t, result.Content[0].Text, "retired and denied")
+ agentSrv.AssertNotCalled(t, "ExecuteCommand", mock.Anything, mock.Anything, mock.Anything)
}
diff --git a/internal/ai/tools/executor.go b/internal/ai/tools/executor.go
index dc96288492..bcdd00bb59 100644
--- a/internal/ai/tools/executor.go
+++ b/internal/ai/tools/executor.go
@@ -243,6 +243,13 @@ type AppContainerActionProvider interface {
ExecuteAction(ctx context.Context, req AppContainerActionRequest) (*AppContainerActionResult, error)
}
+// TypedActionPlanner is the only model-facing infrastructure mutation seam.
+// It can persist a canonical lifecycle plan but exposes no executor or
+// transport authority to the model tool runtime.
+type TypedActionPlanner interface {
+ PlanTypedAction(ctx context.Context, orgID string, req unifiedresources.ActionRequest) (*unifiedresources.ActionPlan, error)
+}
+
// AppContainerReadRequest describes a canonical read-only diagnostic request
// against an API-backed app-container resource.
type AppContainerReadRequest struct {
@@ -472,6 +479,7 @@ type ExecutorConfig struct {
AppContainerActionProvider AppContainerActionProvider
AppContainerReadProvider AppContainerReadProvider
ActionAuditStore unifiedresources.ResourceStore
+ TypedActionPlanner TypedActionPlanner
// Optional typed read access to current infrastructure state.
// When provided, tool handlers should prefer this over models.StateSnapshot iteration.
ReadState unifiedresources.ReadState
@@ -539,6 +547,7 @@ type PulseToolExecutor struct {
appContainerActionProvider AppContainerActionProvider
appContainerReadProvider AppContainerReadProvider
actionAuditStore unifiedresources.ResourceStore
+ typedActionPlanner TypedActionPlanner
// onActionCompleted fires after a terminal-state action audit
// (Completed or Failed, including refused-before-dispatch
// failures) is persisted. Wired by the API layer through the
@@ -655,6 +664,7 @@ func NewPulseToolExecutor(cfg ExecutorConfig) *PulseToolExecutor {
appContainerActionProvider: cfg.AppContainerActionProvider,
appContainerReadProvider: cfg.AppContainerReadProvider,
actionAuditStore: cfg.ActionAuditStore,
+ typedActionPlanner: cfg.TypedActionPlanner,
readState: cfg.ReadState,
controlLevel: cfg.ControlLevel,
protectedGuests: cfg.ProtectedGuests,
@@ -731,6 +741,7 @@ func (e *PulseToolExecutor) Clone() *PulseToolExecutor {
appContainerActionProvider: e.appContainerActionProvider,
appContainerReadProvider: e.appContainerReadProvider,
actionAuditStore: e.actionAuditStore,
+ typedActionPlanner: e.typedActionPlanner,
readState: e.readState,
controlLevel: e.controlLevel,
protectedGuests: append([]string(nil), e.protectedGuests...),
@@ -955,6 +966,11 @@ func (e *PulseToolExecutor) SetActionAuditStore(store unifiedresources.ResourceS
e.actionAuditStore = store
}
+// SetTypedActionPlanner installs the canonical lifecycle planning boundary.
+func (e *PulseToolExecutor) SetTypedActionPlanner(planner TypedActionPlanner) {
+ e.typedActionPlanner = planner
+}
+
// SetOnActionCompleted installs a fire-and-forget callback that runs
// after every terminal-state action audit is persisted (Completed or
// Failed, including refused-before-dispatch failures with stable
@@ -1130,7 +1146,7 @@ func (e *PulseToolExecutor) registerTools() {
// pulse_storage - pools, config, backups, snapshots, ceph, replication, pbs_jobs, raid, disk_health, resource_disks
e.registerStorageTools()
- // pulse_docker - control, updates, check_updates, update, services, tasks, swarm
+ // pulse_docker - read-only updates/check/services/tasks/swarm state
e.registerDockerTools()
// pulse_kubernetes - clusters, nodes, pods, deployments
@@ -1143,13 +1159,9 @@ func (e *PulseToolExecutor) registerTools() {
// This is ALWAYS classified as ToolKindRead and never triggers VERIFYING
e.registerReadTools()
- // pulse_control - guest control, run commands (requires control permission)
- // NOTE: For read-only command execution, use pulse_read instead
+ // pulse_control - plan typed resource capabilities only
e.registerControlTools()
- // pulse_file_edit - read, append, write files (requires control permission)
- e.registerFileTools()
-
// pulse_discovery - get, run, list discoveries
e.registerDiscoveryTools()
diff --git a/internal/ai/tools/invocation_policy_test.go b/internal/ai/tools/invocation_policy_test.go
index 8a24c75020..e3fba9a1bd 100644
--- a/internal/ai/tools/invocation_policy_test.go
+++ b/internal/ai/tools/invocation_policy_test.go
@@ -65,14 +65,13 @@ func TestKubernetesScaleClassifiesWriteAndNeverInvokesUnderReadOnly(t *testing.T
exec := newInvocationPolicyExecutor(t)
exec.SetControlLevel(ControlLevelReadOnly)
text := executeBlockedText(t, exec, "pulse_kubernetes", map[string]interface{}{"type": "scale"})
- assert.Equal(t, agentcapabilities.ControlToolsDisabledMessage, text)
+ assert.Contains(t, text, "retired and denied")
// Deny-mutations policy blocks even with an autonomous control level.
exec.SetControlLevel(ControlLevelAutonomous)
exec.SetDenyInfrastructureMutations(true)
text = executeBlockedText(t, exec, "pulse_kubernetes", map[string]interface{}{"type": "scale"})
- assert.Contains(t, text, "Invocation blocked")
- assert.Contains(t, text, "infrastructure")
+ assert.Contains(t, text, "retired and denied")
}
func TestDockerUpdateQueuesNothingAtReadOnly(t *testing.T) {
@@ -83,7 +82,7 @@ func TestDockerUpdateQueuesNothingAtReadOnly(t *testing.T) {
text := executeBlockedText(t, exec, "pulse_docker", map[string]interface{}{
"action": "update", "container": "nginx", "host": "tower",
})
- assert.Equal(t, agentcapabilities.ControlToolsDisabledMessage, text)
+ assert.Contains(t, text, "retired and denied")
updates.AssertNotCalled(t, "UpdateContainer")
updates.AssertNotCalled(t, "IsUpdateActionsEnabled")
}
@@ -98,7 +97,7 @@ func TestAutonomousDenyMutationsCannotMutateDocker(t *testing.T) {
text := executeBlockedText(t, exec, "pulse_docker", map[string]interface{}{
"action": "update", "container": "nginx", "host": "tower",
})
- assert.Contains(t, text, "Invocation blocked")
+ assert.Contains(t, text, "retired and denied")
updates.AssertNotCalled(t, "UpdateContainer")
// Read subactions remain available under the same policy.
@@ -124,6 +123,45 @@ func TestFabricatedEnumValuesFailClosedAtRuntime(t *testing.T) {
assert.Contains(t, text, "Invocation blocked")
}
+func TestRetiredMutationProfileMatrixDeniesBeforeHandlers(t *testing.T) {
+ profiles := []struct {
+ name string
+ level ControlLevel
+ profile ExecutionProfile
+ autonomous bool
+ }{
+ {name: "interactive-read-only", level: ControlLevelReadOnly, profile: ProfileInteractiveAssistant},
+ {name: "interactive-controlled", level: ControlLevelControlled, profile: ProfileInteractiveAssistant},
+ {name: "interactive-autonomous", level: ControlLevelAutonomous, profile: ProfileInteractiveAssistant, autonomous: true},
+ {name: "patrol-detection", level: ControlLevelAutonomous, profile: ProfilePatrolDetection},
+ {name: "patrol-investigation", level: ControlLevelAutonomous, profile: ProfilePatrolInvestigation},
+ }
+ calls := []struct {
+ tool string
+ args map[string]interface{}
+ }{
+ {tool: agentcapabilities.PulseControlToolName, args: map[string]interface{}{"type": "command", "command": "touch /tmp/x"}},
+ {tool: agentcapabilities.PulseControlToolName, args: map[string]interface{}{"type": "guest", "guest_id": "101", "action": "stop"}},
+ {tool: agentcapabilities.PulseDockerToolName, args: map[string]interface{}{"action": "control", "operation": "restart", "container": "web"}},
+ {tool: agentcapabilities.PulseDockerToolName, args: map[string]interface{}{"action": "update", "container": "web"}},
+ {tool: agentcapabilities.PulseKubernetesToolName, args: map[string]interface{}{"type": "scale", "deployment": "web"}},
+ {tool: agentcapabilities.PulseKubernetesToolName, args: map[string]interface{}{"type": "exec", "pod": "web", "command": "touch /tmp/x"}},
+ {tool: agentcapabilities.PulseFileEditToolName, args: map[string]interface{}{"action": "write", "path": "/tmp/x"}},
+ }
+ for _, posture := range profiles {
+ t.Run(posture.name, func(t *testing.T) {
+ exec := newInvocationPolicyExecutor(t)
+ exec.SetControlLevel(posture.level)
+ exec.SetAutonomousMode(posture.autonomous)
+ exec.ApplyExecutionProfile(posture.profile)
+ for _, call := range calls {
+ text := executeBlockedText(t, exec, call.tool, call.args)
+ assert.Contains(t, text, "retired and denied", "%s %+v", call.tool, call.args)
+ }
+ })
+ }
+}
+
func TestProjectionAndRuntimeEnforcementAgree(t *testing.T) {
exec := newInvocationPolicyExecutor(t)
exec.SetControlLevel(ControlLevelReadOnly)
@@ -396,7 +434,7 @@ func TestPatrolDetectionProfileEnforcesAllowlistedPulseState(t *testing.T) {
text := executeBlockedText(t, exec, "pulse_docker", map[string]interface{}{
"action": "update", "container": "nginx", "host": "tower",
})
- assert.Contains(t, text, "Invocation blocked")
+ assert.Contains(t, text, "retired and denied")
// Pulse-state mutations outside the finding allowlist are blocked
// before the handler: detection must not dismiss alerts or write
@@ -437,7 +475,7 @@ func TestPatrolInvestigationProfileIsStructurallyReadOnly(t *testing.T) {
// No infrastructure mutations.
text := executeBlockedText(t, exec, "pulse_kubernetes", map[string]interface{}{"type": "scale"})
- assert.Contains(t, text, "Invocation blocked")
+ assert.Contains(t, text, "retired and denied")
// No Pulse-state mutations either - not even the Patrol finding tools.
text = executeBlockedText(t, exec, "patrol_report_finding", map[string]interface{}{})
assert.Contains(t, text, "Invocation blocked")
diff --git a/internal/ai/tools/mutation_registry_audit_test.go b/internal/ai/tools/mutation_registry_audit_test.go
new file mode 100644
index 0000000000..51a8f02fcb
--- /dev/null
+++ b/internal/ai/tools/mutation_registry_audit_test.go
@@ -0,0 +1,75 @@
+package tools
+
+import (
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"
+ "github.com/rcourtman/pulse-go-rewrite/internal/mutationregistry"
+)
+
+// This audit derives candidates from the actual constructed tool registry and
+// each registered schema discriminator. A newly registered infrastructure
+// mutation therefore fails unless LookupModelInvocation classifies it.
+func TestRegisteredModelMutationSchemasResolveToClosedRegistry(t *testing.T) {
+ executor := NewPulseToolExecutor(ExecutorConfig{})
+ for name, registered := range executor.registry.tools {
+ descriptor := registered.Invocation
+ if descriptor == nil {
+ t.Fatalf("registered tool %q has no invocation descriptor", name)
+ }
+ if descriptor.Static != nil {
+ if descriptor.Static.Mutation == agentcapabilities.MutationInfrastructure {
+ enumerated := false
+ for _, discriminator := range []string{"type", "action"} {
+ values := registered.Definition.InputSchema.Properties[discriminator].Enum
+ for _, value := range values {
+ enumerated = true
+ assertModelCandidateRegistered(t, name, map[string]interface{}{discriminator: value})
+ }
+ if len(values) > 0 {
+ break
+ }
+ }
+ if !enumerated {
+ assertModelCandidateRegistered(t, name, nil)
+ }
+ }
+ continue
+ }
+ property := registered.Definition.InputSchema.Properties[descriptor.Discriminator]
+ for _, value := range property.Enum {
+ args := map[string]interface{}{descriptor.Discriminator: value}
+ class := descriptor.Classify(args)
+ if class.Mutation == agentcapabilities.MutationInfrastructure {
+ assertModelCandidateRegistered(t, name, args)
+ }
+ }
+ }
+}
+
+func TestRetiredMutationAliasesCannotShadowExtensions(t *testing.T) {
+ for _, alias := range []string{agentcapabilities.LegacyAssistantRunCommandToolName, "pulse_run_command"} {
+ t.Run(alias, func(t *testing.T) {
+ defer func() {
+ if recover() == nil {
+ t.Fatalf("retired alias %q was accepted as an extension", alias)
+ }
+ }()
+ NewToolRegistry().RegisterExtension(RegisteredTool{
+ Definition: Tool{Name: alias},
+ Invocation: StaticInvocation(agentcapabilities.ToolCallKindRead, agentcapabilities.MutationNone),
+ })
+ })
+ }
+}
+
+func assertModelCandidateRegistered(t *testing.T, name string, args map[string]interface{}) {
+ t.Helper()
+ entry, ok := mutationregistry.LookupModelInvocation(name, args)
+ if !ok {
+ t.Fatalf("registered model mutation %s %v has no registry disposition", name, args)
+ }
+ if entry.Disposition != mutationregistry.DispositionLifecycle && entry.Disposition != mutationregistry.DispositionRetiredDenied {
+ t.Fatalf("registered model mutation %s %v has invalid disposition %q", name, args, entry.Disposition)
+ }
+}
diff --git a/internal/ai/tools/names_test.go b/internal/ai/tools/names_test.go
index cb37f1d238..da100182fa 100644
--- a/internal/ai/tools/names_test.go
+++ b/internal/ai/tools/names_test.go
@@ -22,7 +22,6 @@ func TestKnownToolNamesIncludesRegisteredTools(t *testing.T) {
agentcapabilities.PulseDockerToolName,
agentcapabilities.PulseKubernetesToolName,
agentcapabilities.PulseAlertsToolName,
- agentcapabilities.PulseFileEditToolName,
agentcapabilities.PulseKnowledgeToolName,
agentcapabilities.PulsePMGToolName,
agentcapabilities.PulseQuestionToolName,
@@ -37,6 +36,12 @@ func TestKnownToolNamesIncludesRegisteredTools(t *testing.T) {
}
}
+func TestRetiredFileMutationToolIsNotKnown(t *testing.T) {
+ if IsKnownToolName(agentcapabilities.PulseFileEditToolName) {
+ t.Fatal("retired file mutation tool must not remain in the provider catalog")
+ }
+}
+
func TestIsKnownToolNameRejectsUnknown(t *testing.T) {
cases := []string{
"",
diff --git a/internal/ai/tools/provider_projection_test.go b/internal/ai/tools/provider_projection_test.go
index 5178dd4c5d..f5e33beaf5 100644
--- a/internal/ai/tools/provider_projection_test.go
+++ b/internal/ai/tools/provider_projection_test.go
@@ -36,11 +36,14 @@ func TestPulseToolExecutorAssistantProviderToolsUsesRuntimeAvailability(t *testi
projected := exec.AssistantProviderTools(agentcapabilities.AssistantProviderToolOptions{IncludeQuestionTool: true})
names := providerToolNameSet(projected)
- for _, name := range []string{agentcapabilities.PulseQueryToolName, agentcapabilities.PulseReadToolName, agentcapabilities.PulseControlToolName, agentcapabilities.PulseFileEditToolName, agentcapabilities.PulseQuestionToolName} {
+ for _, name := range []string{agentcapabilities.PulseQueryToolName, agentcapabilities.PulseReadToolName, agentcapabilities.PulseControlToolName, agentcapabilities.PulseQuestionToolName} {
if !names[name] {
t.Fatalf("AssistantProviderTools did not expose available tool %s; names=%v", name, names)
}
}
+ if names[agentcapabilities.PulseFileEditToolName] {
+ t.Fatal("AssistantProviderTools exposed retired file mutation tool")
+ }
for _, name := range []string{agentcapabilities.PulseDiscoveryToolName, agentcapabilities.PatrolReportFindingToolName, agentcapabilities.PatrolResolveFindingToolName, agentcapabilities.PatrolGetFindingsToolName} {
if names[name] {
t.Fatalf("AssistantProviderTools exposed unavailable tool %s; names=%v", name, names)
diff --git a/internal/ai/tools/registry.go b/internal/ai/tools/registry.go
index 975256e4bf..761020b7a2 100644
--- a/internal/ai/tools/registry.go
+++ b/internal/ai/tools/registry.go
@@ -6,6 +6,7 @@ import (
"sync"
"github.com/rcourtman/pulse-go-rewrite/internal/agentcapabilities"
+ "github.com/rcourtman/pulse-go-rewrite/internal/mutationregistry"
)
// ToolActionMode describes the state-changing capability of a registered tool.
@@ -200,6 +201,9 @@ func (r *ToolRegistry) RegisterExtension(tool RegisteredTool) {
tool.Definition = tool.Definition.NormalizeCollections()
name := tool.Definition.Name
+ if _, retiredAlias := mutationregistry.LookupModelInvocation(name, nil); retiredAlias {
+ panic(fmt.Sprintf("tool %q is a retired mutation alias and cannot be registered as an extension", name))
+ }
if _, isCanonical := agentcapabilities.InvocationDescriptorFor(name); isCanonical {
panic(fmt.Sprintf("tool %q is a canonical Pulse tool and cannot be registered as an extension", name))
}
@@ -396,6 +400,9 @@ func (r *ToolRegistry) Execute(ctx context.Context, e *PulseToolExecutor, name s
}
name = params.Name
args = params.Arguments
+ if mutation, classified := mutationregistry.LookupModelInvocation(name, args); classified && mutation.Disposition == mutationregistry.DispositionRetiredDenied {
+ return NewErrorResult(fmt.Errorf("mutation %s is retired and denied; use an advertised typed resource action", mutation.ID)), nil
+ }
r.mu.RLock()
tool, exists := r.tools[name]
diff --git a/internal/ai/tools/tools_control.go b/internal/ai/tools/tools_control.go
index f181ce96d9..dd41a48ef4 100644
--- a/internal/ai/tools/tools_control.go
+++ b/internal/ai/tools/tools_control.go
@@ -23,14 +23,14 @@ func (e *PulseToolExecutor) registerControlTools() {
e.registry.registerBuiltin(RegisteredTool{
Definition: Tool{
Name: agentcapabilities.PulseControlToolName,
- Description: `WRITE operations: control canonical resources that explicitly advertise shared Pulse actions (for example Proxmox guests and supported app-containers) or execute state-modifying commands. Some canonical resources are read-only and will reject pulse_control even when their type is vm or system-container. Read-only and Docker-only workflows are exposed through their own governed tools.`,
+ Description: `Plan one typed action for a canonical resource that explicitly advertises the requested capability. The plan is persisted on Pulse's shared action lifecycle; this tool never executes commands or contacts infrastructure directly.`,
InputSchema: InputSchema{
Type: "object",
Properties: map[string]PropertySchema{
"type": {
Type: "string",
- Description: "Control type: guest, resource, or command",
- Enum: []string{"guest", "resource", "command"},
+ Description: "Canonical control type. Only resource is supported.",
+ Enum: []string{"resource"},
},
"guest_id": {
Type: "string",
@@ -42,8 +42,8 @@ func (e *PulseToolExecutor) registerControlTools() {
},
"action": {
Type: "string",
- Description: "For guest/resource: start, stop, shutdown, restart, delete (availability depends on the resolved resource's shared action set)",
- Enum: []string{"start", "stop", "shutdown", "restart", "delete"},
+ Description: "Advertised resource capability name, such as start, stop, shutdown, reboot, or restart",
+ Enum: []string{"start", "stop", "shutdown", "reboot", "restart"},
},
"command": {
Type: "string",
@@ -73,7 +73,7 @@ func (e *PulseToolExecutor) registerControlTools() {
ActionMode: ToolActionWrite,
ApprovalPolicy: ToolApprovalActionPlan,
ApprovalSummary: "hidden in read-only mode; approval required in controlled mode",
- Summary: "Runs shared Pulse control actions; control only resources that explicitly support shared Pulse actions.",
+ Summary: "Plans shared Pulse resource actions; approval and execution stay on the canonical action lifecycle.",
},
})
}
@@ -82,14 +82,10 @@ func (e *PulseToolExecutor) registerControlTools() {
func (e *PulseToolExecutor) executeControl(ctx context.Context, args map[string]interface{}) (CallToolResult, error) {
controlType, _ := args["type"].(string)
switch controlType {
- case "guest":
- return e.executeControlGuest(ctx, args)
case "resource":
return e.executeControlResource(ctx, args)
- case "command":
- return e.executeRunCommand(ctx, args)
default:
- return NewErrorResult(fmt.Errorf("unknown type: %s. Use: guest, resource, command", controlType)), nil
+ return NewErrorResult(fmt.Errorf("control type %q is retired and denied; use type=resource with an advertised capability", controlType)), nil
}
}
@@ -98,8 +94,6 @@ func (e *PulseToolExecutor) executeControlResource(ctx context.Context, args map
resourceRef = strings.TrimSpace(resourceRef)
action, _ := args["action"].(string)
action = strings.TrimSpace(action)
- approvalID := agentcapabilities.ApprovalArgument(args)
-
if resourceRef == "" {
return NewErrorResult(fmt.Errorf("resource_id is required")), nil
}
@@ -121,41 +115,34 @@ func (e *PulseToolExecutor) executeControlResource(ctx context.Context, args map
return NewErrorResult(errors.New(validation.ErrorMsg)), nil
}
- resolved := validation.Resource
- switch resolved.GetKind() {
- case "vm", "system-container":
- guestArgs := map[string]interface{}{
- "guest_id": resolvedResourceControlIdentity(resolved, resourceRef),
- "action": action,
- }
- if force, ok := args["force"].(bool); ok {
- guestArgs["force"] = force
- }
- if approvalID != "" {
- agentcapabilities.WithApprovalArgument(guestArgs, approvalID)
- }
- return e.executeControlGuest(ctx, guestArgs)
-
- case "app-container":
- switch strings.ToLower(strings.TrimSpace(resolved.GetAdapter())) {
- case "docker":
- dockerArgs := map[string]interface{}{
- "container": resolvedResourceControlIdentity(resolved, resourceRef),
- "host": strings.TrimSpace(resolved.GetTargetHost()),
- "operation": action,
- }
- if approvalID != "" {
- agentcapabilities.WithApprovalArgument(dockerArgs, approvalID)
- }
- return e.executeDockerControl(ctx, dockerArgs)
- case "truenas":
- return e.executeNativeAppContainerControl(ctx, resolved, action, approvalID)
- default:
- return NewErrorResult(fmt.Errorf("resource '%s' uses unsupported control adapter %q", resourceRef, resolved.GetAdapter())), nil
- }
+ if e.typedActionPlanner == nil {
+ return NewErrorResult(fmt.Errorf("canonical action planning is unavailable")), nil
}
-
- return NewErrorResult(fmt.Errorf("resource '%s' of kind %q is not controllable through pulse_control type=resource", resourceRef, resolved.GetKind())), nil
+ resourceID := unifiedresources.CanonicalResourceID(validation.Resource.GetResourceID())
+ if resourceID == "" {
+ return NewErrorResult(fmt.Errorf("resource %q has no canonical resource id", resourceRef)), nil
+ }
+ plan, err := e.typedActionPlanner.PlanTypedAction(ctx, e.orgID, unifiedresources.ActionRequest{
+ RequestID: uuid.NewString(),
+ ResourceID: resourceID,
+ CapabilityName: action,
+ Reason: fmt.Sprintf("Assistant proposed %s for %s", action, resourceID),
+ RequestedBy: "pulse_assistant",
+ })
+ if err != nil {
+ return NewErrorResult(err), nil
+ }
+ return NewJSONResult(map[string]interface{}{
+ "planned": true,
+ "action_id": plan.ActionID,
+ "resource_id": resourceID,
+ "capability": action,
+ "requires_approval": plan.RequiresApproval,
+ "approval_policy": plan.ApprovalPolicy,
+ "plan_hash": plan.PlanHash,
+ "expires_at": plan.ExpiresAt,
+ "message": "Typed action planned. Approval and execution remain on the canonical action lifecycle.",
+ }), nil
}
func (e *PulseToolExecutor) executeNativeAppContainerControl(ctx context.Context, resource ResolvedResourceInfo, action string, approvalID string) (CallToolResult, error) {
diff --git a/internal/ai/tools/tools_docker.go b/internal/ai/tools/tools_docker.go
index 59c930b706..53d06a349c 100644
--- a/internal/ai/tools/tools_docker.go
+++ b/internal/ai/tools/tools_docker.go
@@ -53,14 +53,14 @@ func (e *PulseToolExecutor) registerDockerTools() {
e.registry.registerBuiltin(RegisteredTool{
Definition: Tool{
Name: agentcapabilities.PulseDockerToolName,
- Description: `Manage Docker containers, updates, and Swarm services. Actions: control, updates, check_updates, update, services, tasks, swarm.`,
+ 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.`,
InputSchema: InputSchema{
Type: "object",
Properties: map[string]PropertySchema{
"action": {
Type: "string",
Description: "Docker action to perform",
- Enum: []string{"control", "updates", "check_updates", "update", "services", "tasks", "swarm"},
+ Enum: []string{"updates", "check_updates", "services", "tasks", "swarm"},
},
"container": {
Type: "string",
@@ -91,10 +91,9 @@ func (e *PulseToolExecutor) registerDockerTools() {
return exec.executeDocker(ctx, args)
},
Governance: ToolGovernance{
- ActionMode: ToolActionMixed,
- ApprovalPolicy: ToolApprovalActionPlan,
- ApprovalSummary: "read/list actions are safe; control and update subactions require approval in controlled mode",
- Summary: "Lists Docker state and performs governed Docker control/update subactions.",
+ ActionMode: ToolActionRead,
+ ApprovalPolicy: ToolApprovalScopeOnly,
+ Summary: "Reads Docker state; mutations use typed resource actions or remain denied.",
},
})
}
@@ -103,14 +102,10 @@ func (e *PulseToolExecutor) registerDockerTools() {
func (e *PulseToolExecutor) executeDocker(ctx context.Context, args map[string]interface{}) (CallToolResult, error) {
action, _ := args["action"].(string)
switch action {
- case "control":
- return e.executeDockerControl(ctx, args)
case "updates":
return e.executeListDockerUpdates(ctx, args)
case "check_updates":
return e.executeCheckDockerUpdates(ctx, args)
- case "update":
- return e.executeUpdateDockerContainer(ctx, args)
case "services":
return e.executeListDockerServices(ctx, args)
case "tasks":
@@ -118,7 +113,7 @@ func (e *PulseToolExecutor) executeDocker(ctx context.Context, args map[string]i
case "swarm":
return e.executeGetSwarmStatus(ctx, args)
default:
- return NewErrorResult(fmt.Errorf("unknown action: %s. Use: control, updates, check_updates, update, services, tasks, swarm", action)), nil
+ return NewErrorResult(fmt.Errorf("Docker action %q is unavailable; use read actions or pulse_control type=resource for advertised lifecycle capabilities", action)), nil
}
}
diff --git a/internal/ai/tools/tools_file.go b/internal/ai/tools/tools_file.go
index 7c0fe0c57e..bceb2fbe59 100644
--- a/internal/ai/tools/tools_file.go
+++ b/internal/ai/tools/tools_file.go
@@ -83,7 +83,7 @@ Examples:
},
},
Handler: func(ctx context.Context, exec *PulseToolExecutor, args map[string]interface{}) (CallToolResult, error) {
- return exec.executeFileEdit(ctx, args)
+ return NewErrorResult(fmt.Errorf("model-authored file mutation is retired and denied")), nil
},
RequireControl: true,
Governance: ToolGovernance{
diff --git a/internal/ai/tools/tools_file_test.go b/internal/ai/tools/tools_file_test.go
index 4e44d44902..39a6173ed7 100644
--- a/internal/ai/tools/tools_file_test.go
+++ b/internal/ai/tools/tools_file_test.go
@@ -22,7 +22,7 @@ func TestFileTools_Registry(t *testing.T) {
break
}
}
- assert.True(t, found)
+ assert.False(t, found, "retired model file mutation tool must not be registered")
}
func TestExecuteFileEdit_Validation(t *testing.T) {
diff --git a/internal/ai/tools/tools_kubernetes.go b/internal/ai/tools/tools_kubernetes.go
index 34c6dbc369..9cc64229e2 100644
--- a/internal/ai/tools/tools_kubernetes.go
+++ b/internal/ai/tools/tools_kubernetes.go
@@ -40,14 +40,14 @@ func (e *PulseToolExecutor) registerKubernetesTools() {
e.registry.registerBuiltin(RegisteredTool{
Definition: Tool{
Name: agentcapabilities.PulseKubernetesToolName,
- Description: `Query and control Kubernetes clusters, nodes, pods, and deployments. Query: clusters, nodes, pods, deployments. Control: scale, restart, delete_pod, exec, logs.`,
+ Description: `Read Kubernetes clusters, nodes, pods, deployments, and bounded logs. Workload mutations remain unavailable until typed capability, durable delivery, and compensation contracts are complete.`,
InputSchema: InputSchema{
Type: "object",
Properties: map[string]PropertySchema{
"type": {
Type: "string",
Description: "Operation type",
- Enum: []string{"clusters", "nodes", "pods", "deployments", "scale", "restart", "delete_pod", "exec", "logs"},
+ Enum: []string{"clusters", "nodes", "pods", "deployments", "logs"},
},
"cluster": {
Type: "string",
@@ -101,10 +101,9 @@ func (e *PulseToolExecutor) registerKubernetesTools() {
return exec.executeKubernetes(ctx, args)
},
Governance: ToolGovernance{
- ActionMode: ToolActionMixed,
- ApprovalPolicy: ToolApprovalActionPlan,
- ApprovalSummary: "read/list/log actions are safe; scale, restart, delete, and exec subactions require approval in controlled mode",
- Summary: "Reads Kubernetes topology and runs governed workload-control subactions.",
+ ActionMode: ToolActionRead,
+ ApprovalPolicy: ToolApprovalScopeOnly,
+ Summary: "Reads Kubernetes topology and bounded logs; workload mutations are denied.",
},
})
}
@@ -121,19 +120,10 @@ func (e *PulseToolExecutor) executeKubernetes(ctx context.Context, args map[stri
return e.executeGetKubernetesPods(ctx, args)
case "deployments":
return e.executeGetKubernetesDeployments(ctx, args)
- // Control operations
- case "scale":
- return e.executeKubernetesScale(ctx, args)
- case "restart":
- return e.executeKubernetesRestart(ctx, args)
- case "delete_pod":
- return e.executeKubernetesDeletePod(ctx, args)
- case "exec":
- return e.executeKubernetesExec(ctx, args)
case "logs":
return e.executeKubernetesLogs(ctx, args)
default:
- return NewErrorResult(fmt.Errorf("unknown type: %s. Use: clusters, nodes, pods, deployments, scale, restart, delete_pod, exec, logs", resourceType)), nil
+ return NewErrorResult(fmt.Errorf("Kubernetes operation %q is unavailable; only clusters, nodes, pods, deployments, and logs are supported", resourceType)), nil
}
}
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 163ba87c4c..ca72946aa2 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -4149,6 +4149,8 @@ func (h *AISettingsHandler) HandleRunCommand(w http.ResponseWriter, r *http.Requ
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
+ writeJSONError(w, http.StatusGone, agentcapabilities.AgentErrCodeRawCommandRetired, "Raw command execution is retired. Use an advertised typed resource action.")
+ return
// Require authentication
if !CheckAuth(h.getConfig(r.Context()), w, r) {
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 7e3a524098..b65059d50d 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -2592,8 +2592,8 @@ func TestHandleRunCommand_InvalidBody(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- if rec.Code != http.StatusBadRequest {
- t.Fatalf("expected status %d, got %d", http.StatusBadRequest, rec.Code)
+ if rec.Code != http.StatusGone {
+ t.Fatalf("expected status %d, got %d", http.StatusGone, rec.Code)
}
}
@@ -2677,8 +2677,8 @@ func TestHandleRunCommand_RequiresApprovalID(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- if rec.Code != http.StatusBadRequest {
- t.Fatalf("expected status %d, got %d", http.StatusBadRequest, rec.Code)
+ if rec.Code != http.StatusGone {
+ t.Fatalf("expected status %d, got %d", http.StatusGone, rec.Code)
}
}
@@ -2712,7 +2712,8 @@ func TestHandleRunCommand_DefersConsumptionUntilAgentDispatch(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- require.Equal(t, http.StatusOK, rec.Code, "body=%s", rec.Body.String())
+ require.Equal(t, http.StatusGone, rec.Code, "body=%s", rec.Body.String())
+ require.Contains(t, rec.Body.String(), agentcapabilities.AgentErrCodeRawCommandRetired)
stored, found := store.GetApproval(appReq.ID)
require.True(t, found)
@@ -2749,7 +2750,7 @@ func TestHandleRunCommand_RejectsCommandMismatch(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- require.Equal(t, http.StatusConflict, rec.Code)
+ require.Equal(t, http.StatusGone, rec.Code)
stored, found := store.GetApproval(appReq.ID)
require.True(t, found)
@@ -2785,8 +2786,8 @@ func TestHandleRunCommand_RejectsUnsupportedTargetType(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- require.Equal(t, http.StatusBadRequest, rec.Code)
- require.Contains(t, rec.Body.String(), "unsupported target_type")
+ require.Equal(t, http.StatusGone, rec.Code)
+ require.Contains(t, rec.Body.String(), agentcapabilities.AgentErrCodeRawCommandRetired)
stored, found := store.GetApproval(appReq.ID)
require.True(t, found)
@@ -2827,7 +2828,7 @@ func TestHandleRunCommand_RejectsCrossOrgApproval(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleRunCommand(rec, req)
- require.Equal(t, http.StatusNotFound, rec.Code)
+ require.Equal(t, http.StatusGone, rec.Code)
stored, found := store.GetApproval(appReq.ID)
require.True(t, found)
require.False(t, stored.Consumed)
diff --git a/internal/api/assistant_typed_action_planner.go b/internal/api/assistant_typed_action_planner.go
new file mode 100644
index 0000000000..f7bdee936c
--- /dev/null
+++ b/internal/api/assistant_typed_action_planner.go
@@ -0,0 +1,19 @@
+package api
+
+import (
+ "context"
+
+ unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+)
+
+type assistantTypedActionPlanner struct {
+ resources *ResourceHandlers
+}
+
+func (p assistantTypedActionPlanner) PlanTypedAction(ctx context.Context, orgID string, req unified.ActionRequest) (*unified.ActionPlan, error) {
+ plan, err := p.resources.ActionLifecycle().Plan(ctx, orgID, req)
+ if err != nil {
+ return nil, err
+ }
+ return &plan, nil
+}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index bda9b093c8..2fca5b45c4 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -17354,7 +17354,6 @@ func TestContract_PulseMCPAdapterProjectsAgentCapabilitiesManifest(t *testing.T)
`return ProviderToolNames(AssistantNativeProviderTools())`,
`Name: PulseQuestionToolName`,
`InputSchema: PulseQuestionProviderInputSchema(),`,
- `Name: LegacyAssistantRunCommandToolName`,
`Name: LegacyAssistantFetchURLToolName`,
`Name: LegacyAssistantSetResourceURLToolName`,
`type PulseQuestionToolType string`,
@@ -19680,24 +19679,25 @@ func TestContract_AgentSurfaceErrorCodesMatchManifestDeclarations(t *testing.T)
// don't need the specific token. Whitelisted here so the
// emit/declare audit doesn't false-positive on them.
internalOnlyCodes := map[string]bool{
- "action_audit_unavailable": true,
- "action_audit_persist_failed": true,
- "action_plan_failed": true,
- "action_plan_encode_failed": true,
- "action_audit_query_failed": true,
- "action_decision_persist_failed": true,
- "action_decision_encode_failed": true,
- "action_decision_failed": true,
- "action_execution_persist_failed": true,
- "action_execution_encode_failed": true,
- "action_execution_failed": true,
- "action_queue_unavailable": true,
- "action_queue_query_failed": true,
- "action_queue_encode_failed": true,
- "action_not_executing": true,
- "action_policy_validation_failed": true,
- "action_plan_validation_failed": true,
- "resource_registry_unavailable": true,
+ "action_audit_unavailable": true,
+ "action_audit_persist_failed": true,
+ "action_plan_failed": true,
+ "action_plan_encode_failed": true,
+ "action_audit_query_failed": true,
+ "action_decision_persist_failed": true,
+ "action_decision_encode_failed": true,
+ "action_decision_failed": true,
+ "action_execution_persist_failed": true,
+ "action_execution_encode_failed": true,
+ "action_execution_failed": true,
+ "action_queue_unavailable": true,
+ "action_queue_query_failed": true,
+ "action_queue_encode_failed": true,
+ "action_not_executing": true,
+ "action_policy_validation_failed": true,
+ "action_plan_validation_failed": true,
+ "resource_registry_unavailable": true,
+ agentcapabilities.AgentErrCodeRawCommandRetired: true,
}
agentErrorConstantValues := map[string]string{
@@ -19728,6 +19728,7 @@ func TestContract_AgentSurfaceErrorCodesMatchManifestDeclarations(t *testing.T)
"AgentErrCodeActionQueueUnavailable": agentcapabilities.AgentErrCodeActionQueueUnavailable,
"AgentErrCodeActionQueueQueryFailed": agentcapabilities.AgentErrCodeActionQueueQueryFailed,
"AgentErrCodeActionQueueEncodeFailed": agentcapabilities.AgentErrCodeActionQueueEncodeFailed,
+ "AgentErrCodeRawCommandRetired": agentcapabilities.AgentErrCodeRawCommandRetired,
}
// Extract every emitted shared code from writeJSONError /
diff --git a/internal/api/docker_agents.go b/internal/api/docker_agents.go
index b428f39d76..f007264fd4 100644
--- a/internal/api/docker_agents.go
+++ b/internal/api/docker_agents.go
@@ -343,22 +343,7 @@ func (h *DockerAgentHandlers) HandleDeleteHost(w http.ResponseWriter, r *http.Re
}
if !force && strings.EqualFold(priorHost.Status, "online") {
- command, err := h.getMonitor(r.Context()).QueueDockerHostStop(agentID)
- if err != nil {
- writeErrorResponse(w, http.StatusBadRequest, "docker_command_failed", err.Error(), nil)
- return
- }
-
- h.broadcastState(r.Context())
-
- if err := utils.WriteJSONResponse(w, map[string]any{
- "success": true,
- "agentId": agentID,
- "command": command,
- "message": "Stop command queued",
- }); err != nil {
- log.Error().Err(err).Msg("Failed to serialize docker host stop command response")
- }
+ writeErrorResponse(w, http.StatusGone, "docker_runtime_stop_retired", "Remote Docker runtime stop is unavailable until it is routed through the canonical action lifecycle.", nil)
return
}
@@ -547,35 +532,7 @@ func (h *DockerAgentHandlers) HandleContainerUpdate(w http.ResponseWriter, r *ht
return
}
- // Check if Docker update actions are disabled server-wide
- if h.config != nil && h.config.DisableDockerUpdateActions {
- writeErrorResponse(w, http.StatusForbidden, "docker_updates_disabled",
- "Docker container updates are disabled by server configuration. Set PULSE_DISABLE_DOCKER_UPDATE_ACTIONS=false or disable in Settings to enable.", nil)
- return
- }
-
- // Queue the update command
- commandStatus, err := h.getMonitor(r.Context()).QueueDockerContainerUpdateCommand(agentID, req.ContainerID, req.ContainerName)
- if err != nil {
- writeErrorResponse(w, http.StatusBadRequest, "update_command_failed", err.Error(), nil)
- return
- }
-
- h.broadcastState(r.Context())
-
- if err := utils.WriteJSONResponse(w, map[string]any{
- "success": true,
- "commandId": commandStatus.ID,
- "agentId": agentID,
- "container": map[string]string{
- "id": req.ContainerID,
- "name": req.ContainerName,
- },
- "message": "Container update command queued",
- "note": "The update will be executed on the next agent report cycle",
- }); err != nil {
- log.Error().Err(err).Msg("Failed to serialize container update response")
- }
+ writeErrorResponse(w, http.StatusGone, "docker_update_retired", "Docker container updates are unavailable until typed lifecycle delivery and compensation are implemented.", nil)
}
// HandleUpdateAll triggers an update for all containers with updates available on a Docker / Podman host.
@@ -592,30 +549,7 @@ func (h *DockerAgentHandlers) HandleUpdateAll(w http.ResponseWriter, r *http.Req
return
}
- // Check if Docker update actions are disabled server-wide
- if h.config != nil && h.config.DisableDockerUpdateActions {
- writeErrorResponse(w, http.StatusForbidden, "docker_updates_disabled",
- "Docker container updates are disabled by server configuration. Set PULSE_DISABLE_DOCKER_UPDATE_ACTIONS=false or disable in Settings to enable.", nil)
- return
- }
-
- commandStatus, err := h.getMonitor(r.Context()).QueueDockerUpdateAllCommand(agentID)
- if err != nil {
- writeErrorResponse(w, http.StatusBadRequest, "update_all_command_failed", err.Error(), nil)
- return
- }
-
- h.broadcastState(r.Context())
-
- if err := utils.WriteJSONResponse(w, map[string]any{
- "success": true,
- "commandId": commandStatus.ID,
- "agentId": agentID,
- "message": "Update all containers command queued",
- "note": "The update will be executed on the next agent report cycle",
- }); err != nil {
- log.Error().Err(err).Msg("Failed to serialize update all response")
- }
+ writeErrorResponse(w, http.StatusGone, "docker_update_all_retired", "Bulk Docker updates are unavailable until typed lifecycle delivery and compensation are implemented.", nil)
}
// HandleCheckUpdates triggers an immediate update check for all containers on a Docker / Podman host.
diff --git a/internal/api/docker_agents_additional_test.go b/internal/api/docker_agents_additional_test.go
index 10747aebf1..280622ff6f 100644
--- a/internal/api/docker_agents_additional_test.go
+++ b/internal/api/docker_agents_additional_test.go
@@ -273,7 +273,7 @@ func TestDockerAgentHandlers_HandleSetCustomDisplayName(t *testing.T) {
}
}
-func TestDockerAgentHandlers_HandleContainerUpdate(t *testing.T) {
+func TestDockerAgentHandlers_HandleContainerUpdate_Retired(t *testing.T) {
handler, monitor := newDockerAgentHandlers(t, &config.Config{DataPath: t.TempDir()})
hostID := seedDockerHost(t, monitor)
@@ -287,8 +287,8 @@ func TestDockerAgentHandlers_HandleContainerUpdate(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleContainerUpdate(rec, req)
- if rec.Code != http.StatusOK {
- t.Fatalf("status = %d, want 200: %s", rec.Code, rec.Body.String())
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410: %s", rec.Code, rec.Body.String())
}
}
@@ -326,8 +326,8 @@ func TestDockerAgentHandlers_HandleContainerUpdate_Disabled(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleContainerUpdate(rec, req)
- if rec.Code != http.StatusForbidden {
- t.Fatalf("status = %d, want 403", rec.Code)
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410", rec.Code)
}
}
@@ -362,11 +362,11 @@ func TestDockerAgentHandlers_HandleContainerUpdate_BlockedBySecurityPosture(t *t
rec := httptest.NewRecorder()
handler.HandleContainerUpdate(rec, req)
- if rec.Code != http.StatusBadRequest {
- t.Fatalf("status = %d, want 400: %s", rec.Code, rec.Body.String())
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410: %s", rec.Code, rec.Body.String())
}
- if !strings.Contains(rec.Body.String(), "authorization plugins") {
- t.Fatalf("expected authorization plugin block reason, got %s", rec.Body.String())
+ if !strings.Contains(rec.Body.String(), "docker_update_retired") {
+ t.Fatalf("expected stable retirement response, got %s", rec.Body.String())
}
}
@@ -425,12 +425,12 @@ func TestDockerAgentHandlers_HandleUpdateAll(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleUpdateAll(rec, req)
- if rec.Code != http.StatusOK {
- t.Fatalf("status = %d, want 200: %s", rec.Code, rec.Body.String())
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410: %s", rec.Code, rec.Body.String())
}
- if !strings.Contains(rec.Body.String(), "Update all containers") {
- t.Fatalf("expected update-all message")
+ if !strings.Contains(rec.Body.String(), "docker_update_all_retired") {
+ t.Fatalf("expected stable update-all retirement response")
}
}
@@ -443,8 +443,8 @@ func TestDockerAgentHandlers_HandleUpdateAll_Disabled(t *testing.T) {
rec := httptest.NewRecorder()
handler.HandleUpdateAll(rec, req)
- if rec.Code != http.StatusForbidden {
- t.Fatalf("status = %d, want 403", rec.Code)
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410", rec.Code)
}
}
@@ -488,10 +488,10 @@ func TestDockerAgentHandlers_HandleUpdateAll_BlockedBySecurityPosture(t *testing
rec := httptest.NewRecorder()
handler.HandleUpdateAll(rec, req)
- if rec.Code != http.StatusBadRequest {
- t.Fatalf("status = %d, want 400: %s", rec.Code, rec.Body.String())
+ if rec.Code != http.StatusGone {
+ t.Fatalf("status = %d, want 410: %s", rec.Code, rec.Body.String())
}
- if !strings.Contains(rec.Body.String(), "authorization plugins") {
- t.Fatalf("expected authorization plugin block reason, got %s", rec.Body.String())
+ if !strings.Contains(rec.Body.String(), "docker_update_all_retired") {
+ t.Fatalf("expected stable retirement response, got %s", rec.Body.String())
}
}
diff --git a/internal/api/docker_agents_routes_more_test.go b/internal/api/docker_agents_routes_more_test.go
index c87ef9bb2d..b0bfeef1c0 100644
--- a/internal/api/docker_agents_routes_more_test.go
+++ b/internal/api/docker_agents_routes_more_test.go
@@ -74,8 +74,8 @@ func TestDockerAgentHandlers_HandleDockerHostActions_DeleteRoute(t *testing.T) {
req := httptest.NewRequest(http.MethodDelete, "/api/agents/docker/runtimes/"+hostID, nil)
rec := httptest.NewRecorder()
handler.HandleDockerHostActions(rec, req)
- if rec.Code != http.StatusOK {
- t.Fatalf("delete status = %d, want 200", rec.Code)
+ if rec.Code != http.StatusGone {
+ t.Fatalf("delete status = %d, want 410", rec.Code)
}
}
diff --git a/internal/api/router.go b/internal/api/router.go
index 6b235c2f3c..274bb038be 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -2744,6 +2744,13 @@ func (r *Router) wireAIChatDependenciesForService(ctx context.Context, service A
if ctx == nil {
ctx = context.Background()
}
+ if r.resourceHandlers != nil {
+ if plannerConsumer, ok := service.(interface {
+ SetTypedActionPlanner(chat.AssistantTypedActionPlanner)
+ }); ok {
+ plannerConsumer.SetTypedActionPlanner(assistantTypedActionPlanner{resources: r.resourceHandlers})
+ }
+ }
orgID := strings.TrimSpace(GetOrgID(ctx))
if orgID == "" {
orgID = "default"
diff --git a/internal/mutationregistry/audit.go b/internal/mutationregistry/audit.go
new file mode 100644
index 0000000000..1282e8896f
--- /dev/null
+++ b/internal/mutationregistry/audit.go
@@ -0,0 +1,52 @@
+package mutationregistry
+
+import (
+ "fmt"
+ "strings"
+)
+
+// RuntimeCandidate is emitted by executable surface audits from the real model
+// registry, HTTP router, job registration, or transport command catalog.
+type RuntimeCandidate struct {
+ Surface string
+ MutationID string
+ Transport bool
+ DurableAuthorityID string
+}
+
+// AuditRuntimeCandidates requires every mechanically discovered mutation
+// candidate to resolve to exactly one closed registry disposition. Transport
+// candidates additionally name the lifecycle authority that must exist before
+// delivery; retired transports must name no authority.
+func AuditRuntimeCandidates(candidates []RuntimeCandidate) error {
+ seen := make(map[string]string, len(candidates))
+ for _, candidate := range candidates {
+ surface := strings.TrimSpace(candidate.Surface)
+ if surface == "" || strings.TrimSpace(candidate.MutationID) == "" {
+ return fmt.Errorf("mutation candidate has empty surface or id: %+v", candidate)
+ }
+ if prior, duplicate := seen[surface]; duplicate {
+ return fmt.Errorf("mutation surface %q is classified more than once (%s, %s)", surface, prior, candidate.MutationID)
+ }
+ seen[surface] = candidate.MutationID
+ entry, ok := Lookup(candidate.MutationID)
+ if !ok {
+ return fmt.Errorf("mutation surface %q has unregistered id %q", surface, candidate.MutationID)
+ }
+ if !candidate.Transport {
+ continue
+ }
+ if entry.Disposition == DispositionLifecycle {
+ authority, ok := Lookup(candidate.DurableAuthorityID)
+ if !ok || authority.Disposition != DispositionLifecycle || authority.Origin == OriginTransport {
+ return fmt.Errorf("transport %q has no non-transport lifecycle authority", surface)
+ }
+ if entry.Delivery != DeliveryCommittedLifecycle {
+ return fmt.Errorf("transport %q can deliver before committed authority", surface)
+ }
+ } else if candidate.DurableAuthorityID != "" {
+ return fmt.Errorf("denied transport %q must not name executable authority", surface)
+ }
+ }
+ return nil
+}
diff --git a/internal/mutationregistry/caller_audit_test.go b/internal/mutationregistry/caller_audit_test.go
new file mode 100644
index 0000000000..0f9ce409f9
--- /dev/null
+++ b/internal/mutationregistry/caller_audit_test.go
@@ -0,0 +1,65 @@
+package mutationregistry
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestNoRawModelCommandOrRollbackAuthority(t *testing.T) {
+ root := repoRoot(t)
+ assertSourceOmits(t, filepath.Join(root, "internal/agentcapabilities/schema.go"),
+ "legacyAssistantRunCommandTool()",
+ "Execute a shell command. By default runs on the current target")
+ assertSourceOmits(t, filepath.Join(root, "internal/ai/tools/tools_control.go"),
+ "return e.executeRunCommand(ctx, args)")
+ assertSourceOmits(t, filepath.Join(root, "internal/ai/tools/tools_file.go"),
+ "return exec.executeFileEdit(ctx, args)")
+}
+
+func TestNoDirectDockerMutationQueueCaller(t *testing.T) {
+ root := repoRoot(t)
+ for _, path := range []string{
+ "internal/api/docker_agents.go",
+ "internal/ai/tools/adapters.go",
+ } {
+ assertSourceOmits(t, filepath.Join(root, path),
+ ".QueueDockerContainerUpdateCommand(",
+ ".QueueDockerUpdateAllCommand(")
+ }
+}
+
+func TestWebSocketTransportCannotOriginateAuthority(t *testing.T) {
+ for _, entry := range Entries() {
+ if entry.Origin != OriginTransport {
+ continue
+ }
+ if entry.Disposition == DispositionLifecycle && entry.Delivery != DeliveryCommittedLifecycle {
+ t.Errorf("%s: transport may run only after committed lifecycle authority", entry.ID)
+ }
+ }
+}
+
+func repoRoot(t *testing.T) string {
+ t.Helper()
+ root, err := filepath.Abs(filepath.Join("..", ".."))
+ if err != nil {
+ t.Fatal(err)
+ }
+ return root
+}
+
+func assertSourceOmits(t *testing.T, path string, forbidden ...string) {
+ t.Helper()
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ source := string(data)
+ for _, text := range forbidden {
+ if strings.Contains(source, text) {
+ t.Errorf("%s still contains retired authority %q", path, text)
+ }
+ }
+}
diff --git a/internal/mutationregistry/cmd/generate/main.go b/internal/mutationregistry/cmd/generate/main.go
new file mode 100644
index 0000000000..7dcca4d2bf
--- /dev/null
+++ b/internal/mutationregistry/cmd/generate/main.go
@@ -0,0 +1,50 @@
+package main
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "go/format"
+ "os"
+ "sort"
+)
+
+type entry struct {
+ ID string `json:"id"`
+ Origin string `json:"origin"`
+ ResourceClass string `json:"resource_class"`
+ ResourceKind string `json:"resource_kind"`
+ Capability string `json:"capability"`
+ Entrypoint string `json:"entrypoint"`
+ Disposition string `json:"disposition"`
+ LifecycleExecutor string `json:"lifecycle_executor"`
+ Approval string `json:"approval_floor"`
+ Delivery string `json:"delivery"`
+ Verification string `json:"verification"`
+ Rollback string `json:"rollback"`
+ ResidualOwners []string `json:"residual_owners"`
+}
+
+func main() {
+ raw, err := os.ReadFile("manifest.json")
+ must(err)
+ var entries []entry
+ must(json.Unmarshal(raw, &entries))
+ sort.Slice(entries, func(i, j int) bool { return entries[i].ID < entries[j].ID })
+ var out bytes.Buffer
+ out.WriteString("// Generated code; DO NOT EDIT.\n\npackage mutationregistry\n\n")
+ out.WriteString("var generatedEntries = []Entry{\n")
+ for _, e := range entries {
+ fmt.Fprintf(&out, "\t{ID:%q, Origin:Origin(%q), ResourceClass:ResourceClass(%q), ResourceKind:%q, Capability:%q, Entrypoint:%q, Disposition:Disposition(%q), LifecycleExecutor:%q, Approval:ApprovalFloor(%q), Delivery:DeliveryClass(%q), Verification:VerificationClass(%q), Rollback:RollbackClass(%q), ResidualOwners:%#v},\n", e.ID, e.Origin, e.ResourceClass, e.ResourceKind, e.Capability, e.Entrypoint, e.Disposition, e.LifecycleExecutor, e.Approval, e.Delivery, e.Verification, e.Rollback, e.ResidualOwners)
+ }
+ out.WriteString("}\n\nvar generatedByID = func() map[string]Entry {\n\tout := make(map[string]Entry, len(generatedEntries))\n\tfor _, entry := range generatedEntries { out[entry.ID] = entry }\n\treturn out\n}()\n")
+ formatted, err := format.Source(out.Bytes())
+ must(err)
+ must(os.WriteFile("registry_generated.go", formatted, 0o644))
+}
+
+func must(err error) {
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/internal/mutationregistry/generate.go b/internal/mutationregistry/generate.go
new file mode 100644
index 0000000000..6c3a2bdd69
--- /dev/null
+++ b/internal/mutationregistry/generate.go
@@ -0,0 +1,3 @@
+package mutationregistry
+
+//go:generate go run ./cmd/generate
diff --git a/internal/mutationregistry/manifest.json b/internal/mutationregistry/manifest.json
new file mode 100644
index 0000000000..6b437c3062
--- /dev/null
+++ b/internal/mutationregistry/manifest.json
@@ -0,0 +1,50 @@
+[
+ {"id":"admin.agent.deployment","origin":"api","resource_class":"pulse_administration","resource_kind":"agent-enrollment","capability":"deploy_agent","entrypoint":"agentexec deploy_install/deploy_cancel","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"admin.inventory.docker-runtime","origin":"api","resource_class":"pulse_administration","resource_kind":"docker-runtime-record","capability":"manage_inventory","entrypoint":"/api/agents/docker/runtimes/* metadata and enrollment","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"admin.inventory.kubernetes-cluster","origin":"api","resource_class":"pulse_administration","resource_kind":"kubernetes-cluster-record","capability":"manage_inventory","entrypoint":"/api/agents/kubernetes/clusters/* metadata and enrollment","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"admin.patrol.control-settings","origin":"api","resource_class":"pulse_administration","resource_kind":"patrol-config","capability":"set_patrol_control","entrypoint":"PUT /api/ai/patrol/autonomy","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"admin.pulse.self-update","origin":"api","resource_class":"pulse_administration","resource_kind":"pulse-server","capability":"self_update","entrypoint":"POST /api/updates/apply and /api/updates/rollback","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+
+ {"id":"action.api.decision","origin":"api","resource_class":"customer_infrastructure","resource_kind":"unified-resource","capability":"decide_action","entrypoint":"POST /api/actions/{id}/decision","disposition":"lifecycle","lifecycle_executor":"internal/actionlifecycle.Service.Decide","approval_floor":"admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"action.api.execute","origin":"api","resource_class":"customer_infrastructure","resource_kind":"unified-resource","capability":"execute_action","entrypoint":"POST /api/actions/{id}/execute","disposition":"lifecycle","lifecycle_executor":"internal/actionlifecycle.Service.Execute","approval_floor":"admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"action.api.plan","origin":"api","resource_class":"customer_infrastructure","resource_kind":"unified-resource","capability":"plan_action","entrypoint":"POST /api/actions/plan","disposition":"lifecycle","lifecycle_executor":"internal/actionlifecycle.Service.PlanWithOptions","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+
+ {"id":"assistant.docker.control","origin":"model","resource_class":"customer_infrastructure","resource_kind":"app-container","capability":"start_stop_restart","entrypoint":"pulse_docker action=control","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_05_typed_lifecycle_migration"]},
+ {"id":"assistant.docker.update","origin":"model","resource_class":"customer_infrastructure","resource_kind":"app-container","capability":"update_container","entrypoint":"pulse_docker action=update","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"assistant.file.append","origin":"model","resource_class":"customer_infrastructure","resource_kind":"remote-file","capability":"append_file","entrypoint":"pulse_file_edit action=append","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_no_replacement"]},
+ {"id":"assistant.file.write","origin":"model","resource_class":"customer_infrastructure","resource_kind":"remote-file","capability":"write_file","entrypoint":"pulse_file_edit action=write","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_no_replacement"]},
+ {"id":"assistant.guest.control","origin":"model","resource_class":"customer_infrastructure","resource_kind":"vm_or_system-container","capability":"start_stop_shutdown_restart","entrypoint":"pulse_control type=guest","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["use_assistant_resource_action"]},
+ {"id":"assistant.kubernetes.delete-pod","origin":"model","resource_class":"customer_infrastructure","resource_kind":"kubernetes-pod","capability":"delete_pod","entrypoint":"pulse_kubernetes type=delete_pod","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"assistant.kubernetes.exec","origin":"model","resource_class":"customer_infrastructure","resource_kind":"kubernetes-pod","capability":"exec","entrypoint":"pulse_kubernetes type=exec","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_arbitrary_command_boundary"]},
+ {"id":"assistant.kubernetes.restart","origin":"model","resource_class":"customer_infrastructure","resource_kind":"kubernetes-deployment","capability":"rollout_restart","entrypoint":"pulse_kubernetes type=restart","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"assistant.kubernetes.scale","origin":"model","resource_class":"customer_infrastructure","resource_kind":"kubernetes-deployment","capability":"scale","entrypoint":"pulse_kubernetes type=scale","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"assistant.raw-command","origin":"model","resource_class":"customer_infrastructure","resource_kind":"agent-target","capability":"raw_command","entrypoint":"pulse_control type=command","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_arbitrary_command_boundary"]},
+ {"id":"assistant.resource-action","origin":"model","resource_class":"customer_infrastructure","resource_kind":"unified-resource","capability":"advertised_resource_action","entrypoint":"pulse_control type=resource","disposition":"lifecycle","lifecycle_executor":"internal/actionlifecycle.Service.PlanWithOptions","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"assistant.truenas.app-control","origin":"model","resource_class":"customer_infrastructure","resource_kind":"truenas-app","capability":"start_stop_restart","entrypoint":"pulse_control type=resource adapter=truenas","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+
+ {"id":"docker.api.runtime-stop","origin":"api","resource_class":"customer_infrastructure","resource_kind":"docker-runtime","capability":"stop_agent","entrypoint":"DELETE /api/agents/docker/runtimes/*","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"docker.api.update-all","origin":"api","resource_class":"customer_infrastructure","resource_kind":"docker-host","capability":"update_all_containers","entrypoint":"POST /api/agents/docker/runtimes/*/update-all","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"docker.api.update-container","origin":"api","resource_class":"customer_infrastructure","resource_kind":"app-container","capability":"update_container","entrypoint":"POST /api/agents/docker/containers/update","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+
+ {"id":"legacy.api.run-command","origin":"legacy","resource_class":"customer_infrastructure","resource_kind":"agent-target","capability":"raw_command","entrypoint":"POST /api/ai/run-command","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_compatibility_response_only"]},
+ {"id":"legacy.enterprise.remediation-approve","origin":"legacy","resource_class":"customer_infrastructure","resource_kind":"remediation-plan","capability":"approve_raw_steps","entrypoint":"enterprise remediation approve endpoint","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["read_only_historical_import"]},
+ {"id":"legacy.enterprise.remediation-execute","origin":"legacy","resource_class":"customer_infrastructure","resource_kind":"remediation-plan","capability":"execute_raw_steps","entrypoint":"enterprise remediation execute endpoint","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["read_only_historical_import"]},
+ {"id":"legacy.enterprise.remediation-rollback","origin":"legacy","resource_class":"customer_infrastructure","resource_kind":"remediation-plan","capability":"execute_raw_rollback","entrypoint":"enterprise remediation rollback endpoint","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["read_only_historical_import"]},
+ {"id":"legacy.model.run-command","origin":"legacy","resource_class":"customer_infrastructure","resource_kind":"agent-target","capability":"raw_command","entrypoint":"run_command provider alias","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["retired_compatibility_response_only"]},
+
+ {"id":"patrol.typed-action","origin":"job","resource_class":"customer_infrastructure","resource_kind":"unified-resource","capability":"advertised_resource_action","entrypoint":"patrol_propose_action -> OrchestratorActionBroker","disposition":"lifecycle","lifecycle_executor":"internal/actionlifecycle.Service","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"resource.docker.container-lifecycle","origin":"api","resource_class":"customer_infrastructure","resource_kind":"app-container","capability":"start_stop_restart","entrypoint":"docker.container.lifecycle","disposition":"lifecycle","lifecycle_executor":"dockerContainerActionExecutor","approval_floor":"admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"resource.host.package-cache-cleanup","origin":"api","resource_class":"customer_infrastructure","resource_kind":"agent","capability":"clean_package_cache","entrypoint":"host.storage_cleanup","disposition":"lifecycle","lifecycle_executor":"hostStorageCleanupActionExecutor","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"unsupported"},
+ {"id":"resource.host.package-update","origin":"api","resource_class":"customer_infrastructure","resource_kind":"agent","capability":"install_os_updates","entrypoint":"host.package_updates","disposition":"lifecycle","lifecycle_executor":"hostUpdateActionExecutor","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"resource.proxmox.guest-lifecycle","origin":"api","resource_class":"customer_infrastructure","resource_kind":"vm_or_system-container","capability":"start_shutdown_reboot_stop","entrypoint":"proxmox.vm.lifecycle/proxmox.ct.lifecycle","disposition":"lifecycle","lifecycle_executor":"proxmoxGuestActionExecutor","approval_floor":"admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+
+ {"id":"transport.agent.host-package-cache-cleanup","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"agent","capability":"clean_package_cache","entrypoint":"agentexec host_storage_cleanup","disposition":"lifecycle","lifecycle_executor":"hostStorageCleanupActionExecutor","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"unsupported"},
+ {"id":"transport.agent.host-package-update","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"agent","capability":"install_os_updates","entrypoint":"agentexec host_update","disposition":"lifecycle","lifecycle_executor":"hostUpdateActionExecutor","approval_floor":"policy_or_admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"transport.agent.raw-command","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"agent-target","capability":"executor_owned_command","entrypoint":"agentexec execute_command","disposition":"lifecycle","lifecycle_executor":"dockerContainerActionExecutor/proxmoxGuestActionExecutor","approval_floor":"admin","delivery":"committed_lifecycle_before_transport","verification":"required","rollback":"task_10_truth_and_compensation","residual_owners":["task_10_truth_and_compensation"]},
+ {"id":"transport.agent.deploy-cancel","origin":"transport","resource_class":"pulse_administration","resource_kind":"agent-enrollment","capability":"deploy_agent","entrypoint":"agentexec deploy_cancel","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"transport.agent.deploy-install","origin":"transport","resource_class":"pulse_administration","resource_kind":"agent-enrollment","capability":"deploy_agent","entrypoint":"agentexec deploy_install","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"transport.agent.deploy-preflight","origin":"transport","resource_class":"pulse_administration","resource_kind":"agent-enrollment","capability":"deploy_agent","entrypoint":"agentexec deploy_preflight","disposition":"administrative_exception","approval_floor":"admin","delivery":"administrative_transaction","verification":"administrative","rollback":"unsupported","residual_owners":["task_12_final_governance"]},
+ {"id":"transport.docker.runtime-stop","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"docker-runtime","capability":"stop_agent","entrypoint":"docker command stop","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"transport.docker.update-all","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"docker-host","capability":"update_all_containers","entrypoint":"docker command update_all","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]},
+ {"id":"transport.docker.update-container","origin":"transport","resource_class":"customer_infrastructure","resource_kind":"app-container","capability":"update_container","entrypoint":"docker command update_container","disposition":"retired_denied","approval_floor":"admin","delivery":"denied_before_transport","verification":"denied","rollback":"denied","residual_owners":["task_07_durable_delivery","task_10_truth_and_compensation"]}
+]
diff --git a/internal/mutationregistry/registry.go b/internal/mutationregistry/registry.go
new file mode 100644
index 0000000000..e65c8fddbd
--- /dev/null
+++ b/internal/mutationregistry/registry.go
@@ -0,0 +1,185 @@
+// Package mutationregistry owns the closed product-wide classification of
+// runtime-reachable infrastructure mutations. Runtime surfaces may execute a
+// mutation only when this registry classifies it as canonical lifecycle work;
+// retired entries must fail before transport, and administrative exceptions
+// must not target customer infrastructure.
+package mutationregistry
+
+import (
+ "errors"
+ "fmt"
+ "sort"
+ "strings"
+)
+
+type Disposition string
+type Origin string
+type ResourceClass string
+type ApprovalFloor string
+type DeliveryClass string
+type VerificationClass string
+type RollbackClass string
+
+const (
+ DispositionLifecycle Disposition = "lifecycle"
+ DispositionAdministrativeException Disposition = "administrative_exception"
+ DispositionRetiredDenied Disposition = "retired_denied"
+
+ OriginAPI Origin = "api"
+ OriginJob Origin = "job"
+ OriginLegacy Origin = "legacy"
+ OriginModel Origin = "model"
+ OriginTransport Origin = "transport"
+
+ ResourceCustomerInfrastructure ResourceClass = "customer_infrastructure"
+ ResourcePulseAdministration ResourceClass = "pulse_administration"
+
+ ApprovalNone ApprovalFloor = "none"
+ ApprovalAdmin ApprovalFloor = "admin"
+ ApprovalPolicy ApprovalFloor = "policy_or_admin"
+
+ DeliveryCommittedLifecycle DeliveryClass = "committed_lifecycle_before_transport"
+ DeliveryAdministrative DeliveryClass = "administrative_transaction"
+ DeliveryDeniedBeforeTransport DeliveryClass = "denied_before_transport"
+
+ VerificationRequired VerificationClass = "required"
+ VerificationAdministrative VerificationClass = "administrative"
+ VerificationDenied VerificationClass = "denied"
+
+ RollbackUnsupported RollbackClass = "unsupported"
+ RollbackTask10 RollbackClass = "task_10_truth_and_compensation"
+ RollbackDenied RollbackClass = "denied"
+)
+
+// Entry is generated from manifest.json. Capability is the canonical resource
+// capability where one exists; Entrypoint names the live or compatibility
+// surface whose disposition is enforced.
+type Entry struct {
+ ID string `json:"id"`
+ Origin Origin `json:"origin"`
+ ResourceClass ResourceClass `json:"resource_class"`
+ ResourceKind string `json:"resource_kind"`
+ Capability string `json:"capability"`
+ Entrypoint string `json:"entrypoint"`
+ Disposition Disposition `json:"disposition"`
+ LifecycleExecutor string `json:"lifecycle_executor,omitempty"`
+ Approval ApprovalFloor `json:"approval_floor"`
+ Delivery DeliveryClass `json:"delivery"`
+ Verification VerificationClass `json:"verification"`
+ Rollback RollbackClass `json:"rollback"`
+ ResidualOwners []string `json:"residual_owners,omitempty"`
+}
+
+func Entries() []Entry {
+ out := make([]Entry, len(generatedEntries))
+ for i := range generatedEntries {
+ out[i] = cloneEntry(generatedEntries[i])
+ }
+ return out
+}
+
+func Lookup(id string) (Entry, bool) {
+ entry, ok := generatedByID[strings.TrimSpace(id)]
+ return cloneEntry(entry), ok
+}
+
+// LookupModelInvocation maps every model-reachable infrastructure mutation to
+// its closed registry identity. The mapping is intentionally string-based so
+// the registry remains below provider/tool packages and cannot acquire a
+// dependency cycle. Unknown invocations are not treated as safe by callers;
+// their existing fail-closed classifier still applies.
+func LookupModelInvocation(toolName string, args map[string]interface{}) (Entry, bool) {
+ toolName = strings.TrimSpace(toolName)
+ stringArg := func(key string) string {
+ value, _ := args[key].(string)
+ return strings.ToLower(strings.TrimSpace(value))
+ }
+ id := ""
+ switch toolName {
+ case "pulse_control":
+ switch stringArg("type") {
+ case "resource":
+ id = "assistant.resource-action"
+ case "guest":
+ id = "assistant.guest.control"
+ case "command":
+ id = "assistant.raw-command"
+ }
+ case "pulse_docker":
+ switch stringArg("action") {
+ case "control":
+ id = "assistant.docker.control"
+ case "update":
+ id = "assistant.docker.update"
+ }
+ case "pulse_kubernetes":
+ switch stringArg("type") {
+ case "scale", "restart", "exec":
+ id = "assistant.kubernetes." + stringArg("type")
+ case "delete_pod":
+ id = "assistant.kubernetes.delete-pod"
+ }
+ case "pulse_file_edit":
+ switch stringArg("action") {
+ case "append", "write":
+ id = "assistant.file." + stringArg("action")
+ }
+ case "run_command", "pulse_run_command":
+ id = "legacy.model.run-command"
+ }
+ if id == "" {
+ return Entry{}, false
+ }
+ return Lookup(id)
+}
+
+func cloneEntry(entry Entry) Entry {
+ entry.ResidualOwners = append([]string(nil), entry.ResidualOwners...)
+ return entry
+}
+
+func Validate() error {
+ if len(generatedEntries) == 0 {
+ return errors.New("mutation registry is empty")
+ }
+ seen := make(map[string]struct{}, len(generatedEntries))
+ for i, entry := range generatedEntries {
+ if strings.TrimSpace(entry.ID) == "" || strings.TrimSpace(entry.Entrypoint) == "" {
+ return fmt.Errorf("entry %d has an empty id or entrypoint", i)
+ }
+ if _, duplicate := seen[entry.ID]; duplicate {
+ return fmt.Errorf("duplicate mutation id %q", entry.ID)
+ }
+ seen[entry.ID] = struct{}{}
+ switch entry.Disposition {
+ case DispositionLifecycle:
+ if entry.ResourceClass != ResourceCustomerInfrastructure || entry.LifecycleExecutor == "" || entry.Delivery != DeliveryCommittedLifecycle {
+ return fmt.Errorf("lifecycle mutation %q has an incomplete canonical binding", entry.ID)
+ }
+ case DispositionAdministrativeException:
+ if entry.ResourceClass != ResourcePulseAdministration || entry.LifecycleExecutor != "" || entry.Delivery != DeliveryAdministrative {
+ return fmt.Errorf("administrative exception %q crosses the infrastructure boundary", entry.ID)
+ }
+ case DispositionRetiredDenied:
+ if entry.LifecycleExecutor != "" || entry.Delivery != DeliveryDeniedBeforeTransport || entry.Verification != VerificationDenied || entry.Rollback != RollbackDenied {
+ return fmt.Errorf("retired mutation %q is not fully denied", entry.ID)
+ }
+ default:
+ return fmt.Errorf("mutation %q has unknown disposition %q", entry.ID, entry.Disposition)
+ }
+ }
+ ids := make([]string, 0, len(seen))
+ for id := range seen {
+ ids = append(ids, id)
+ }
+ if !sort.StringsAreSorted(ids) {
+ sort.Strings(ids)
+ }
+ return nil
+}
+
+func init() {
+ if err := Validate(); err != nil {
+ panic(err)
+ }
+}
diff --git a/internal/mutationregistry/registry_audit_test.go b/internal/mutationregistry/registry_audit_test.go
new file mode 100644
index 0000000000..e6d4dc1366
--- /dev/null
+++ b/internal/mutationregistry/registry_audit_test.go
@@ -0,0 +1,91 @@
+package mutationregistry
+
+import (
+ "testing"
+)
+
+func TestEveryRegisteredMutationHasDisposition(t *testing.T) {
+ if err := Validate(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestMigratingInfrastructureMutationsUseActionLifecycle(t *testing.T) {
+ for _, entry := range Entries() {
+ if entry.Disposition != DispositionLifecycle {
+ continue
+ }
+ if entry.LifecycleExecutor == "" {
+ t.Errorf("%s: lifecycle mutation has no executor", entry.ID)
+ }
+ if entry.Delivery != DeliveryCommittedLifecycle {
+ t.Errorf("%s: lifecycle mutation delivery=%q, want %q", entry.ID, entry.Delivery, DeliveryCommittedLifecycle)
+ }
+ }
+}
+
+func TestAdministrativeExceptionsCannotDispatchInfrastructureActions(t *testing.T) {
+ for _, entry := range Entries() {
+ if entry.Disposition != DispositionAdministrativeException {
+ continue
+ }
+ if entry.LifecycleExecutor != "" {
+ t.Errorf("%s: administrative exception must not bind a lifecycle executor", entry.ID)
+ }
+ if entry.ResourceClass == ResourceCustomerInfrastructure {
+ t.Errorf("%s: customer-infrastructure mutation cannot be an administrative exception", entry.ID)
+ }
+ }
+}
+
+func TestRetiredMutationsFailClosed(t *testing.T) {
+ for _, entry := range Entries() {
+ if entry.Disposition != DispositionRetiredDenied {
+ continue
+ }
+ if entry.Delivery != DeliveryDeniedBeforeTransport {
+ t.Errorf("%s: retired mutation delivery=%q, want denied before transport", entry.ID, entry.Delivery)
+ }
+ if entry.LifecycleExecutor != "" {
+ t.Errorf("%s: retired mutation still binds executor %q", entry.ID, entry.LifecycleExecutor)
+ }
+ }
+}
+
+func TestRegistryLookupReturnsClone(t *testing.T) {
+ entry, ok := Lookup("assistant.raw-command")
+ if !ok {
+ t.Fatal("assistant.raw-command missing")
+ }
+ entry.ResidualOwners[0] = "mutated"
+ again, _ := Lookup("assistant.raw-command")
+ if again.ResidualOwners[0] == "mutated" {
+ t.Fatal("registry exposed mutable generated state")
+ }
+}
+
+func TestRuntimeCandidateAuditNegativeFixtures(t *testing.T) {
+ t.Run("unknown candidate", func(t *testing.T) {
+ err := AuditRuntimeCandidates([]RuntimeCandidate{{Surface: "fixture:new-route", MutationID: "fixture.unregistered"}})
+ if err == nil {
+ t.Fatal("unregistered mutation candidate passed")
+ }
+ })
+ t.Run("alias shadow", func(t *testing.T) {
+ err := AuditRuntimeCandidates([]RuntimeCandidate{
+ {Surface: "fixture:alias", MutationID: "assistant.raw-command"},
+ {Surface: "fixture:alias", MutationID: "legacy.model.run-command"},
+ })
+ if err == nil {
+ t.Fatal("multiply classified alias passed")
+ }
+ })
+ t.Run("transport before authority", func(t *testing.T) {
+ err := AuditRuntimeCandidates([]RuntimeCandidate{{
+ Surface: "fixture:transport", MutationID: "transport.agent.host-package-update", Transport: true,
+ }})
+ if err == nil {
+ t.Fatal("transport without durable authority passed")
+ }
+ })
+}
diff --git a/internal/mutationregistry/registry_generated.go b/internal/mutationregistry/registry_generated.go
new file mode 100644
index 0000000000..8c1629ad4b
--- /dev/null
+++ b/internal/mutationregistry/registry_generated.go
@@ -0,0 +1,56 @@
+// Generated code; DO NOT EDIT.
+
+package mutationregistry
+
+var generatedEntries = []Entry{
+ {ID: "action.api.decision", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "unified-resource", Capability: "decide_action", Entrypoint: "POST /api/actions/{id}/decision", Disposition: Disposition("lifecycle"), LifecycleExecutor: "internal/actionlifecycle.Service.Decide", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "action.api.execute", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "unified-resource", Capability: "execute_action", Entrypoint: "POST /api/actions/{id}/execute", Disposition: Disposition("lifecycle"), LifecycleExecutor: "internal/actionlifecycle.Service.Execute", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "action.api.plan", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "unified-resource", Capability: "plan_action", Entrypoint: "POST /api/actions/plan", Disposition: Disposition("lifecycle"), LifecycleExecutor: "internal/actionlifecycle.Service.PlanWithOptions", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "admin.agent.deployment", Origin: Origin("api"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "agent-enrollment", Capability: "deploy_agent", Entrypoint: "agentexec deploy_install/deploy_cancel", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "admin.inventory.docker-runtime", Origin: Origin("api"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "docker-runtime-record", Capability: "manage_inventory", Entrypoint: "/api/agents/docker/runtimes/* metadata and enrollment", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "admin.inventory.kubernetes-cluster", Origin: Origin("api"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "kubernetes-cluster-record", Capability: "manage_inventory", Entrypoint: "/api/agents/kubernetes/clusters/* metadata and enrollment", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "admin.patrol.control-settings", Origin: Origin("api"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "patrol-config", Capability: "set_patrol_control", Entrypoint: "PUT /api/ai/patrol/autonomy", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "admin.pulse.self-update", Origin: Origin("api"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "pulse-server", Capability: "self_update", Entrypoint: "POST /api/updates/apply and /api/updates/rollback", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "assistant.docker.control", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "app-container", Capability: "start_stop_restart", Entrypoint: "pulse_docker action=control", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_05_typed_lifecycle_migration"}},
+ {ID: "assistant.docker.update", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "app-container", Capability: "update_container", Entrypoint: "pulse_docker action=update", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "assistant.file.append", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "remote-file", Capability: "append_file", Entrypoint: "pulse_file_edit action=append", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_no_replacement"}},
+ {ID: "assistant.file.write", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "remote-file", Capability: "write_file", Entrypoint: "pulse_file_edit action=write", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_no_replacement"}},
+ {ID: "assistant.guest.control", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "vm_or_system-container", Capability: "start_stop_shutdown_restart", Entrypoint: "pulse_control type=guest", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"use_assistant_resource_action"}},
+ {ID: "assistant.kubernetes.delete-pod", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "kubernetes-pod", Capability: "delete_pod", Entrypoint: "pulse_kubernetes type=delete_pod", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "assistant.kubernetes.exec", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "kubernetes-pod", Capability: "exec", Entrypoint: "pulse_kubernetes type=exec", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_arbitrary_command_boundary"}},
+ {ID: "assistant.kubernetes.restart", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "kubernetes-deployment", Capability: "rollout_restart", Entrypoint: "pulse_kubernetes type=restart", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "assistant.kubernetes.scale", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "kubernetes-deployment", Capability: "scale", Entrypoint: "pulse_kubernetes type=scale", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "assistant.raw-command", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent-target", Capability: "raw_command", Entrypoint: "pulse_control type=command", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_arbitrary_command_boundary"}},
+ {ID: "assistant.resource-action", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "unified-resource", Capability: "advertised_resource_action", Entrypoint: "pulse_control type=resource", Disposition: Disposition("lifecycle"), LifecycleExecutor: "internal/actionlifecycle.Service.PlanWithOptions", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "assistant.truenas.app-control", Origin: Origin("model"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "truenas-app", Capability: "start_stop_restart", Entrypoint: "pulse_control type=resource adapter=truenas", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "docker.api.runtime-stop", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "docker-runtime", Capability: "stop_agent", Entrypoint: "DELETE /api/agents/docker/runtimes/*", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "docker.api.update-all", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "docker-host", Capability: "update_all_containers", Entrypoint: "POST /api/agents/docker/runtimes/*/update-all", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "docker.api.update-container", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "app-container", Capability: "update_container", Entrypoint: "POST /api/agents/docker/containers/update", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "legacy.api.run-command", Origin: Origin("legacy"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent-target", Capability: "raw_command", Entrypoint: "POST /api/ai/run-command", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_compatibility_response_only"}},
+ {ID: "legacy.enterprise.remediation-approve", Origin: Origin("legacy"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "remediation-plan", Capability: "approve_raw_steps", Entrypoint: "enterprise remediation approve endpoint", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"read_only_historical_import"}},
+ {ID: "legacy.enterprise.remediation-execute", Origin: Origin("legacy"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "remediation-plan", Capability: "execute_raw_steps", Entrypoint: "enterprise remediation execute endpoint", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"read_only_historical_import"}},
+ {ID: "legacy.enterprise.remediation-rollback", Origin: Origin("legacy"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "remediation-plan", Capability: "execute_raw_rollback", Entrypoint: "enterprise remediation rollback endpoint", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"read_only_historical_import"}},
+ {ID: "legacy.model.run-command", Origin: Origin("legacy"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent-target", Capability: "raw_command", Entrypoint: "run_command provider alias", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"retired_compatibility_response_only"}},
+ {ID: "patrol.typed-action", Origin: Origin("job"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "unified-resource", Capability: "advertised_resource_action", Entrypoint: "patrol_propose_action -> OrchestratorActionBroker", Disposition: Disposition("lifecycle"), LifecycleExecutor: "internal/actionlifecycle.Service", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "resource.docker.container-lifecycle", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "app-container", Capability: "start_stop_restart", Entrypoint: "docker.container.lifecycle", Disposition: Disposition("lifecycle"), LifecycleExecutor: "dockerContainerActionExecutor", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "resource.host.package-cache-cleanup", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent", Capability: "clean_package_cache", Entrypoint: "host.storage_cleanup", Disposition: Disposition("lifecycle"), LifecycleExecutor: "hostStorageCleanupActionExecutor", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string(nil)},
+ {ID: "resource.host.package-update", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent", Capability: "install_os_updates", Entrypoint: "host.package_updates", Disposition: Disposition("lifecycle"), LifecycleExecutor: "hostUpdateActionExecutor", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "resource.proxmox.guest-lifecycle", Origin: Origin("api"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "vm_or_system-container", Capability: "start_shutdown_reboot_stop", Entrypoint: "proxmox.vm.lifecycle/proxmox.ct.lifecycle", Disposition: Disposition("lifecycle"), LifecycleExecutor: "proxmoxGuestActionExecutor", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "transport.agent.deploy-cancel", Origin: Origin("transport"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "agent-enrollment", Capability: "deploy_agent", Entrypoint: "agentexec deploy_cancel", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "transport.agent.deploy-install", Origin: Origin("transport"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "agent-enrollment", Capability: "deploy_agent", Entrypoint: "agentexec deploy_install", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "transport.agent.deploy-preflight", Origin: Origin("transport"), ResourceClass: ResourceClass("pulse_administration"), ResourceKind: "agent-enrollment", Capability: "deploy_agent", Entrypoint: "agentexec deploy_preflight", Disposition: Disposition("administrative_exception"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("administrative_transaction"), Verification: VerificationClass("administrative"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string{"task_12_final_governance"}},
+ {ID: "transport.agent.host-package-cache-cleanup", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent", Capability: "clean_package_cache", Entrypoint: "agentexec host_storage_cleanup", Disposition: Disposition("lifecycle"), LifecycleExecutor: "hostStorageCleanupActionExecutor", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("unsupported"), ResidualOwners: []string(nil)},
+ {ID: "transport.agent.host-package-update", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent", Capability: "install_os_updates", Entrypoint: "agentexec host_update", Disposition: Disposition("lifecycle"), LifecycleExecutor: "hostUpdateActionExecutor", Approval: ApprovalFloor("policy_or_admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "transport.agent.raw-command", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "agent-target", Capability: "executor_owned_command", Entrypoint: "agentexec execute_command", Disposition: Disposition("lifecycle"), LifecycleExecutor: "dockerContainerActionExecutor/proxmoxGuestActionExecutor", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("committed_lifecycle_before_transport"), Verification: VerificationClass("required"), Rollback: RollbackClass("task_10_truth_and_compensation"), ResidualOwners: []string{"task_10_truth_and_compensation"}},
+ {ID: "transport.docker.runtime-stop", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "docker-runtime", Capability: "stop_agent", Entrypoint: "docker command stop", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "transport.docker.update-all", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "docker-host", Capability: "update_all_containers", Entrypoint: "docker command update_all", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+ {ID: "transport.docker.update-container", Origin: Origin("transport"), ResourceClass: ResourceClass("customer_infrastructure"), ResourceKind: "app-container", Capability: "update_container", Entrypoint: "docker command update_container", Disposition: Disposition("retired_denied"), LifecycleExecutor: "", Approval: ApprovalFloor("admin"), Delivery: DeliveryClass("denied_before_transport"), Verification: VerificationClass("denied"), Rollback: RollbackClass("denied"), ResidualOwners: []string{"task_07_durable_delivery", "task_10_truth_and_compensation"}},
+}
+
+var generatedByID = func() map[string]Entry {
+ out := make(map[string]Entry, len(generatedEntries))
+ for _, entry := range generatedEntries {
+ out[entry.ID] = entry
+ }
+ return out
+}()
diff --git a/internal/mutationregistry/runtime_surface_audit_test.go b/internal/mutationregistry/runtime_surface_audit_test.go
new file mode 100644
index 0000000000..ce402e09ff
--- /dev/null
+++ b/internal/mutationregistry/runtime_surface_audit_test.go
@@ -0,0 +1,176 @@
+package mutationregistry
+
+import (
+ "os"
+ "path/filepath"
+ "regexp"
+ "sort"
+ "strings"
+ "testing"
+)
+
+// TestInfrastructureAPIRoutesResolveToRegistry scans the real router sources,
+// not a duplicate ID inventory. Its scope is deliberately limited to the
+// infrastructure mutation namespaces below; settings/metadata CRUD is outside
+// M1 and is not claimed as infrastructure enumeration.
+func TestInfrastructureAPIRoutesResolveToRegistry(t *testing.T) {
+ root := repoRoot(t)
+ files := []string{
+ "internal/api/router_routes_monitoring.go",
+ "internal/api/router_routes_registration.go",
+ "internal/api/router_routes_ai_relay.go",
+ }
+ catalog := map[string]string{
+ "/api/actions/plan": "action.api.plan",
+ "/api/actions/pending": "",
+ "/api/actions/{id}/decision": "action.api.decision",
+ "/api/actions/{id}/execute": "action.api.execute",
+ "/api/agents/docker/report": "",
+ "/api/agents/docker/commands/": "",
+ "/api/agents/docker/runtimes/": "docker.api.runtime-stop",
+ "/api/agents/docker/containers/update": "docker.api.update-container",
+ "/api/updates/check": "",
+ "/api/updates/apply": "admin.pulse.self-update",
+ "/api/updates/rollback": "admin.pulse.self-update",
+ "/api/updates/status": "",
+ "/api/updates/stream": "",
+ "/api/updates/plan": "",
+ "/api/updates/history": "",
+ "/api/updates/history/entry": "",
+ "/api/ai/run-command": "legacy.api.run-command",
+ "/api/ai/remediation/plans": "",
+ "/api/ai/remediation/plan": "",
+ "/api/ai/remediation/approve": "legacy.enterprise.remediation-approve",
+ "/api/ai/remediation/execute": "legacy.enterprise.remediation-execute",
+ "/api/ai/remediation/rollback": "legacy.enterprise.remediation-rollback",
+ }
+ routeRE := regexp.MustCompile(`"(?:GET |POST |PUT |DELETE )?(/api/[^"]+)"`)
+ found := map[string]bool{}
+ for _, relative := range files {
+ data, err := os.ReadFile(filepath.Join(root, relative))
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, match := range routeRE.FindAllStringSubmatch(string(data), -1) {
+ route := match[1]
+ if !auditedInfrastructurePrefix(route) {
+ continue
+ }
+ found[route] = true
+ id, classified := catalog[route]
+ if !classified {
+ t.Errorf("runtime infrastructure route %q is unclassified", route)
+ continue
+ }
+ if id != "" {
+ if err := AuditRuntimeCandidates([]RuntimeCandidate{{Surface: "http:" + route, MutationID: id}}); err != nil {
+ t.Error(err)
+ }
+ }
+ }
+ }
+ for route := range catalog {
+ if !found[route] {
+ t.Errorf("classified route %q is no longer registered", route)
+ }
+ }
+ // The shared Docker gateway contains a second mutation sub-route.
+ dockerSource, _ := os.ReadFile(filepath.Join(root, "internal/api/docker_agents.go"))
+ if !strings.Contains(string(dockerSource), `"/update-all"`) {
+ t.Fatal("Docker update-all handler candidate not found")
+ }
+ if err := AuditRuntimeCandidates([]RuntimeCandidate{{Surface: "http:/api/agents/docker/runtimes/#update-all", MutationID: "docker.api.update-all"}}); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func auditedInfrastructurePrefix(route string) bool {
+ for _, prefix := range []string{"/api/actions/", "/api/agents/docker/", "/api/updates/", "/api/ai/remediation/", "/api/ai/run-command"} {
+ if strings.HasPrefix(route, prefix) {
+ return true
+ }
+ }
+ return false
+}
+
+func TestTransportCommandCatalogsResolveToRegistry(t *testing.T) {
+ root := repoRoot(t)
+ docker := scanNamedStringConstants(t, filepath.Join(root, "internal/monitoring/docker_commands.go"), `DockerCommandType\w+`)
+ dockerCatalog := map[string]string{
+ "DockerCommandTypeStop": "transport.docker.runtime-stop",
+ "DockerCommandTypeUpdateContainer": "transport.docker.update-container",
+ "DockerCommandTypeUpdateAll": "transport.docker.update-all",
+ "DockerCommandTypeCheckUpdates": "",
+ }
+ auditConstantCatalog(t, docker, dockerCatalog, nil)
+
+ agent := scanNamedStringConstants(t, filepath.Join(root, "internal/agentexec/types.go"), `MsgType\w+`)
+ agentCatalog := map[string]string{
+ "MsgTypeAgentRegister": "", "MsgTypeAgentPing": "", "MsgTypeCommandResult": "",
+ "MsgTypeHostStorageCleanupResult": "", "MsgTypeHostUpdateResult": "", "MsgTypeRegistered": "", "MsgTypePong": "",
+ "MsgTypeExecuteCmd": "transport.agent.raw-command", "MsgTypeHostStorageCleanup": "transport.agent.host-package-cache-cleanup",
+ "MsgTypeReadFile": "", "MsgTypeHostUpdate": "transport.agent.host-package-update",
+ "MsgTypeDeployPreflight": "transport.agent.deploy-preflight", "MsgTypeDeployInstall": "transport.agent.deploy-install",
+ "MsgTypeDeployCancelJob": "transport.agent.deploy-cancel", "MsgTypeDeployProgress": "",
+ }
+ authority := map[string]string{
+ "MsgTypeExecuteCmd": "assistant.resource-action",
+ "MsgTypeHostStorageCleanup": "resource.host.package-cache-cleanup",
+ "MsgTypeHostUpdate": "resource.host.package-update",
+ }
+ auditConstantCatalog(t, agent, agentCatalog, authority)
+}
+
+func TestPatrolJobRegistrationResolvesToRegistry(t *testing.T) {
+ root := repoRoot(t)
+ router, _ := os.ReadFile(filepath.Join(root, "internal/api/router.go"))
+ broker, _ := os.ReadFile(filepath.Join(root, "internal/api/patrol_action_broker.go"))
+ if !strings.Contains(string(router), "SetActionBrokerFactory") || !strings.Contains(string(broker), "PlanWithOptions") {
+ t.Fatal("Patrol action job registration is no longer mechanically discoverable")
+ }
+ if err := AuditRuntimeCandidates([]RuntimeCandidate{{Surface: "job:patrol-action-broker", MutationID: "patrol.typed-action"}}); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func scanNamedStringConstants(t *testing.T, path, namePattern string) map[string]string {
+ t.Helper()
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ re := regexp.MustCompile(`(?m)^\s*(` + namePattern + `)(?:\s+\w+)?\s*=\s*"([^"]+)"`)
+ out := map[string]string{}
+ for _, match := range re.FindAllStringSubmatch(string(data), -1) {
+ out[match[1]] = match[2]
+ }
+ return out
+}
+
+func auditConstantCatalog(t *testing.T, actual, catalog, authority map[string]string) {
+ t.Helper()
+ for name, value := range actual {
+ id, ok := catalog[name]
+ if !ok {
+ t.Errorf("transport command %s=%q is unclassified", name, value)
+ continue
+ }
+ if id == "" {
+ continue
+ }
+ candidate := RuntimeCandidate{Surface: "transport:" + value, MutationID: id, Transport: true, DurableAuthorityID: authority[name]}
+ if err := AuditRuntimeCandidates([]RuntimeCandidate{candidate}); err != nil {
+ t.Error(err)
+ }
+ }
+ var stale []string
+ for name := range catalog {
+ if _, ok := actual[name]; !ok {
+ stale = append(stale, name)
+ }
+ }
+ sort.Strings(stale)
+ if len(stale) > 0 {
+ t.Errorf("classified transport constants no longer exist: %v", stale)
+ }
+}