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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Improve Patrol supporting context signal
rcourtman7f8db38aaca7
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 549b8c0e22..568a5cc144 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -502,6 +502,11 @@ the canonical monitored-system blocked payload.and the canonical alert-triggered Patrol enqueue path in `internal/api/router.go`, so alert-fired Patrol work flows through the unified alert bridge and trigger manager instead of being duplicated by monitor callback wiringand the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` card, so canonical recent-change timelines stay rendered through one governed frontend card instead of separate page-local list loopsand the shared `frontend-modern/src/utils/resourceChangePresentation.ts` formatter used by the summary page and resource drawer, so canonical change wording does not drift across surfaces+ and the Patrol-owned supporting-context selector, so same-state recent-change+ records from the canonical AI payload are normalized into changed-substate+ wording before Patrol renders them or attaches them to Assistant, avoiding+ no-op operator copy such as `online` to `online` while preserving the+ backend-owned timeline eventand the `/api/ai/intelligence/changes` route plus `internal/api/contract_test.go`, so the canonical recent-changes endpoint stays on the same intelligence facade and contract snapshot instead of bypassing the shared timeline sourceand the canonical policy-posture snapshot derived from unified resources, so sensitivity, routing, and redaction counts stay owned by the same AI summary contract instead of being reconstructed as a page-local governance rollupand the resource-intelligence payload carried by the drawer AI card, so the resource-detail surface stays on one canonical intelligence contract instead of introducing a separate detail endpointdiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex dd88e8daa4..2644650049 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -760,7 +760,10 @@ prompt explain the same operator-facing priority.decorative rather than a second label source. The Patrol-owned supporting-contextpresenter must also keep the disclosure toggle plus evidence-boundary copycentralized instead of letting the workspace reintroduce inline shell-local- trust wording. The same shared feature-shell boundary owns the+ trust wording, while the Patrol investigation-context owner normalizes+ same-state recent-change records into changed-substate wording before the+ workspace or Assistant handoff renders them. The same shared feature-shell+ boundary owns thecommercial-facing Patrol capability language: Pro-locked helper copy,autonomy segmented controls, and run-history/result labels must use`Remediate`, `remediated`, or safe remediation wording while legacy APIdiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 373f225b3c..470af63fcf 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -962,6 +962,11 @@ The Patrol page and resource drawer now also share the canonical`frontend-modern/src/utils/resourceChangePresentation.ts` formatter sorecent-change kind and headline wording stays aligned wherever the canonicaltimeline is surfaced.+Patrol-owned supporting context may still apply a bounded explanation-layer+normalization before rendering recent changes or attaching them to Assistant:+same-state timeline records must describe the changed substate, such as Docker+image status or command posture, instead of surfacing no-op wording like an+`online` to `online` transition in the Patrol page or Assistant handoff.The Patrol page and resource drawer now keep canonical relationship semanticsin the backend correlation path, while the visible frontend staystimeline-first and does not surface a separate relationship presentationdiff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsxindex 134160dcf5..e02dbfb49f 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx@@ -300,7 +300,7 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatsummaryText: state.investigationContextSummary(),},supportingEvidence: {- recentChanges: state.intelligenceSummary()?.recent_changes,+ recentChanges: state.supportingRecentChanges(),correlations: state.correlations(),},recommendedNextStep: {diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsxindex 6a3514ce1c..fb29ecbe61 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx@@ -171,7 +171,7 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceStclass="space-y-0"title="Recent changes"subtitle={PATROL_SUPPORTING_CONTEXT_CHANGE_SUBTITLE}- changes={state.intelligenceSummary()?.recent_changes}+ changes={state.supportingRecentChanges()}maxChanges={3}compact/>diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsxindex d3b69812e4..5c7e8c5ea2 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx@@ -378,6 +378,32 @@ function createPatrolState(): PatrolIntelligenceState {patrolStream: {isStreaming: () => false,},+ supportingRecentChanges: () => [+ {+ id: 'change-1',+ observedAt: '2026-05-06T12:08:00Z',+ resourceId: 'vm-100',+ kind: 'metric_anomaly',+ sourceType: 'heuristic',+ sourceAdapter: 'proxmox_adapter',+ confidence: 'high',+ relatedResources: ['backup-job'],+ reason: 'CPU spike after backup job',+ },+ {+ id: 'change-2',+ observedAt: '2026-05-06T12:07:00Z',+ resourceId: 'vm-100',+ kind: 'command_executed',+ sourceType: 'agent_action',+ sourceAdapter: 'agent:ops-helper',+ confidence: 'medium',+ reason: 'systemctl restart workload.service',+ metadata: {+ command: 'systemctl restart workload.service',+ },+ },+ ],setActiveTab: vi.fn(),setFindingsFilterOverride: vi.fn(),setSelectedRun: vi.fn(),diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex 0d286b822a..73543ea570 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -17,6 +17,7 @@ import {buildPatrolRemediationPlanAssistantBriefing,buildPatrolRemediationPlanAssistantPrompt,patrolAssistantFindingHandoffRequiresApprovalMode,+ selectPatrolSupportingRecentChanges,} from '../patrolInvestigationContextModel';describe('patrolInvestigationContextModel', () => {@@ -97,6 +98,72 @@ describe('patrolInvestigationContextModel', () => {});});+ it('normalizes same-state recent changes before Patrol uses them as Assistant context', () => {+ const changes = selectPatrolSupportingRecentChanges([+ {+ id: 'change-1',+ observedAt: '2026-05-06T12:08:00Z',+ resourceId: 'app-container-1',+ kind: 'state_transition',+ from: 'online',+ to: 'online',+ sourceType: 'pulse_diff',+ sourceAdapter: 'docker_adapter',+ confidence: 'high',+ reason: 'resource state changed',+ metadata: {+ changedFields: ['docker.command'],+ },+ },+ ]);++ expect(changes).toHaveLength(1);+ expect(changes[0]).toMatchObject({+ from: undefined,+ to: undefined,+ reason: 'Docker command changed while online',+ });+ });++ it('keeps same-state recent changes out of Patrol Assistant no-op wording', () => {+ const handoff = buildPatrolAssessmentAssistantHandoff({+ assessment: {+ title: 'Patrol runtime issue',+ description: 'Coverage is incomplete.',+ },+ investigationContext: {+ recentChangeCount: 1,+ correlationCount: 0,+ governedResourceCount: 0,+ hasContext: true,+ summaryText: '1 recent change',+ },+ supportingEvidence: {+ recentChanges: [+ {+ id: 'change-1',+ observedAt: '2026-05-06T12:08:00Z',+ resourceId: 'app-container-1',+ kind: 'state_transition',+ from: 'online',+ to: 'online',+ sourceType: 'pulse_diff',+ sourceAdapter: 'docker_adapter',+ confidence: 'high',+ reason: 'resource state changed',+ metadata: {+ changedFields: ['docker.command'],+ },+ },+ ],+ },+ activeFindings: [],+ });++ expect(handoff.context.handoffContext).toContain('Docker command changed while online');+ expect(handoff.context.handoffContext).not.toContain('online to online');+ });+it('builds a model-only Assistant handoff for the current Patrol assessment', () => {const handoff = buildPatrolAssessmentAssistantHandoff({assessment: {diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 097343a227..ca7be57e1f 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -307,6 +307,19 @@ const MAX_ASSESSMENT_RESOURCES = 8;const MAX_ASSESSMENT_HANDOFF_ACTIONS = 4;const MAX_PATROL_RUN_HANDOFF_RESOURCES = 8;const MAX_PATROL_BRIEFING_SUGGESTED_PROMPTS = 3;+const SAME_STATE_CHANGED_FIELD_LABELS: Record<string, string> = {+ 'docker.command': 'Docker command',+ 'docker.updateStatus': 'Docker image status',+ 'proxmox.lifecycle': 'Proxmox lifecycle',+ status: 'status',+ incidents: 'incident state',+ relationships: 'relationships',+ capabilities: 'capabilities',+ tags: 'tags',+ parentId: 'parent relationship',+ customUrl: 'custom URL',+ identity: 'identity',+};interface NormalizedPatrolAssessmentRecommendedNextStep {title: string;@@ -358,6 +371,12 @@ export function buildPatrolInvestigationContextSummary(};}+export function selectPatrolSupportingRecentChanges(+ changes?: ResourceChange[] | null,+): ResourceChange[] {+ return normalizeAssessmentRecentChanges(changes);+}+export function buildPatrolInvestigationRecordPresentation(record?: InvestigationRecord | null,): PatrolInvestigationRecordPresentation {@@ -1658,7 +1677,72 @@ function normalizeAssessmentRecentChanges(changes?: ResourceChange[] | null): RenormalizeText(change.id) || normalizeText(change.resourceId) || normalizeText(change.kind),),),- ).slice(0, MAX_ASSESSMENT_RECENT_CHANGES);+ )+ .map(normalizePatrolSupportingRecentChange)+ .slice(0, MAX_ASSESSMENT_RECENT_CHANGES);+}++function normalizePatrolSupportingRecentChange(change: ResourceChange): ResourceChange {+ if (!isSameStateTransition(change)) {+ return change;+ }++ const reason = formatSameStateTransitionReason(change);+ return {+ ...change,+ from: undefined,+ to: undefined,+ reason,+ };+}++function isSameStateTransition(change: ResourceChange): boolean {+ if (change.kind !== 'state_transition' && change.kind !== 'restart') {+ return false;+ }+ const from = normalizeText(change.from).toLowerCase();+ const to = normalizeText(change.to).toLowerCase();+ return Boolean(from && to && from === to);+}++function formatSameStateTransitionReason(change: ResourceChange): string {+ const state = normalizeText(change.from) || normalizeText(change.to) || 'current state';+ const changedFieldLabels = getSameStateChangedFieldLabels(change);+ if (changedFieldLabels.length > 0) {+ return `${formatCompactLabelList(changedFieldLabels)} changed while ${state}`;+ }++ const reason = normalizeText(change.reason);+ if (reason && reason.toLowerCase() !== 'resource state changed') {+ return `${reason} while ${state}`;+ }++ return `state details changed while ${state}`;+}++function getSameStateChangedFieldLabels(change: ResourceChange): string[] {+ const changedFields = change.metadata?.changedFields;+ if (!Array.isArray(changedFields)) {+ return [];+ }++ const labels: string[] = [];+ for (const field of changedFields) {+ const key = normalizeText(String(field));+ if (!key) continue;+ const label = SAME_STATE_CHANGED_FIELD_LABELS[key] ?? formatIdentifierLabel(key);+ if (label && !labels.includes(label)) {+ labels.push(label);+ }+ }+ return labels;+}++function formatCompactLabelList(labels: string[]): string {+ if (labels.length === 0) return '';+ if (labels.length === 1) return labels[0];+ if (labels.length === 2) return `${labels[0]} and ${labels[1]}`;+ return `${labels[0]}, ${labels[1]}, and ${labels.length - 2} more`;}function normalizeAssessmentCorrelations(diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex cfe600ce38..78e4b500a5 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -30,6 +30,7 @@ import { normalizePatrolRuntimeBlockedReason } from '@/utils/patrolRuntimePresenimport {buildPatrolConfigurationFailureHandoff,buildPatrolInvestigationContextSummary,+ selectPatrolSupportingRecentChanges,type PatrolConfigurationFailureInput,} from './patrolInvestigationContextModel';@@ -563,9 +564,18 @@ export function usePatrolIntelligenceState() {const intelligenceSummary = createMemo(() => aiIntelligenceStore.intelligenceSummary);const circuitBreakerStatus = createMemo(() => aiIntelligenceStore.circuitBreakerStatus);const policyPosture = createMemo(() => intelligenceSummary()?.policy_posture);+ const supportingRecentChanges = createMemo(() =>+ selectPatrolSupportingRecentChanges(intelligenceSummary()?.recent_changes),+ );+ const supportingRecentChangeCount = createMemo(() => {+ if (Array.isArray(intelligenceSummary()?.recent_changes)) {+ return supportingRecentChanges().length;+ }+ return intelligenceSummary()?.recent_changes_count;+ });const investigationContext = createMemo(() =>buildPatrolInvestigationContextSummary({- recentChangesCount: intelligenceSummary()?.recent_changes_count,+ recentChangesCount: supportingRecentChangeCount(),correlations: aiIntelligenceStore.correlations,policyPosture: policyPosture(),}),@@ -955,6 +965,7 @@ export function usePatrolIntelligenceState() {showInvestigationContext,shouldSurfaceInvestigationContext,summaryStats,+ supportingRecentChanges,triggerPatrolDisabledReason,};}