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.

Prioritize Patrol findings in Assistant handoffs

rcourtmanb213b59f7a57
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index a20385ecea..da23e2c57b 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -635,6 +635,13 @@ This prevents the score chip from showing grade A while the same
assessment surface warns the operator that coverage is incomplete or
recent runs failed, which previously happened whenever one successful
manual run sat among many failed startup runs.
+Downstream Assistant handoffs must treat that coverage factor as a
+secondary caveat when Patrol also carries active findings, pending
+approvals, or governed action references. The coverage-gap explanation
+and scoped-activity prompt are primary Assistant framing only for
+coverage-only assessments; active Patrol findings keep the prompt,
+briefing action label, and safety note focused on finding priority,
+affected resources, evidence, and the governed next step.
Absence-based auto-resolve paths in `internal/ai/patrol_ai.go` are
all gated on the category whitelist exposed by
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f4cb49f858..049f9a6da7 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -551,6 +551,12 @@ the canonical monitored-system blocked payload.
so the drawer does not fall back to generic assessment copy when governed
actions are present or when the summary already exposes a concrete
recommended next step
+ and that same Patrol investigation-context owner, so coverage signals from
+ the canonical AI summary remain secondary caveats when the same assessment
+ carries active findings, pending approvals, or governed action references;
+ Assistant prompt emphasis, briefing action labels, and safety notes must
+ lead with finding priority, affected resources, evidence, and the governed
+ next step instead of recasting the whole handoff as a coverage gap
and that same Patrol investigation-context owner, so coverage-incomplete
assessments with no active infrastructure findings are serialized as a
verification-gap handoff: prompt and visible briefing copy must explain what
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index d75e8e4fe4..a777d49923 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1019,7 +1019,11 @@ prompt explain the same operator-facing priority.
without parsing a compressed context sentence. The same feature helper owns
recommendation-aware suggested prompts; shared drawer primitives must render
those prompts without replacing a provider-settings recovery path with
- generic coverage wording. Finding-level drawer opens may also pass one bounded
+ generic coverage wording. Assessment-level Patrol prompts, action labels,
+ and safety notes must also prioritize active findings, pending approvals,
+ and governed action references over secondary coverage caveats, reserving
+ coverage-gap-first wording for assessments with no active findings.
+ Finding-level drawer opens may also pass one bounded
model-only finding context, one target resource reference, one safe
route-owned next-step action label/href, and one `handoff_actions` reference
for a live approval or proposed fix. It must not expose raw command or
@@ -2474,7 +2478,9 @@ or polling lifecycle. The Patrol feature is the current reference shape:
feature shell, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
owns the runtime state machine, `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`
owns the pure investigation-context summary and Patrol-to-Assistant operator
-briefing derivation,
+briefing derivation, including the rule that active findings, pending
+approvals, and governed action references outrank secondary coverage caveats
+when building the Assistant prompt, action label, and safety note,
`frontend-modern/src/stores/aiIntelligenceSummaryModel.ts` owns canonical AI
summary normalization at the shared store boundary, and the Patrol-owned
header/banner/summary/workspace section files under
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 32d0ee9cfc..d59ca96ccd 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -620,6 +620,12 @@ must not pair an `Issues detected` headline with a raw coverage-only
`overall_health.prediction` sentence from a separate source; when active
findings and incomplete verification are both true, the Patrol summary should
describe both in one canonical assessment message.
+The same precedence applies to Patrol-to-Assistant assessment handoffs. An
+active finding, pending approval, or governed action reference must remain the
+primary Assistant prompt and briefing posture even when the attached model
+context carries a secondary coverage caveat. Coverage-incomplete language such
+as explaining scoped activity or a full-run gap is the primary handoff framing
+only for coverage-only assessments with no active findings.
That same assessment contract must also distinguish Patrol-owned runtime
findings from infrastructure findings. When the only active Patrol findings are
synthetic Patrol service/runtime conditions such as the `ai-service`
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
index aa783a000f..468c01fc98 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
@@ -182,6 +182,21 @@ describe('PatrolIntelligenceSummary', () => {
},
}),
manualRunRequested: () => false,
+ patrolRunHistory: {
+ value: () => [
+ {
+ id: 'run-scoped-1',
+ started_at: '2026-05-06T12:00:00Z',
+ completed_at: '2026-05-06T12:01:00Z',
+ type: 'scoped',
+ status: 'error',
+ resources_checked: 0,
+ new_findings: 0,
+ error_count: 1,
+ finding_ids: [],
+ },
+ ],
+ },
patrolStream: {
phase: () => 'Running',
currentTool: () => '',
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
index e6b258f4f0..e3768b95cf 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
@@ -451,6 +451,75 @@ describe('patrolInvestigationContextModel', () => {
});
});
+ it('prioritizes active findings over secondary coverage caveats in assessment handoffs', () => {
+ const handoff = buildPatrolAssessmentAssistantHandoff({
+ assessment: {
+ title: 'Issues detected',
+ description:
+ 'Patrol surfaced one active warning finding in your infrastructure. Review the active findings for more detail.',
+ eyebrow: 'Patrol assessment',
+ },
+ overallHealth: {
+ grade: 'B',
+ score: 85,
+ prediction: 'Coverage is incomplete for secondary activity.',
+ factors: [{ category: 'coverage' }],
+ },
+ verification: {
+ title: 'Recently verified',
+ description: 'The most recent full patrol completed successfully and checked 58 resources.',
+ lastFullRunAt: '2026-05-12T21:22:35Z',
+ activityMixLabel: '8 full, 3 alert-cleared',
+ },
+ latestRun: {
+ kindLabel: 'Full patrol',
+ status: { label: 'issues found' },
+ timestamp: '2026-05-12T21:22:35Z',
+ coverageSummary: 'Checked 58 resources',
+ findingsSnapshotAvailable: true,
+ },
+ investigationContext: {
+ recentChangeCount: 3,
+ correlationCount: 70,
+ governedResourceCount: 55,
+ hasContext: true,
+ summaryText: '3 recent changes · 70 correlations · 55 policy-covered resources',
+ },
+ recommendedNextStep: {
+ title: 'Review active findings',
+ description:
+ 'Use the findings workspace to prioritize current risk, recent changes, and governed remediation.',
+ actionLabel: 'Review findings',
+ actionKind: 'review_findings',
+ },
+ activeFindings: [
+ {
+ id: 'finding-backup',
+ title: 'Backup failed',
+ severity: 'warning',
+ status: 'active',
+ resourceId: 'backup-delly',
+ resourceName: 'delly',
+ resourceType: 'backup',
+ },
+ ],
+ });
+
+ expect(handoff.prompt).toContain('Start by prioritizing 1 active finding');
+ expect(handoff.prompt).not.toContain('why Patrol coverage is incomplete');
+ expect(handoff.prompt).not.toContain('what the latest scoped activity did and did not prove');
+ expect(handoff.context.briefing).toMatchObject({
+ actionLabel: 'Recommended: Review findings',
+ safetyNote:
+ 'Assistant can explain the Patrol recommendation; Patrol runs, settings changes, diagnostics, and remediation remain operator-controlled.',
+ suggestedPrompts: [
+ 'Prioritize findings and safest next step',
+ 'Explain recent changes and correlations',
+ 'List evidence to verify before action',
+ ],
+ });
+ });
+
it('links route-owned Patrol assessment recommendations in Assistant briefing', () => {
const handoff = buildPatrolAssessmentAssistantHandoff({
assessment: {
diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
index 761b216664..eb2cd6ecc8 100644
--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
@@ -897,24 +897,8 @@ function buildPatrolAssessmentAssistantPrompt(
description: string,
handoffActions: AIChatHandoffAction[],
): string {
- 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(
- 'pending governed approvals',
- pendingApprovalCount,
- )}, approval policy, dry-run posture, and the safest next step from the attached context.`
- : actionCount > 0
- ? `Start by reviewing ${formatAssessmentMetricCount(
- 'governed action references',
- actionCount,
- )}, risk, and the safest next step from the attached context.`
- : hasCoverageGap
- ? 'Start by explaining why Patrol coverage is incomplete, what the latest scoped activity did and did not prove, and whether a full Patrol verification should run before action.'
- : 'Use the attached model-only Patrol assessment context before suggesting next actions. Help me understand priority, risk, and safe next steps.';
+ const reviewInstruction = buildPatrolAssessmentReviewPromptInstruction(input, handoffActions);
return [
`Discuss the current Pulse Patrol assessment: ${title}.`,
@@ -927,6 +911,43 @@ function buildPatrolAssessmentAssistantPrompt(
.join('\n\n');
}
+function buildPatrolAssessmentReviewPromptInstruction(
+ input: PatrolAssessmentAssistantHandoffInput,
+ handoffActions: AIChatHandoffAction[],
+): string {
+ const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);
+ const actionCount = handoffActions.length;
+ const activeFindingCount = normalizeNonNegativeCount(input.activeFindings?.length);
+ const hasCoverageOnlyGap = assessmentHasCoverageGap(input) && activeFindingCount === 0;
+
+ if (pendingApprovalCount > 0) {
+ return `Start by reviewing ${formatAssessmentMetricCount(
+ 'pending governed approvals',
+ pendingApprovalCount,
+ )}, approval policy, dry-run posture, and the safest next step from the attached context.`;
+ }
+
+ if (actionCount > 0) {
+ return `Start by reviewing ${formatAssessmentMetricCount(
+ 'governed action references',
+ actionCount,
+ )}, risk, and the safest next step from the attached context.`;
+ }
+
+ if (activeFindingCount > 0) {
+ return `Start by prioritizing ${formatAssessmentMetricCount(
+ 'active findings',
+ activeFindingCount,
+ )}, affected resources, evidence, verification caveats, and the safest next step from the attached context.`;
+ }
+
+ if (hasCoverageOnlyGap) {
+ return 'Start by explaining why Patrol coverage is incomplete, what the latest scoped activity did and did not prove, and whether a full Patrol verification should run before action.';
+ }
+
+ return 'Use the attached model-only Patrol assessment context before suggesting next actions. Help me understand priority, risk, and safe next steps.';
+}
+
function buildPatrolAssessmentAssistantBriefing(
input: PatrolAssessmentAssistantHandoffInput,
): AIChatContextBriefing {
@@ -1058,7 +1079,9 @@ function buildPatrolAssessmentActionPosture(
): { actionLabel: string; actionHref?: string; safetyNote: string } {
const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);
const actionCount = handoffActions.length;
+ const activeFindingCount = normalizeNonNegativeCount(input.activeFindings?.length);
const hasCoverageGap = assessmentHasCoverageGap(input);
+ const hasCoverageOnlyGap = hasCoverageGap && activeFindingCount === 0;
const recommendedNextStep = normalizeAssessmentRecommendedNextStep(input.recommendedNextStep);
const recommendedNextStepActionHref =
getAssessmentRecommendedNextStepActionHref(recommendedNextStep);
@@ -1100,7 +1123,7 @@ function buildPatrolAssessmentActionPosture(
};
}
- if (hasCoverageGap) {
+ if (hasCoverageOnlyGap) {
return {
actionLabel: recommendedNextStep?.actionLabel
? `Recommended: ${recommendedNextStep.actionLabel}`