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
Carry Patrol recommendation into Assistant handoffs
rcourtmanfc6612c5ecb1
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 4b34b8aca0..3aa81e7459 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -508,7 +508,8 @@ the canonical monitored-system blocked payload.and that same Patrol investigation-context owner, so the current Patrolassessment summary may open Assistant with bounded model-only assessment,verification, latest-run, supporting-context evidence, active-finding, and- resource reference context plus safe source-owned suggested prompts; active+ resource reference context plus safe source-owned suggested prompts and the+ Patrol-owned recommended next step as safe metadata; activefinding entries may carry live pending Patrol approval posture only as safestructured handoff actions with approval ID/status/risk/target/request/expirymetadata, action plan identity/policy/expiry, dry-run posture, and command@@ -516,13 +517,15 @@ the canonical monitored-system blocked payload.and may derive visible action labels, safety notes, and approval-awaresuggested prompts plus first-turn prompt emphasis from that same safe metadataso the drawer does not fall back to generic assessment copy when governed- actions are present+ actions are present or when the summary already exposes a concrete+ recommended next stepand that same Patrol investigation-context owner, so coverage-incompleteassessments with no active infrastructure findings are serialized as averification-gap handoff: prompt and visible briefing copy must explain whatscoped activity did and did not prove, keep latest-run and supporting-context- facts model-only, and avoid introducing backend fields beyond the existing- Patrol status plus run-history contracts+ facts model-only, carry the existing summary recommendation as safe+ handoff-only metadata, and avoid introducing backend fields beyond the+ existing Patrol status plus run-history contractsand that same Patrol investigation-context owner, so visible Assistantdrawer handoffs may include live pending-approval metadata only as safeoperator context: approval ID, status, risk, requested/expiry timestamps,diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex da41b36f5b..bd499cba52 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -231,7 +231,10 @@ the Patrol helper owns the decision text, while the section component onlyrenders a compact inline accent and one bounded action inside the existingassessment shell. Feature-owned recommendation actions may use the sharedbutton/link shape, but they must not create a second full-width action band or-nest another card inside the primary Pulse surface.+nest another card inside the primary Pulse surface. If the same assessment+opens Assistant, the Patrol-to-Assistant handoff must carry that exact+recommendation as safe bounded metadata so the drawer briefing and first-turn+prompt explain the same operator-facing priority.1. Add shared primitives in `frontend-modern/src/components/shared/`Framed product table surfaces must consume the shared `TableCard` frame and@@ -538,8 +541,9 @@ nest another card inside the primary Pulse surface.`frontend-modern/src/components/Settings/ConnectionEditor/ConnectionEditor.tsx`,but the editor now serves as governed dialog content under the sourcemanager rather than replacing the page inline. The `?add=pick` route owns- the grouped source-type picker, `?add=detect` owns the detect-from-address- utility, and typed add routes jump straight into the matching credential+ the search-first infrastructure source finder, `?add=detect` owns the+ detect-from-address utility, and typed add routes jump straight into the+ matching credentialslot through `initialType`.The picker and typed add dialog must use the shared source-strategyvocabulary so users choose between API inventory, Agent telemetry, and API@@ -975,10 +979,10 @@ nest another card inside the primary Pulse surface.`frontend-modern/src/utils/workloadEmptyStatePresentation.ts`. Both theinfrastructure empty state and the Workloads no-resources state must routefirst-time operators into the canonical- `/settings/infrastructure?add=pick` source picker, describe platform API- inventory and Pulse Agent telemetry as equal source strategies, and avoid- falling back to either passive “nothing here yet” wording or the retired- install-first / `Platform connections` split. Workloads routes that already+ `/settings/infrastructure?add=pick` source picker, let operators choose by+ recognizable system/service names instead of collection-method taxonomy,+ and avoid falling back to either passive “nothing here yet” wording or the+ retired install-first / `Platform connections` split. Workloads routes that alreadyhave canonical unified-resource infrastructure sources but no workloadinventory must use a distinct no-inventory presentation that pointsoperators at credentials, permissions, and collection status in thediff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 6af25e31ad..331d022be1 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -241,7 +241,11 @@ Patrol-specific presentation helpers.verification recency, latest run, secondary investigation context, boundedrecent-change and learned-correlation evidence, active-finding summaries,structured resource references, structured approval/action references, and- safe source-owned suggested prompts as model-only context. Active-finding+ safe source-owned suggested prompts as model-only context. The same handoff+ must also carry the Patrol-owned recommended next step as safe bounded+ metadata, including its title, detail copy, action label, and known action+ kind when present, so Assistant explains the same operator-facing priority+ shown in the summary card instead of inventing a separate next step. Active-findingsummaries may include live pending approval posture only as safe metadata:approval ID, pending status, risk, target, requested/expiry timestamps,action plan identity, approval policy, plan expiry, dry-run posture, and@@ -332,15 +336,20 @@ opens Assistant throughpackages the current Patrol assessment, verification posture, latest run,secondary investigation context, bounded recent-change and learned-correlationevidence, bounded active-finding summaries, source-owned suggested prompts, and-deduped resource references plus safe structured approval/action references as+the Patrol-owned recommended next step, plus deduped resource references and+safe structured approval/action references asmodel-only context while forcing `autonomousMode:false` and summarizingproposed-fix command-bearing records and command-bearing change events withoutraw command text. Its visible Assistant briefing must also use those safereferences to distinguish pending governed approvals or attached actionreferences from a generic assessment discussion, including approval-policy and-dry-run posture when available, and its initial prompt must prioritize those-approvals or action references before broader assessment discussion while-command payloads stay out of the drawer.+dry-run posture when available. When no approval or governed action outranks+the summary recommendation, the briefing action label and initial prompt may+lead with that recommendation, but Assistant remains explanatory and may not+start Patrol runs, settings changes, diagnostics, remediation, or approvals+from the handoff. Its initial prompt must prioritize approvals or action+references before broader assessment discussion while command payloads stay+out of the drawer.Run-history rows now follow that same Assistant handoff model. A selected`frontend-modern/src/components/patrol/RunHistoryEntry.tsx` row may openAssistant throughdiff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsxindex 1bef979302..8fa26d84c0 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx@@ -279,8 +279,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat});},);- const assessmentAssistantHandoff = createMemo(() =>- buildPatrolAssessmentAssistantHandoff({+ const assessmentAssistantHandoff = createMemo(() => {+ const recommendation = recommendedNextStep();+ return buildPatrolAssessmentAssistantHandoff({assessment: assessment(),overallHealth: state.intelligenceSummary()?.overall_health,scoreChipLabel: scoreChipLabel(),@@ -299,9 +300,15 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatrecentChanges: state.intelligenceSummary()?.recent_changes,correlations: state.correlations(),},+ recommendedNextStep: {+ title: recommendation.title,+ description: recommendation.description,+ actionLabel: recommendation.action?.label,+ actionKind: recommendation.action?.kind,+ },activeFindings: activeFindingsWithApprovalContext(),- }),- );+ });+ });const handleDiscussAssessment = async () => {await aiIntelligenceStore.loadPendingApprovals();diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsxindex c98be4d3ae..b4ae664370 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx@@ -74,6 +74,12 @@ describe('PatrolIntelligenceSummary', () => {expect(context.handoffContext).toContain('[Patrol Assessment Context]');expect(context.handoffContext).toContain('Source: Pulse Patrol current assessment');expect(context.handoffContext).toContain('Supporting Context: 2 recent changes');+ expect(context.handoffContext).toContain(+ 'Recommended Next Step: Review the pending Patrol approval',+ );+ expect(context.handoffContext).toContain(+ 'Recommended Next Step Action: Review approvals (review_approvals)',+ );expect(context.handoffContext).toContain('Recent Change 1: Metric anomaly');expect(context.handoffContext).toContain('Correlation 1: Nightly backup job');expect(context.handoffContext).toContain('Finding 1: High CPU usage');@@ -84,6 +90,8 @@ describe('PatrolIntelligenceSummary', () => {expect(context.handoffContext).toContain('expires 2026-05-06T12:10:00Z');expect(context.context).toMatchObject({pendingApprovalCount: 1,+ recommendedNextStepTitle: 'Review the pending Patrol approval',+ recommendedNextStepActionKind: 'review_approvals',});expect(context.handoffResources).toEqual([{ id: 'vm-100', name: 'web-server', type: 'vm', node: 'pve-1' },@@ -114,6 +122,11 @@ describe('PatrolIntelligenceSummary', () => {'Review pending approvals and safest next step',],});+ expect((context.briefing as { detailLines?: string[] }).detailLines).toEqual(+ expect.arrayContaining([+ expect.stringContaining('Recommended next step: Review the pending Patrol approval'),+ ]),+ );expect(JSON.stringify(context)).not.toContain('systemctl restart workload.service');});});diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex 323c36de6a..9ad6cfb4b3 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -328,13 +328,24 @@ describe('patrolInvestigationContextModel', () => {hasContext: true,summaryText: '100 recent changes · 29 correlations · 116 policy-covered resources',},+ recommendedNextStep: {+ title: 'Verify full coverage',+ description:+ 'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.',+ actionLabel: 'Run Patrol',+ actionKind: 'run_patrol',+ },activeFindings: [],});expect(handoff.prompt).toContain('why Patrol coverage is incomplete');expect(handoff.prompt).toContain('what the latest scoped activity did and did not prove');+ expect(handoff.prompt).toContain(+ 'Patrol\'s visible recommended next step is "Verify full coverage"',+ );+ expect(handoff.prompt).toContain('available Patrol-owned action: Run Patrol');expect(handoff.context.briefing).toMatchObject({- actionLabel: 'Review coverage gap',+ actionLabel: 'Recommended: Run Patrol',safetyNote:'Assistant can explain the gap; full Patrol runs, diagnostics, and remediation remain operator-controlled.',suggestedPrompts: [@@ -344,9 +355,48 @@ describe('patrolInvestigationContextModel', () => {],});expect(handoff.context.handoffContext).toContain('Assessment: Coverage incomplete');+ expect(handoff.context.handoffContext).toContain('Recommended Next Step: Verify full coverage');+ expect(handoff.context.handoffContext).toContain(+ 'Recommended Next Step Action: Run Patrol (run_patrol)',+ );expect(handoff.context.handoffContext).toContain('Supporting Context: 100 recent changes · 29 correlations · 116 policy-covered resources',);+ expect(handoff.context.context).toMatchObject({+ recommendedNextStepTitle: 'Verify full coverage',+ recommendedNextStepActionKind: 'run_patrol',+ });+ });++ it('withholds unsafe recommendation text from assessment handoffs', () => {+ const handoff = buildPatrolAssessmentAssistantHandoff({+ assessment: {+ title: 'Coverage incomplete',+ description: 'Patrol coverage is incomplete.',+ },+ overallHealth: {+ grade: 'C',+ score: 65,+ factors: [{ category: 'coverage' }],+ },+ recommendedNextStep: {+ title: 'Run sudo systemctl restart workload.service',+ description: 'Use token abc123 before running curl against the host.',+ actionLabel: 'sudo restart',+ actionKind: 'run_patrol',+ },+ });++ expect(handoff.context.handoffContext).toContain('Recommended Next Step: Run Patrol');+ expect(handoff.context.handoffContext).toContain(+ 'Recommended Next Step Detail: sensitive or command detail withheld',+ );+ expect(handoff.context.handoffContext).toContain(+ 'Recommended Next Step Action: Run Patrol (run_patrol)',+ );+ expect(JSON.stringify(handoff)).not.toContain('systemctl');+ expect(JSON.stringify(handoff)).not.toContain('abc123');+ expect(JSON.stringify(handoff)).not.toContain('curl');});it('carries live governed approval posture into assessment finding handoffs', () => {diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 1b0f9c462a..a3c38d511b 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -194,6 +194,20 @@ export interface PatrolAssessmentAssistantFindingInput {investigationRecord?: InvestigationRecord | null;}+export type PatrolAssessmentRecommendedNextStepActionKind =+ | 'discuss_assessment'+ | 'open_provider_settings'+ | 'review_approvals'+ | 'review_findings'+ | 'run_patrol';++export interface PatrolAssessmentRecommendedNextStepInput {+ title?: string | null;+ description?: string | null;+ actionLabel?: string | null;+ actionKind?: PatrolAssessmentRecommendedNextStepActionKind | string | null;+}+export interface PatrolAssessmentAssistantHandoffInput {assessment?: {title?: string | null;@@ -239,6 +253,7 @@ export interface PatrolAssessmentAssistantHandoffInput {recentChanges?: ResourceChange[] | null;correlations?: ResourceCorrelation[] | null;} | null;+ recommendedNextStep?: PatrolAssessmentRecommendedNextStepInput | null;activeFindings?: PatrolAssessmentAssistantFindingInput[] | null;}@@ -291,6 +306,26 @@ const MAX_ASSESSMENT_HANDOFF_ACTIONS = 4;const MAX_PATROL_RUN_HANDOFF_RESOURCES = 8;const MAX_PATROL_BRIEFING_SUGGESTED_PROMPTS = 3;+interface NormalizedPatrolAssessmentRecommendedNextStep {+ title: string;+ description?: string;+ actionLabel?: string;+ actionKind?: PatrolAssessmentRecommendedNextStepActionKind;+ actionSummary?: string;+}++const PATROL_ASSESSMENT_RECOMMENDED_NEXT_STEP_ACTION_LABELS: Record<+ PatrolAssessmentRecommendedNextStepActionKind,+ string+> = {+ discuss_assessment: 'Discuss with Assistant',+ open_provider_settings: 'Open provider settings',+ review_approvals: 'Review approvals',+ review_findings: 'Review findings',+ run_patrol: 'Run Patrol',+};+const WITHHELD_RECOMMENDATION_TEXT = 'sensitive or command detail withheld';+export function buildPatrolInvestigationContextSummary(input: PatrolInvestigationContextSummaryInput,): PatrolInvestigationContextSummary {@@ -504,6 +539,7 @@ export function buildPatrolAssessmentAssistantHandoff(): PatrolAssessmentAssistantHandoff {const title = normalizeText(input.assessment?.title) || 'Pulse Patrol assessment';const description = normalizeText(input.assessment?.description);+ const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);const handoffContext = buildPatrolAssessmentAssistantModelContext(input);const recentChanges = normalizeAssessmentRecentChanges(input.supportingEvidence?.recentChanges);const correlations = normalizeAssessmentCorrelations(input.supportingEvidence?.correlations);@@ -531,6 +567,12 @@ export function buildPatrolAssessmentAssistantHandoff(correlationDetailCount: correlations.length,governedResourceCount: input.investigationContext?.governedResourceCount ?? 0,pendingApprovalCount: normalizeAssessmentPendingApprovalCount(input.activeFindings),+ ...(recommendedNextStep+ ? {+ recommendedNextStepTitle: recommendedNextStep.title,+ recommendedNextStepActionKind: recommendedNextStep.actionKind,+ }+ : {}),},},};@@ -717,6 +759,7 @@ function buildPatrolAssessmentAssistantPrompt(const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);const actionCount = handoffActions.length;const hasCoverageGap = assessmentHasCoverageGap(input);+ const recommendationInstruction = buildPatrolAssessmentRecommendationPromptInstruction(input);const reviewInstruction =pendingApprovalCount > 0? `Start by reviewing ${formatAssessmentMetricCount(@@ -736,6 +779,7 @@ function buildPatrolAssessmentAssistantPrompt(`Discuss the current Pulse Patrol assessment: ${title}.`,description,reviewInstruction,+ recommendationInstruction,'Do not infer, repeat, or execute raw command text from this handoff.',].filter(isNonEmptyString)@@ -752,6 +796,9 @@ function buildPatrolAssessmentAssistantBriefing(const verification = formatAssessmentVerification(input);const latestRun = formatAssessmentLatestRun(input);const contextSummary = normalizeText(input.investigationContext?.summaryText);+ const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);+ const recommendedNextStepLine =+ formatAssessmentRecommendedNextStepDetailLine(recommendedNextStep);const findings = normalizeAssessmentFindings(input.activeFindings);const recentChanges = normalizeAssessmentRecentChanges(input.supportingEvidence?.recentChanges);const correlations = normalizeAssessmentCorrelations(input.supportingEvidence?.correlations);@@ -770,9 +817,9 @@ function buildPatrolAssessmentAssistantBriefing(title: 'Patrol assessment attached',subject: title,statusLabel: [health, attentionSummary].filter(isNonEmptyString).join(' · ') || undefined,- detailLines: [description, verification, latestRun, contextSummary]+ detailLines: [description, recommendedNextStepLine, verification, latestRun, contextSummary].filter(isNonEmptyString)- .slice(0, 4),+ .slice(0, 5),evidence: [...findingEvidence.slice(0, 3), ...supportingEvidence].slice(0, 5),actionLabel: actionPosture.actionLabel,safetyNote: actionPosture.safetyNote,@@ -784,6 +831,41 @@ function buildPatrolAssessmentAssistantBriefing(};}+function buildPatrolAssessmentRecommendationPromptInstruction(+ input: PatrolAssessmentAssistantHandoffInput,+): string | undefined {+ const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);+ if (!recommendedNextStep) return undefined;++ const parts = [+ `Patrol's visible recommended next step is "${recommendedNextStep.title}"`,+ recommendedNextStep.description+ ? `detail: ${truncateContextText(recommendedNextStep.description, 180)}`+ : undefined,+ recommendedNextStep.actionLabel+ ? `available Patrol-owned action: ${recommendedNextStep.actionLabel}`+ : undefined,+ ].filter(isNonEmptyString);++ return `${parts.join('; ')}. Explain that recommendation before alternatives, but keep Patrol runs, settings changes, diagnostics, remediation, and approvals in governed controls.`;+}++function formatAssessmentRecommendedNextStepDetailLine(+ recommendedNextStep?: NormalizedPatrolAssessmentRecommendedNextStep,+): string | undefined {+ if (!recommendedNextStep) return undefined;++ return formatBriefingStringList(+ [+ `Recommended next step: ${recommendedNextStep.title}`,+ recommendedNextStep.description,+ recommendedNextStep.actionLabel ? `action ${recommendedNextStep.actionLabel}` : undefined,+ ],+ 3,+ 'recommendation facts',+ );+}+function buildPatrolAssessmentActionPosture(input: PatrolAssessmentAssistantHandoffInput,handoffActions: AIChatHandoffAction[],@@ -791,6 +873,7 @@ function buildPatrolAssessmentActionPosture(const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);const actionCount = handoffActions.length;const hasCoverageGap = assessmentHasCoverageGap(input);+ const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);const hasDryRunPosture = handoffActions.some((action) =>Boolean(normalizeText(action.actionDryRunSummary) || normalizeText(action.actionPreflight)),);@@ -831,12 +914,22 @@ function buildPatrolAssessmentActionPosture(if (hasCoverageGap) {return {- actionLabel: 'Review coverage gap',+ actionLabel: recommendedNextStep?.actionLabel+ ? `Recommended: ${recommendedNextStep.actionLabel}`+ : 'Review coverage gap',safetyNote:'Assistant can explain the gap; full Patrol runs, diagnostics, and remediation remain operator-controlled.',};}+ if (recommendedNextStep?.actionLabel || recommendedNextStep?.title) {+ return {+ actionLabel: `Recommended: ${recommendedNextStep.actionLabel || recommendedNextStep.title}`,+ safetyNote:+ 'Assistant can explain the Patrol recommendation; Patrol runs, settings changes, diagnostics, and remediation remain operator-controlled.',+ };+ }+return {actionLabel: 'Discuss Patrol assessment',safetyNote: 'Diagnostics and remediation require governed approval.',@@ -964,6 +1057,7 @@ function assessmentFindingHasGovernedAction(function buildPatrolAssessmentAssistantModelContext(input: PatrolAssessmentAssistantHandoffInput,): string {+ const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);const findings = normalizeAssessmentFindings(input.activeFindings);const recentChanges = normalizeAssessmentRecentChanges(input.supportingEvidence?.recentChanges);const correlations = normalizeAssessmentCorrelations(input.supportingEvidence?.correlations);@@ -991,6 +1085,9 @@ function buildPatrolAssessmentAssistantModelContext(formatContextLine('Assessment Scope', input.assessment?.eyebrow),formatContextLine('Health', formatAssessmentHealth(input)),formatContextLine('Attention', formatAssessmentAttentionSummary(input)),+ formatContextLine('Recommended Next Step', recommendedNextStep?.title),+ formatContextLine('Recommended Next Step Detail', recommendedNextStep?.description),+ formatContextLine('Recommended Next Step Action', recommendedNextStep?.actionSummary),formatContextLine('Verification', formatAssessmentVerification(input)),formatContextLine('Last Patrol', formatAssessmentRecency(input)),formatContextLine('Latest Run', formatAssessmentLatestRun(input)),@@ -2631,6 +2728,82 @@ function formatPatrolSuggestedPrompts(values: string[]): string[] {);}+function normalizeAssessmentRecommendedNextStep(+ input?: PatrolAssessmentRecommendedNextStepInput | null,+): NormalizedPatrolAssessmentRecommendedNextStep | undefined {+ if (!input) return undefined;++ const actionKind = normalizeAssessmentRecommendedNextStepActionKind(input.actionKind);+ const title = formatSafeAssessmentRecommendationText(input.title, 140);+ const description = formatSafeAssessmentRecommendationText(input.description, 260);+ const fallbackActionLabel = actionKind+ ? PATROL_ASSESSMENT_RECOMMENDED_NEXT_STEP_ACTION_LABELS[actionKind]+ : undefined;+ const safeActionLabel = formatSafeAssessmentRecommendationText(input.actionLabel, 80);+ const actionLabel =+ safeActionLabel === WITHHELD_RECOMMENDATION_TEXT && fallbackActionLabel+ ? fallbackActionLabel+ : safeActionLabel || fallbackActionLabel;+ const effectiveTitle =+ title === WITHHELD_RECOMMENDATION_TEXT && actionLabel ? actionLabel : title || actionLabel;+ const actionSummary = formatAssessmentRecommendedNextStepActionSummary(actionLabel, actionKind);++ if (!effectiveTitle && !description && !actionSummary) {+ return undefined;+ }++ return {+ title: effectiveTitle || 'Review Patrol recommendation',+ description,+ actionLabel,+ actionKind,+ actionSummary,+ };+}++function normalizeAssessmentRecommendedNextStepActionKind(+ value?: string | null,+): PatrolAssessmentRecommendedNextStepActionKind | undefined {+ const normalized = normalizeText(value).toLowerCase();+ if (!normalized) return undefined;+ return Object.prototype.hasOwnProperty.call(+ PATROL_ASSESSMENT_RECOMMENDED_NEXT_STEP_ACTION_LABELS,+ normalized,+ )+ ? (normalized as PatrolAssessmentRecommendedNextStepActionKind)+ : undefined;+}++function formatAssessmentRecommendedNextStepActionSummary(+ actionLabel?: string,+ actionKind?: PatrolAssessmentRecommendedNextStepActionKind,+): string | undefined {+ if (actionLabel && actionKind) return `${actionLabel} (${actionKind})`;+ if (actionLabel) return actionLabel;+ if (actionKind) return PATROL_ASSESSMENT_RECOMMENDED_NEXT_STEP_ACTION_LABELS[actionKind];+ return undefined;+}++function formatSafeAssessmentRecommendationText(+ value?: string | null,+ limit: number = 240,+): string | undefined {+ const normalized = truncateContextText(value, limit);+ if (!normalized) return undefined;+ if (assessmentRecommendationTextShouldBeWithheld(normalized)) {+ return WITHHELD_RECOMMENDATION_TEXT;+ }+ return normalized;+}++function assessmentRecommendationTextShouldBeWithheld(value: string): boolean {+ return (+ /(password|secret|token|api[_-]?key|credential|private[_-]?key)/i.test(value) ||+ /\b(systemctl|sudo|bash|sh\s+-c|curl|wget|kubectl)\b/i.test(value) ||+ /\b(docker|ssh)\s+\S+/i.test(value)+ );+}+function formatBriefingStringList(values: Array<string | undefined>,limit: number,