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.

Cover Patrol handoff approval mode

rcourtmanbbaa6c0a6cb5
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 59c4ceba58..986f299781 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -280,7 +280,9 @@ profile and assignment columns, but embedded table framing must route through
boundary: lifecycle-adjacent consumers may rely on Assistant approval
semantics, but scoped `autonomous_mode:false` chat requests must not be
reinterpreted as agent registration, assignment, installer, or connection
- lifecycle state.
+ lifecycle state. Patrol finding handoffs that force approval-required mode
+ from a non-empty `finding_id` are likewise AI/runtime governance, not an
+ agent command grant or lifecycle authorization primitive.
Lifecycle flows must not reintroduce anonymous bootstrap identity,
tenant-local commercial-owner surrogates, or fake activation records when
they traverse those shared handlers. They also must not infer tenant
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index a1f0431890..765e97db60 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -372,10 +372,11 @@ runtime cost control, and shared AI transport surfaces.
Proposed-fix command text must stay out of both the persisted chat message
and the model-only handoff context, and command payloads remain
approval-context data, not conversational copy.
- `/api/ai/chat` must also clamp Patrol finding handoffs that resolve to
- model-only briefing, resource, or action context to approval-required mode
- by forcing the request-local autonomous-mode override to false, even when a
- caller supplied `autonomous_mode:true`. That clamp belongs to the
+ `/api/ai/chat` must also clamp Patrol finding handoffs to
+ approval-required mode when a request carries a non-empty `finding_id` or
+ resolves to model-only briefing, resource, or action context, by forcing the
+ request-local autonomous-mode override to false, even when a caller supplied
+ `autonomous_mode:true`. That clamp belongs to the
backend/API execution boundary, does not mutate the user's persistent AI
control setting, and prevents product-originated Patrol action context from
becoming silent command authority.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index fdce72f799..17433de65b 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1976,13 +1976,13 @@ last-known approval/action status, risk level, and summary timestamp; it must
not serialize the model-only `handoff_context`, runtime failure detail, action
preflight/result bodies, remediation descriptions, raw commands, or approval
command payloads.
-Patrol finding handoffs are stricter than ordinary chat requests: when
-`finding_id` resolves to model-only Patrol briefing, resource, or action
-context, `internal/api/ai_handler.go` must clamp the request-local autonomous
-mode to false even if the caller supplied `autonomous_mode:true`. That
-server-side clamp is part of the public API contract because the frontend
-handoff setting is only advisory unless the backend preserves the
-approval-required boundary.
+Patrol finding handoffs are stricter than ordinary chat requests: when a request
+carries a non-empty `finding_id` or resolves to model-only Patrol briefing,
+resource, or action context, `internal/api/ai_handler.go` must clamp the
+request-local autonomous mode to false even if the caller supplied
+`autonomous_mode:true`. That server-side clamp is part of the public API
+contract because the frontend handoff setting is only advisory unless the
+backend preserves the approval-required boundary.
That same backend API boundary now also owns the negative space around
assistant control. Wiring native TrueNAS app actions into
`internal/api/router.go`, `internal/api/ai_handler.go`, or adjacent backend
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index c8c019ade9..89922e82a4 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -193,10 +193,11 @@ Patrol-specific presentation helpers.
counts are allowed, safe suggested prompts may ask about plan risk,
prerequisites, rollback, and verification, while command and rollback command
text stays in the governed remediation or approval surface. Generic finding
- discussion handoffs must also force request-local approval-required mode when
- the finding already references a live approval, proposed fix, fix outcome, or
- remediation plan, so default autonomous Assistant settings cannot bypass the
- Patrol action-governance boundary. The assembled handoff must still pass
+ discussion handoffs must also force request-local approval-required mode for
+ any non-empty Patrol `finding_id`, including findings that reference a live
+ approval, proposed fix, fix outcome, or remediation plan, so default
+ autonomous Assistant settings cannot bypass the Patrol action-governance
+ boundary. The assembled handoff must still pass
through the Assistant runtime's resource-policy sanitizer before prompt
injection, so Patrol-owned prose
cannot leak governed resource names, IDs, aliases, nodes, paths, or
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index cf18fc0513..47a613ae91 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1109,6 +1109,12 @@ AI/runtime review identity only. Storage and recovery may display or link from
the safe run ID, run type/status, runtime-failure flag, or scoped resource label
as incident context, but they must not reinterpret it as backup freshness,
restore proof, storage health authority, or recovery-local remediation state.
+Patrol finding handoffs that force approval-required Assistant mode from a
+non-empty `finding_id` follow the same adjacent API boundary: storage and
+recovery may treat the resulting Assistant session as incident context, but
+must not reinterpret the finding ID or approval-required chat mode as backup
+freshness, restore authorization, storage remediation permission, or recovery
+transport state.
That same storage ownership also includes the shared storage-source presentation
contract in `frontend-modern/src/utils/storageSources.ts`: storage pages and
cross-surface storage links must reuse one canonical ordering, label, tone, and
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index f1e47d0453..749810e5fa 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -825,11 +825,18 @@ func chatAutonomousModeForScopedHandoff(requested *bool, handoffContext string,
if strings.TrimSpace(handoffContext) == "" && len(handoffResources) == 0 && len(handoffActions) == 0 && chat.NormalizeHandoffMetadata(handoffMetadata) == (chat.HandoffMetadata{}) {
return requested
}
+ return chatApprovalRequiredAutonomousMode()
+}
+
+func chatApprovalRequiredAutonomousMode() *bool {
approvalRequired := false
return &approvalRequired
}
func chatAutonomousModeForFindingHandoff(requested *bool, findingID, handoffContext string, handoffResources []chat.HandoffResource, handoffActions []chat.HandoffAction, handoffMetadata chat.HandoffMetadata) *bool {
+ if strings.TrimSpace(findingID) != "" {
+ return chatApprovalRequiredAutonomousMode()
+ }
return chatAutonomousModeForScopedHandoff(requested, handoffContext, handoffResources, handoffActions, handoffMetadata)
}
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 550cf44c9c..3665d196d3 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -583,6 +583,77 @@ func TestHandleChat_PassesAutonomousModeOverride(t *testing.T) {
assert.Equal(t, http.StatusOK, w.Code)
}
+func TestChatAutonomousModeForFindingHandoffRequiresApprovalForProductHandoffs(t *testing.T) {
+ requestedAutonomous := true
+ requestedManual := false
+ if got := chatAutonomousModeForFindingHandoff(&requestedAutonomous, "", "", nil, nil, chat.HandoffMetadata{}); got != &requestedAutonomous {
+ t.Fatalf("plain chat should pass requested autonomous mode through, got %#v", got)
+ }
+ if got := chatAutonomousModeForFindingHandoff(&requestedManual, "", "", nil, nil, chat.HandoffMetadata{}); got != &requestedManual {
+ t.Fatalf("plain chat should pass requested manual mode through, got %#v", got)
+ }
+ if got := chatAutonomousModeForFindingHandoff(nil, "", "", nil, nil, chat.HandoffMetadata{}); got != nil {
+ t.Fatalf("plain chat with no override should preserve nil autonomous mode, got %#v", got)
+ }
+
+ cases := []struct {
+ name string
+ findingID string
+ handoffContext string
+ handoffResources []chat.HandoffResource
+ handoffActions []chat.HandoffAction
+ handoffMetadata chat.HandoffMetadata
+ }{
+ {
+ name: "finding id only",
+ findingID: "finding-123",
+ },
+ {
+ name: "scoped handoff context",
+ handoffContext: "[Patrol Finding Context]\nFinding ID: finding-123",
+ },
+ {
+ name: "handoff resource",
+ handoffResources: []chat.HandoffResource{{ID: "vm-100", Type: "vm"}},
+ },
+ {
+ name: "handoff action",
+ handoffActions: []chat.HandoffAction{{ActionID: "action-123", FindingID: "finding-123"}},
+ },
+ {
+ name: "patrol run metadata",
+ handoffMetadata: chat.HandoffMetadata{Kind: "patrol_run", RunID: "run-1"},
+ },
+ {
+ name: "patrol assessment metadata",
+ handoffMetadata: chat.HandoffMetadata{Kind: "patrol_assessment"},
+ },
+ {
+ name: "patrol configuration failure metadata",
+ handoffMetadata: chat.HandoffMetadata{Kind: "patrol_configuration_failure", RuntimeFailure: true},
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := chatAutonomousModeForFindingHandoff(
+ &requestedAutonomous,
+ tc.findingID,
+ tc.handoffContext,
+ tc.handoffResources,
+ tc.handoffActions,
+ tc.handoffMetadata,
+ )
+ if got == nil {
+ t.Fatalf("expected approval-required autonomous mode, got nil")
+ }
+ if *got {
+ t.Fatalf("expected approval-required autonomous mode false, got true")
+ }
+ })
+ }
+}
+
func TestHandleChat_PassesScopedHandoffContext(t *testing.T) {
cfg := &config.Config{}
h := newTestAIHandler(cfg, nil, nil)
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index c5c8408da0..d797657c4a 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -212,6 +212,8 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
"ApprovalRequestedAt",
"ApprovalExpiresAt",
"func chatAutonomousModeForFindingHandoff(requested *bool, findingID, handoffContext string, handoffResources []chat.HandoffResource, handoffActions []chat.HandoffAction, handoffMetadata chat.HandoffMetadata) *bool",
+ `if strings.TrimSpace(findingID) != ""`,
+ "chatApprovalRequiredAutonomousMode()",
"AutonomousMode: chatAutonomousModeForFindingHandoff(req.AutonomousMode, findingID, handoffContext, handoffResources, handoffActions, handoffMetadata)",
`appendChatContextLine(&b, "Finding Status", unifiedFindingChatStatus(f, time.Now()))`,
`appendChatContextLine(&b, "Finding Detected At", f.DetectedAt.Format(time.RFC3339))`,