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.

Surface Assistant finding lifecycle context

rcourtman1f424523da2d
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index bb029b9fe3..b3284c3728 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -366,7 +366,8 @@ profile and assignment columns, but embedded table framing must route through
AI/runtime context selector and still cannot become agent enrollment,
lifecycle, or command-websocket authority. Clearing that stored handoff when
the finding no longer resolves is also AI/runtime invalidation, not an agent
- lifecycle transition. Unified finding lifecycle facts included in Assistant
+ lifecycle transition. Unified finding lifecycle facts, latest lifecycle
+ event briefing lines, and detailed lifecycle context included in Assistant
handoff context remain Patrol/AI review metadata and must not become agent
lifecycle state or fleet-control authority. Related root-cause or correlated
finding summaries resolved for the same Assistant handoff follow that same
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 50b6885721..e2dceb2c83 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -204,7 +204,10 @@ runtime cost control, and shared AI transport surfaces.
resolved, snoozed, dismissed or suppressed state, detection/last-seen/
resolved timestamps, recurrence, regression, and recent lifecycle events so
Assistant explains the current Patrol record rather than only the original
- investigation narrative. Assistant runtime may also hydrate canonical
+ investigation narrative. The operator briefing may surface the latest
+ lifecycle event as the current handoff state, and detailed lifecycle events
+ must stay in a bounded `[Finding Lifecycle Context]` block with an explicit
+ model-only boundary. Assistant runtime may also hydrate canonical
resource-policy context for those handoff resources, using the same
unified-resource resolution and policy presentation helpers that govern
mention prefetch and provider-bound redaction; that context remains
@@ -956,15 +959,17 @@ 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, related-finding, and action-audit hydration in the
-existing canonical AI runtime handoff builders. Related root-cause and
+latest lifecycle event, and governed action posture as operator guidance, while
+leaving detailed lifecycle history, current resource-state, timeline,
+related-finding, and action-audit hydration in the existing canonical AI
+runtime handoff builders. Related root-cause and
correlated finding records may be summarized from current unified finding state
and may seed their own handoff resources for canonical policy, state, topology,
and timeline hydration. That related context is explanation and review context
-only, not approval or execution authority. The assembled briefing and related
-context are policy-sanitized by the chat handoff runtime before prompt
-injection, so governed resource names, IDs, aliases, nodes, paths, and
+only, not approval or execution authority. Detailed lifecycle events are
+likewise current Patrol review context only. The assembled briefing, lifecycle,
+and related context are policy-sanitized by the chat handoff runtime before
+prompt injection, so governed resource names, IDs, aliases, nodes, paths, and
addresses are redacted or represented through the canonical AI-safe summary
instead of leaking through product prose.
The same page and drawer now also render their recent-change timeline through
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b55cfeed98..c493f82d86 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -311,12 +311,13 @@ the canonical monitored-system blocked payload.
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, related root-cause/correlation finding context, and structured
- handoff actions model-only, with the briefing summarizing operator next
- steps and governed action posture without raw command text. Related finding
- context must resolve from the current unified finding store, stay bounded
- and deduplicated, and seed only structured handoff resources for canonical
+ keep `[Operator Briefing]`, `[Finding Context]`, `[Finding Lifecycle
+ Context]`, structured handoff resources, related root-cause/correlation
+ finding context, and structured handoff actions model-only, with the
+ briefing summarizing operator next steps, latest lifecycle event, and
+ governed action posture without raw command text. Related finding context
+ must resolve from the current unified finding store, stay bounded and
+ deduplicated, and seed only structured handoff resources for canonical
policy, state, topology, and timeline hydration. Chat execution owns
resource-policy sanitization of the assembled model-only handoff before
prompt injection, so API payload builders may pass structured product
@@ -782,7 +783,9 @@ the canonical monitored-system blocked payload.
snoozed/dismissed/suppressed status, detection/last-seen/resolution
timestamps, recurrence/regression facts, and recent lifecycle events, so API
consumers do not reduce Assistant context to an outdated investigation
- summary. Chat execution may also resolve root-cause and correlated finding
+ summary. The briefing may carry the latest lifecycle event as the current
+ handoff state, while the detailed lifecycle list must stay bounded and
+ model-only. Chat execution may also resolve root-cause and correlated finding
IDs from that current unified finding into compact related-finding summaries
and structured handoff resources, but those related records remain
model-only explanation context and must not become saved user text,
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index ac8e56417d..19a647409b 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -130,9 +130,10 @@ Patrol-specific presentation helpers.
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. The
- assembled handoff must still pass through the Assistant runtime's
+ conclusion, latest lifecycle event, recommended next step, and governed
+ approval/proposed-fix posture instead of behaving like a generic chat over a
+ pasted incident dump. 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
addresses outside the canonical policy boundary.
@@ -142,10 +143,12 @@ Patrol-specific presentation helpers.
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
- treating the investigation conclusion as the whole current record. Patrol
- must keep the visible finding and drawer briefing tied to the shared
- investigation payload rather than forking a Patrol-local lifecycle, policy,
- topology, or timeline summary.
+ treating the investigation conclusion as the whole current record. Detailed
+ lifecycle events in Assistant handoff context must stay bounded, model-only,
+ and explicitly separated from approval/execution authority. Patrol must keep
+ the visible finding and drawer briefing tied to the shared investigation
+ payload rather than forking a Patrol-local lifecycle, policy, topology, or
+ timeline summary.
## Current State
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 222dd6576c..065ab7a931 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -424,7 +424,8 @@ bypass the API fail-closed execution gate.
finding no longer resolves is adjacent AI/runtime invalidation, not a
recovery freshness or restore-support decision. Structured action or
approval references carried by that handoff are also adjacent AI/runtime
- review metadata only. Unified finding lifecycle facts carried by the same
+ review metadata only. Unified finding lifecycle facts, latest lifecycle
+ event briefing lines, and detailed lifecycle context carried by the same
handoff remain Patrol/AI review metadata and must not become backup recency,
restore support, or storage-local lifecycle state. Related root-cause or
correlated finding summaries resolved for that Assistant handoff are also
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 934d48cffe..fdcc9dfd22 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -975,6 +975,9 @@ func appendUnifiedFindingOperatorBriefingContext(b *strings.Builder, f *unified.
appendChatContextLine(b, "Resource", formatUnifiedFindingBriefingResource(f))
appendChatContextLine(b, "Priority", formatUnifiedFindingBriefingPriority(f))
appendChatContextLine(b, "Investigation", formatUnifiedFindingBriefingInvestigation(f))
+ if latestLifecycle := formatUnifiedFindingLatestLifecycleEvent(f.Lifecycle); latestLifecycle != "" {
+ appendChatContextLine(b, "Latest Lifecycle Event", latestLifecycle)
+ }
appendChatContextLine(b, "Current Conclusion", unifiedFindingBriefingConclusion(f))
appendChatContextLine(b, "Recommended Next Step", unifiedFindingBriefingNextStep(f))
appendChatContextLine(b, "Action Posture", unifiedFindingBriefingActionPosture(f))
@@ -1180,32 +1183,64 @@ func appendUnifiedFindingLifecycleEventContext(b *strings.Builder, events []unif
if len(events) > findingChatContextListLimit {
start = len(events) - findingChatContextListLimit
}
+ type formattedLifecycleEvent struct {
+ Label string
+ Summary string
+ }
+ formatted := make([]formattedLifecycleEvent, 0, findingChatContextListLimit)
for idx, event := range events[start:] {
- parts := make([]string, 0, 4)
- if !event.At.IsZero() {
- parts = append(parts, event.At.Format(time.RFC3339))
- }
- eventType := strings.TrimSpace(event.Type)
- if eventType != "" {
- parts = append(parts, eventType)
- }
- message := strings.TrimSpace(event.Message)
- if message != "" {
- parts = append(parts, message)
- }
- from := strings.TrimSpace(event.From)
- to := strings.TrimSpace(event.To)
- if from != "" || to != "" {
- parts = append(parts, from+" -> "+to)
- }
- if len(parts) == 0 {
+ summary := formatUnifiedFindingLifecycleEvent(event)
+ if summary == "" {
continue
}
- appendChatContextLine(b, fmt.Sprintf("Lifecycle Event %d", idx+1), strings.Join(parts, " | "))
+ formatted = append(formatted, formattedLifecycleEvent{
+ Label: fmt.Sprintf("Lifecycle Event %d", idx+1),
+ Summary: summary,
+ })
+ }
+ if len(formatted) == 0 {
+ return
+ }
+
+ appendChatContextLine(b, "", "")
+ appendChatContextLine(b, "[Finding Lifecycle Context]", "")
+ for _, event := range formatted {
+ appendChatContextLine(b, event.Label, event.Summary)
}
if start > 0 {
appendChatContextLine(b, "Lifecycle Additional Count", strconv.Itoa(start))
}
+ appendChatContextLine(b, "Lifecycle Boundary", "Finding lifecycle events are current Patrol review context only; they do not grant approval or execution authority.")
+}
+
+func formatUnifiedFindingLatestLifecycleEvent(events []unified.UnifiedFindingLifecycleEvent) string {
+ for idx := len(events) - 1; idx >= 0; idx-- {
+ if summary := formatUnifiedFindingLifecycleEvent(events[idx]); summary != "" {
+ return summary
+ }
+ }
+ return ""
+}
+
+func formatUnifiedFindingLifecycleEvent(event unified.UnifiedFindingLifecycleEvent) string {
+ parts := make([]string, 0, 4)
+ if !event.At.IsZero() {
+ parts = append(parts, event.At.Format(time.RFC3339))
+ }
+ eventType := strings.TrimSpace(event.Type)
+ if eventType != "" {
+ parts = append(parts, eventType)
+ }
+ message := strings.TrimSpace(event.Message)
+ if message != "" {
+ parts = append(parts, message)
+ }
+ from := strings.TrimSpace(event.From)
+ to := strings.TrimSpace(event.To)
+ if from != "" || to != "" {
+ parts = append(parts, from+" -> "+to)
+ }
+ return strings.Join(parts, " | ")
}
func appendInvestigationRecordChatContext(b *strings.Builder, rec *aicontracts.InvestigationRecord) {
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index c79918049e..4cf14bf924 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -726,6 +726,7 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
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, "Latest Lifecycle Event: 2026-05-06T12:03:00Z | investigation_completed | Fix queued for approval | investigating -> fix_queued")
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")
@@ -751,7 +752,9 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
assert.Contains(t, reqArg.HandoffContext, "Loop State: awaiting_approval")
assert.Contains(t, reqArg.HandoffContext, "Regression Count: 2")
assert.Contains(t, reqArg.HandoffContext, "Last Regression At: 2026-05-06T12:06:00Z")
+ assert.Contains(t, reqArg.HandoffContext, "[Finding Lifecycle Context]")
assert.Contains(t, reqArg.HandoffContext, "Lifecycle Event 2: 2026-05-06T12:03:00Z | investigation_completed | Fix queued for approval | investigating -> fix_queued")
+ assert.Contains(t, reqArg.HandoffContext, "Lifecycle Boundary: Finding lifecycle events are current Patrol review context only")
assert.Contains(t, reqArg.HandoffContext, "Resource ID: vm-100")
assert.Contains(t, reqArg.HandoffContext, "Subject Resource ID: vm-100")
assert.Contains(t, reqArg.HandoffContext, "Conclusion: Backup job saturated CPU.")
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index bf4c3c042b..1397667bc2 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -166,8 +166,12 @@ 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)",
+ "formatUnifiedFindingLatestLifecycleEvent(f.Lifecycle)",
+ "[Finding Lifecycle Context]",
+ "Lifecycle Boundary",
"appendUnifiedFindingOperatorBriefingContext(&b, f)",
"[Operator Briefing]",
+ "Latest Lifecycle Event",
"Operator Boundary",
`return "suppressed"`,
"Prompt:",