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.

Enrich Assistant related finding handoffs

rcourtman6269bc2afa1a
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index adedcbad2f..bb029b9fe3 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -368,14 +368,18 @@ profile and assignment columns, but embedded table framing must route through
the finding no longer resolves is also AI/runtime invalidation, not an agent
lifecycle transition. Unified finding lifecycle facts included in Assistant
handoff context remain Patrol/AI review metadata and must not become agent
- lifecycle state or fleet-control authority. Structured Assistant handoff action
- references from the same Patrol finding remain AI/runtime review metadata
- only; lifecycle code must not treat approval IDs, action IDs, fix IDs,
- action lifecycle state, risk, or target-resource labels from that handoff as
- agent command grants, enrollment proof, or auto-approval policy. Any approval
- or action-audit status snapshot refreshed for Assistant review remains
- read-only AI/runtime context and must not become command-websocket authority
- or lifecycle execution state.
+ lifecycle state or fleet-control authority. Related root-cause or correlated
+ finding summaries resolved for the same Assistant handoff follow that same
+ isolation rule: they may explain Patrol context to the model and seed
+ model-only handoff resources, but they are not enrollment evidence,
+ command-websocket identity, agent command grants, or auto-approval policy.
+ Structured Assistant handoff action references from the same Patrol finding
+ remain AI/runtime review metadata only; lifecycle code must not treat
+ approval IDs, action IDs, fix IDs, action lifecycle state, risk, or
+ target-resource labels from that handoff as agent command grants, enrollment
+ proof, or auto-approval policy. Any approval or action-audit status snapshot
+ refreshed for Assistant review remains read-only AI/runtime context and must
+ not become command-websocket authority or lifecycle execution state.
The same isolation rule applies to CSRF token-store behavior in
`internal/api/csrf_store.go`: lifecycle-adjacent browser flows may rely on
the shared API/security layer to keep parallel replacement-token retries
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index d77b44c525..50b6885721 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -189,7 +189,14 @@ runtime cost control, and shared AI transport surfaces.
persist as session model-context metadata so follow-up turns can refresh the
current unified finding and investigation record before model execution;
those references remain model-only context selectors, not saved user text or
- lifecycle authority. If the referenced finding no longer resolves through
+ lifecycle authority. When the current finding identifies root-cause or
+ correlated finding IDs, Assistant may resolve those related findings through
+ the current unified finding store and include compact related-finding
+ summaries plus their structured handoff resources as model-only explanation
+ context. Those related findings must be deduplicated, bounded, refreshed
+ from current store state, and treated only as context for the same operator
+ conversation; they do not grant approval, lifecycle, disclosure, or
+ execution authority. If the referenced finding no longer resolves through
the current unified finding store, Assistant must invalidate the stored
model-only handoff and unpinned handoff-seeded resource scope instead of
falling back to stale investigation context. The refreshed finding context
@@ -950,12 +957,16 @@ 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 assembled briefing is 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.
+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
+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
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 d7367b316b..b55cfeed98 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -312,12 +312,16 @@ the canonical monitored-system blocked payload.
`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. Chat execution owns resource-policy sanitization of the
- assembled model-only handoff before prompt injection, so API payload
- builders may pass structured product context without turning raw resource
- identity into user-authored text or disclosure authority.
+ 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
+ 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
+ context without turning raw resource identity into user-authored text or
+ disclosure authority.
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
@@ -778,7 +782,12 @@ 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 hydrate canonical
+ summary. 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,
+ disclosure authority, lifecycle authority, approval authority, or execution
+ authority. Chat execution may also hydrate canonical
resource-policy context for those resources through unified-resource
resolution and shared policy presentation helpers, but the resulting handling
guidance is read-only, model-only 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 03f968eca0..ac8e56417d 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -120,6 +120,13 @@ 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.
+ When a Patrol finding declares root-cause or correlated finding IDs, the
+ Assistant handoff may also resolve those related findings through the current
+ unified finding store and summarize them as model-only context. Those
+ related finding summaries may seed their own structured resources for the
+ same canonical policy, state, topology, and timeline hydration, but Patrol
+ presentation must treat them as explanation for the current finding rather
+ than approval, lifecycle, disclosure, or execution authority.
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,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7a3513ebc5..222dd6576c 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -426,11 +426,16 @@ bypass the API fail-closed execution gate.
approval references carried by that handoff are also adjacent AI/runtime
review metadata only. Unified finding lifecycle facts carried by the same
handoff remain Patrol/AI review metadata and must not become backup recency,
- restore support, or storage-local lifecycle state. Current resource-state,
- source-health, incident, metric, and capability summaries carried by that
- handoff are also adjacent AI/runtime context and must not become backup
- freshness, restore eligibility, recovery execution authority, or
- storage-local capability truth.
+ restore support, or storage-local lifecycle state. Related root-cause or
+ correlated finding summaries resolved for that Assistant handoff are also
+ adjacent AI/runtime explanation context only; storage and recovery surfaces
+ must not reinterpret those related records or their seeded handoff resources
+ as backup freshness, restore eligibility, recovery execution authority, or
+ storage-local capability truth. Current resource-state, source-health,
+ incident, metric, and capability summaries carried by that handoff are also
+ adjacent AI/runtime context and must not become backup freshness, restore
+ eligibility, recovery execution authority, or storage-local capability
+ truth.
storage and recovery surfaces must not reinterpret approval IDs, action IDs,
action lifecycle state, fix IDs, risk, or target labels as restore support,
backup freshness, recovery execution authority, or a storage-local approval
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 1049f66162..934d48cffe 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -785,7 +785,16 @@ type ChatRequest struct {
const findingChatContextListLimit = 5
-func buildUnifiedFindingChatContext(f *unified.UnifiedFinding) string {
+type unifiedFindingLookup interface {
+ Get(findingID string) *unified.UnifiedFinding
+}
+
+type unifiedRelatedFindingContext struct {
+ Label string
+ Finding *unified.UnifiedFinding
+}
+
+func buildUnifiedFindingChatContext(f *unified.UnifiedFinding, lookup unifiedFindingLookup) string {
if f == nil {
return ""
}
@@ -834,6 +843,7 @@ func buildUnifiedFindingChatContext(f *unified.UnifiedFinding) string {
}
appendChatContextLine(&b, "Root Cause ID", f.RootCauseID)
appendStringListChatContext(&b, "Correlated Finding", f.CorrelatedIDs)
+ appendUnifiedFindingRelatedContext(&b, f, lookup)
appendChatContextLine(&b, "Remediation ID", f.RemediationID)
appendChatContextLine(&b, "Investigation Status", f.InvestigationStatus)
appendChatContextLine(&b, "Investigation Outcome", f.InvestigationOutcome)
@@ -860,6 +870,94 @@ func buildUnifiedFindingChatContext(f *unified.UnifiedFinding) string {
return b.String()
}
+func appendUnifiedFindingRelatedContext(b *strings.Builder, f *unified.UnifiedFinding, lookup unifiedFindingLookup) {
+ if b == nil || f == nil || lookup == nil {
+ return
+ }
+ related := resolveUnifiedFindingRelatedContext(f, lookup)
+ if len(related) == 0 {
+ return
+ }
+
+ appendChatContextLine(b, "", "")
+ appendChatContextLine(b, "[Related Finding Context]", "")
+ for _, item := range related {
+ if item.Finding == nil {
+ continue
+ }
+ appendChatContextLine(b, item.Label, formatUnifiedRelatedFindingSummary(item.Finding))
+ }
+ appendChatContextLine(b, "Related Finding Boundary", "Related findings are current unified finding context for explanation only; they do not grant approval or execution authority.")
+}
+
+func resolveUnifiedFindingRelatedContext(f *unified.UnifiedFinding, lookup unifiedFindingLookup) []unifiedRelatedFindingContext {
+ if f == nil || lookup == nil {
+ return nil
+ }
+
+ related := make([]unifiedRelatedFindingContext, 0, findingChatContextListLimit)
+ seen := map[string]struct{}{
+ strings.ToLower(strings.TrimSpace(f.ID)): {},
+ }
+ add := func(label, findingID string) {
+ if len(related) >= findingChatContextListLimit {
+ return
+ }
+ findingID = strings.TrimSpace(findingID)
+ if findingID == "" {
+ return
+ }
+ key := strings.ToLower(findingID)
+ if _, ok := seen[key]; ok {
+ return
+ }
+ seen[key] = struct{}{}
+ relatedFinding := lookup.Get(findingID)
+ if relatedFinding == nil {
+ return
+ }
+ related = append(related, unifiedRelatedFindingContext{
+ Label: label,
+ Finding: relatedFinding,
+ })
+ }
+
+ add("Root Cause Finding", f.RootCauseID)
+ correlatedCount := 0
+ for _, findingID := range f.CorrelatedIDs {
+ correlatedCount++
+ add(fmt.Sprintf("Correlated Finding %d", correlatedCount), findingID)
+ if len(related) >= findingChatContextListLimit {
+ break
+ }
+ }
+ return related
+}
+
+func formatUnifiedRelatedFindingSummary(f *unified.UnifiedFinding) string {
+ if f == nil {
+ return ""
+ }
+
+ parts := make([]string, 0, 5)
+ if id := strings.TrimSpace(f.ID); id != "" {
+ parts = append(parts, id)
+ }
+ if finding := formatUnifiedFindingBriefingFinding(f); finding != "" {
+ parts = append(parts, finding)
+ }
+ if resource := formatUnifiedFindingBriefingResource(f); resource != "" {
+ parts = append(parts, "resource "+resource)
+ }
+ if investigation := formatUnifiedFindingBriefingInvestigation(f); investigation != "" {
+ parts = append(parts, "investigation "+investigation)
+ }
+ if conclusion := unifiedFindingBriefingConclusion(f); conclusion != "" {
+ parts = append(parts, "conclusion "+conclusion)
+ }
+ return strings.Join(parts, " | ")
+}
+
func appendUnifiedFindingOperatorBriefingContext(b *strings.Builder, f *unified.UnifiedFinding) {
if b == nil || f == nil {
return
@@ -1163,12 +1261,12 @@ func appendInvestigationRecordChatContext(b *strings.Builder, rec *aicontracts.I
}
}
-func buildUnifiedFindingHandoffResources(f *unified.UnifiedFinding) []chat.HandoffResource {
+func buildUnifiedFindingHandoffResources(f *unified.UnifiedFinding, lookup unifiedFindingLookup) []chat.HandoffResource {
if f == nil {
return nil
}
- resources := make([]chat.HandoffResource, 0, 2)
+ resources := make([]chat.HandoffResource, 0, 2+findingChatContextListLimit)
add := func(resource chat.HandoffResource) {
resource.ID = strings.TrimSpace(resource.ID)
resource.Name = strings.TrimSpace(resource.Name)
@@ -1201,6 +1299,26 @@ func buildUnifiedFindingHandoffResources(f *unified.UnifiedFinding) []chat.Hando
Node: f.InvestigationRecord.Subject.Node,
})
}
+ for _, related := range resolveUnifiedFindingRelatedContext(f, lookup) {
+ relatedFinding := related.Finding
+ if relatedFinding == nil {
+ continue
+ }
+ add(chat.HandoffResource{
+ ID: relatedFinding.ResourceID,
+ Name: relatedFinding.ResourceName,
+ Type: relatedFinding.ResourceType,
+ Node: relatedFinding.Node,
+ })
+ if relatedFinding.InvestigationRecord != nil {
+ add(chat.HandoffResource{
+ ID: relatedFinding.InvestigationRecord.Subject.ResourceID,
+ Name: relatedFinding.InvestigationRecord.Subject.ResourceName,
+ Type: relatedFinding.InvestigationRecord.Subject.ResourceType,
+ Node: relatedFinding.InvestigationRecord.Subject.Node,
+ })
+ }
+ }
return resources
}
@@ -1511,8 +1629,8 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {
if store != nil {
if f := store.Get(findingID); f != nil {
findingResolved = true
- handoffContext = buildUnifiedFindingChatContext(f)
- handoffResources = buildUnifiedFindingHandoffResources(f)
+ handoffContext = buildUnifiedFindingChatContext(f, store)
+ handoffResources = buildUnifiedFindingHandoffResources(f, store)
handoffActions = buildUnifiedFindingHandoffActions(f)
}
}
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 107b8a1de3..c79918049e 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -663,6 +663,53 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
ApprovalID: "approval-123",
},
})
+ store.AddFromAI(&unified.UnifiedFinding{
+ ID: "finding-root",
+ Source: unified.SourceAIPatrol,
+ Severity: unified.SeverityWarning,
+ Category: unified.CategoryCapacity,
+ ResourceID: "storage-100",
+ ResourceName: "backup-store",
+ ResourceType: "storage",
+ Node: "pve-1",
+ Title: "Backup storage pressure",
+ Description: "Backup storage latency increased before the CPU spike.",
+ DetectedAt: detectedAt.Add(-5 * time.Minute),
+ LastSeenAt: lastSeenAt,
+ AIContext: "Backup storage pressure preceded the workload CPU saturation.",
+ AIConfidence: 0.74,
+ InvestigationStatus: "completed",
+ InvestigationOutcome: "root_cause",
+ })
+ store.AddFromAI(&unified.UnifiedFinding{
+ ID: "finding-storage",
+ Source: unified.SourceAIPatrol,
+ Severity: unified.SeverityWarning,
+ Category: unified.CategoryCapacity,
+ ResourceID: "storage-200",
+ ResourceName: "vm-datastore",
+ ResourceType: "storage",
+ Node: "pve-2",
+ Title: "Datastore latency",
+ Description: "Datastore writes were elevated during the same window.",
+ DetectedAt: detectedAt.Add(-4 * time.Minute),
+ LastSeenAt: lastSeenAt,
+ InvestigationStatus: "completed",
+ InvestigationOutcome: "correlated",
+ InvestigationRecord: &aicontracts.InvestigationRecord{
+ ID: "investigation-storage",
+ Subject: aicontracts.InvestigationRecordSubject{
+ ResourceID: "storage-200",
+ ResourceName: "vm-datastore",
+ ResourceType: "storage",
+ Node: "pve-2",
+ },
+ Status: aicontracts.InvestigationStatusCompleted,
+ Outcome: aicontracts.OutcomeResolved,
+ Confidence: aicontracts.InvestigationRecordConfidenceMedium,
+ Conclusion: "Datastore latency recovered after backup completion.",
+ },
+ })
h.SetUnifiedStore(store)
mockSvc.On("IsRunning").Return(true)
@@ -694,6 +741,10 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
assert.Contains(t, reqArg.HandoffContext, "AI Confidence: 0.87")
assert.Contains(t, reqArg.HandoffContext, "Root Cause ID: finding-root")
assert.Contains(t, reqArg.HandoffContext, "Correlated Finding 1: finding-storage")
+ assert.Contains(t, reqArg.HandoffContext, "[Related Finding Context]")
+ assert.Contains(t, reqArg.HandoffContext, "Root Cause Finding: finding-root | Backup storage pressure (warning, capacity, active) | resource backup-store (storage) [storage-100] on pve-1 | investigation completed; outcome root_cause; ai confidence 0.74 | conclusion Backup storage pressure preceded the workload CPU saturation.")
+ assert.Contains(t, reqArg.HandoffContext, "Correlated Finding 1: finding-storage | Datastore latency (warning, capacity, active) | resource vm-datastore (storage) [storage-200] on pve-2 | investigation completed; outcome resolved; confidence medium | conclusion Datastore latency recovered after backup completion.")
+ assert.Contains(t, reqArg.HandoffContext, "Related Finding Boundary: Related findings are current unified finding context for explanation only")
assert.Contains(t, reqArg.HandoffContext, "Remediation ID: remediation-123")
assert.Contains(t, reqArg.HandoffContext, "Last Investigated At: 2026-05-06T12:04:00Z")
assert.Contains(t, reqArg.HandoffContext, "Investigation Attempts: 1")
@@ -715,6 +766,16 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
Name: "web-server",
Type: "vm",
Node: "pve-1",
+ }, {
+ ID: "storage-100",
+ Name: "backup-store",
+ Type: "storage",
+ Node: "pve-1",
+ }, {
+ ID: "storage-200",
+ Name: "vm-datastore",
+ Type: "storage",
+ Node: "pve-2",
}}, reqArg.HandoffResources)
assert.Equal(t, []chat.HandoffAction{{
FindingID: "finding-123",
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index d38e959d5a..bf4c3c042b 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -142,8 +142,8 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
for _, required := range []string{
`svc.GetModelHandoffFindingID(ctx, req.SessionID)`,
`svc.ClearModelHandoffContext(ctx, sessionID)`,
- "handoffContext = buildUnifiedFindingChatContext(f)",
- "handoffResources = buildUnifiedFindingHandoffResources(f)",
+ "handoffContext = buildUnifiedFindingChatContext(f, store)",
+ "handoffResources = buildUnifiedFindingHandoffResources(f, store)",
"handoffActions = buildUnifiedFindingHandoffActions(f)",
`appendChatContextLine(&b, "Finding Status", unifiedFindingChatStatus(f, time.Now()))`,
`appendChatContextLine(&b, "Finding Detected At", f.DetectedAt.Format(time.RFC3339))`,
@@ -156,6 +156,9 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
`appendChatContextLine(&b, "AI Context", f.AIContext)`,
`appendChatContextLine(&b, "Root Cause ID", f.RootCauseID)`,
`appendStringListChatContext(&b, "Correlated Finding", f.CorrelatedIDs)`,
+ "appendUnifiedFindingRelatedContext(&b, f, lookup)",
+ "[Related Finding Context]",
+ "Related Finding Boundary",
`appendChatContextLine(&b, "Remediation ID", f.RemediationID)`,
`appendChatContextLine(&b, "Last Investigated At", f.LastInvestigatedAt.Format(time.RFC3339))`,
`appendChatContextLine(&b, "Investigation Attempts", strconv.Itoa(f.InvestigationAttempts))`,