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
Show live approval state in Assistant handoff
rcourtman990f9fbc2157
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 34f5c42bc9..4d8dbb4f7c 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -411,6 +411,11 @@ the canonical monitored-system blocked payload.and the shared dashboard-load bundle inside `frontend-modern/src/stores/aiIntelligence.ts`, so the page orchestration stays on the store-owned bundle instead of enumerating the AI fetches inlineand the shared `frontend-modern/src/components/Infrastructure/ResourcePolicySummary.tsx` card, so the AI summary page renders the governed policy-posture counts while the resource drawer stays on per-resource policy lines instead of carrying duplicate posture UI loopsand the dedicated `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts` owner, so recent-change, learned-correlation, and policy-coverage summary text stays derived from the canonical AI payload in one place instead of as hook-local count and pluralization logic+ and that same Patrol investigation-context owner, so visible Assistant+ drawer handoffs may include live pending-approval metadata only as safe+ operator context: approval ID, status, risk, requested/expiry timestamps,+ and target label are allowed, while approval command payloads stay inside+ governed approval/remediation surfacesand the dedicated `frontend-modern/src/stores/aiIntelligenceSummaryModel.ts` owner, so recent-change counts and governed policy-posture fallbacks normalize once at the shared store boundary instead of as Patrol-hook-local payload repairand the shared `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx` card, so learned correlations and correlation context stay rendered through one governed frontend card instead of separate page-local list loopsand the same shared correlation card's ordering and truncation rule, so callers pass raw correlations instead of encoding their own top-N sort behavior@@ -2950,7 +2955,10 @@ step, and operator-decision framing plus approval/proposed-fix posture withoutraw command text. Patrol's frontend Assistant drawer briefing must use that sameoperator frame for visible handoffs from findings, while the downstream chatservice hydrates live resource state, timeline, and action audit context around-that same handoff.+that same handoff. Frontend Patrol handoff helpers may consume current pending+approval list payloads only as safe metadata for that visible briefing: approval+ID, status, risk, request/expiry timestamps, and target label are allowed, while+approval command text remains inside the governed approval/remediation surface.Patrol run-history serialization and persistence must also preserve full fieldparity across API responses and restart boundaries, including`pmg_checked`, `rejected_findings`, `triage_flags`, `triage_skipped_llm`, anddiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 29abe87383..85518edece 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -816,6 +816,10 @@ frontend primitive boundary.Patrol finding handoffs should still provide that briefing from currentfinding facts when a durable Patrol investigation record is not attachedyet, rather than opening the shared drawer as empty generic chat.+ When the feature helper adds live approval state to the generic drawer+ briefing, it may pass only safe approval metadata into+ `AIChatContextBriefing`; raw approval commands remain owned by the governed+ approval/remediation panels.11. Keep shared filter primitives coherent with route-owned option hydration.Feature shells such as `frontend-modern/src/features/infrastructure/`must keep a route-owned canonical option visible in shared selects likediff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex e9e5c91ed8..b8fdd89fb0 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -145,7 +145,11 @@ Patrol-specific presentation helpers.structured investigation record is not available yet, the same Patrol-ownedhelper must still brief the operator from current finding facts such asactive status, severity, recurrence, and loop state instead of opening a- generic empty Assistant drawer. The assembled handoff must still pass+ generic empty Assistant drawer. When a live pending Patrol approval exists+ for that finding, the visible Assistant briefing may include only safe+ approval metadata such as approval ID, pending status, risk, requested time,+ expiry, and target label; it must not copy the approval command payload into+ Assistant drawer prose. The assembled handoff must still passthrough the Assistant runtime'sresource-policy sanitizer before prompt injection, so Patrol-owned prosecannot leak governed resource names, IDs, aliases, nodes, paths, ordiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 330b3f3909..6c970b7bef 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -4115,11 +4115,13 @@"test_prefixes": [],"exact_files": ["frontend-modern/src/components/Brand/__tests__/PulsePatrolLogo.test.tsx",+ "frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts","frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx","frontend-modern/src/stores/__tests__/aiIntelligence.test.ts","frontend-modern/src/stores/__tests__/aiIntelligenceSummaryModel.test.ts","frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",- "tests/integration/tests/18-patrol-runtime-state.spec.ts"+ "tests/integration/tests/18-patrol-runtime-state.spec.ts",+ "tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts"]},{diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsxindex 7f6f8ff882..36f73998d6 100644--- a/frontend-modern/src/components/AI/FindingsPanel.tsx+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx@@ -417,10 +417,14 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {setEditingNoteId(null);};- const handleDiscussWithAssistant = (finding: UnifiedFinding, e: Event) => {+ const handleDiscussWithAssistant = async (finding: UnifiedFinding, e: Event) => {e.stopPropagation();+ await aiIntelligenceStore.loadPendingApprovals();const subject = getFindingSubjectPresentation(finding).label;const title = getFindingTitlePresentation(finding).label;+ const pendingApproval = aiIntelligenceStore.patrolPendingApprovals.find(+ (approval) => approval.toolId === 'investigation_fix' && approval.targetId === finding.id,+ );const prompt = buildPatrolAssistantFindingPrompt({title,subject,@@ -437,6 +441,16 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {regressionCount: finding.regressionCount,lastRegressionAt: finding.lastRegressionAt,remediationId: finding.remediationPlanId,+ pendingApproval: pendingApproval+ ? {+ id: pendingApproval.id,+ status: pendingApproval.status,+ riskLevel: pendingApproval.riskLevel,+ requestedAt: pendingApproval.requestedAt,+ expiresAt: pendingApproval.expiresAt,+ targetName: pendingApproval.targetName,+ }+ : undefined,investigationRecord: finding.investigationRecord,});aiChatStore.openWithPrompt(prompt, {diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.tsindex 7d5e8af52e..78dfd0c8c7 100644--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts@@ -47,6 +47,8 @@ describe('FindingsPanel assistant handoff', () => {expect(findingsPanelSource).toContain('buildPatrolAssistantFindingBriefing');expect(findingsPanelSource).toContain('briefing,');expect(findingsPanelSource).toContain('investigationRecord: finding.investigationRecord');+ expect(findingsPanelSource).toContain('pendingApproval: pendingApproval');+ expect(findingsPanelSource).toContain('await aiIntelligenceStore.loadPendingApprovals()');});});diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex 98bc2fb4e2..648d6254f6 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -158,6 +158,9 @@ describe('patrolInvestigationContextModel', () => {});it('builds a drawer briefing for Assistant handoff without exposing raw commands', () => {+ const approvalRequestedAt = new Date(Date.now() - 60_000).toISOString();+ const approvalExpiresAt = new Date(Date.now() + 10 * 60_000).toISOString();+const briefing = buildPatrolAssistantFindingBriefing({title: 'High CPU usage',subject: 'web-server',@@ -168,6 +171,14 @@ describe('patrolInvestigationContextModel', () => {regressionCount: 2,lastRegressionAt: '2026-05-06T12:06:00Z',remediationId: 'remediation-1',+ pendingApproval: {+ id: 'approval-1',+ status: 'pending',+ riskLevel: 'high',+ requestedAt: approvalRequestedAt,+ expiresAt: approvalExpiresAt,+ targetName: 'web-server',+ },investigationRecord: {id: 'record-1',finding_id: 'finding-1',@@ -199,10 +210,10 @@ describe('patrolInvestigationContextModel', () => {subject: 'High CPU usage on web-server',statusLabel: 'Completed · Fix Queued · High confidence',detailLines: [- 'Attention: active critical finding; regressed 2 times; last regression 2026-05-06T12:06:00Z; loop awaiting approval; approval approval-1; destructive proposed fix; fix queued for governed review',+ 'Attention: active critical finding; regressed 2 times; last regression 2026-05-06T12:06:00Z; loop awaiting approval; approval approval-1; live approval pending; destructive proposed fix; fix queued for governed review','Backup job saturated CPU.','Approve a controlled restart after the backup completes.',- 'Decision: review governed approval approval-1 before execution; proposed fix fix-1; risk medium; destructive true',+ `Decision: review live governed approval approval-1 before execution; approval pending; target web-server; expires ${approvalExpiresAt}; requested ${approvalRequestedAt}; proposed fix fix-1; risk high; destructive true`,],evidence: ['CPU stayed above 95% for 10 minutes', 'Verified: CPU returned below 50%'],actionLabel: 'Restart the workload service',diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 886641e9eb..cb0a99a5ca 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -47,6 +47,15 @@ export interface PatrolAssistantFindingPromptInput {investigationRecord?: InvestigationRecord | null;}+export interface PatrolAssistantApprovalBriefingInput {+ id?: string | null;+ status?: string | null;+ riskLevel?: string | null;+ requestedAt?: string | null;+ expiresAt?: string | null;+ targetName?: string | null;+}+export interface PatrolAssistantFindingBriefingInput {title: string;subject: string;@@ -57,6 +66,7 @@ export interface PatrolAssistantFindingBriefingInput {regressionCount?: number | null;lastRegressionAt?: string | null;remediationId?: string | null;+ pendingApproval?: PatrolAssistantApprovalBriefingInput | null;investigationRecord?: InvestigationRecord | null;}@@ -248,6 +258,10 @@ function buildPatrolAssistantAttentionReason(if (approvalId) {parts.push(`approval ${approvalId}`);}+ const pendingApproval = normalizeApprovalBriefing(input.pendingApproval);+ if (pendingApproval.status === 'pending') {+ parts.push('live approval pending');+ }if (record.proposedFix?.destructive) {parts.push('destructive proposed fix');}@@ -291,9 +305,24 @@ function buildPatrolAssistantOperatorDecision(const record = input.investigationRecord;if (record) {- const approvalId = normalizeText(record.approval_id);+ const pendingApproval = normalizeApprovalBriefing(input.pendingApproval);+ const approvalId = pendingApproval.id || normalizeText(record.approval_id);if (approvalId) {- const parts = [`review governed approval ${approvalId} before execution`];+ const parts = [+ `review ${pendingApproval.status === 'pending' ? 'live ' : ''}governed approval ${approvalId} before execution`,+ ];+ if (pendingApproval.status) {+ parts.push(`approval ${pendingApproval.status}`);+ }+ if (pendingApproval.targetName) {+ parts.push(`target ${pendingApproval.targetName}`);+ }+ if (pendingApproval.expiresAt) {+ parts.push(`expires ${pendingApproval.expiresAt}`);+ }+ if (pendingApproval.requestedAt) {+ parts.push(`requested ${pendingApproval.requestedAt}`);+ }if (record.proposed_fix) {const fixId = normalizeText(record.proposed_fix.id);if (fixId) {@@ -301,7 +330,7 @@ function buildPatrolAssistantOperatorDecision(} else if (normalizeText(record.proposed_fix.description)) {parts.push('proposed fix recorded');}- const risk = normalizeText(record.proposed_fix.risk_level);+ const risk = pendingApproval.riskLevel || normalizeText(record.proposed_fix.risk_level);if (risk) {parts.push(`risk ${risk}`);}@@ -340,6 +369,21 @@ function buildPatrolAssistantOperatorDecision(}}+ const pendingApproval = normalizeApprovalBriefing(input.pendingApproval);+ if (pendingApproval.id) {+ const parts = [`Review live governed approval ${pendingApproval.id} before execution.`];+ if (pendingApproval.status) {+ parts.push(`Status: ${pendingApproval.status}.`);+ }+ if (pendingApproval.targetName) {+ parts.push(`Target: ${pendingApproval.targetName}.`);+ }+ if (pendingApproval.expiresAt) {+ parts.push(`Expires: ${pendingApproval.expiresAt}.`);+ }+ return parts.join(' ');+ }+const remediationId = normalizeText(input.remediationId);if (remediationId) {return `Review governed remediation ${remediationId} before execution.`;@@ -375,6 +419,19 @@ function buildPatrolAssistantSafetyNote(return undefined;}+function normalizeApprovalBriefing(+ approval?: PatrolAssistantApprovalBriefingInput | null,+): Required<PatrolAssistantApprovalBriefingInput> {+ return {+ id: normalizeText(approval?.id),+ status: normalizeText(approval?.status).toLowerCase(),+ riskLevel: normalizeText(approval?.riskLevel).toLowerCase(),+ requestedAt: normalizeText(approval?.requestedAt),+ expiresAt: normalizeText(approval?.expiresAt),+ targetName: normalizeText(approval?.targetName),+ };+}+function normalizeCorrelationCount(correlations?: CorrelationsResponse | null): number {if (!correlations) return 0;if (typeof correlations.count === 'number' && Number.isFinite(correlations.count)) {diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex 936ebe0a6c..ce80d57a7b 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -15,11 +15,13 @@ RECOVERY_PRODUCT_SURFACE_EXACT_FILES = [PATROL_PAGE_AND_STATE_EXACT_FILES = ["frontend-modern/src/components/Brand/__tests__/PulsePatrolLogo.test.tsx",+ "frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts","frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx","frontend-modern/src/stores/__tests__/aiIntelligence.test.ts","frontend-modern/src/stores/__tests__/aiIntelligenceSummaryModel.test.ts","frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts","tests/integration/tests/18-patrol-runtime-state.spec.ts",+ "tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts",]PLATFORM_CONNECTIONS_WORKSPACE_EXACT_FILES = [diff --git a/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts b/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.tsindex 8a5032d327..36c584ccd7 100644--- a/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts+++ b/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts@@ -45,6 +45,37 @@ test.describe("Patrol Assistant operator briefing", () => {test("shows attention and operator-decision context in the Assistant drawer", async ({page,}) => {+ const approvalRequestedAt = new Date(Date.now() - 60_000).toISOString();+ const approvalExpiresAt = new Date(Date.now() + 10 * 60_000).toISOString();++ await page.route("**/api/security/status", async (route) => {+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({+ hasAuthentication: true,+ hasHTTPS: true,+ apiTokenConfigured: true,+ exportProtected: true,+ hideLocalLogin: false,+ publicAccess: false,+ requiresAuth: true,+ ssoEnabled: false,+ ssoProviders: [],+ sessionCapabilities: {+ assistantEnabled: true,+ demoMode: false,+ },+ presentationPolicy: {+ demoMode: false,+ readOnly: false,+ hideCommercial: false,+ hideUpgrade: false,+ },+ }),+ });+ });+await page.route("**/api/resources**", async (route) => {const requestUrl = new URL(route.request().url());if (requestUrl.pathname !== "/api/resources") {@@ -334,7 +365,23 @@ test.describe("Patrol Assistant operator briefing", () => {await route.fulfill({status: 200,contentType: "application/json",- body: JSON.stringify({ approvals: [] }),+ body: JSON.stringify({+ approvals: [+ {+ id: "approval-1",+ toolId: "investigation_fix",+ command: "systemctl restart workload.service",+ targetType: "host",+ targetId: "finding-operator-briefing",+ targetName: "web-server",+ context: "Restart the workload service",+ riskLevel: "high",+ status: "pending",+ requestedAt: approvalRequestedAt,+ expiresAt: approvalExpiresAt,+ },+ ],+ }),});});@@ -360,16 +407,16 @@ test.describe("Patrol Assistant operator briefing", () => {await expect(assistantContext).toBeVisible();await expect(assistantContext).toContainText("Operator briefing attached");await expect(assistantContext).toContainText(- "Attention: active critical finding; regressed 2 times; last regression 2026-05-06T12:06:00Z; loop awaiting approval; approval approval-1; destructive proposed fix; fix queued for governed review",+ "Attention: active critical finding; regressed 2 times; last regression 2026-05-06T12:06:00Z; loop awaiting approval; approval approval-1; live approval pending; destructive proposed fix; fix queued for governed review",);await expect(assistantContext).toContainText(- "Decision: review governed approval approval-1 before execution; proposed fix fix-1; risk medium; destructive true",+ `Decision: review live governed approval approval-1 before execution; approval pending; target web-server; expires ${approvalExpiresAt}; requested ${approvalRequestedAt}; proposed fix fix-1; risk high; destructive true`,);await expect(assistantContext).toContainText("Command details stay in approval context; destructive actions require governed approval.",);await expect(- page.getByText("systemctl restart workload.service"),+ assistantContext.getByText("systemctl restart workload.service"),).toHaveCount(0);await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });