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.

Add guided prompts to Patrol finding handoffs

rcourtman1d70402f71fa
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index ccb6ca131a..5982f4d6ab 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -328,7 +328,11 @@ the canonical monitored-system blocked payload.
surfaces. Frontend finding-discussion handoffs that carry any live approval,
proposed-fix, fix outcome, or remediation-plan reference must force a
request-local approval-required Assistant mode instead of inheriting the
- user's persistent autonomous control setting. Direct alert-investigation API
+ user's persistent autonomous control setting. Frontend-visible Patrol
+ briefing payloads may include short suggested prompts, but those prompts
+ must be derived from the same safe action posture, evidence, recurrence, and
+ remediation-plan metadata as the briefing and must never carry raw approval,
+ command, or rollback command text. Direct alert-investigation API
handoffs through `internal/api/ai_handlers.go` must enforce that same
request-scoped boundary by setting `ai.ExecuteRequest.AutonomousMode` to
false and `ai.ExecuteRequest.RequireCommandApproval` to true; API proof must
@@ -3018,6 +3022,10 @@ paste raw approval or proposed-fix command text into the authored chat prompt.
Patrol remediation-plan Assistant prompts must also pass only safe plan metadata,
step labels, risk/status, and command counts; raw plan command and rollback
command payloads remain owned by the governed remediation/action APIs and panels.
+Frontend Assistant briefing suggested prompts for those finding and plan
+handoffs must stay bounded to safe operator questions about evidence,
+confidence, approval risk, prerequisites, recurrence, rollback, and verification
+rather than becoming another place to serialize executable action details.
Patrol run-history serialization and persistence must also preserve full field
parity across API responses and restart boundaries, including
`pmg_checked`, `rejected_findings`, `triage_flags`, `triage_skipped_llm`, and
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index d41862357c..03d4c87508 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -820,7 +820,11 @@ frontend primitive boundary.
evidence summaries, operator-decision copy, action copy, safety note, and
any bounded suggested prompts. Suggested prompts may fill the drawer input
for the operator, but they must not submit automatically or change the
- request-local approval-required mode.
+ request-local approval-required mode. Patrol finding and remediation-plan
+ suggested prompts must be derived from safe briefing metadata such as
+ evidence, confidence, approval risk, prerequisites, recurrence, rollback,
+ and verification posture; they must not become another primitive path for
+ raw approval, command, or rollback command payload text.
When those feature-owned helpers attach backend model-only context, the
drawer store may carry only bounded handoff text and structured resource
references for the shared chat transport; approval, lifecycle, and command
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 6b005ac36b..faae0a29df 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -146,8 +146,10 @@ Patrol-specific presentation helpers.
Patrol-owned operator frame, including current severity/status, recurrence or
regression, loop state, approval/proposed-fix posture, and the explicit
operator decision being requested. That visible briefing remains a summary
- surface only: proposed-fix commands stay summarized by count and destructive
- action copy must point back to governed approval/remediation context. When a
+ surface only: proposed-fix commands stay summarized by count, safe suggested
+ prompts must steer the operator toward evidence, approval risk, recurrence,
+ and next-step review without carrying command text, and destructive action
+ copy must point back to governed approval/remediation context. When a
structured investigation record is not available yet, the same Patrol-owned
helper must still brief the operator from current finding facts such as
active status, severity, recurrence, and loop state instead of opening a
@@ -163,14 +165,15 @@ Patrol-specific presentation helpers.
briefing for the pending approval, and never paste the approval command or
proposed-fix command text into the chat prompt. Remediation-plan Assistant
handoffs follow the same boundary: step labels, plan status, risk, and command
- counts are allowed, while command and rollback command text stays in the
- governed remediation or approval surface. Generic finding discussion
- handoffs must also force request-local approval-required mode when the finding
- already references a live approval, proposed fix, fix outcome, or remediation
- plan, so default autonomous Assistant settings cannot bypass the Patrol
- action-governance boundary. The assembled handoff must still pass through the
- Assistant runtime's
- resource-policy sanitizer before prompt injection, so Patrol-owned prose
+ counts are allowed, safe suggested prompts may ask about plan risk,
+ prerequisites, rollback, and verification, while command and rollback command
+ text stays in the governed remediation or approval surface. Generic finding
+ discussion handoffs must also force request-local approval-required mode when
+ the finding already references a live approval, proposed fix, fix outcome, or
+ remediation plan, so default autonomous Assistant settings cannot bypass the
+ Patrol action-governance boundary. The assembled handoff must still pass
+ through the Assistant runtime's resource-policy sanitizer before prompt
+ injection, so Patrol-owned prose
cannot leak governed resource names, IDs, aliases, nodes, paths, or
addresses outside the canonical policy boundary.
If the referenced finding is no longer current, Assistant must drop the
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
index 95b58d7848..b7b740d524 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
@@ -406,6 +406,11 @@ describe('patrolInvestigationContextModel', () => {
commandSummary: '1 command recorded for approval context',
safetyNote:
'Command details stay in approval context; destructive actions require governed approval.',
+ suggestedPrompts: [
+ 'Review approval risk and next step',
+ 'Explain Patrol evidence and confidence',
+ 'Summarize remediation without command text',
+ ],
});
expect(JSON.stringify(briefing)).not.toContain('systemctl restart workload.service');
});
@@ -460,6 +465,11 @@ describe('patrolInvestigationContextModel', () => {
expect(briefing.safetyNote).toBe(
'Command details stay in governed remediation context; execution requires the approval flow.',
);
+ expect(briefing.suggestedPrompts).toEqual([
+ 'Review plan risk and prerequisites',
+ 'Explain commands without command text',
+ 'Check rollback and verification steps',
+ ]);
expect(JSON.stringify(briefing)).not.toContain('systemctl');
});
@@ -530,6 +540,11 @@ describe('patrolInvestigationContextModel', () => {
actionLabel: undefined,
commandSummary: undefined,
safetyNote: undefined,
+ suggestedPrompts: [
+ 'Explain current finding status',
+ 'Explain current Patrol loop state',
+ 'Explain recurrence and what changed',
+ ],
});
});
@@ -562,6 +577,11 @@ describe('patrolInvestigationContextModel', () => {
actionLabel: 'Approval approval-1',
commandSummary: undefined,
safetyNote: 'Execution requires the governed approval flow.',
+ suggestedPrompts: [
+ 'Review approval risk and next step',
+ 'Explain current finding status',
+ 'List approval prerequisites before action',
+ ],
});
});
});
diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
index c8b87014a4..6c0fa04400 100644
--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
@@ -170,7 +170,7 @@ const MAX_ASSESSMENT_FINDINGS = 5;
const MAX_ASSESSMENT_RECENT_CHANGES = 3;
const MAX_ASSESSMENT_CORRELATIONS = 3;
const MAX_ASSESSMENT_RESOURCES = 8;
-const MAX_ASSESSMENT_SUGGESTED_PROMPTS = 3;
+const MAX_PATROL_BRIEFING_SUGGESTED_PROMPTS = 3;
export function buildPatrolInvestigationContextSummary(
input: PatrolInvestigationContextSummaryInput,
@@ -382,10 +382,7 @@ function buildPatrolAssessmentSuggestedPrompts(
prompts.push('Identify early warning signals');
}
- return Array.from(new Set(prompts.map(normalizeText).filter(isNonEmptyString))).slice(
- 0,
- MAX_ASSESSMENT_SUGGESTED_PROMPTS,
- );
+ return formatPatrolSuggestedPrompts(prompts);
}
function assessmentFindingHasGovernedAction(
@@ -1012,6 +1009,7 @@ export function buildPatrolRemediationPlanAssistantBriefing(
safetyNote: commandSummary
? 'Command details stay in governed remediation context; execution requires the approval flow.'
: 'Review the governed remediation context before execution.',
+ suggestedPrompts: buildPatrolRemediationPlanSuggestedPrompts(plan, steps, commandSummary),
};
}
@@ -1062,9 +1060,86 @@ export function buildPatrolAssistantFindingBriefing(
(pendingApproval.id ? `Approval ${pendingApproval.id}` : undefined),
commandSummary: record.proposedFix?.commandSummary,
safetyNote: buildPatrolAssistantSafetyNote(record, pendingApproval),
+ suggestedPrompts: buildPatrolFindingSuggestedPrompts(input, record, pendingApproval),
};
}
+function buildPatrolRemediationPlanSuggestedPrompts(
+ plan: RemediationPlan,
+ steps: RemediationPlan['steps'],
+ commandSummary?: string,
+): string[] {
+ const prompts = ['Review plan risk and prerequisites'];
+ const hasSteps = Array.isArray(steps) && steps.length > 0;
+ const riskLevel = normalizeText(plan.risk_level).toLowerCase();
+
+ if (commandSummary) {
+ prompts.push('Explain commands without command text');
+ }
+
+ if (hasSteps) {
+ prompts.push('Check rollback and verification steps');
+ } else {
+ prompts.push('Identify missing plan details');
+ }
+
+ if (!commandSummary && (riskLevel === 'high' || riskLevel === 'critical')) {
+ prompts.push('Check rollback and failure handling');
+ }
+
+ return formatPatrolSuggestedPrompts(prompts);
+}
+
+function buildPatrolFindingSuggestedPrompts(
+ input: PatrolAssistantFindingBriefingInput,
+ record: PatrolInvestigationRecordPresentation,
+ pendingApproval: Required<PatrolAssistantApprovalBriefingInput>,
+): string[] {
+ const prompts: string[] = [];
+ const requiresApproval = patrolAssistantFindingHandoffRequiresApprovalMode({
+ investigationOutcome: input.investigationRecord?.outcome,
+ remediationId: input.remediationId,
+ pendingApproval,
+ investigationRecord: input.investigationRecord,
+ });
+ const hasLoopState = Boolean(normalizeText(input.loopState));
+ const hasRecurrence =
+ normalizeNonNegativeCount(input.regressionCount) > 0 ||
+ normalizeNonNegativeCount(input.timesRaised) > 1;
+
+ if (requiresApproval) {
+ prompts.push('Review approval risk and next step');
+ } else if (record.hasRecord) {
+ prompts.push('Prioritize finding and safest next step');
+ } else {
+ prompts.push('Explain current finding status');
+ }
+
+ if (record.hasRecord) {
+ prompts.push('Explain Patrol evidence and confidence');
+ } else if (requiresApproval) {
+ prompts.push('Explain current finding status');
+ } else if (hasLoopState) {
+ prompts.push('Explain current Patrol loop state');
+ } else {
+ prompts.push('List evidence to gather before action');
+ }
+
+ if (record.proposedFix?.commandSummary) {
+ prompts.push('Summarize remediation without command text');
+ } else if (requiresApproval) {
+ prompts.push('List approval prerequisites before action');
+ } else if (hasRecurrence) {
+ prompts.push('Explain recurrence and what changed');
+ } else if (hasLoopState) {
+ prompts.push('Explain current Patrol loop state');
+ } else {
+ prompts.push('List evidence to gather before action');
+ }
+
+ return formatPatrolSuggestedPrompts(prompts);
+}
+
function buildPatrolAssistantAttentionReason(
input: PatrolAssistantFindingBriefingInput,
record: PatrolInvestigationRecordPresentation,
@@ -1347,6 +1422,13 @@ function formatPlanCommandSummary(plan: RemediationPlan): string | undefined {
return parts.join('; ');
}
+function formatPatrolSuggestedPrompts(values: string[]): string[] {
+ return Array.from(new Set(values.map(normalizeText).filter(isNonEmptyString))).slice(
+ 0,
+ MAX_PATROL_BRIEFING_SUGGESTED_PROMPTS,
+ );
+}
+
function formatBriefingStringList(
values: Array<string | undefined>,
limit: number,
diff --git a/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts b/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts
index 36c584ccd7..60361280ce 100644
--- a/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts
+++ b/tests/integration/tests/73-patrol-assistant-operator-briefing.spec.ts
@@ -415,10 +415,32 @@ test.describe("Patrol Assistant operator briefing", () => {
await expect(assistantContext).toContainText(
"Command details stay in approval context; destructive actions require governed approval.",
);
+ await expect(
+ assistantContext.getByRole("button", {
+ name: "Review approval risk and next step",
+ }),
+ ).toBeVisible();
+ await expect(
+ assistantContext.getByRole("button", {
+ name: "Explain Patrol evidence and confidence",
+ }),
+ ).toBeVisible();
+ await expect(
+ assistantContext.getByRole("button", {
+ name: "Summarize remediation without command text",
+ }),
+ ).toBeVisible();
await expect(
assistantContext.getByText("systemctl restart workload.service"),
).toHaveCount(0);
+ await assistantContext
+ .getByRole("button", { name: "Review approval risk and next step" })
+ .click();
+ await expect(
+ page.getByPlaceholder("Ask about your infrastructure..."),
+ ).toHaveValue("Review approval risk and next step");
+
await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });
});
});