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.

Add Assistant operator briefing handoff

rcourtman67974f2ada09
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 2920061bde..adedcbad2f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -985,6 +985,12 @@ prior chat session. Lifecycle-adjacent mobile pairing and setup flows depend
on `/api/ai/approvals` becoming ready from the first governed settings save,
not only after some earlier process-start or chat-start side effect has
already initialized the approval store.
+That same shared `internal/api/ai_handler.go` dependency now also assumes
+Assistant finding handoffs may include a model-only operator briefing from
+Patrol's unified finding and structured investigation record. Lifecycle-adjacent
+setup, install, and fleet surfaces may treat that briefing as adjacent
+AI/runtime guidance only; it must not become agent readiness, install status,
+or lifecycle execution authority.
That same shared dependency now also assumes hosted cloud handoff authorizes
tenant org access before browser lifecycle continues. Lifecycle-adjacent opens
into hosted workspaces may depend on `internal/api/cloud_handoff_handlers.go`,
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index b2db89ad12..2944fe6193 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -940,6 +940,14 @@ card, so the learned-correlation layout and edge wording stay aligned across
both surfaces. That shared card also owns the correlation ordering and
truncation rule, so callers pass raw learned edges instead of page-specific
top-N slices.
+Assistant finding handoffs now also receive a model-only operator briefing
+derived from the current unified finding and structured Patrol investigation
+record before the lower-level finding context. That briefing must summarize the
+finding, resource, priority, investigation confidence, recommended next step,
+and governed action posture as operator guidance, while leaving current
+resource-state, timeline, and action-audit hydration in the existing canonical
+AI runtime handoff builders. It is explanation and review context only, not
+approval or execution authority.
The same page and drawer now also render their recent-change timeline through
the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx`
card, so the canonical recent-change layout and relative-time wording stay
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 4d767c9738..35b4b99d12 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -308,6 +308,13 @@ the canonical monitored-system blocked payload.
hide/unhide, pending uninstall, display-name, and host metadata paths must
use Docker / Podman agent or host wording instead of generic container
runtime labels.
+3c. Route Assistant finding handoff context changes through
+ `internal/api/ai_handler.go`, `internal/api/ai_handler_test.go`, and
+ `internal/api/contract_test.go` together. Patrol-originated handoffs must
+ keep `[Operator Briefing]`, `[Finding Context]`, structured handoff
+ resources, and structured handoff actions model-only, with the briefing
+ summarizing operator next steps and governed action posture without raw
+ command text.
4. Route unified resource sensitivity, routing, and `aiSafeSummary` payload changes through `internal/api/resources.go`, `internal/api/contract_test.go`, and the canonical frontend resource consumer proofs together; resource governance metadata must not ship as an API-only or frontend-only heuristic
That same resource payload contract owns `aggregations.policyPosture` on
`/api/resources` and `/api/resources/stats`. The aggregation must be derived
@@ -2899,6 +2906,14 @@ actions visible even when no live pending approval remains and
`/api/ai/findings/{id}/investigation` resolves to `null` or omits
`proposed_fix`: queued remediation state cannot collapse into a dead badge with
no user action path.
+The `/api/ai/chat` finding handoff contract must also include a model-only
+`[Operator Briefing]` generated from the unified finding and structured Patrol
+investigation record before detailed `[Finding Context]`. The briefing is the
+canonical operator-facing frame for Assistant: it carries the finding summary,
+resource, priority, investigation confidence, recommended next step, and
+approval/proposed-fix posture without raw command text, and the downstream chat
+service then hydrates live resource state, timeline, and action audit context
+around that same handoff.
Patrol run-history serialization and persistence must also preserve full field
parity across API responses and restart boundaries, including
`pmg_checked`, `rejected_findings`, `triage_flags`, `triage_skipped_llm`, and
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index cd713747bb..6cddca4645 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -120,9 +120,14 @@ Patrol-specific presentation helpers.
for explanation; Assistant resolves those state, topology, and timeline
lookups through the current canonical unified-resource model before falling
back to handoff IDs where compatibility requires it.
- If the referenced finding is no longer current,
- Assistant must drop the stored handoff instead of continuing from stale
- Patrol context. Assistant handoff context must also carry the unified
+ Assistant handoffs from Patrol findings must also include a concise operator
+ briefing derived from the unified finding and structured investigation record
+ before the detailed finding context, so Assistant leads with the current risk,
+ conclusion, recommended next step, and governed approval/proposed-fix posture
+ instead of behaving like a generic chat over a pasted incident dump.
+ If the referenced finding is no longer current, Assistant must drop the
+ stored handoff instead of continuing from stale Patrol context. Assistant
+ handoff context must also carry the unified
finding's current lifecycle and recency facts, including active/resolved/
snoozed/dismissed/suppressed state, detection/last-seen/resolution
timestamps, recurrence/regression, and recent lifecycle events, rather than
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index cae7e5127f..b88b050956 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -443,6 +443,10 @@ Assistant handoff context may hydrate those normalized action-audit facts for
review, but that read is still model-only context: it must remain org-scoped,
must not expose raw command text or raw execution output, and must not grant
approval or execution authority.
+Assistant operator briefings generated from Patrol findings follow the same
+boundary: they may summarize approval IDs, proposed-fix IDs, risk, destructive
+posture, and recommended next steps for review, but they must not expose raw
+command payloads or convert chat into approval or execution authority.
Action planning and action decision mutations remain privileged runtime
control surfaces even though the decision endpoint does not execute the
capability. `POST /api/actions/plan` and
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d6a3b8199b..7a3513ebc5 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -437,6 +437,11 @@ bypass the API fail-closed execution gate.
bypass. Any refreshed approval or action-audit status snapshot in Assistant
handoff context is still read-only AI/runtime context and must not become
recovery freshness, restore eligibility, or storage-local execution state.
+ Operator briefings generated for those same Assistant finding handoffs are
+ also adjacent AI/runtime context only: storage and recovery surfaces may read
+ their Patrol conclusion or recommended next step as investigation guidance,
+ but must not reinterpret the briefing as backup recency, restore support, or
+ storage-local action authority.
That same adjacent `internal/api/` boundary still carries Patrol-run
execution identity. Storage and recovery may observe shared Patrol
transport through `internal/api/chat_service_adapter.go`, but they must not
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 97671b42e6..1049f66162 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -791,6 +791,7 @@ func buildUnifiedFindingChatContext(f *unified.UnifiedFinding) string {
}
var b strings.Builder
+ appendUnifiedFindingOperatorBriefingContext(&b, f)
appendChatContextLine(&b, "[Finding Context]", "")
appendChatContextLine(&b, "ID", f.ID)
appendChatContextLine(&b, "Title", f.Title)
@@ -859,6 +860,200 @@ func buildUnifiedFindingChatContext(f *unified.UnifiedFinding) string {
return b.String()
}
+func appendUnifiedFindingOperatorBriefingContext(b *strings.Builder, f *unified.UnifiedFinding) {
+ if b == nil || f == nil {
+ return
+ }
+
+ briefingSource := "Product structured finding"
+ if f.Source == unified.SourceAIPatrol {
+ briefingSource = "Pulse Patrol structured finding"
+ }
+
+ appendChatContextLine(b, "[Operator Briefing]", "")
+ appendChatContextLine(b, "Briefing Source", briefingSource)
+ appendChatContextLine(b, "Operator Role", "Explain the investigation, highlight current risk, and guide the operator through evidence, approval, or continued monitoring.")
+ appendChatContextLine(b, "Finding", formatUnifiedFindingBriefingFinding(f))
+ appendChatContextLine(b, "Resource", formatUnifiedFindingBriefingResource(f))
+ appendChatContextLine(b, "Priority", formatUnifiedFindingBriefingPriority(f))
+ appendChatContextLine(b, "Investigation", formatUnifiedFindingBriefingInvestigation(f))
+ appendChatContextLine(b, "Current Conclusion", unifiedFindingBriefingConclusion(f))
+ appendChatContextLine(b, "Recommended Next Step", unifiedFindingBriefingNextStep(f))
+ appendChatContextLine(b, "Action Posture", unifiedFindingBriefingActionPosture(f))
+ appendChatContextLine(b, "Operator Boundary", "Treat Patrol data as product context for explanation and review; do not invent commands, expose raw command text, or treat chat as approval or execution authority.")
+ appendChatContextLine(b, "", "")
+}
+
+func formatUnifiedFindingBriefingFinding(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ title := strings.TrimSpace(f.Title)
+ if title == "" {
+ title = strings.TrimSpace(f.ID)
+ }
+ qualifiers := nonEmptyStrings(
+ string(f.Severity),
+ string(f.Category),
+ unifiedFindingChatStatus(f, time.Now()),
+ )
+ if len(qualifiers) == 0 {
+ return title
+ }
+ if title == "" {
+ return strings.Join(qualifiers, ", ")
+ }
+ return title + " (" + strings.Join(qualifiers, ", ") + ")"
+}
+
+func formatUnifiedFindingBriefingResource(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ resource := formatChatResource(f.ResourceName, f.ResourceType)
+ resourceID := strings.TrimSpace(f.ResourceID)
+ if resourceID != "" {
+ if resource == "" {
+ resource = resourceID
+ } else {
+ resource += " [" + resourceID + "]"
+ }
+ }
+ if node := strings.TrimSpace(f.Node); node != "" {
+ if resource == "" {
+ resource = "node " + node
+ } else {
+ resource += " on " + node
+ }
+ }
+ return resource
+}
+
+func formatUnifiedFindingBriefingPriority(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ parts := nonEmptyStrings(
+ strings.TrimSpace(string(f.Severity)+" "+string(f.Category)),
+ "status "+unifiedFindingChatStatus(f, time.Now()),
+ )
+ if loopState := strings.TrimSpace(f.LoopState); loopState != "" {
+ parts = append(parts, "loop "+loopState)
+ }
+ if f.TimesRaised > 0 {
+ parts = append(parts, fmt.Sprintf("raised %d times", f.TimesRaised))
+ }
+ if f.RegressionCount > 0 {
+ parts = append(parts, fmt.Sprintf("regressed %d times", f.RegressionCount))
+ }
+ return strings.Join(parts, "; ")
+}
+
+func formatUnifiedFindingBriefingInvestigation(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ rec := f.InvestigationRecord
+ parts := make([]string, 0, 5)
+ if rec != nil {
+ parts = append(parts, nonEmptyStrings(
+ string(rec.Status),
+ briefingLabelValue("outcome", string(rec.Outcome)),
+ briefingLabelValue("confidence", string(rec.Confidence)),
+ )...)
+ } else {
+ parts = append(parts, nonEmptyStrings(
+ f.InvestigationStatus,
+ briefingLabelValue("outcome", f.InvestigationOutcome),
+ )...)
+ }
+ if f.InvestigationAttempts > 0 {
+ parts = append(parts, fmt.Sprintf("attempts %d", f.InvestigationAttempts))
+ }
+ if f.AIConfidence > 0 && (rec == nil || strings.TrimSpace(string(rec.Confidence)) == "") {
+ parts = append(parts, fmt.Sprintf("ai confidence %.2f", f.AIConfidence))
+ }
+ return strings.Join(parts, "; ")
+}
+
+func unifiedFindingBriefingConclusion(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+ if f.InvestigationRecord != nil {
+ if conclusion := strings.TrimSpace(f.InvestigationRecord.Conclusion); conclusion != "" {
+ return conclusion
+ }
+ }
+ for _, value := range []string{f.AIContext, f.Description, f.Evidence} {
+ if normalized := strings.TrimSpace(value); normalized != "" {
+ return normalized
+ }
+ }
+ return ""
+}
+
+func unifiedFindingBriefingNextStep(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+ if unifiedFindingChatStatus(f, time.Now()) == "resolved" {
+ return "Explain the resolution and any monitoring follow-up; do not propose execution unless a new active finding is raised."
+ }
+ if f.InvestigationRecord != nil {
+ if next := strings.TrimSpace(f.InvestigationRecord.RecommendedAction); next != "" {
+ return next
+ }
+ if f.InvestigationRecord.ProposedFix != nil {
+ if description := strings.TrimSpace(f.InvestigationRecord.ProposedFix.Description); description != "" {
+ return "Review proposed fix: " + description
+ }
+ }
+ }
+ if recommendation := strings.TrimSpace(f.Recommendation); recommendation != "" {
+ return recommendation
+ }
+ return "Explain what Patrol knows and identify the next evidence to verify before remediation."
+}
+
+func unifiedFindingBriefingActionPosture(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ rec := f.InvestigationRecord
+ parts := make([]string, 0, 5)
+ if rec != nil {
+ if approvalID := strings.TrimSpace(rec.ApprovalID); approvalID != "" {
+ parts = append(parts, "approval "+approvalID)
+ }
+ if rec.ProposedFix != nil {
+ if fixID := strings.TrimSpace(rec.ProposedFix.ID); fixID != "" {
+ parts = append(parts, "proposed fix "+fixID)
+ } else if description := strings.TrimSpace(rec.ProposedFix.Description); description != "" {
+ parts = append(parts, "proposed fix recorded")
+ }
+ if risk := strings.TrimSpace(rec.ProposedFix.RiskLevel); risk != "" {
+ parts = append(parts, "risk "+risk)
+ }
+ if rec.ProposedFix.Destructive {
+ parts = append(parts, "destructive true")
+ }
+ }
+ }
+ if remediationID := strings.TrimSpace(f.RemediationID); remediationID != "" {
+ parts = append(parts, "remediation "+remediationID)
+ }
+ if len(parts) == 0 {
+ return "No governed action is ready; keep the response investigative."
+ }
+ return strings.Join(parts, "; ")
+}
+
func unifiedFindingChatStatus(f *unified.UnifiedFinding, now time.Time) string {
if f == nil {
return ""
@@ -1108,6 +1303,28 @@ func appendStringListChatContext(b *strings.Builder, label string, values []stri
}
}
+func nonEmptyStrings(values ...string) []string {
+ out := make([]string, 0, len(values))
+ for _, value := range values {
+ if normalized := strings.TrimSpace(value); normalized != "" {
+ out = append(out, normalized)
+ }
+ }
+ return out
+}
+
+func briefingLabelValue(label, value string) string {
+ value = strings.TrimSpace(value)
+ if value == "" {
+ return ""
+ }
+ label = strings.TrimSpace(label)
+ if label == "" {
+ return value
+ }
+ return label + " " + value
+}
+
func appendChatContextLine(b *strings.Builder, label string, value string) {
label = strings.TrimSpace(label)
value = strings.TrimSpace(value)
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 8aa8bf7cea..107b8a1de3 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -673,6 +673,16 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
reqArg := args.Get(1).(chat.ExecuteRequest)
assert.Equal(t, "finding-123", reqArg.FindingID)
assert.Equal(t, "What happened?", reqArg.Prompt)
+ assert.Contains(t, reqArg.HandoffContext, "[Operator Briefing]")
+ assert.Contains(t, reqArg.HandoffContext, "Briefing Source: Pulse Patrol structured finding")
+ assert.Contains(t, reqArg.HandoffContext, "Finding: High CPU usage (critical, performance, active)")
+ assert.Contains(t, reqArg.HandoffContext, "Resource: web-server (vm) [vm-100] on pve-1")
+ assert.Contains(t, reqArg.HandoffContext, "Priority: critical performance; status active; loop awaiting_approval; raised 3 times; regressed 2 times")
+ assert.Contains(t, reqArg.HandoffContext, "Investigation: completed; outcome fix_queued; confidence high; attempts 1")
+ assert.Contains(t, reqArg.HandoffContext, "Current Conclusion: Backup job saturated CPU.")
+ assert.Contains(t, reqArg.HandoffContext, "Recommended Next Step: Approve a controlled service restart after backup completion.")
+ assert.Contains(t, reqArg.HandoffContext, "Action Posture: approval approval-123; proposed fix fix-123; risk medium; destructive true; remediation remediation-123")
+ assert.Contains(t, reqArg.HandoffContext, "Operator Boundary: Treat Patrol data as product context for explanation and review")
assert.Contains(t, reqArg.HandoffContext, "[Finding Context]")
assert.Contains(t, reqArg.HandoffContext, "[Investigation Record]")
assert.Contains(t, reqArg.HandoffContext, "Finding Status: active")
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index ab3d18d019..16849d75d5 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -163,6 +163,9 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
`appendChatContextLine(&b, "Regression Count", strconv.Itoa(f.RegressionCount))`,
`appendChatContextLine(&b, "Last Regression At", f.LastRegressionAt.Format(time.RFC3339))`,
"appendUnifiedFindingLifecycleEventContext(&b, f.Lifecycle)",
+ "appendUnifiedFindingOperatorBriefingContext(&b, f)",
+ "[Operator Briefing]",
+ "Operator Boundary",
`return "suppressed"`,
"Prompt:",
"HandoffContext:",