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.

Fail closed on unknown remediation lock state for autonomous dispatches

rcourtmanf4c2fd0c3846
diff --git a/cmd/pulse-agent/runtime_health.go b/cmd/pulse-agent/runtime_health.go
index 8c7cf7c998..e71b36cb3c 100644
--- a/cmd/pulse-agent/runtime_health.go
+++ b/cmd/pulse-agent/runtime_health.go
@@ -59,21 +59,6 @@ func newRuntimeHealth(ready *atomic.Bool, enabled map[string]bool) *runtimeHealt
return r
}
-func (r *runtimeHealth) setEnabled(name string, enabled bool) {
- if r == nil {
- return
- }
- r.mu.Lock()
- defer r.mu.Unlock()
- state := moduleStateDisabled
- if enabled {
- state = moduleStateStarting
- }
- r.modules[name] = moduleHealth{Name: name, Enabled: enabled, State: state, UpdatedAt: r.now()}
- agentModuleEnabled.WithLabelValues(name).Set(boolGauge(enabled))
- r.reconcileReadyLocked()
-}
-
func (r *runtimeHealth) setState(name, state string, err error) {
if r == nil {
return
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 1006efb23c..3abb1421f8 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -4133,16 +4133,28 @@ new-finding path auto-dismisses with reason `expected_behavior`,
attributes the suppression on the lifecycle timeline
(`operator_state_cause: maintenance_window`, with
`maintenance_end_at` metadata), and persists the finding for audit
-history. The action broker (`executeCommandWithAudit` in
-`internal/ai/tools/action_audit.go`) consults the same
-`resource_operator_state` table on every dispatch and refuses with
+history. The action broker consults the same `resource_operator_state` table
+on every dispatch — both the agent-command path
+(`executeCommandWithAudit`) and the native provider path
+(`executeNativeActionWithAudit`) in
+`internal/ai/tools/action_audit.go` run the shared
+`checkRemediationLockForDispatch` gate — and refuses with
`unifiedresources.ErrResourceRemediationLocked` when the operator
has set `NeverAutoRemediate=true` on the target resource. Refusal
persists a Failed audit record whose `ErrorMessage` is prefixed
`resource_remediation_locked:` so the audit timeline shows every
refused dispatch, paralleling the `plan_drift:` shape from the drift
guard. Operator state outranks per-action approval — the broker
-refuses even when the approval ID resolves and the plan hash matches. The `IntentionallyOffline` branch is the indefinite
+refuses even when the approval ID resolves and the plan hash matches.
+When the lock state cannot be determined (no audit store wired, or
+the operator-state lookup errors), dispatches that do not carry an
+approved human decision fail CLOSED with
+`ErrRemediationLockStateUnknown` and a Failed audit record prefixed
+`remediation_lock_state_unknown:` — the broker must not assume an
+unreadable lock is unset while Patrol or Assistant run autonomously.
+Dispatches backed by an approved human decision keep the historical
+fail-open posture on unknown lock state (the operator explicitly
+signed off on the exact plan), with the degraded lookup logged. The `IntentionallyOffline` branch is the indefinite
counterpart — same auto-dismiss but with
`operator_state_cause: intentionally_offline` and no
`maintenance_end_at` field because the suppression has no scheduled
diff --git a/internal/actionplanner/planner.go b/internal/actionplanner/planner.go
index cef752b344..f638bf6702 100644
--- a/internal/actionplanner/planner.go
+++ b/internal/actionplanner/planner.go
@@ -553,15 +553,6 @@ func displayResourceName(resource unified.Resource) string {
return unified.CanonicalResourceID(resource.ID)
}
-type normalizedIdentity struct {
- MachineID string `json:"machineId,omitempty"`
- DMIUUID string `json:"dmiUuid,omitempty"`
- Hostnames []string `json:"hostnames,omitempty"`
- IPAddresses []string `json:"ipAddresses,omitempty"`
- MACAddresses []string `json:"macAddresses,omitempty"`
- ClusterName string `json:"clusterName,omitempty"`
-}
-
type normalizedCapabilityForResourceHash struct {
Name string `json:"name"`
Type unified.CapabilityType `json:"type"`
@@ -625,17 +616,6 @@ func normalizeDataSources(sources []unified.DataSource) []unified.DataSource {
return out
}
-func normalizeIdentity(identity unified.ResourceIdentity) normalizedIdentity {
- return normalizedIdentity{
- MachineID: strings.TrimSpace(identity.MachineID),
- DMIUUID: strings.TrimSpace(identity.DMIUUID),
- Hostnames: sortedTrimmedStrings(identity.Hostnames),
- IPAddresses: sortedTrimmedStrings(identity.IPAddresses),
- MACAddresses: sortedTrimmedStrings(identity.MACAddresses),
- ClusterName: strings.TrimSpace(identity.ClusterName),
- }
-}
-
func normalizeCapabilitiesForResourceHash(capabilities []unified.ResourceCapability) []normalizedCapabilityForResourceHash {
out := make([]normalizedCapabilityForResourceHash, 0, len(capabilities))
for _, capability := range capabilities {
diff --git a/internal/agentcapabilities/tool_marker.go b/internal/agentcapabilities/tool_marker.go
index 2cbee06440..855e81c6cb 100644
--- a/internal/agentcapabilities/tool_marker.go
+++ b/internal/agentcapabilities/tool_marker.go
@@ -163,12 +163,6 @@ func ApprovalRequiredToolMarkerPayloadJSON(content string) ([]byte, bool) {
return toolMarkerPayloadJSON(content, ToolMarkerApprovalRequiredPrefix)
}
-// PolicyBlockedToolMarkerPayloadJSON returns the marker payload bytes when
-// content carries the shared policy-blocked prefix.
-func PolicyBlockedToolMarkerPayloadJSON(content string) ([]byte, bool) {
- return toolMarkerPayloadJSON(content, ToolMarkerPolicyBlockedPrefix)
-}
-
// ParseApprovalRequiredToolMarkerPayload parses a shared approval-required
// marker into a generic payload map and verifies the stable payload type.
func ParseApprovalRequiredToolMarkerPayload(content string) (map[string]any, bool) {
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index 8192e3aa35..94dd451e88 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -1579,15 +1579,6 @@ func firstNonEmptyString(values ...string) string {
return ""
}
-func statusIsRunningOrOnline(status string) bool {
- switch strings.ToLower(strings.TrimSpace(status)) {
- case "running", "online", "ready", "healthy":
- return true
- default:
- return false
- }
-}
-
func sanitizeHandoffContextForResourcePolicy(handoffContext string, handoffResources []HandoffResource, provider tools.UnifiedResourceProvider) string {
return sanitizeTextForHandoffResourcePolicy(handoffContext, handoffResources, provider)
}
diff --git a/internal/ai/model_resolution.go b/internal/ai/model_resolution.go
index 9ce0404f4d..a5fcce0262 100644
--- a/internal/ai/model_resolution.go
+++ b/internal/ai/model_resolution.go
@@ -21,12 +21,6 @@ func ResolveConfiguredChatModel(ctx context.Context, cfg *config.AIConfig) (stri
return modelresolution.ResolveConfiguredChatModel(ctx, cfg)
}
-// ResolveConfiguredChatModelOffline returns the effective chat-suitable model
-// without calling provider model catalogs.
-func ResolveConfiguredChatModelOffline(cfg *config.AIConfig) (string, error) {
- return modelresolution.ResolveConfiguredChatModelOffline(cfg)
-}
-
// ResolvePreferredModelForProvider returns the best model to use for the requested
// provider. Explicit provider-scoped selections win; otherwise Pulse resolves a
// recommended model from the provider's live catalog.
@@ -45,24 +39,8 @@ func ResolveConfiguredChatProviderModel(ctx context.Context, cfg *config.AIConfi
return modelresolution.ResolveConfiguredChatProviderModel(ctx, cfg, provider)
}
-// ResolveConfiguredChatProviderModelOffline resolves a chat-suitable model for
-// the requested provider without calling provider model catalogs.
-func ResolveConfiguredChatProviderModelOffline(cfg *config.AIConfig, provider string) (string, error) {
- return modelresolution.ResolveConfiguredChatProviderModelOffline(cfg, provider)
-}
-
// SelectRecommendedProviderModel picks the current best candidate from a provider's
// live model catalog. The policy is intentionally vendor-neutral but Assistant first.
func SelectRecommendedProviderModel(models []providers.ModelInfo) (providers.ModelInfo, bool) {
return modelresolution.SelectRecommendedProviderModel(models)
}
-
-// isModelUsableWithConfig reports whether model names a non-retired provider
-// with usable credentials in the supplied config.
-func isModelUsableWithConfig(cfg *config.AIConfig, model string) bool {
- return modelresolution.IsModelUsableWithConfig(cfg, model)
-}
-
-func isModelUsableForChatWithConfig(cfg *config.AIConfig, model string) bool {
- return modelresolution.IsModelUsableForChatWithConfig(cfg, model)
-}
diff --git a/internal/ai/tools/action_audit.go b/internal/ai/tools/action_audit.go
index cb6a3b8723..b7d1f2387d 100644
--- a/internal/ai/tools/action_audit.go
+++ b/internal/ai/tools/action_audit.go
@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
+ "errors"
"fmt"
"strings"
"time"
@@ -19,6 +20,16 @@ import (
const approvalAuditActor = approval.RequesterPulseAssistant
+// ErrRemediationLockStateUnknown is returned when the broker cannot
+// determine whether the operator has set NeverAutoRemediate on the
+// target resource — no audit store is wired, or the operator-state
+// lookup failed. Autonomous (non-human-approved) dispatches must fail
+// CLOSED on this error: a broker that cannot read the operator's
+// "never touch this" flag must not assume it is unset. Human-approved
+// dispatches may proceed, since the operator has explicitly signed
+// off on the specific plan.
+var ErrRemediationLockStateUnknown = errors.New("remediation lock state unknown; operator approval required")
+
func (e *PulseToolExecutor) executeCommandWithAudit(
ctx context.Context,
capabilityName string,
@@ -142,29 +153,16 @@ func (e *PulseToolExecutor) executeCommandWithAudit(
// must refuse the dispatch even with a valid approval and matching
// plan hash. The operator's per-resource intent outranks the
// per-action approval — this is the safety mechanism for "do not
- // touch this resource even if you think you should." Persists a
- // Failed audit record with `resource_remediation_locked:` prefix
- // so the audit history shows every refused dispatch.
- if locked, lockErr := e.isResourceRemediationLocked(resourceID); lockErr != nil {
- log.Warn().Str("action_id", plan.ActionID).Err(lockErr).Msg("Operator-state lookup failed; allowing dispatch (fail-open) but logging")
- } else if locked {
- log.Warn().
- Str("action_id", plan.ActionID).
- Str("resource_id", resourceID).
- Str("capability", capabilityName).
- Msg("Refusing action execution: resource is operator-locked against automated remediation")
- now := time.Now().UTC()
- record.State = unifiedresources.ActionStateFailed
- record.UpdatedAt = now
- errMessage := fmt.Sprintf("resource_remediation_locked: %s", unifiedresources.ErrResourceRemediationLocked.Error())
- record.Result = &unifiedresources.ExecutionResult{
- Success: false,
- ErrorMessage: errMessage,
- }
- e.recordActionAudit(record)
- e.recordActionLifecycle(record.ID, unifiedresources.ActionStateFailed, requestedBy, "resource remediation lock refused")
- e.publishActionCompleted(record)
- return nil, unifiedresources.ErrResourceRemediationLocked
+ // touch this resource even if you think you should." When the lock
+ // state cannot be determined (no store, or lookup error), only a
+ // dispatch backed by an approved human decision may proceed;
+ // autonomous dispatches fail closed. Persists a Failed audit record
+ // with `resource_remediation_locked:` or
+ // `remediation_lock_state_unknown:` prefix so the audit history
+ // shows every refused dispatch.
+ if refusal := e.checkRemediationLockForDispatch(plan.ActionID, resourceID, capabilityName, hasApprovedActionApproval(approvalRecords)); refusal != nil {
+ e.refuseDispatchForRemediationLock(record, requestedBy, refusal)
+ return nil, refusal
}
record, err := e.recordActionExecutionStart(record, approvalID, requestedBy, fmt.Sprintf("dispatching command to agent %s", agentID), planFromApproval)
@@ -310,6 +308,15 @@ func (e *PulseToolExecutor) executeNativeActionWithAudit(
}
record.Approvals = approvalRecords
+ // Same operator-lock gate as the agent-command dispatch path: native
+ // provider dispatches (e.g. TrueNAS app start/stop/restart) are write
+ // actions on the resource, and the operator's NeverAutoRemediate flag
+ // must gate them identically — including failing closed for
+ // autonomous dispatches when the lock state cannot be determined.
+ if refusal := e.checkRemediationLockForDispatch(plan.ActionID, resourceID, capabilityName, hasApprovedActionApproval(approvalRecords)); refusal != nil {
+ return e.refuseDispatchForRemediationLock(record, requestedBy, refusal), refusal
+ }
+
record, err := e.recordActionExecutionStart(record, approvalID, requestedBy, "dispatching native resource action", planFromApproval)
if err != nil {
return &unifiedresources.ExecutionResult{Success: false, ErrorMessage: err.Error()}, err
@@ -1084,26 +1091,106 @@ func approvalTimestamp(req *approval.ApprovalRequest) time.Time {
// isResourceRemediationLocked returns whether the operator has set
// NeverAutoRemediate=true on the resource the dispatch targets.
-// Returns (false, nil) when no audit store is wired (degraded mode —
-// the fail-open posture is consistent with the rest of audit-store
-// callers in this file), when the resource has no operator state, or
+// Returns (false, nil) when the resource has no operator state, or
// when only IntentionallyOffline (without NeverAutoRemediate) is set.
-// Returns the error from the store on lookup failure so the caller can
-// log it; caller policy is fail-open on lookup error.
+// When the lock state cannot be determined — no audit store is wired,
+// or the store lookup fails — it returns an error wrapping
+// ErrRemediationLockStateUnknown so the caller can
+// distinguish "not locked" from "unknown". Caller policy lives in
+// checkRemediationLockForDispatch: autonomous (non-human-approved)
+// dispatches fail closed on unknown state; human-approved dispatches
+// keep the historical fail-open posture.
func (e *PulseToolExecutor) isResourceRemediationLocked(resourceID string) (bool, error) {
- if e == nil || e.actionAuditStore == nil {
- return false, nil
- }
canonical := strings.TrimSpace(resourceID)
if canonical == "" {
return false, nil
}
+ if e == nil || e.actionAuditStore == nil {
+ return false, fmt.Errorf("%w: no action audit store is wired", ErrRemediationLockStateUnknown)
+ }
state, found, err := e.actionAuditStore.GetResourceOperatorState(canonical)
if err != nil {
- return false, err
+ return false, fmt.Errorf("%w: operator-state lookup failed: %s", ErrRemediationLockStateUnknown, err.Error())
}
if !found {
return false, nil
}
return state.NeverAutoRemediate, nil
}
+
+// checkRemediationLockForDispatch applies the operator NeverAutoRemediate
+// policy at the dispatch decision point. Returns nil when the dispatch may
+// proceed, ErrResourceRemediationLocked when the operator has locked the
+// resource, or an ErrRemediationLockStateUnknown-wrapped error when the
+// lock state cannot be determined and the dispatch carries no approved
+// human decision. Autonomous dispatches fail CLOSED on unknown lock state:
+// a broker that cannot read the operator's "never touch this" flag must
+// not assume it is unset. Human-approved dispatches keep the historical
+// fail-open posture — the operator explicitly signed off on this exact
+// plan, so a degraded operator-state lookup does not override their
+// decision — but the degraded lookup is still logged.
+func (e *PulseToolExecutor) checkRemediationLockForDispatch(actionID, resourceID, capabilityName string, humanApproved bool) error {
+ locked, lockErr := e.isResourceRemediationLocked(resourceID)
+ if lockErr != nil {
+ if humanApproved {
+ log.Warn().
+ Str("action_id", actionID).
+ Str("resource_id", resourceID).
+ Str("capability", capabilityName).
+ Err(lockErr).
+ Msg("Remediation lock state unknown; allowing human-approved dispatch (fail-open) but logging")
+ return nil
+ }
+ log.Warn().
+ Str("action_id", actionID).
+ Str("resource_id", resourceID).
+ Str("capability", capabilityName).
+ Err(lockErr).
+ Msg("Refusing autonomous action execution: remediation lock state unknown (fail-closed); operator approval required")
+ return lockErr
+ }
+ if locked {
+ log.Warn().
+ Str("action_id", actionID).
+ Str("resource_id", resourceID).
+ Str("capability", capabilityName).
+ Msg("Refusing action execution: resource is operator-locked against automated remediation")
+ return unifiedresources.ErrResourceRemediationLocked
+ }
+ return nil
+}
+
+// refuseDispatchForRemediationLock persists a Failed audit record for a
+// dispatch refused by the remediation-lock gate and returns the
+// ExecutionResult describing the refusal. The ErrorMessage carries a
+// stable prefix (`resource_remediation_locked:` or
+// `remediation_lock_state_unknown:`) so audit-UI filters and alert rules
+// can branch on the token.
+func (e *PulseToolExecutor) refuseDispatchForRemediationLock(record unifiedresources.ActionAuditRecord, requestedBy string, refusal error) *unifiedresources.ExecutionResult {
+ now := time.Now().UTC()
+ record.State = unifiedresources.ActionStateFailed
+ record.UpdatedAt = now
+ result := &unifiedresources.ExecutionResult{
+ Success: false,
+ ErrorMessage: remediationLockRefusalMessage(refusal),
+ }
+ record.Result = result
+ e.recordActionAudit(record)
+ e.recordActionLifecycle(record.ID, unifiedresources.ActionStateFailed, requestedBy, remediationLockLifecycleMessage(refusal))
+ e.publishActionCompleted(record)
+ return result
+}
+
+func remediationLockRefusalMessage(refusal error) string {
+ if errors.Is(refusal, ErrRemediationLockStateUnknown) {
+ return fmt.Sprintf("remediation_lock_state_unknown: %s", refusal.Error())
+ }
+ return fmt.Sprintf("resource_remediation_locked: %s", refusal.Error())
+}
+
+func remediationLockLifecycleMessage(refusal error) string {
+ if errors.Is(refusal, ErrRemediationLockStateUnknown) {
+ return "remediation lock state unknown refused"
+ }
+ return "resource remediation lock refused"
+}
diff --git a/internal/ai/tools/action_audit_remediation_lock_test.go b/internal/ai/tools/action_audit_remediation_lock_test.go
new file mode 100644
index 0000000000..1e3ed2ee8f
--- /dev/null
+++ b/internal/ai/tools/action_audit_remediation_lock_test.go
@@ -0,0 +1,380 @@
+package tools
+
+import (
+ "context"
+ "errors"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/agentexec"
+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/approval"
+ unifiedresources "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
+ "github.com/stretchr/testify/mock"
+)
+
+// failingOperatorStateStore simulates an audit store whose operator-state
+// lookup errors (e.g. sqlite I/O failure) while every other store surface
+// keeps working, so refusal audit records can still be asserted.
+type failingOperatorStateStore struct {
+ *unifiedresources.MemoryStore
+}
+
+func (s *failingOperatorStateStore) GetResourceOperatorState(string) (unifiedresources.ResourceOperatorState, bool, error) {
+ return unifiedresources.ResourceOperatorState{}, false, errors.New("simulated operator-state lookup failure")
+}
+
+// installApprovedApproval seeds the global approval store with an approved,
+// plan-less approval and returns its ID. Plan-less keeps the plan-drift
+// check out of the way: these tests exercise the remediation-lock gate's
+// human-approved branch, which keys off the approved decision record.
+func installApprovedApproval(t *testing.T, id, command, targetType, targetID string) {
+ t.Helper()
+ approvalStore, err := approval.NewStore(approval.StoreConfig{
+ DataDir: t.TempDir(),
+ DisablePersistence: true,
+ })
+ if err != nil {
+ t.Fatalf("NewStore: %v", err)
+ }
+ previousApprovalStore := approval.GetStore()
+ approval.SetStore(approvalStore)
+ t.Cleanup(func() { approval.SetStore(previousApprovalStore) })
+
+ req := &approval.ApprovalRequest{
+ ID: id,
+ Command: command,
+ TargetType: targetType,
+ TargetID: targetID,
+ TargetName: targetID,
+ Context: "test approval",
+ }
+ if err := approvalStore.CreateApproval(req); err != nil {
+ t.Fatalf("CreateApproval: %v", err)
+ }
+ if _, err := approvalStore.Approve(id, "[email protected]"); err != nil {
+ t.Fatalf("Approve: %v", err)
+ }
+}
+
+// TestExecuteCommandWithAuditFailsClosedOnLockLookupErrorWithoutApproval
+// covers the autonomous posture (Patrol / assisted autonomy: no human
+// approval on the dispatch) when the operator-state lookup errors. The
+// broker cannot tell whether the operator set NeverAutoRemediate, so it
+// must fail CLOSED — refuse the dispatch, surface "remediation lock state
+// unknown", and leave a Failed audit record with the stable
+// `remediation_lock_state_unknown:` prefix.
+func TestExecuteCommandWithAuditFailsClosedOnLockLookupErrorWithoutApproval(t *testing.T) {
+ actionStore := &failingOperatorStateStore{MemoryStore: unifiedresources.NewMemoryStore()}
+ agentServer := &mockAgentServer{}
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ AgentServer: agentServer,
+ ActionAuditStore: actionStore,
+ })
+ executor.SetAutonomousMode(true)
+
+ result, err := executor.executeCommandWithAudit(
+ context.Background(),
+ "pulse_control",
+ "agent-degraded",
+ "", // no approval — autonomous dispatch
+ false,
+ "agent-degraded",
+ agentexec.ExecuteCommandPayload{
+ Command: "systemctl restart workload",
+ TargetType: "agent",
+ TargetID: "agent-degraded",
+ },
+ "pulse_patrol",
+ "restart workload service",
+ )
+ if !errors.Is(err, ErrRemediationLockStateUnknown) {
+ t.Fatalf("executeCommandWithAudit error = %v, want ErrRemediationLockStateUnknown", err)
+ }
+ if result != nil {
+ t.Fatalf("expected nil result on fail-closed refusal, got %#v", result)
+ }
+ agentServer.AssertNotCalled(t, "ExecuteCommand", mock.Anything, mock.Anything, mock.Anything)
+
+ audits, auditErr := actionStore.GetActionAudits("agent-degraded", time.Time{}, 10)
+ if auditErr != nil {
+ t.Fatalf("GetActionAudits: %v", auditErr)
+ }
+ if len(audits) != 1 {
+ t.Fatalf("expected 1 refused audit record, got %d", len(audits))
+ }
+ refused := audits[0]
+ if refused.State != unifiedresources.ActionStateFailed {
+ t.Fatalf("audit state = %q, want %q", refused.State, unifiedresources.ActionStateFailed)
+ }
+ if refused.Result == nil || refused.Result.Success {
+ t.Fatalf("expected Result.Success=false, got %#v", refused.Result)
+ }
+ if !strings.HasPrefix(refused.Result.ErrorMessage, "remediation_lock_state_unknown:") {
+ t.Fatalf("expected ErrorMessage to start with remediation_lock_state_unknown:, got %q", refused.Result.ErrorMessage)
+ }
+}
+
+// TestExecuteCommandWithAuditFailsClosedWithNilStoreWithoutApproval covers
+// the degraded deployment where no audit store is wired at all (e.g. the
+// sqlite store failed to initialize and the chat service continued with a
+// warning). Autonomous write dispatches must fail closed rather than
+// silently ignoring an operator lock the broker cannot read.
+func TestExecuteCommandWithAuditFailsClosedWithNilStoreWithoutApproval(t *testing.T) {
+ agentServer := &mockAgentServer{}
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ AgentServer: agentServer,
+ // No ActionAuditStore.
+ })
+ executor.SetAutonomousMode(true)
+
+ result, err := executor.executeCommandWithAudit(
+ context.Background(),
+ "pulse_control",
+ "agent-nostore",
+ "",
+ false,
+ "agent-nostore",
+ agentexec.ExecuteCommandPayload{
+ Command: "systemctl restart workload",
+ TargetType: "agent",
+ TargetID: "agent-nostore",
+ },
+ "pulse_patrol",
+ "restart workload service",
+ )
+ if !errors.Is(err, ErrRemediationLockStateUnknown) {
+ t.Fatalf("executeCommandWithAudit error = %v, want ErrRemediationLockStateUnknown", err)
+ }
+ if result != nil {
+ t.Fatalf("expected nil result on fail-closed refusal, got %#v", result)
+ }
+ agentServer.AssertNotCalled(t, "ExecuteCommand", mock.Anything, mock.Anything, mock.Anything)
+}
+
+// TestExecuteCommandWithAuditAllowsHumanApprovedDispatchOnLockLookupError
+// pins the interactive posture: when the dispatch is backed by an approved
+// human decision, an unknown lock state keeps the historical fail-open
+// behavior — the operator explicitly signed off on the action, so a
+// degraded operator-state lookup does not override their decision.
+func TestExecuteCommandWithAuditAllowsHumanApprovedDispatchOnLockLookupError(t *testing.T) {
+ actionStore := &failingOperatorStateStore{MemoryStore: unifiedresources.NewMemoryStore()}
+ installApprovedApproval(t, "approval-degraded", "systemctl restart workload", "agent", "agent-degraded")
+
+ agentServer := &mockAgentServer{}
+ agentServer.On("ExecuteCommand", mock.Anything, "agent-degraded", mock.Anything).
+ Return(&agentexec.CommandResultPayload{Stdout: "OK", ExitCode: 0}, nil)
+
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ AgentServer: agentServer,
+ ActionAuditStore: actionStore,
+ })
+
+ result, err := executor.executeCommandWithAudit(
+ context.Background(),
+ "pulse_control",
+ "agent-degraded",
+ "approval-degraded",
+ true,
+ "agent-degraded",
+ agentexec.ExecuteCommandPayload{
+ Command: "systemctl restart workload",
+ TargetType: "agent",
+ TargetID: "agent-degraded",
+ },
+ "pulse_control",
+ "restart workload service",
+ )
+ if err != nil {
+ t.Fatalf("executeCommandWithAudit unexpected error: %v", err)
+ }
+ if result == nil {
+ t.Fatal("expected human-approved dispatch to proceed; got nil result")
+ }
+ agentServer.AssertCalled(t, "ExecuteCommand", mock.Anything, "agent-degraded", mock.Anything)
+}
+
+// TestExecuteCommandWithAuditAllowsHumanApprovedDispatchWithNilStore covers
+// the human-approved branch with no audit store wired: same fail-open
+// posture as the lookup-error case.
+func TestExecuteCommandWithAuditAllowsHumanApprovedDispatchWithNilStore(t *testing.T) {
+ installApprovedApproval(t, "approval-nostore", "systemctl restart workload", "agent", "agent-nostore")
+
+ agentServer := &mockAgentServer{}
+ agentServer.On("ExecuteCommand", mock.Anything, "agent-nostore", mock.Anything).
+ Return(&agentexec.CommandResultPayload{Stdout: "OK", ExitCode: 0}, nil)
+
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ AgentServer: agentServer,
+ // No ActionAuditStore.
+ })
+
+ result, err := executor.executeCommandWithAudit(
+ context.Background(),
+ "pulse_control",
+ "agent-nostore",
+ "approval-nostore",
+ true,
+ "agent-nostore",
+ agentexec.ExecuteCommandPayload{
+ Command: "systemctl restart workload",
+ TargetType: "agent",
+ TargetID: "agent-nostore",
+ },
+ "pulse_control",
+ "restart workload service",
+ )
+ if err != nil {
+ t.Fatalf("executeCommandWithAudit unexpected error: %v", err)
+ }
+ if result == nil {
+ t.Fatal("expected human-approved dispatch to proceed; got nil result")
+ }
+ agentServer.AssertCalled(t, "ExecuteCommand", mock.Anything, "agent-nostore", mock.Anything)
+}
+
+// TestExecuteNativeActionWithAuditRefusesWhenResourceIsRemediationLocked
+// pins the lock gate on the native-provider dispatch path (e.g. TrueNAS
+// app start/stop/restart), which previously skipped the remediation lock
+// entirely. The operator's NeverAutoRemediate flag must gate native write
+// dispatches identically to agent-command dispatches.
+func TestExecuteNativeActionWithAuditRefusesWhenResourceIsRemediationLocked(t *testing.T) {
+ actionStore := unifiedresources.NewMemoryStore()
+ if err := actionStore.SetResourceOperatorState(unifiedresources.ResourceOperatorState{
+ CanonicalID: "app-locked",
+ NeverAutoRemediate: true,
+ SetAt: time.Now().UTC(),
+ SetBy: "operator:richard",
+ }); err != nil {
+ t.Fatalf("SetResourceOperatorState: %v", err)
+ }
+
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ ActionAuditStore: actionStore,
+ })
+
+ executed := false
+ result, err := executor.executeNativeActionWithAudit(
+ context.Background(),
+ "pulse_control",
+ "app-locked",
+ "",
+ false,
+ map[string]any{"action": "restart"},
+ "pulse_control",
+ "restart app-container",
+ func(context.Context) (*unifiedresources.ExecutionResult, error) {
+ executed = true
+ return &unifiedresources.ExecutionResult{Success: true}, nil
+ },
+ )
+ if !errors.Is(err, unifiedresources.ErrResourceRemediationLocked) {
+ t.Fatalf("executeNativeActionWithAudit error = %v, want ErrResourceRemediationLocked", err)
+ }
+ if executed {
+ t.Fatal("native action executed despite operator remediation lock")
+ }
+ if result == nil || result.Success {
+ t.Fatalf("expected failed ExecutionResult, got %#v", result)
+ }
+ if !strings.HasPrefix(result.ErrorMessage, "resource_remediation_locked:") {
+ t.Fatalf("expected ErrorMessage to start with resource_remediation_locked:, got %q", result.ErrorMessage)
+ }
+
+ audits, auditErr := actionStore.GetActionAudits("app-locked", time.Time{}, 10)
+ if auditErr != nil {
+ t.Fatalf("GetActionAudits: %v", auditErr)
+ }
+ if len(audits) != 1 {
+ t.Fatalf("expected 1 refused audit record, got %d", len(audits))
+ }
+ if audits[0].State != unifiedresources.ActionStateFailed {
+ t.Fatalf("audit state = %q, want %q", audits[0].State, unifiedresources.ActionStateFailed)
+ }
+}
+
+// TestExecuteNativeActionWithAuditFailsClosedOnUnknownLockStateWithoutApproval
+// covers both unknown-state shapes on the native path: nil store and a
+// store whose operator-state lookup errors. Autonomous native dispatches
+// must fail closed in both.
+func TestExecuteNativeActionWithAuditFailsClosedOnUnknownLockStateWithoutApproval(t *testing.T) {
+ cases := []struct {
+ name string
+ store unifiedresources.ResourceStore
+ }{
+ {name: "nil store", store: nil},
+ {name: "lookup error", store: &failingOperatorStateStore{MemoryStore: unifiedresources.NewMemoryStore()}},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ ActionAuditStore: tc.store,
+ })
+ executor.SetAutonomousMode(true)
+
+ executed := false
+ result, err := executor.executeNativeActionWithAudit(
+ context.Background(),
+ "pulse_control",
+ "app-degraded",
+ "",
+ false,
+ map[string]any{"action": "restart"},
+ "pulse_patrol",
+ "restart app-container",
+ func(context.Context) (*unifiedresources.ExecutionResult, error) {
+ executed = true
+ return &unifiedresources.ExecutionResult{Success: true}, nil
+ },
+ )
+ if !errors.Is(err, ErrRemediationLockStateUnknown) {
+ t.Fatalf("executeNativeActionWithAudit error = %v, want ErrRemediationLockStateUnknown", err)
+ }
+ if executed {
+ t.Fatal("native action executed despite unknown remediation lock state")
+ }
+ if result == nil || result.Success {
+ t.Fatalf("expected failed ExecutionResult, got %#v", result)
+ }
+ if !strings.HasPrefix(result.ErrorMessage, "remediation_lock_state_unknown:") {
+ t.Fatalf("expected ErrorMessage to start with remediation_lock_state_unknown:, got %q", result.ErrorMessage)
+ }
+ })
+ }
+}
+
+// TestExecuteNativeActionWithAuditAllowsHumanApprovedDispatchOnUnknownLockState
+// pins the human-approved fail-open branch on the native path.
+func TestExecuteNativeActionWithAuditAllowsHumanApprovedDispatchOnUnknownLockState(t *testing.T) {
+ actionStore := &failingOperatorStateStore{MemoryStore: unifiedresources.NewMemoryStore()}
+ installApprovedApproval(t, "approval-native", "truenas app restart myapp", "app-container", "app-degraded")
+
+ executor := NewPulseToolExecutor(ExecutorConfig{
+ ActionAuditStore: actionStore,
+ })
+
+ executed := false
+ result, err := executor.executeNativeActionWithAudit(
+ context.Background(),
+ "pulse_control",
+ "app-degraded",
+ "approval-native",
+ true,
+ map[string]any{"action": "restart"},
+ "pulse_control",
+ "restart app-container",
+ func(context.Context) (*unifiedresources.ExecutionResult, error) {
+ executed = true
+ return &unifiedresources.ExecutionResult{Success: true}, nil
+ },
+ )
+ if err != nil {
+ t.Fatalf("executeNativeActionWithAudit unexpected error: %v", err)
+ }
+ if !executed {
+ t.Fatal("expected human-approved native dispatch to proceed")
+ }
+ if result == nil || !result.Success {
+ t.Fatalf("expected successful ExecutionResult, got %#v", result)
+ }
+}
diff --git a/internal/ai/tools/control_run_command_test.go b/internal/ai/tools/control_run_command_test.go
index 81651cfd68..2161cca5a8 100644
--- a/internal/ai/tools/control_run_command_test.go
+++ b/internal/ai/tools/control_run_command_test.go
@@ -323,9 +323,10 @@ func TestPulseToolExecutor_RunCommandLXCRouting(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeRunCommand(ctx, map[string]interface{}{
"command": "grep pattern /var/log/*.log",
@@ -359,9 +360,10 @@ func TestPulseToolExecutor_RunCommandLXCRouting(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeRunCommand(ctx, map[string]interface{}{
"command": "ls /tmp/*.txt",
@@ -388,9 +390,10 @@ func TestPulseToolExecutor_RunCommandLXCRouting(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeRunCommand(ctx, map[string]interface{}{
"command": "ls /tmp/*.txt",
diff --git a/internal/ai/tools/control_test.go b/internal/ai/tools/control_test.go
index 3d1355abfb..13847c4f22 100644
--- a/internal/ai/tools/control_test.go
+++ b/internal/ai/tools/control_test.go
@@ -9,6 +9,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/agentexec"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -55,9 +56,10 @@ func TestPulseToolExecutor_ExecuteControlGuest(t *testing.T) {
stateProv := &mockStateProvider{}
agentSrv := &mockAgentServer{}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: stateProv,
- AgentServer: agentSrv,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: stateProv,
+ AgentServer: agentSrv,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
state := models.StateSnapshot{
@@ -103,9 +105,10 @@ func TestPulseToolExecutor_ExecuteControlDocker(t *testing.T) {
stateProv := &mockStateProvider{}
agentSrv := &mockAgentServer{}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: stateProv,
- AgentServer: agentSrv,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: stateProv,
+ AgentServer: agentSrv,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
state := models.StateSnapshot{
diff --git a/internal/ai/tools/file_docker_test.go b/internal/ai/tools/file_docker_test.go
index f62fadb519..072fd8b775 100644
--- a/internal/ai/tools/file_docker_test.go
+++ b/internal/ai/tools/file_docker_test.go
@@ -12,6 +12,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/agentexec"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
@@ -67,9 +68,10 @@ func TestExecuteFileReadDocker(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileRead(ctx, "/config/settings.json", "tower", "jellyfin")
require.NoError(t, err)
@@ -98,9 +100,10 @@ func TestExecuteFileReadDocker(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileRead(ctx, "/etc/hostname", "tower", "") // empty container
require.NoError(t, err)
@@ -122,9 +125,10 @@ func TestExecuteFileReadDocker(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileRead(ctx, "/config/test.json", "tower", "nonexistent")
require.NoError(t, err)
@@ -168,9 +172,10 @@ func TestExecuteFileWriteDocker(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileWrite(ctx, "/etc/nginx/nginx.conf", content, "tower", "nginx", map[string]interface{}{})
require.NoError(t, err)
@@ -238,9 +243,10 @@ func TestExecuteFileAppendDocker(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileAppend(ctx, "/var/log/app.log", content, "tower", "logcontainer", map[string]interface{}{})
require.NoError(t, err)
@@ -300,9 +306,10 @@ func TestExecuteFileWriteLXCVMTargets(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileWrite(ctx, "/opt/test/config.yaml", content, "homepage-docker", "", map[string]interface{}{})
require.NoError(t, err)
@@ -354,9 +361,10 @@ func TestExecuteFileWriteLXCVMTargets(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileWrite(ctx, "/etc/test.conf", content, "test-vm", "", map[string]interface{}{})
require.NoError(t, err)
@@ -399,9 +407,10 @@ func TestExecuteFileWriteLXCVMTargets(t *testing.T) {
}, nil)
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: models.StateSnapshot{}},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileWrite(ctx, "/tmp/test.txt", content, "tower", "", map[string]interface{}{})
require.NoError(t, err)
@@ -453,9 +462,10 @@ func TestExecuteFileWriteLXCVMTargets(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileAppend(ctx, "/var/log/app.log", content, "homepage-docker", "", map[string]interface{}{})
require.NoError(t, err)
@@ -501,9 +511,10 @@ func TestExecuteFileEditDockerNestedRouting(t *testing.T) {
}
exec := NewPulseToolExecutor(ExecutorConfig{
- StateProvider: &mockStateProvider{state: state},
- AgentServer: mockAgent,
- ControlLevel: ControlLevelAutonomous,
+ StateProvider: &mockStateProvider{state: state},
+ AgentServer: mockAgent,
+ ControlLevel: ControlLevelAutonomous,
+ ActionAuditStore: unifiedresources.NewMemoryStore(),
})
result, err := exec.executeFileRead(ctx, "/config/test.json", "homepage-docker", "nginx")
require.NoError(t, err)
diff --git a/internal/api/agent_activity_telemetry.go b/internal/api/agent_activity_telemetry.go
index bdec1c5b04..a3d0ea099f 100644
--- a/internal/api/agent_activity_telemetry.go
+++ b/internal/api/agent_activity_telemetry.go
@@ -12,13 +12,6 @@ import (
"github.com/rs/zerolog/log"
)
-func (r *Router) withExternalAgentActivity(activity string, handler http.HandlerFunc) http.HandlerFunc {
- return func(w http.ResponseWriter, req *http.Request) {
- r.recordExternalAgentActivity(req, activity)
- handler(w, req)
- }
-}
-
func (r *Router) withExternalAgentCapabilityActivity(capabilityName string, handler http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {
r.recordExternalAgentCapabilityActivity(req, capabilityName)
diff --git a/internal/api/agent_resource_context.go b/internal/api/agent_resource_context.go
index 98b1174ac5..1d7027e855 100644
--- a/internal/api/agent_resource_context.go
+++ b/internal/api/agent_resource_context.go
@@ -317,18 +317,6 @@ func (p agentFindingsProvider) ActiveFindingCount() int {
return p.activeCount()
}
-// agentFindingsProviderFunc is a function adapter so wire-up code can
-// pass a closure without declaring a struct.
-type agentFindingsProviderFunc func(resourceID string) []AgentResourceFindingSnapshot
-
-// ActiveFindingsForResource implements AgentFindingsProvider.
-func (f agentFindingsProviderFunc) ActiveFindingsForResource(resourceID string) []AgentResourceFindingSnapshot {
- if f == nil {
- return nil
- }
- return f(resourceID)
-}
-
// AgentApprovalsProvider returns still-pending approvals as
// agent-stable projections. Per-resource context needs full
// summaries; fleet context needs only a resource-keyed count map so
diff --git a/internal/api/licensing_bridge.go b/internal/api/licensing_bridge.go
index 683ddf7566..a0c3518f5f 100644
--- a/internal/api/licensing_bridge.go
+++ b/internal/api/licensing_bridge.go
@@ -180,20 +180,6 @@ func buildEntitlementPayloadFromLicensing(status *licenseStatus, subscriptionSta
return pkglicensing.BuildEntitlementPayload(status, subscriptionState)
}
-func buildRuntimeCapabilitiesPayloadFromLicensing(
- status *licenseStatus,
- subscriptionState string,
-) runtimeCapabilitiesPayloadModel {
- return pkglicensing.BuildRuntimeCapabilitiesPayload(status, subscriptionState)
-}
-
-func buildCommercialPosturePayloadFromLicensing(
- status *licenseStatus,
- subscriptionState string,
-) commercialPosturePayloadModel {
- return pkglicensing.BuildCommercialPosturePayload(status, subscriptionState)
-}
-
func buildFeatureMapFromLicensing(service *licenseService) map[string]bool {
return pkglicensing.BuildFeatureMap(service, nil)
}
diff --git a/internal/config/ai_providers.go b/internal/config/ai_providers.go
index d1f007ed88..4400d5b8e8 100644
--- a/internal/config/ai_providers.go
+++ b/internal/config/ai_providers.go
@@ -317,11 +317,6 @@ func LookupAIProviderDefinition(provider string) (AIProviderDefinition, bool) {
return AIProviderDefinition{}, false
}
-func IsKnownAIProvider(provider string) bool {
- _, ok := LookupAIProviderDefinition(provider)
- return ok
-}
-
func IsOpenAICompatibleProvider(provider string) bool {
def, ok := LookupAIProviderDefinition(provider)
return ok && def.Protocol == AIProviderProtocolOpenAICompatible
diff --git a/internal/hostagent/nvidia_smi.go b/internal/hostagent/nvidia_smi.go
index 648ae84f49..71d159f298 100644
--- a/internal/hostagent/nvidia_smi.go
+++ b/internal/hostagent/nvidia_smi.go
@@ -187,10 +187,6 @@ func parseNVIDIASMIStats(output string) ([]agentshost.GPUSensor, error) {
return gpus, nil
}
-func parseNVIDIASMITemperatureValue(value string) (float64, bool) {
- return parseNVIDIASMINumber(value, false)
-}
-
func parseNVIDIASMINumber(value string, allowZero bool) (float64, bool) {
value = strings.TrimSpace(value)
if value == "" {
diff --git a/internal/mock/generator.go b/internal/mock/generator.go
index 8b2920c94f..83f91a0583 100644
--- a/internal/mock/generator.go
+++ b/internal/mock/generator.go
@@ -3796,18 +3796,6 @@ func generateMockHostRate(ioType string) float64 {
}
}
-func fluctuateMockHostRate(current float64, ioType string, min, max float64) float64 {
- if current <= 0 {
- current = generateMockHostRate(ioType)
- }
- changeFactor := 1 + ((rand.Float64()*2)-1)*0.25
- next := current * changeFactor
- if rand.Float64() < 0.04 {
- next *= 1.4 + rand.Float64()*0.8
- }
- return clampFloat(next, min, max)
-}
-
func generateDockerContainers(hostName string, hostIdx int, config MockConfig, podman bool) []models.DockerContainer {
base := config.DockerContainersPerHost
if base < 1 {
diff --git a/internal/monitoring/guest_agent_work.go b/internal/monitoring/guest_agent_work.go
index a7c593aeda..35bdfd7fbb 100644
--- a/internal/monitoring/guest_agent_work.go
+++ b/internal/monitoring/guest_agent_work.go
@@ -2,7 +2,6 @@ package monitoring
import (
"context"
- "time"
)
func (m *Monitor) efficientQEMUWorkerCount(total int) int {
@@ -60,10 +59,3 @@ func (m *Monitor) runGuestAgentVMWork(ctx context.Context, work func(context.Con
work(workCtx)
return true
}
-
-func guestAgentVMBudgetOrZero(m *Monitor) time.Duration {
- if m == nil {
- return 0
- }
- return m.guestAgentVMBudget
-}
diff --git a/internal/monitoring/monitor_backups.go b/internal/monitoring/monitor_backups.go
index 5d5fabbd18..37739973b1 100644
--- a/internal/monitoring/monitor_backups.go
+++ b/internal/monitoring/monitor_backups.go
@@ -422,14 +422,6 @@ func shouldPreserveBackups(nodeCount int, hadSuccessfulNode bool, storagesWithBa
return false
}
-func shouldPreservePBSBackups(datastoreCount, datastoreFetches int) bool {
- // If there are datastores but all fetches failed, preserve existing backups
- if datastoreCount > 0 && datastoreFetches == 0 {
- return true
- }
- return false
-}
-
func (m *Monitor) syncGuestBackupTimesAndResourceStore() {
if m == nil || m.state == nil {
return
diff --git a/internal/telemetry/pulse_intelligence_evidence.go b/internal/telemetry/pulse_intelligence_evidence.go
index 6d887df1e0..f1e6d6591f 100644
--- a/internal/telemetry/pulse_intelligence_evidence.go
+++ b/internal/telemetry/pulse_intelligence_evidence.go
@@ -16,12 +16,6 @@ type PulseIntelligenceAIUsageEvidence struct {
PatrolAICalls int
}
-// AssistantCollaborationActive reports whether Assistant produced contextual
-// or tool-backed collaboration, not merely a starter prompt render.
-func (e PulseIntelligenceAIUsageEvidence) AssistantCollaborationActive() bool {
- return e.AssistantContextAICalls > 0 || e.AssistantToolCalls > 0
-}
-
// PulseIntelligenceAIUsageEvidenceFromHistory projects AI usage history into
// the same content-free Pulse Intelligence evidence used by telemetry and the
// agent operations-loop status endpoint.