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.

Hydrate Patrol requester in Assistant handoffs

rcourtmandd15d23a35e6
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index d92793e1bc..07b0b07b94 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -290,8 +290,9 @@ profile and assignment columns, but embedded table framing must route through
Patrol queued-fix approvals may now seed the shared action-audit store with
planned and pending lifecycle evidence, but lifecycle surfaces must treat
those records and their persisted requester identity as action-governance
- context only; they do not create install, enrollment, assignment, or
- fleet-command authority.
+ context only. Backend-refreshed Assistant handoffs may also carry that
+ requester identity as provenance, but it still does not create install,
+ enrollment, assignment, or fleet-command authority.
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 d7f54a804c..0132409dca 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -663,7 +663,10 @@ of creating Patrol-only execution context or collapsing Patrol proposals into
generic Assistant-origin actions. The approval record itself must also persist
and expose that requester identity so `/api/ai/approvals` and Assistant
handoffs preserve Patrol provenance before later action-audit hydration refreshes
-the current action state.
+the current action state. Backend chat refresh of a Patrol finding handoff must
+hydrate the same requester identity directly from the live approval record, so
+Assistant does not depend on browser-authored metadata to distinguish
+Patrol-origin proposals from generic Assistant actions.
The same ownership includes the Pulse query tool schema under
`internal/ai/tools/`: topology-query input names must stay canonical inside
the AI runtime itself, so new tool arguments such as `max_proxmox_nodes`
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b2101fe541..b95d799e01 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -442,7 +442,10 @@ the canonical monitored-system blocked payload.
Patrol-origin proposals as generic Assistant-origin actions. `/api/ai/approvals`
must expose the persisted `requestedBy` identity so frontend Assistant
handoffs can carry Patrol provenance before the chat runtime refreshes the
- current action state from action audit.
+ current action state from action audit. Backend `/api/ai/chat` refresh of
+ a finding handoff must also recover that requester identity from the live
+ approval record when action audit has not yet hydrated the current action
+ state.
Action execution is API-owned as the next explicit contract:
`POST /api/actions/{id}/execute` may only start execution for an approved
action or an approval-free executable plan, must atomically persist the
@@ -3156,7 +3159,7 @@ visible handoffs from findings, while the downstream chat
service hydrates live resource state, timeline, and action audit context around
that same handoff. Backend chat handling must treat matching frontend Patrol
handoff context as secondary to durable finding context, not a replacement for
-server-refreshed approval, resource, or action authority. Frontend Patrol
+server-refreshed approval, resource, action, or requester authority. Frontend Patrol
handoff helpers may consume current pending
approval list payloads only as safe metadata for that visible briefing and any
structured `handoff_actions`: approval ID, status, risk, request/expiry
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 3a2dd020aa..e4e0ed5add 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1128,6 +1128,9 @@ incident-adjacent context, including the requester identity that distinguishes
Patrol-origin proposals from generic Assistant work, but they must not treat the
pending action state, approval policy, requester, or preflight posture as
recovery proof or storage-local execution permission.
+Backend-refreshed Assistant handoffs may recover the same requester identity
+from a live approval record before action audit hydration, but storage and
+recovery still consume it only as incident-adjacent provenance.
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/ai/chat/service.go b/internal/ai/chat/service.go
index 4ec539df77..bda65709af 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -1385,6 +1385,9 @@ func HydrateHandoffActionFromApproval(action *HandoffAction, req *approval.Appro
action.ApprovalDecidedAt = formatHandoffActionTime(*req.DecidedAt)
}
action.ApprovalConsumed = req.Consumed
+ if requestedBy := strings.TrimSpace(approval.RequesterForRequest(req)); requestedBy != "" {
+ action.ActionRequestedBy = requestedBy
+ }
if strings.TrimSpace(action.RiskLevel) == "" {
action.RiskLevel = strings.TrimSpace(string(req.RiskLevel))
}
diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.go
index 2bbe1c971f..1bfed144a1 100644
--- a/internal/ai/chat/service_execute_additional_test.go
+++ b/internal/ai/chat/service_execute_additional_test.go
@@ -112,6 +112,7 @@ func TestHydrateHandoffActionFromApprovalCopiesSafeLifecycleMetadata(t *testing.
action := HandoffAction{FindingID: "finding-123"}
HydrateHandoffActionFromApproval(&action, &approval.ApprovalRequest{
ID: "approval-123",
+ ToolID: "investigation_fix",
Command: "systemctl restart workload.service",
TargetType: "vm",
TargetID: "vm-100",
@@ -138,6 +139,9 @@ func TestHydrateHandoffActionFromApprovalCopiesSafeLifecycleMetadata(t *testing.
if action.ApprovalID != "approval-123" || action.ApprovalStatus != "approved" || !action.ApprovalConsumed {
t.Fatalf("approval lifecycle was not hydrated: %#v", action)
}
+ if action.ActionRequestedBy != approval.RequesterPulsePatrol {
+ t.Fatalf("approval requester identity was not hydrated: %#v", action)
+ }
if action.ApprovalRequestedAt != requestedAt.Format(time.RFC3339) ||
action.ApprovalExpiresAt != expiresAt.Format(time.RFC3339) ||
action.ApprovalDecidedAt != decidedAt.Format(time.RFC3339) {
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 749810e5fa..32aca4fbe2 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -1919,6 +1919,9 @@ func unifiedFindingHandoffActionOperatorDecision(action chat.HandoffAction) stri
if state := strings.TrimSpace(action.ActionState); state != "" {
parts = append(parts, "action state "+state)
}
+ if requestedBy := strings.TrimSpace(action.ActionRequestedBy); requestedBy != "" {
+ parts = append(parts, "requested by "+requestedBy)
+ }
if policy := strings.TrimSpace(action.ActionApprovalPolicy); policy != "" {
parts = append(parts, "approval policy "+policy)
}
@@ -1965,6 +1968,9 @@ func unifiedFindingHandoffActionPosture(action chat.HandoffAction) string {
if state := strings.TrimSpace(action.ActionState); state != "" {
parts = append(parts, "action state "+state)
}
+ if requestedBy := strings.TrimSpace(action.ActionRequestedBy); requestedBy != "" {
+ parts = append(parts, "requested by "+requestedBy)
+ }
if policy := strings.TrimSpace(action.ActionApprovalPolicy); policy != "" {
parts = append(parts, "approval policy "+policy)
}
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 3665d196d3..1b434ec197 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -1349,6 +1349,7 @@ func TestHandleChat_RecoversLivePatrolApprovalForFindingHandoffAction(t *testing
ApprovalRequestedAt: approvalRequestedAt,
ApprovalExpiresAt: approvalExpiresAt,
ActionID: "action-live",
+ ActionRequestedBy: approval.RequesterPulsePatrol,
ActionApprovalPolicy: "admin",
ActionRequiresApproval: true,
ActionPlanExpiresAt: actionPlanExpiresAt,
@@ -1365,8 +1366,8 @@ func TestHandleChat_RecoversLivePatrolApprovalForFindingHandoffAction(t *testing
TargetResourceType: "vm",
TargetNode: "pve-1",
}}, reqArg.HandoffActions)
- assert.Contains(t, reqArg.HandoffContext, "Operator Decision: review governed approval approval-live before execution; approval status pending; approval expires "+approvalExpiresAt+"; action action-live; approval policy admin; plan expires "+actionPlanExpiresAt+"; proposed fix fix-123; risk high; destructive true")
- assert.Contains(t, reqArg.HandoffContext, "Action Posture: approval approval-live; approval status pending; approval requested "+approvalRequestedAt+"; approval expires "+approvalExpiresAt+"; action action-live; approval policy admin; action requires approval true; plan expires "+actionPlanExpiresAt+"; proposed fix fix-123; risk high; destructive true")
+ assert.Contains(t, reqArg.HandoffContext, "Operator Decision: review governed approval approval-live before execution; approval status pending; approval expires "+approvalExpiresAt+"; action action-live; requested by pulse_patrol; approval policy admin; plan expires "+actionPlanExpiresAt+"; proposed fix fix-123; risk high; destructive true")
+ assert.Contains(t, reqArg.HandoffContext, "Action Posture: approval approval-live; approval status pending; approval requested "+approvalRequestedAt+"; approval expires "+approvalExpiresAt+"; action action-live; requested by pulse_patrol; approval policy admin; action requires approval true; plan expires "+actionPlanExpiresAt+"; proposed fix fix-123; risk high; destructive true")
assert.NotContains(t, reqArg.HandoffContext, "Action Posture: proposed fix fix-123; risk medium")
assert.NotContains(t, reqArg.HandoffContext, "systemctl restart workload.service")
assert.NotContains(t, fmt.Sprintf("%#v", reqArg.HandoffActions), "systemctl restart workload.service")
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 7f87153ac4..17e0f9c750 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -319,6 +319,8 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
"refreshHandoffActionStatus(handoffActions, s.orgID, s.actionAuditStore)",
"HydrateHandoffActionFromApproval(&actions[idx], req)",
"func HydrateHandoffActionFromApproval(action *HandoffAction, req *approval.ApprovalRequest)",
+ "approval.RequesterForRequest(req)",
+ "action.ActionRequestedBy = requestedBy",
"mergeHandoffResourcePolicyContext(handoffContext, handoffResources, handoffResourceProvider)",
"mergeHandoffResourceStateContext(handoffContext, handoffResources, handoffResourceProvider)",
"mergeHandoffResourceRelationshipContext(handoffContext, handoffResources, handoffResourceProvider)",
@@ -386,6 +388,7 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
"ApprovalStatus",
"ActionID",
"ActionState",
+ "ActionRequestedBy",
"ActionPlanExpiresAt",
"ActionDryRunSummary",
"ActionResult",