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.

Make Patrol Assistant prompts action-aware

rcourtmandf0d8565a5f2
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 51588c2692..da45fd1b7d 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -460,8 +460,9 @@ the canonical monitored-system blocked payload.
metadata, action plan identity/policy/expiry, dry-run posture, and command
counts instead of pasting page-local UI text or raw command payloads into chat,
and may derive visible action labels, safety notes, and approval-aware
- suggested prompts from that same safe metadata so the drawer does not fall
- back to generic assessment copy when governed actions are present
+ suggested prompts plus first-turn prompt emphasis from that same safe metadata
+ so the drawer does not fall back to generic assessment copy when governed
+ actions are present
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,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index ccd23b6833..607cc45345 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -821,7 +821,8 @@ frontend primitive boundary.
model-only refresh, but the shared drawer stays a generic shell rather than
a Patrol summary prompt builder. The Patrol helper may turn those same safe
references into visible action labels, safety notes, and approval-aware
- suggested prompts, but it must not expose raw command or execution payloads.
+ suggested prompts or first-turn prompt emphasis, but it must not expose raw
+ command or execution payloads.
The
drawer may render a generic
context-briefing band from `frontend-modern/src/stores/aiChat.ts`, but
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index d665d19ece..e9885ba3a0 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -224,9 +224,10 @@ Patrol-specific presentation helpers.
action plan identity, approval policy, plan expiry, dry-run posture, and
command count. They must force request-local approval-required mode, keep raw
command and approval payloads out of prompt and drawer copy, surface visible
- drawer action posture from the same safe references, and frame Assistant as
- explanation, prioritization, and safe next-step review rather than a generic
- reactive chat
+ drawer action posture from the same safe references, make the initial prompt
+ lead with approval/action review when governed references are attached, and
+ frame Assistant as explanation, prioritization, and safe next-step review
+ rather than a generic reactive chat
box.
## Current State
@@ -288,7 +289,9 @@ proposed-fix command-bearing records and command-bearing change events without
raw command text. Its visible Assistant briefing must also use those safe
references to distinguish pending governed approvals or attached action
references from a generic assessment discussion, including approval-policy and
-dry-run posture when available, while command payloads stay out of the drawer.
+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.
That active-runtime label must stay operational rather than verdict-like: the
header chip should communicate that Patrol is enabled or available, not imply
that infrastructure health is currently good merely because the runtime is on.
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
index 0112f014f5..8d1b2aaba8 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
@@ -53,6 +53,9 @@ describe('PatrolIntelligenceSummary', () => {
expect(loadPendingApprovals).toHaveBeenCalledTimes(1);
const [prompt, context] = openWithPrompt.mock.calls[0] as [string, Record<string, unknown>];
expect(prompt).toContain('Discuss the current Pulse Patrol assessment');
+ expect(prompt).toContain('Start by reviewing 1 pending governed approval');
+ expect(prompt).toContain('approval policy, dry-run posture');
+ expect(prompt).toContain('Do not infer, repeat, or execute raw command text');
expect(context.autonomousMode).toBe(false);
expect(context.handoffContext).toContain('[Patrol Assessment Context]');
expect(context.handoffContext).toContain('Source: Pulse Patrol current assessment');
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
index 723cf02ac1..9b5e66cba1 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
@@ -238,6 +238,8 @@ describe('patrolInvestigationContextModel', () => {
});
expect(handoff.prompt).toContain('Discuss the current Pulse Patrol assessment');
+ expect(handoff.prompt).toContain('Start by reviewing 1 governed action reference');
+ expect(handoff.prompt).toContain('Do not infer, repeat, or execute raw command text');
expect(handoff.context.autonomousMode).toBe(false);
expect(handoff.context.handoffContext).toContain('[Patrol Assessment Context]');
expect(handoff.context.handoffContext).toContain('Source: Pulse Patrol current assessment');
@@ -314,6 +316,8 @@ describe('patrolInvestigationContextModel', () => {
});
expect(handoff.context.autonomousMode).toBe(false);
+ expect(handoff.prompt).toContain('Start by reviewing 1 pending governed approval');
+ expect(handoff.prompt).toContain('approval policy, dry-run posture');
expect(handoff.context.handoffContext).toContain('Finding 1: High CPU usage');
expect(handoff.context.handoffContext).toContain('approval approval-1');
expect(handoff.context.handoffContext).toContain('live approval pending');
diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
index d8a16b71ba..659787f4e1 100644
--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
@@ -366,14 +366,7 @@ export function buildPatrolAssessmentAssistantHandoff(
const handoffActions = buildPatrolAssessmentHandoffActions(input);
return {
- prompt: [
- `Discuss the current Pulse Patrol assessment: ${title}.`,
- description,
- 'Use the attached model-only Patrol assessment context before suggesting next actions. Help me understand priority, risk, and safe next steps.',
- 'Do not infer, repeat, or execute raw command text from this handoff.',
- ]
- .filter(isNonEmptyString)
- .join('\n\n'),
+ prompt: buildPatrolAssessmentAssistantPrompt(input, title, description, handoffActions),
context: {
targetType: 'dashboard',
targetId: 'pulse-patrol-assessment',
@@ -396,6 +389,37 @@ export function buildPatrolAssessmentAssistantHandoff(
};
}
+function buildPatrolAssessmentAssistantPrompt(
+ input: PatrolAssessmentAssistantHandoffInput,
+ title: string,
+ description: string,
+ handoffActions: AIChatHandoffAction[],
+): string {
+ const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);
+ const actionCount = handoffActions.length;
+ 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.`
+ : 'Use the attached model-only Patrol assessment context before suggesting next actions. Help me understand priority, risk, and safe next steps.';
+
+ return [
+ `Discuss the current Pulse Patrol assessment: ${title}.`,
+ description,
+ reviewInstruction,
+ 'Do not infer, repeat, or execute raw command text from this handoff.',
+ ]
+ .filter(isNonEmptyString)
+ .join('\n\n');
+}
+
function buildPatrolAssessmentAssistantBriefing(
input: PatrolAssessmentAssistantHandoffInput,
): AIChatContextBriefing {