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 trusted APT action review

rcourtmanb0ee11e162aa
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index b99563cd21..5fd065c7d0 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -3963,6 +3963,21 @@
],
"release_gate_ids": [],
"proof_commands": [
+ {
+ "id": "ra35-apt-product-trust-browser",
+ "run": [
+ "env",
+ "PLAYWRIGHT_BASE_URL=http://127.0.0.1:5173",
+ "tests/integration/node_modules/.bin/playwright",
+ "test",
+ "--config=tests/integration/playwright.config.ts",
+ "tests/78-monitor-first-patrol-workbench.spec.ts",
+ "tests/81-actions-inbox.spec.ts",
+ "--project=chromium",
+ "--grep",
+ "APT"
+ ]
+ },
{
"id": "ra35-chat-authority-boundary",
"run": [
@@ -4041,6 +4056,17 @@
}
],
"evidence": [
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/features/actions/__tests__/aptActionPresentation.test.ts",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/features/actions/aptActionPresentation.ts",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "internal/actionlifecycle/service.go",
@@ -4171,6 +4197,18 @@
"repo": "pulse",
"path": "pkg/aicontracts/orchestrator_deps.go",
"kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": "tests/integration/tests/81-actions-inbox.spec.ts",
+ "kind": "file",
+ "evidence_tier": "test-proof"
}
]
},
@@ -7981,7 +8019,7 @@
},
{
"id": "action-governance-auditability-post-rc-hardening",
- "summary": "Task 07 durable delivery and generic agent-operation receipts are accepted: transactional dispatch admission, one-shot send CAS, immutable attempt/action/operation/digest/agent binding, query-only restart reconciliation, strict sanitized terminal envelopes, and permanent replay-denial tombstones. Task 09 now consumes that owner for both APT workflows and completes the fake-only detector-to-finding, exact empty-parameter proposal, shared policy/approval, typed dispatch, delayed/callback-loss/reopened-server receipt reconciliation, ActionResultV2 truth, terminal audit, and finding reconciliation floor without blind resend. Host update health is explicit tri-state evidence from a fixed read-only catalog; legacy v1 receipts lacking additive health facts terminalize as health-unknown/inconclusive. Task 10 remains sole owner of execution, verification, evidence, compensation, and rollback truth. Claims 16 and 17 and both workflow scorecards remain open below operational completion until browser proof, disposable Debian/Ubuntu lab proof, and Task 12 certification pass. Mobile/relay consumption remains separate with no local workaround for absent core APIs. Raw model command, file write, arbitrary pod exec, legacy run_command, /api/ai/run-command, and enterprise command remediation remain retired with no replacement or executable historical authority.",
+ "summary": "Task 07 durable delivery and generic agent-operation receipts are accepted: transactional dispatch admission, one-shot send CAS, immutable attempt/action/operation/digest/agent binding, query-only restart reconciliation, strict sanitized terminal envelopes, and permanent replay-denial tombstones. Task 09 consumes that owner for both APT workflows and completes the fake-only detector-to-finding, exact empty-parameter proposal, shared policy/approval, typed dispatch, delayed/callback-loss/reopened-server receipt reconciliation, ActionResultV2 truth, terminal audit, and finding reconciliation floor without blind resend. Task 11 adds the desktop/browser tier-5 Product Trust consumer: bounded command/path/package-free Patrol evidence; exact empty parameter and elevated-versus-low-risk review; separate execution, evidence-sourced verification, and recovery cards; agent-attested confirmed updates; reboot fact without reboot authority; partial/unknown-health recovery; measured irreversible cleanup; and one durable receipt across reconnect, all exercised in current-build Chromium and a 390-pixel viewport with fake typed API fixtures only. Malformed phases, counts, timestamps, usage, or cleanup arithmetic fail closed. Task 10 remains sole owner of execution, verification, evidence, compensation, and rollback truth. Claims 16 and 17 and both workflow scorecards remain operationally open until disposable Debian/Ubuntu tier-6 proof and Task 12 final-SHA certification pass. Mobile/relay, physical-device, MSP aggregation, and real-lab proof remain separate. Raw model command, file write, arbitrary pod exec, legacy run_command, /api/ai/run-command, and enterprise command remediation remain retired with no replacement or executable historical authority.",
"owner": "project-owner",
"status": "planned",
"recorded_at": "2026-04-25",
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 021a9af27c..f84d4c528e 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -7483,3 +7483,12 @@ floor is implemented for both workflows. Claims 16/17 and both workflow
scorecards remain below operational completion; browser certification,
disposable Debian/Ubuntu execution, and Task 12 final-SHA certification remain
open and are not inferred from fake-only proof.
+
+The frontend APT Product Trust consumer mirrors the canonical API rather than
+inventing local execution, verification, evidence, health, recovery, or
+compensation enums. `UnifiedFinding.key` is preserved from the Patrol finding
+wire record so bounded evidence presentation can select the exact owned
+workflow. Action list/detail continues to carry policy provenance,
+`ActionResultV2`, durable dispatch attempt, and receipt fields unchanged. Unit
+guards pin those projections and verify that APT presentation reads the shared
+`ActionAuditRecord`/`ActionResultV2` types directly.
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 44eee57ff8..588ab9286d 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -4952,3 +4952,12 @@ action state and approval policy, not only from a legacy approval id. A
`pending_approval` action or any non-`none` approval floor remains explicitly
approval-bound in shared handoff metadata so Assistant, the collapsed finding
row, and the expanded action review cannot disagree.
+
+The shared Actions dialog remains the responsive and accessible review
+primitive for typed APT maintenance. Its heading supplies the dialog accessible
+name, the close control has an explicit name, pending action rows are keyboard
+reachable, and the scroll-bounded panel keeps safety, execution, verification,
+recovery, delivery, and next-step content actionable at desktop and 390-pixel
+phone viewports. Responsive layout must not hide the exact parameter authority,
+evidence source, or recovery instruction, and it must not add a duplicate legacy
+verification card when `ActionResultV2` is present.
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index c0e5eaee68..779e32e779 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -2002,3 +2002,15 @@ limits explicitly allow inconclusive verification and never turn execution
success into outcome truth. Task 11 still owns acknowledgement presentation,
cancel/no-submit browser proof, and device coverage; M7 remains open until that
work and Task 12 certification are complete.
+
+APT Patrol findings preserve the backend-owned finding `key` through the
+canonical frontend store. Presentation recognizes only the exact bounded update
+or cleanup observation envelope, validates non-negative safe integer counts,
+finite 0..100 filesystem usage, and valid agent-observed/server-received
+timestamps, and suppresses inventory hashes and fingerprints from the default
+monitoring view. Invalid evidence fails closed to a refresh-before-acting
+message. A reboot-required observation explicitly says that neither the finding
+nor its action authorizes a reboot. Contradicted, inconclusive, or health-unknown
+postconditions remain actionable; only canonical confirmed postcondition truth
+may support resolution. Package-manager internals remain forensic detail rather
+than the least-expert default.
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index e455776e7b..43a9fd7ea0 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1710,6 +1710,29 @@ through the canonical resource model, but unified-resource consumers must not
reintroduce removed workload aliases or feature-local resource-type shims just
to satisfy one table, drawer, or badge surface.
+### APT Product Trust browser projection
+
+The durable Actions inbox and resource action history consume the canonical APT
+workflows without adding a frontend action-truth dialect. The shared
+`aptActionPresentation.ts` translator may recognize only the complete bounded
+host-update and package-cache summaries emitted by the accepted backend
+contract. It validates the closed phase set, safe integer counts, cleanup byte
+arithmetic, and exact empty parameter envelope before presenting facts. Any
+partial, malformed, unknown-phase, or arithmetically impossible summary yields
+no fact card and directs the operator to refresh and review the canonical
+record. Execution, verification plus adjacent evidence source, and compensation
+remain three independent `ActionResultV2` cards.
+
+APT review presents server-recorded policy provenance and distinguishes the
+elevated update posture from low-risk-eligible cache cleanup. Both typed actions
+declare that no command, path, package selection, removal choice, or reboot
+authority is accepted from the browser. Reboot-required is a reported fact only;
+there is no reboot control. Durable attempt and receipt detail appears once and
+explains that refresh or reconnect rehydrates the existing action rather than
+creating a duplicate. Package cleanup is explicitly irreversible; an
+inconclusive or failed cleanup requires a fresh scan and never presents fake
+rollback or automatic retry.
+
Task 09 owns shared APT telemetry freshness in
`internal/unifiedresources/host_apt_telemetry.go`. Capability construction,
finding admission, and execution readiness consume the same dual-timestamp and
diff --git a/frontend-modern/src/api/__tests__/actionAudit.test.ts b/frontend-modern/src/api/__tests__/actionAudit.test.ts
index a1db1c0d64..f2f02ed66e 100644
--- a/frontend-modern/src/api/__tests__/actionAudit.test.ts
+++ b/frontend-modern/src/api/__tests__/actionAudit.test.ts
@@ -1,3 +1,4 @@
+import { createHash } from 'node:crypto';
import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('@/utils/apiClient', () => ({
@@ -9,11 +10,64 @@ import { ResourceActionsAPI } from '@/api/resourceActions';
import { apiFetchJSON } from '@/utils/apiClient';
import type {
ActionAuditRecord,
+ ActionEvidence,
ActionDecisionResponse,
ActionExecutionResponse,
+ ActionResultV2,
ResourceActionRequest,
} from '@/types/actionAudit';
+const canonicalEvidenceDigest = (evidence: ActionEvidence): string => {
+ const envelope = {
+ version: evidence.version,
+ id: evidence.id,
+ observerId: evidence.observerId,
+ observerKind: evidence.observerKind,
+ observerTrustDomain: evidence.observerTrustDomain,
+ executorTrustDomain: evidence.executorTrustDomain,
+ method: evidence.method,
+ subjectId: evidence.subjectId,
+ observedAt: evidence.observedAt,
+ receivedAt: evidence.receivedAt,
+ ...(evidence.reasonCode ? { reasonCode: evidence.reasonCode } : {}),
+ ...(evidence.summary ? { summary: evidence.summary } : {}),
+ ...(evidence.refs?.length ? { refs: evidence.refs } : {}),
+ digest: '',
+ };
+ return `sha256:${createHash('sha256').update(JSON.stringify(envelope)).digest('hex')}`;
+};
+
+const makeAgentEvidence = (id: string): ActionEvidence => {
+ const envelope: ActionEvidence = { version: 1, id, observerId: 'agent:pve-1', observerKind: 'unified_agent', observerTrustDomain: 'agent:pve-1', executorTrustDomain: 'agent:pve-1', method: 'typed_read_after_write', subjectId: 'proxmox:node:pve-1', observedAt: '2026-07-12T10:01:00Z', receivedAt: '2026-07-12T10:05:00Z', digest: '' };
+ return { ...envelope, digest: canonicalEvidenceDigest(envelope) };
+};
+
+const legacyVerificationStatus = (truth: ActionResultV2): 'verified' | 'failed' | 'unverified' | 'unknown' =>
+ truth.verification.status === 'confirmed'
+ ? 'verified'
+ : truth.verification.status === 'contradicted'
+ ? 'failed'
+ : truth.verification.status === 'inconclusive'
+ ? 'unverified'
+ : 'unknown';
+
+const isTask10FixtureValid = (truth: ActionResultV2): boolean => {
+ if (truth.execution.status !== 'succeeded' && !truth.execution.reasonCode?.trim()) return false;
+ const evidenceCount = truth.verification.evidence?.length ?? 0;
+ if (truth.verification.status === 'inconclusive' && !truth.verification.reasonCode?.trim()) return false;
+ if (truth.verification.status === 'not_attempted' && (truth.verification.evidenceClass !== 'none' || evidenceCount !== 0)) return false;
+ if ((truth.verification.status === 'confirmed' || truth.verification.status === 'contradicted') && (truth.verification.evidenceClass === 'none' || evidenceCount === 0)) return false;
+ if (truth.verification.evidenceClass === 'none' && evidenceCount !== 0) return false;
+ if (truth.verification.evidenceClass !== 'none' && evidenceCount === 0) return false;
+ if ((truth.verification.evidence ?? []).some((evidence) => {
+ const observedAt = new Date(evidence.observedAt).valueOf();
+ const receivedAt = new Date(evidence.receivedAt).valueOf();
+ return !Number.isFinite(observedAt) || !Number.isFinite(receivedAt) || receivedAt < observedAt || evidence.digest !== canonicalEvidenceDigest(evidence);
+ })) return false;
+ if (truth.verification.evidenceClass === 'independent' && (truth.verification.evidence ?? []).some((evidence) => evidence.observerTrustDomain === evidence.executorTrustDomain)) return false;
+ return true;
+};
+
describe('ActionAuditAPI', () => {
const apiFetchJSONMock = vi.mocked(apiFetchJSON);
@@ -155,6 +209,59 @@ describe('ActionAuditAPI', () => {
});
});
+ it('preserves typed APT ActionResultV2 axes and the durable receipt without normalization', async () => {
+ const evidence = makeAgentEvidence('apt-update-evidence');
+ const audit = {
+ id: 'apt-update', createdAt: '2026-07-12T10:00:00Z', updatedAt: '2026-07-12T10:05:00Z', state: 'completed' as const,
+ request: { requestId: 'apt-request', resourceId: 'proxmox:node:pve-1', capabilityName: 'install_os_updates', params: {}, reason: 'Resolve the current update finding', requestedBy: 'pulse_patrol' },
+ plan: { actionId: 'apt-update', requestId: 'apt-request', allowed: true, requiresApproval: true, approvalPolicy: 'admin' as const, rollbackAvailable: false },
+ result: { success: false, actionResultV2: { version: 2 as const, execution: { status: 'inconclusive' as const, reasonCode: 'possible_partial_effect', summary: 'APT package updates: phase=install; 6 pending before, 3 pending after; package manager health: unhealthy; recovery required: true; reboot required: false' }, verification: { status: 'contradicted' as const, evidenceClass: 'agent_attested' as const, summary: 'Three updates remain.', evidence: [evidence] }, compensation: { support: 'unavailable' as const, status: 'not_available' as const } } },
+ verificationOutcome: { status: 'failed' as const },
+ };
+ const detail = { audit, events: [], attempt: { id: 'attempt-1', actionId: audit.id, state: 'receipt_recorded' as const, createdAt: audit.createdAt, updatedAt: audit.updatedAt, dispatchCount: 1 }, receipt: { attemptId: 'attempt-1', actionId: audit.id, transportRequestId: 'transport-1', receivedAt: audit.updatedAt } };
+ apiFetchJSONMock.mockResolvedValueOnce(detail);
+
+ await expect(ResourceActionsAPI.getAction(audit.id)).resolves.toEqual(detail);
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/actions/apt-update');
+ expect((await Promise.resolve(detail)).audit.result.actionResultV2).toMatchObject({
+ execution: { status: 'inconclusive' },
+ verification: { status: 'contradicted', evidenceClass: 'agent_attested' },
+ compensation: { support: 'unavailable', status: 'not_available' },
+ });
+ expect(detail.receipt).toMatchObject({ attemptId: 'attempt-1', transportRequestId: 'transport-1' });
+ expect(detail.audit.verificationOutcome?.status).toBe('failed');
+ expect(detail.audit.result?.actionResultV2?.verification.evidence?.[0].digest).toBe(canonicalEvidenceDigest(evidence));
+ });
+
+ it('guards tier-5 APT fixtures against impossible Task10 evidence combinations', () => {
+ const evidence = makeAgentEvidence('evidence-1');
+ const compensation = { support: 'unavailable' as const, status: 'not_available' as const };
+ const valid = [
+ { version: 2, execution: { status: 'succeeded' }, verification: { status: 'confirmed', evidenceClass: 'agent_attested', evidence: [evidence] }, compensation },
+ { version: 2, execution: { status: 'inconclusive', reasonCode: 'possible_partial_effect' }, verification: { status: 'contradicted', evidenceClass: 'agent_attested', evidence: [evidence] }, compensation },
+ { version: 2, execution: { status: 'inconclusive', reasonCode: 'possible_partial_effect' }, verification: { status: 'inconclusive', evidenceClass: 'none', reasonCode: 'package_manager_health_unknown' }, compensation },
+ ] satisfies ActionResultV2[];
+ expect(valid.every(isTask10FixtureValid)).toBe(true);
+ expect(valid.map(legacyVerificationStatus)).toEqual(['verified', 'failed', 'unverified']);
+ const notAttempted = { version: 2, execution: { status: 'not_run', reasonCode: 'preflight_refused' }, verification: { status: 'not_attempted', evidenceClass: 'none' }, compensation } satisfies ActionResultV2;
+ expect(isTask10FixtureValid(notAttempted)).toBe(true);
+ expect(legacyVerificationStatus(notAttempted)).toBe('unknown');
+ expect(evidence.digest).toBe(canonicalEvidenceDigest(evidence));
+ expect(new Date(evidence.receivedAt).valueOf()).toBeGreaterThanOrEqual(new Date(evidence.observedAt).valueOf());
+
+ const impossible = [
+ { ...valid[0], verification: { status: 'confirmed', evidenceClass: 'none', evidence: [] } },
+ { ...valid[1], verification: { status: 'contradicted', evidenceClass: 'agent_attested', evidence: [] } },
+ { ...valid[2], verification: { status: 'inconclusive', evidenceClass: 'none' } },
+ { ...valid[2], verification: { status: 'inconclusive', evidenceClass: 'none', reasonCode: 'package_manager_health_unknown', evidence: [evidence] } },
+ { ...valid[2], verification: { status: 'not_attempted', evidenceClass: 'agent_attested', evidence: [evidence] } },
+ { ...valid[2], execution: { status: 'inconclusive' } },
+ { ...valid[0], verification: { ...valid[0].verification, evidence: [{ ...evidence, digest: `sha256:${'a'.repeat(64)}` }] } },
+ { ...valid[0], verification: { ...valid[0].verification, evidence: [{ ...evidence, receivedAt: '2026-07-12T09:59:00Z', digest: canonicalEvidenceDigest({ ...evidence, receivedAt: '2026-07-12T09:59:00Z', digest: '' }) }] } },
+ ] as ActionResultV2[];
+ expect(impossible.map(isTask10FixtureValid)).toEqual([false, false, false, false, false, false, false, false]);
+ });
+
it('builds the canonical resource-scoped action audit query', async () => {
apiFetchJSONMock.mockResolvedValueOnce({
audits: [
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index 464efc1fa0..9f00927d29 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -73,6 +73,7 @@ import {
getFindingSubjectPresentation,
getFindingTitlePresentation,
getFindingRecencyPresentation,
+ getFindingEvidencePresentation,
hasFindingInvestigationDetails,
hasFindingInvestigationHandoffPointer,
getInvestigationConfidenceBadgeTone,
@@ -1356,7 +1357,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
<Show when={finding.evidence}>
<p class="text-sm text-base-content mt-2">
<span class="font-medium">What Pulse checked:</span>{' '}
- {finding.evidence}
+ {getFindingEvidencePresentation(finding)}
</p>
</Show>
<Show when={finding.recommendation}>
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 27d8a24f2d..25fd399877 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -64,6 +64,15 @@ const aiFindingPresentationSource = readFileSync(
);
describe('FindingsPanel assistant handoff', () => {
+ it('routes bounded APT evidence through the canonical finding presenter in collapsed and expanded detail', () => {
+ expect(findingsPanelSource).toContain('getFindingEvidencePresentation');
+ expect(findingsPanelSource).toContain('{getFindingEvidencePresentation(finding)}');
+ expect(aiFindingPresentationSource).toContain("finding.key === 'apt-host-updates'");
+ expect(aiFindingPresentationSource).toContain("finding.key === 'apt-package-cache-pressure'");
+ expect(aiFindingPresentationSource).not.toContain('inventory=${');
+ expect(aiFindingPresentationSource).not.toContain('fingerprint=${');
+ });
+
it('passes stale Patrol coverage into the current-work empty-state presenter', () => {
expect(findingsPanelSource).toContain('coverageStale?: boolean');
expect(findingsPanelSource).toContain('coverageStale: props.coverageStale');
diff --git a/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx b/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx
index 8dfeb8f78c..2a29aee4d2 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx
@@ -12,6 +12,7 @@ import {
getActionAuditVerificationOutcomePresentation,
shouldRenderActionAuditVerification,
} from '@/utils/actionAuditPresentation';
+import { getAPTActionPresentation } from '@/features/actions/aptActionPresentation';
interface ResourceActionHistoryProps {
audits: ActionAuditRecord[];
@@ -27,6 +28,8 @@ const ActionHistoryRow: Component<{ audit: ActionAuditRecord }> = (props) => {
const resultPresentation = () => getActionAuditResultPresentation(props.audit);
const verificationOutcome = () => getActionAuditVerificationOutcomePresentation(props.audit);
const verification = () => getActionAuditVerification(props.audit);
+ const apt = () => getAPTActionPresentation(props.audit);
+ const compensation = () => props.audit.result?.actionResultV2?.compensation;
return (
<div class="rounded border border-border bg-surface-hover px-2 py-1.5 text-[10px]">
@@ -96,7 +99,7 @@ const ActionHistoryRow: Component<{ audit: ActionAuditRecord }> = (props) => {
<Show when={presentation.reasonLabel}>
<div class="mt-0.5 font-medium">{presentation.reasonLabel}</div>
</Show>
- <Show when={presentation.detail}>
+ <Show when={presentation.detail && !apt()}>
<div class="mt-0.5 opacity-80">{presentation.detail}</div>
</Show>
<Show when={presentation.recordedDetail}>
@@ -109,6 +112,11 @@ const ActionHistoryRow: Component<{ audit: ActionAuditRecord }> = (props) => {
);
})()}
</Show>
+ <Show when={apt()?.facts.length}>
+ <dl data-testid="resource-apt-action-facts" class="grid gap-1 rounded border border-border bg-surface px-2 py-1.5 sm:grid-cols-2">
+ <For each={apt()?.facts ?? []}>{(fact) => <div class="flex items-start justify-between gap-2"><dt class="text-muted">{fact.label}</dt><dd class="text-right font-medium text-base-content">{fact.value}</dd></div>}</For>
+ </dl>
+ </Show>
<Show when={verificationOutcome()}>
{(() => {
const outcome = verificationOutcome()!;
@@ -126,6 +134,16 @@ const ActionHistoryRow: Component<{ audit: ActionAuditRecord }> = (props) => {
);
})()}
</Show>
+ <Show when={compensation()}>
+ {(recovery) => (
+ <div data-testid="resource-action-recovery-truth" class="rounded border border-border bg-surface px-2 py-1 text-[10px] text-base-content">
+ <div class="font-medium">Recovery: {formatActionCapabilityLabel(recovery().status)}</div>
+ <div class="mt-0.5 text-muted">Support: {formatActionCapabilityLabel(recovery().support)}</div>
+ <Show when={recovery().summary}><div class="mt-0.5">{recovery().summary}</div></Show>
+ </div>
+ )}
+ </Show>
+ <Show when={apt()}>{(presentation) => <div data-testid="resource-apt-action-next-step" class="rounded border border-blue-200 bg-blue-50 px-2 py-1 text-[10px] text-blue-900 dark:border-blue-800 dark:bg-blue-950/40 dark:text-blue-200"><span class="font-medium">Next: </span>{presentation().nextStep}</div>}</Show>
<Show when={shouldRenderActionAuditVerification(props.audit)}>
{(() => {
const v = verification()!;
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceActionHistory.verification.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/ResourceActionHistory.verification.test.ts
index 2df9f87d2b..49ff4ea94a 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceActionHistory.verification.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceActionHistory.verification.test.ts
@@ -75,6 +75,31 @@ describe('ResourceActionHistory verification rendering', () => {
expect(actionHistory.queryByText('should not render')).toBeNull();
expect(actionHistory.queryByText('sensitive output')).toBeNull();
});
+
+ it('keeps APT execution, verification, recovery, bounded facts, and next step separate without a duplicate legacy card', () => {
+ cleanup();
+ const apt = actionAudit({
+ request: { requestId: 'apt-request', resourceId: 'proxmox:node:pve-1', capabilityName: 'install_os_updates', reason: 'Resolve pending operating system updates', requestedBy: 'pulse_patrol' },
+ plan: { actionId: 'apt-action', requestId: 'apt-request', allowed: true, requiresApproval: true, approvalPolicy: 'admin', rollbackAvailable: false },
+ result: { success: false, actionResultV2: {
+ version: 2,
+ execution: { status: 'inconclusive', summary: 'APT package updates: phase=install; 6 pending before, 3 pending after; package manager health: unhealthy; recovery required: true; reboot required: false' },
+ verification: { status: 'contradicted', evidenceClass: 'agent_attested', summary: 'Three updates still remain.' },
+ compensation: { support: 'unavailable', status: 'not_available', summary: 'No rollback is available; repair is required.' },
+ } },
+ verification: { ran: true, success: false, command: 'legacy command must not render', output: 'legacy output must not render' },
+ });
+ render(() => ResourceActionHistory({ audits: [apt], count: 1, loadingLabel: 'Actions loaded', error: '', onRetry: () => undefined }));
+ const history = within(screen.getByTestId('resource-action-history-section'));
+ expect(history.getByText('Execution inconclusive')).toBeInTheDocument();
+ expect(history.getByText('Outcome contradicted')).toBeInTheDocument();
+ expect(history.getByText('Recovery: Not Available')).toBeInTheDocument();
+ expect(history.getByText('Known unhealthy')).toBeInTheDocument();
+ expect(history.getByText('Do not retry. Repair the host update system, run a fresh scan, and create a new plan only after health is known.')).toBeInTheDocument();
+ expect(history.queryByText('legacy command must not render')).toBeNull();
+ expect(history.queryByText('Legacy check failed (source unclassified)')).toBeNull();
+ expect(screen.getAllByTestId('resource-action-recovery-truth')).toHaveLength(1);
+ });
});
const actionAudit = (overrides: Partial<ActionAuditRecord> = {}): ActionAuditRecord => ({
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
index 99ffaa2ff8..e02ff8eed2 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -206,6 +206,10 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceActionHistorySource).toContain('getActionAuditResultPresentation');
expect(resourceActionHistorySource).toContain('getActionAuditVerificationOutcomePresentation');
expect(resourceActionHistorySource).toContain('formatActionApprovalPolicyLabel');
+ expect(resourceActionHistorySource).toContain('getAPTActionPresentation');
+ expect(resourceActionHistorySource).toContain('resource-apt-action-facts');
+ expect(resourceActionHistorySource).toContain('resource-action-recovery-truth');
+ expect(resourceActionHistorySource).toContain('resource-apt-action-next-step');
// The audit history must surface the broker's read-after-write
// verification outcome alongside the dispatch result, not silently
// drop it. Pin the wiring so future refactors cannot regress to an
@@ -213,10 +217,11 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceActionHistorySource).toContain(
'shouldRenderActionAuditVerification(props.audit)',
);
- expect(resourceActionHistorySource).toContain('Verified');
- expect(resourceActionHistorySource).toContain('Verification failed');
+ expect(resourceActionHistorySource).toContain('Legacy check passed (source unclassified)');
+ expect(resourceActionHistorySource).toContain('Legacy check failed (source unclassified)');
expect(actionAuditPresentationSource).toContain('resource_remediation_locked:');
- expect(actionAuditPresentationSource).toContain('Verification confirmed');
+ expect(actionAuditPresentationSource).toContain('Confirmed by executing agent');
+ expect(actionAuditPresentationSource).toContain('Confirmed by independent observer');
expect(actionAuditApiSource).toContain('/api/audit/actions');
expect(actionAuditApiSource).toContain('ACTION_AUDIT_UNAVAILABLE_STATUSES');
expect(actionAuditPresentationSource).toContain('pending_approval');
@@ -922,9 +927,9 @@ describe('ResourceDetailDrawer change history section', () => {
expect(actionHistory.getByText('Restart nginx')).toBeInTheDocument();
expect(actionHistory.getByText('Approval scoped to this resource.')).toBeInTheDocument();
expect(actionHistory.getByText('nginx restarted')).toBeInTheDocument();
- expect(actionHistory.getByText('Verification confirmed')).toBeInTheDocument();
expect(actionHistory.getByText('Readback reported nginx active.')).toBeInTheDocument();
- expect(actionHistory.getByText('Verified')).toBeInTheDocument();
+ expect(actionHistory.getAllByText('Legacy check passed (source unclassified)')).toHaveLength(2);
+ expect(actionHistory.queryByText('Verified')).toBeNull();
expect(actionHistory.getByText("systemctl is-active 'nginx'")).toBeInTheDocument();
expect(actionHistory.getByText('active')).toBeInTheDocument();
expect(actionHistory.getByText('Refused')).toBeInTheDocument();
diff --git a/frontend-modern/src/features/actions/ActionDecisionPacket.tsx b/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
index a0fdffde9d..467e5c8786 100644
--- a/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
+++ b/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
@@ -1,5 +1,5 @@
import { For, Show, createMemo, type Component } from 'solid-js';
-import type { ActionAuditRecord } from '@/types/actionAudit';
+import type { ActionAuditRecord, ActionDetailResponse } from '@/types/actionAudit';
import {
formatActionName,
formatEvidenceClass,
@@ -7,10 +7,13 @@ import {
formatPolicyReason,
verificationTruthLabel,
} from './actionPresentation';
+import { getAPTActionPresentation } from './aptActionPresentation';
-export const ActionDecisionPacket: Component<{ audit: ActionAuditRecord }> = (props) => {
+export const ActionDecisionPacket: Component<{ audit: ActionAuditRecord; detail?: ActionDetailResponse }> = (props) => {
const policy = () => props.audit.plan.policyDecision;
const result = () => props.audit.result?.actionResultV2;
+ const apt = () => getAPTActionPresentation(props.audit);
+ const firstEvidence = () => result()?.verification.evidence?.[0];
const expiry = createMemo(() => {
const value = new Date(props.audit.plan.expiresAt ?? '');
return Number.isNaN(value.valueOf()) ? 'Not recorded' : value.toLocaleString();
@@ -34,6 +37,20 @@ export const ActionDecisionPacket: Component<{ audit: ActionAuditRecord }> = (pr
</Show>
</section>
+ <Show when={apt()}>
+ {(presentation) => (
+ <section aria-labelledby="action-safety-heading" data-testid="apt-action-safety" class="rounded-lg border border-border bg-surface p-4">
+ <h3 id="action-safety-heading" class="text-sm font-semibold text-base-content">Safety and authority</h3>
+ <dl class="mt-3 grid gap-3 text-sm sm:grid-cols-2">
+ <div><dt class="text-muted">Risk posture</dt><dd class="font-medium">{presentation().safetyPosture}</dd></div>
+ <div><dt class="text-muted">Decision required</dt><dd class="font-medium">{presentation().approvalPosture}</dd></div>
+ <div class="sm:col-span-2"><dt class="text-muted">Operator-selected parameters</dt><dd>{presentation().parameterAuthority}</dd></div>
+ <div class="sm:col-span-2"><dt class="text-muted">What this action can do</dt><dd>{presentation().authorityBoundary}</dd></div>
+ </dl>
+ </section>
+ )}
+ </Show>
+
<section aria-labelledby="action-policy-heading" class="rounded-lg border border-border bg-surface p-4">
<h3 id="action-policy-heading" class="text-sm font-semibold text-base-content">Why Pulse allows this review</h3>
<Show when={policy()?.status === 'resolved'} fallback={<p class="mt-2 text-sm text-amber-700">This older action has no server-recorded policy provenance. Re-plan it before acting.</p>}>
@@ -60,20 +77,28 @@ export const ActionDecisionPacket: Component<{ audit: ActionAuditRecord }> = (pr
{(truth) => (
<section aria-labelledby="action-result-heading" class="space-y-3">
<h3 id="action-result-heading" class="text-sm font-semibold text-base-content">Recorded outcome</h3>
+ <Show when={apt()?.facts.length}>
+ <div data-testid="apt-action-facts" class="rounded-lg border border-border bg-surface p-4">
+ <div class="text-xs font-semibold uppercase tracking-wide text-muted">Agent-reported facts</div>
+ <dl class="mt-3 grid gap-3 text-sm sm:grid-cols-2">
+ <For each={apt()?.facts ?? []}>{(fact) => <div><dt class="text-muted">{fact.label}</dt><dd class="font-medium">{fact.value}</dd></div>}</For>
+ </dl>
+ </div>
+ </Show>
<div data-testid="action-execution-truth" class="rounded-lg border border-border bg-surface p-4">
<div class="text-xs font-semibold uppercase tracking-wide text-muted">Execution</div>
<div class="mt-1 font-semibold">{truth().execution.status === 'not_run' ? 'Did not run' : formatActionName(truth().execution.status)}</div>
<Show when={truth().execution.reasonCode}><div class="mt-1 text-xs text-muted">Reason: {formatActionName(truth().execution.reasonCode!)}</div></Show>
- <Show when={truth().execution.summary}><p class="mt-2 text-sm">{truth().execution.summary}</p></Show>
+ <Show when={truth().execution.summary && !apt()}><p class="mt-2 text-sm">{truth().execution.summary}</p></Show>
</div>
<div data-testid="action-verification-truth" class="rounded-lg border border-border bg-surface p-4">
<div class="text-xs font-semibold uppercase tracking-wide text-muted">Verification</div>
<div class="mt-1 font-semibold">{verificationTruthLabel(truth().verification.status, truth().verification.evidenceClass)}</div>
<div class="mt-1 text-sm text-muted">Source: {formatEvidenceClass(truth().verification.evidenceClass)}</div>
<Show when={truth().verification.reasonCode}><div class="mt-1 text-xs text-muted">Reason: {formatActionName(truth().verification.reasonCode!)}</div></Show>
- <Show when={truth().verification.summary}><p class="mt-2 text-sm">{truth().verification.summary}</p></Show>
+ <Show when={truth().verification.summary && (!apt() || truth().verification.summary !== truth().execution.summary)}><p class="mt-2 text-sm">{truth().verification.summary}</p></Show>
<Show when={(truth().verification.evidence ?? []).length > 0}>
- <details class="mt-3 rounded border border-border-subtle p-3 text-xs"><summary class="cursor-pointer font-medium">Evidence details</summary><ul class="mt-2 space-y-2"><For each={truth().verification.evidence}>{(evidence) => <li><div>{evidence.summary || evidence.method}</div><div class="text-muted">Observed by {evidence.observerId} · {evidence.observerTrustDomain}</div></li>}</For></ul></details>
+ <details class="mt-3 rounded border border-border-subtle p-3 text-xs"><summary class="cursor-pointer font-medium">Evidence details</summary><ul class="mt-2 space-y-2"><For each={truth().verification.evidence}>{(evidence) => <li><div>{apt() ? 'Typed read-after-write observation' : evidence.summary || evidence.method}</div><div class="text-muted">Observed by {evidence.observerId} · {evidence.observerTrustDomain}</div><div class="text-muted">Agent observed {new Date(evidence.observedAt).toLocaleString()} · Pulse received {new Date(evidence.receivedAt).toLocaleString()}</div></li>}</For></ul></details>
</Show>
</div>
<div data-testid="action-compensation-truth" class="rounded-lg border border-border bg-surface p-4">
@@ -83,9 +108,23 @@ export const ActionDecisionPacket: Component<{ audit: ActionAuditRecord }> = (pr
<Show when={truth().compensation.strategy}><div class="mt-1 text-sm">Strategy: {truth().compensation.strategy}</div></Show>
<Show when={truth().compensation.summary}><p class="mt-2 text-sm">{truth().compensation.summary}</p></Show>
</div>
+ <Show when={apt()}>{(presentation) => <div data-testid="apt-action-next-step" class="rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900 dark:border-blue-800 dark:bg-blue-950/40 dark:text-blue-200"><div class="font-semibold">What to do next</div><p class="mt-1">{presentation().nextStep}</p></div>}</Show>
</section>
)}
</Show>
+
+ <Show when={props.detail?.attempt || props.detail?.receipt}>
+ <section aria-labelledby="action-delivery-heading" data-testid="action-delivery-truth" class="rounded-lg border border-border bg-surface p-4">
+ <h3 id="action-delivery-heading" class="text-sm font-semibold text-base-content">Durable delivery record</h3>
+ <p class="mt-2 text-sm font-medium">{props.detail?.receipt ? 'One agent receipt is recorded for this action.' : props.detail?.attempt?.state === 'receipt_pending' ? 'The action was sent once and Pulse is waiting for the durable agent receipt.' : 'Pulse recorded the delivery attempt before sending it.'}</p>
+ <p class="mt-1 text-sm text-muted">Refreshing or reconnecting re-reads this action record; it does not create another action.</p>
+ <dl class="mt-3 grid gap-3 text-sm sm:grid-cols-2">
+ <Show when={firstEvidence()?.observedAt}><div><dt class="text-muted">Agent observation</dt><dd>{new Date(firstEvidence()!.observedAt).toLocaleString()}</dd></div></Show>
+ <Show when={props.detail?.receipt?.receivedAt}><div><dt class="text-muted">Receipt recorded by Pulse</dt><dd>{new Date(props.detail!.receipt!.receivedAt).toLocaleString()}</dd></div></Show>
+ </dl>
+ <details class="mt-3 rounded border border-border-subtle p-3 text-xs"><summary class="cursor-pointer font-medium">Delivery identifiers</summary><div class="mt-2 break-all text-muted">Action {props.audit.id}<Show when={props.detail?.attempt?.id}> · Attempt {props.detail?.attempt?.id}</Show><Show when={props.detail?.receipt?.transportRequestId}> · Transport {props.detail?.receipt?.transportRequestId}</Show></div></details>
+ </section>
+ </Show>
</div>
);
};
diff --git a/frontend-modern/src/features/actions/ActionReviewDialog.tsx b/frontend-modern/src/features/actions/ActionReviewDialog.tsx
index e6e8da997b..f285e2a40c 100644
--- a/frontend-modern/src/features/actions/ActionReviewDialog.tsx
+++ b/frontend-modern/src/features/actions/ActionReviewDialog.tsx
@@ -7,6 +7,7 @@ import { notificationStore } from '@/stores/notifications';
import type { ActionDetailResponse } from '@/types/actionAudit';
import { ActionDecisionPacket } from './ActionDecisionPacket';
import { formatActionName } from './actionPresentation';
+import { getAPTActionPresentation } from './aptActionPresentation';
export const ActionReviewDialog: Component<{
detail: ActionDetailResponse | null;
@@ -26,20 +27,26 @@ export const ActionReviewDialog: Component<{
const hasCurrentPolicyProvenance = createMemo(
() => audit()?.plan.policyDecision?.status === 'resolved',
);
+ const aptParametersValid = createMemo(() => {
+ const action = audit();
+ return action ? getAPTActionPresentation(action)?.parametersValid !== false : false;
+ });
const isExpired = createMemo(() => {
const expiresAt = audit()?.plan.expiresAt;
if (!expiresAt) return true;
const timestamp = new Date(expiresAt).valueOf();
return Number.isNaN(timestamp) || timestamp <= clock();
});
- const canDecide = () => hasCurrentPolicyProvenance() && !isExpired() && audit()?.state === 'pending_approval';
+ const canDecide = () => hasCurrentPolicyProvenance() && aptParametersValid() && !isExpired() && audit()?.state === 'pending_approval';
const canExecute = () =>
hasCurrentPolicyProvenance() &&
+ aptParametersValid() &&
!isExpired() &&
(audit()?.state === 'approved' ||
(audit()?.state === 'planned' && !audit()?.plan.requiresApproval));
const invalidActionMessage = createMemo(() => {
if (!hasCurrentPolicyProvenance()) return 'This action has no current server policy provenance. Close it and create a new plan before approving or running anything.';
+ if (!aptParametersValid()) return 'This host-maintenance action contains unexpected operator-selected parameters. Close it and create a new plan; do not approve or run this record.';
if (isExpired()) return 'This action review expired. Close it and create a new plan so current resource and policy state can be checked again.';
return '';
});
@@ -90,7 +97,7 @@ export const ActionReviewDialog: Component<{
<div><p class="text-xs font-semibold uppercase tracking-wide text-muted">Governed action review</p><h2 id="action-review-title" class="mt-1 text-xl font-semibold">{formatActionName(record().request.capabilityName)}</h2><p class="mt-1 break-all text-sm text-muted">{record().request.resourceId}</p></div>
<Button variant="ghost" size="icon" aria-label="Close action review" onClick={props.onClose}><XIcon class="h-5 w-5" /></Button>
</header>
- <div class="overflow-y-auto px-5 py-4"><ActionDecisionPacket audit={record()} /><Show when={invalidActionMessage()}><div role="alert" data-testid="action-review-invalid" class="mt-4 rounded border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:bg-amber-950/40 dark:text-amber-200">{invalidActionMessage()}</div></Show><Show when={error()}><div role="alert" class="mt-4 rounded border border-red-300 bg-red-50 p-3 text-sm text-red-800 dark:bg-red-950/40 dark:text-red-200">{error()}</div></Show></div>
+ <div class="overflow-y-auto px-5 py-4"><ActionDecisionPacket audit={record()} detail={props.detail ?? undefined} /><Show when={invalidActionMessage()}><div role="alert" data-testid="action-review-invalid" class="mt-4 rounded border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:bg-amber-950/40 dark:text-amber-200">{invalidActionMessage()}</div></Show><Show when={error()}><div role="alert" class="mt-4 rounded border border-red-300 bg-red-50 p-3 text-sm text-red-800 dark:bg-red-950/40 dark:text-red-200">{error()}</div></Show></div>
<footer class="flex flex-col-reverse gap-2 border-t border-border px-5 py-4 sm:flex-row sm:justify-end">
<Button onClick={props.onClose}>Close</Button>
<Show when={canDecide()}><Button variant="danger" disabled={busy()} onClick={() => void decide('rejected')}>Reject</Button><Button variant="primary" isLoading={busy()} onClick={() => void decide('approved')}>Approve</Button></Show>
diff --git a/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx b/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
index 6561b2f49e..e644bc39ba 100644
--- a/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
+++ b/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
@@ -59,4 +59,33 @@ describe('ActionDecisionPacket', () => {
expect(within(screen.getByTestId('action-compensation-truth')).getByText('Not Attempted')).toBeInTheDocument();
cleanup();
});
+
+ it('shows bounded APT facts, agent attestation, recovery, and one durable receipt without a reboot control', () => {
+ const aptAudit: ActionAuditRecord = {
+ ...audit,
+ request: { ...audit.request, resourceId: 'proxmox:node:pve-1', capabilityName: 'install_os_updates', params: {} },
+ plan: {
+ ...audit.plan,
+ policyDecision: {
+ ...audit.plan.policyDecision!,
+ scope: { ...audit.plan.policyDecision!.scope, resourceId: 'proxmox:node:pve-1', capabilityName: 'install_os_updates' },
+ authorities: audit.plan.policyDecision!.authorities.map((authority) => ({ ...authority, scope: { ...authority.scope, resourceId: 'proxmox:node:pve-1', capabilityName: 'install_os_updates' }, reasonCodes: ['capability_approval_admin', 'capability_auto_elevated'] })),
+ },
+ },
+ result: { success: true, actionResultV2: {
+ version: 2,
+ execution: { status: 'succeeded', summary: 'APT package updates: phase=complete; 6 pending before, 0 pending after; package manager health: healthy; recovery required: false; reboot required: true' },
+ verification: { status: 'confirmed', evidenceClass: 'agent_attested', summary: 'The executing agent observed the canonical postcondition.', evidence: [{ version: 1, id: 'evidence-1', observerId: 'agent:pve-1', observerKind: 'agent', observerTrustDomain: 'host:pve-1', executorTrustDomain: 'host:pve-1', method: 'typed_read_after_write', subjectId: 'proxmox:node:pve-1', observedAt: '2026-07-12T00:01:00Z', receivedAt: '2026-07-12T00:05:00Z', digest: 'sha256:evidence' }] },
+ compensation: { support: 'unavailable', status: 'not_available', summary: 'No rollback is available.' },
+ } },
+ };
+ render(() => <ActionDecisionPacket audit={aptAudit} detail={{ audit: aptAudit, events: [], attempt: { id: 'attempt-1', actionId: aptAudit.id, state: 'receipt_recorded', createdAt: aptAudit.createdAt, updatedAt: aptAudit.updatedAt, dispatchCount: 1 }, receipt: { attemptId: 'attempt-1', actionId: aptAudit.id, transportRequestId: 'transport-1', receivedAt: '2026-07-12T00:05:00Z' } }} />);
+ expect(within(screen.getByTestId('apt-action-facts')).getByText('Yes — fact only; no reboot was authorized')).toBeInTheDocument();
+ expect(within(screen.getByTestId('action-verification-truth')).getByText('Confirmed by executing agent')).toBeInTheDocument();
+ expect(within(screen.getByTestId('action-compensation-truth')).getByText('No rollback is available.')).toBeInTheDocument();
+ expect(screen.getByText('One agent receipt is recorded for this action.')).toBeInTheDocument();
+ expect(screen.getAllByTestId('action-delivery-truth')).toHaveLength(1);
+ expect(screen.queryByRole('button', { name: /reboot/i })).toBeNull();
+ expect(screen.queryByText('APT package updates:', { exact: false })).toBeNull();
+ });
});
diff --git a/frontend-modern/src/features/actions/__tests__/ActionReviewDialog.test.tsx b/frontend-modern/src/features/actions/__tests__/ActionReviewDialog.test.tsx
index 32b43971bc..8e89f46101 100644
--- a/frontend-modern/src/features/actions/__tests__/ActionReviewDialog.test.tsx
+++ b/frontend-modern/src/features/actions/__tests__/ActionReviewDialog.test.tsx
@@ -38,4 +38,14 @@ describe('ActionReviewDialog trust gates', () => {
expect(screen.queryByRole('button', { name: 'Approve' })).toBeNull();
expect(screen.getByTestId('action-review-invalid')).toHaveTextContent('review expired');
});
+
+ it('offers no decision or run control when a typed APT action carries parameters', () => {
+ const audit = makeAudit('resolved', '2099-01-01T00:00:00Z');
+ audit.request = { ...audit.request, capabilityName: 'install_os_updates', params: { package: 'curl' } };
+ audit.plan.policyDecision!.scope.capabilityName = 'install_os_updates';
+ render(() => <ActionReviewDialog detail={detail(audit)} onClose={vi.fn()} />);
+ expect(screen.getByTestId('action-review-invalid')).toHaveTextContent('unexpected operator-selected parameters');
+ expect(screen.queryByRole('button', { name: 'Approve' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Run action' })).toBeNull();
+ });
});
diff --git a/frontend-modern/src/features/actions/__tests__/aptActionPresentation.test.ts b/frontend-modern/src/features/actions/__tests__/aptActionPresentation.test.ts
new file mode 100644
index 0000000000..6263c09c70
--- /dev/null
+++ b/frontend-modern/src/features/actions/__tests__/aptActionPresentation.test.ts
@@ -0,0 +1,125 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { describe, expect, it } from 'vitest';
+import type { ActionAuditRecord, ActionExecutionStatus, ActionVerificationTruthStatus } from '@/types/actionAudit';
+import { getAPTActionPresentation } from '../aptActionPresentation';
+
+const source = readFileSync(resolve(__dirname, '..', 'aptActionPresentation.ts'), 'utf8');
+
+const makeAudit = ({
+ capabilityName = 'install_os_updates',
+ summary,
+ execution = 'inconclusive',
+ verification = 'inconclusive',
+ reasonCode = 'capability_auto_elevated',
+ params,
+}: {
+ capabilityName?: 'install_os_updates' | 'clean_package_cache';
+ summary?: string;
+ execution?: ActionExecutionStatus;
+ verification?: ActionVerificationTruthStatus;
+ reasonCode?: 'capability_auto_elevated' | 'capability_auto_low_risk';
+ params?: Record<string, unknown>;
+} = {}): ActionAuditRecord => ({
+ id: 'apt-action', createdAt: '2026-07-12T10:00:00Z', updatedAt: '2026-07-12T10:01:00Z', state: 'completed',
+ request: { requestId: 'apt-request', resourceId: 'proxmox:node:pve-1', capabilityName, params, reason: 'Resolve the current Patrol finding', requestedBy: 'pulse_patrol' },
+ plan: {
+ actionId: 'apt-action', requestId: 'apt-request', allowed: true, requiresApproval: reasonCode === 'capability_auto_elevated', approvalPolicy: reasonCode === 'capability_auto_elevated' ? 'admin' : 'none', rollbackAvailable: false,
+ policyDecision: { version: 1, status: 'resolved', decisionId: 'decision', actionId: 'apt-action', scope: { orgId: 'org-1', resourceId: 'proxmox:node:pve-1', capabilityName }, approvalRequirement: { version: 1, floor: reasonCode === 'capability_auto_elevated' ? 'admin' : 'none', quorum: 1, disallowRequester: false }, planningAllowed: true, requiresApproval: reasonCode === 'capability_auto_elevated', authorities: [{ kind: 'capability_registry', sourceId: `capability-registry:${capabilityName}`, status: 'consulted', scope: { orgId: 'org-1', resourceId: 'proxmox:node:pve-1', capabilityName }, reasonCodes: [reasonCode] }] },
+ },
+ result: { success: execution === 'succeeded', actionResultV2: { version: 2, execution: { status: execution, summary }, verification: { status: verification, evidenceClass: 'agent_attested' }, compensation: { support: 'unavailable', status: 'not_available' } } },
+ verificationOutcome: { status: 'unknown' },
+});
+
+describe('APT action presentation', () => {
+ it('presents an elevated update plan with exact empty parameter authority', () => {
+ const presentation = getAPTActionPresentation(makeAudit());
+ expect(presentation).toMatchObject({ safetyPosture: 'Elevated change', approvalPosture: 'Administrator approval required', parametersValid: true });
+ expect(presentation?.parameterAuthority).toContain('accepts no command, path, package selection, removal choice, or reboot request');
+ expect(presentation?.authorityBoundary).toContain('cannot remove packages or reboot');
+ });
+
+ it('presents cleanup as low-risk eligible but irreversible and bounded', () => {
+ const presentation = getAPTActionPresentation(makeAudit({ capabilityName: 'clean_package_cache', reasonCode: 'capability_auto_low_risk' }));
+ expect(presentation).toMatchObject({ safetyPosture: 'Low-risk automation eligible', approvalPosture: 'No separate approval required by this plan' });
+ expect(presentation?.authorityBoundary).toContain('only downloaded package data');
+ });
+
+ it('shows confirmed agent-attested update facts without inventing independent proof or reboot authority', () => {
+ const presentation = getAPTActionPresentation(makeAudit({
+ summary: 'APT package updates: phase=complete; 6 pending before, 0 pending after; package manager health: healthy; recovery required: false; reboot required: true',
+ execution: 'succeeded', verification: 'confirmed',
+ }));
+ expect(presentation?.facts).toEqual(expect.arrayContaining([
+ { label: 'Updates remaining', value: '0' },
+ { label: 'Update system health', value: 'Known healthy' },
+ { label: 'Reboot required', value: 'Yes — fact only; no reboot was authorized' },
+ ]));
+ expect(presentation?.nextStep).toContain('separate governed action');
+ });
+
+ it('makes a partial unhealthy install recovery-required and forbids automatic retry', () => {
+ const presentation = getAPTActionPresentation(makeAudit({
+ summary: 'APT package updates: phase=install; 6 pending before, 3 pending after; package manager health: unhealthy; recovery required: true; reboot required: false',
+ execution: 'inconclusive', verification: 'contradicted',
+ }));
+ expect(presentation?.facts).toEqual(expect.arrayContaining([
+ { label: 'Last phase reached', value: 'Install updates' },
+ { label: 'Updates remaining', value: '3' },
+ { label: 'Update system health', value: 'Known unhealthy' },
+ { label: 'Recovery required', value: 'Yes' },
+ ]));
+ expect(presentation?.nextStep).toMatch(/^Do not retry\./);
+ });
+
+ it('keeps a delayed legacy result inconclusive when health is unknown', () => {
+ const presentation = getAPTActionPresentation(makeAudit({
+ summary: 'APT package updates: phase=verify; 4 pending before, 4 pending after; package manager health: unknown; recovery required: false; reboot required: false',
+ }));
+ expect(presentation?.facts).toContainEqual({ label: 'Update system health', value: 'Unknown' });
+ expect(presentation?.nextStep).toContain('Do not retry automatically');
+ });
+
+ it('shows measured cleanup bytes and an irreversible rescan-required failure', () => {
+ const presentation = getAPTActionPresentation(makeAudit({
+ capabilityName: 'clean_package_cache', reasonCode: 'capability_auto_low_risk',
+ summary: 'APT package cache: phase=clean; 104857600 bytes before, 52428800 bytes after, 52428800 bytes reclaimed; rollback available: false; rescan required: true',
+ execution: 'failed', verification: 'inconclusive',
+ }));
+ expect(presentation?.facts).toEqual(expect.arrayContaining([
+ { label: 'Downloaded package data before', value: '100 MB' },
+ { label: 'Downloaded package data after', value: '50.0 MB' },
+ { label: 'Space reclaimed', value: '50.0 MB' },
+ { label: 'Rollback', value: 'Unavailable — cleanup is irreversible' },
+ { label: 'Fresh rescan required', value: 'Yes' },
+ ]));
+ expect(presentation?.nextStep).toContain('Do not retry automatically');
+ });
+
+ it('fails closed for unexpected parameters and malformed result summaries', () => {
+ const presentation = getAPTActionPresentation(makeAudit({ params: { package: 'curl' }, summary: 'phase=complete; success=true' }));
+ expect(presentation?.parametersValid).toBe(false);
+ expect(presentation?.facts).toEqual([]);
+ expect(presentation?.parameterAuthority).toContain('Unexpected parameters');
+ expect(presentation?.nextStep).toContain('Refresh this action record');
+ });
+
+ it.each([
+ ['unknown update phase', 'install_os_updates', 'APT package updates: phase=download; 6 pending before, 3 pending after; package manager health: healthy; recovery required: false; reboot required: false'],
+ ['cleanup-only phase in update', 'install_os_updates', 'APT package updates: phase=clean; 6 pending before, 3 pending after; package manager health: healthy; recovery required: false; reboot required: false'],
+ ['update-only phase in cleanup', 'clean_package_cache', 'APT package cache: phase=install; 100 bytes before, 50 bytes after, 50 bytes reclaimed; rollback available: false; rescan required: false'],
+ ['unsafe update count', 'install_os_updates', 'APT package updates: phase=verify; 999999999999999999999 pending before, 0 pending after; package manager health: healthy; recovery required: false; reboot required: false'],
+ ['impossible cleanup remainder', 'clean_package_cache', 'APT package cache: phase=verify; 100 bytes before, 120 bytes after, 0 bytes reclaimed; rollback available: false; rescan required: true'],
+ ['impossible cleanup reclaimed arithmetic', 'clean_package_cache', 'APT package cache: phase=verify; 100 bytes before, 50 bytes after, 40 bytes reclaimed; rollback available: false; rescan required: true'],
+ ] as const)('fails closed for %s', (_name, capabilityName, summary) => {
+ const presentation = getAPTActionPresentation(makeAudit({ capabilityName, summary }));
+ expect(presentation?.facts).toEqual([]);
+ expect(presentation?.nextStep).toContain('Refresh this action record');
+ });
+
+ it('does not declare a second frontend action truth dialect', () => {
+ expect(source).not.toMatch(/(?:type|enum)\s+APT(?:Execution|Verification|Evidence|Health|Recovery|Compensation)/);
+ expect(source).toContain("import type { ActionAuditRecord } from '@/types/actionAudit'");
+ expect(source).toContain("actionResultV2?.verification");
+ });
+});
diff --git a/frontend-modern/src/features/actions/actionPresentation.ts b/frontend-modern/src/features/actions/actionPresentation.ts
index c06cdcde7b..da2a8b7951 100644
--- a/frontend-modern/src/features/actions/actionPresentation.ts
+++ b/frontend-modern/src/features/actions/actionPresentation.ts
@@ -6,7 +6,11 @@ import type {
} from '@/types/actionAudit';
export const formatActionName = (value: string): string =>
- value
+ value === 'install_os_updates'
+ ? 'Install operating system updates'
+ : value === 'clean_package_cache'
+ ? 'Clear downloaded package data'
+ : value
.replace(/[._-]+/g, ' ')
.trim()
.replace(/\b\w/g, (letter) => letter.toUpperCase());
diff --git a/frontend-modern/src/features/actions/aptActionPresentation.ts b/frontend-modern/src/features/actions/aptActionPresentation.ts
new file mode 100644
index 0000000000..38f1f94358
--- /dev/null
+++ b/frontend-modern/src/features/actions/aptActionPresentation.ts
@@ -0,0 +1,161 @@
+import type { ActionAuditRecord } from '@/types/actionAudit';
+import { formatBytes } from '@/utils/format';
+
+export interface APTActionPresentationFact {
+ label: string;
+ value: string;
+}
+
+export interface APTActionPresentation {
+ title: string;
+ safetyPosture: string;
+ approvalPosture: string;
+ parameterAuthority: string;
+ parametersValid: boolean;
+ authorityBoundary: string;
+ facts: APTActionPresentationFact[];
+ nextStep: string;
+}
+
+const parseCount = (value: string): number | undefined => {
+ const parsed = Number(value);
+ return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : undefined;
+};
+
+const formatPhase = (value: string, workflow: 'update' | 'cleanup'): string | undefined => {
+ switch (value.trim()) {
+ case 'preflight':
+ return 'Safety check before changes';
+ case 'refresh':
+ return workflow === 'update' ? 'Refresh update information' : undefined;
+ case 'install':
+ return workflow === 'update' ? 'Install updates' : undefined;
+ case 'clean':
+ return workflow === 'cleanup' ? 'Clear downloaded package data' : undefined;
+ case 'verify':
+ return 'Check the result';
+ case 'complete':
+ return 'Completed workflow';
+ default:
+ return undefined;
+ }
+};
+
+const getPolicyReasonCodes = (audit: ActionAuditRecord): string[] =>
+ (audit.plan.policyDecision?.authorities ?? []).flatMap((authority) => authority.reasonCodes);
+
+const hasExactEmptyParameters = (audit: ActionAuditRecord): boolean =>
+ audit.request.params === undefined || Object.keys(audit.request.params).length === 0;
+
+const getUpdateFacts = (summary: string): APTActionPresentationFact[] => {
+ const match = summary.match(
+ /^APT package updates: phase=([^;]+); (\d+) pending before, (\d+) pending after; package manager health: (healthy|unhealthy|unknown); recovery required: (true|false); reboot required: (true|false)$/,
+ );
+ if (!match) return [];
+ const before = parseCount(match[2]);
+ const after = parseCount(match[3]);
+ const phase = formatPhase(match[1], 'update');
+ if (before === undefined || after === undefined || !phase) return [];
+ const health = match[4] === 'healthy' ? 'Known healthy' : match[4] === 'unhealthy' ? 'Known unhealthy' : 'Unknown';
+ return [
+ { label: 'Last phase reached', value: phase },
+ { label: 'Updates before', value: String(before) },
+ { label: 'Updates remaining', value: String(after) },
+ { label: 'Update system health', value: health },
+ { label: 'Recovery required', value: match[5] === 'true' ? 'Yes' : 'No' },
+ { label: 'Reboot required', value: match[6] === 'true' ? 'Yes — fact only; no reboot was authorized' : 'No' },
+ ];
+};
+
+const getCleanupFacts = (summary: string): APTActionPresentationFact[] => {
+ const match = summary.match(
+ /^APT package cache: phase=([^;]+); (\d+) bytes before, (\d+) bytes after, (\d+) bytes reclaimed; rollback available: false; rescan required: (true|false)$/,
+ );
+ if (!match) return [];
+ const before = parseCount(match[2]);
+ const after = parseCount(match[3]);
+ const reclaimed = parseCount(match[4]);
+ const phase = formatPhase(match[1], 'cleanup');
+ if (
+ before === undefined ||
+ after === undefined ||
+ reclaimed === undefined ||
+ !phase ||
+ after > before ||
+ reclaimed !== before - after
+ ) return [];
+ return [
+ { label: 'Last phase reached', value: phase },
+ { label: 'Downloaded package data before', value: formatBytes(before) },
+ { label: 'Downloaded package data after', value: formatBytes(after) },
+ { label: 'Space reclaimed', value: formatBytes(reclaimed) },
+ { label: 'Rollback', value: 'Unavailable — cleanup is irreversible' },
+ { label: 'Fresh rescan required', value: match[5] === 'true' ? 'Yes' : 'No' },
+ ];
+};
+
+const getFactValue = (facts: APTActionPresentationFact[], label: string): string =>
+ facts.find((fact) => fact.label === label)?.value ?? '';
+
+export const isAPTAction = (audit: Pick<ActionAuditRecord, 'request'>): boolean =>
+ audit.request.capabilityName === 'install_os_updates' ||
+ audit.request.capabilityName === 'clean_package_cache';
+
+export const getAPTActionPresentation = (
+ audit: ActionAuditRecord,
+): APTActionPresentation | undefined => {
+ if (!isAPTAction(audit)) return undefined;
+
+ const isUpdate = audit.request.capabilityName === 'install_os_updates';
+ const parametersValid = hasExactEmptyParameters(audit);
+ const reasons = getPolicyReasonCodes(audit);
+ const summary = audit.result?.actionResultV2?.execution.summary?.trim() ?? '';
+ const facts = isUpdate ? getUpdateFacts(summary) : getCleanupFacts(summary);
+ const verification = audit.result?.actionResultV2?.verification;
+ const recoveryRequired = getFactValue(facts, 'Recovery required') === 'Yes';
+ const health = getFactValue(facts, 'Update system health');
+ const rescanRequired = getFactValue(facts, 'Fresh rescan required') === 'Yes';
+
+ let nextStep = 'Review the server policy and exact scope before making a decision.';
+ if (audit.result?.actionResultV2 && facts.length === 0) {
+ nextStep = 'Refresh this action record and review the canonical result before deciding what to do next.';
+ } else if (verification?.status === 'confirmed') {
+ nextStep = isUpdate
+ ? 'Review the remaining-update and reboot facts. A reboot, if needed, is a separate governed action.'
+ : 'Review the measured space reclaimed. Create another cleanup plan only if a fresh scan still shows pressure.';
+ } else if (audit.result?.actionResultV2) {
+ if (isUpdate && recoveryRequired) {
+ nextStep = 'Do not retry. Repair the host update system, run a fresh scan, and create a new plan only after health is known.';
+ } else if (isUpdate && health === 'Unknown') {
+ nextStep = 'Do not retry automatically. Run a fresh host scan so update-system health and remaining updates are known.';
+ } else if (!isUpdate && rescanRequired) {
+ nextStep = 'Do not retry automatically. Run a fresh scan to measure the current cache pressure before creating another plan.';
+ } else {
+ nextStep = 'Review the separate execution and verification results, then rescan before creating another plan.';
+ }
+ }
+
+ return {
+ title: isUpdate ? 'Install operating system updates' : 'Clear downloaded package data',
+ safetyPosture: reasons.includes('capability_auto_elevated')
+ ? 'Elevated change'
+ : reasons.includes('capability_auto_low_risk')
+ ? 'Low-risk automation eligible'
+ : 'Server policy controlled',
+ approvalPosture:
+ audit.plan.approvalPolicy === 'admin'
+ ? 'Administrator approval required'
+ : audit.plan.requiresApproval
+ ? 'Explicit approval required'
+ : 'No separate approval required by this plan',
+ parameterAuthority: parametersValid
+ ? 'None. This typed action accepts no command, path, package selection, removal choice, or reboot request.'
+ : 'Unexpected parameters are present. Close this review and create a new plan.',
+ parametersValid,
+ authorityBoundary: isUpdate
+ ? 'The agent may refresh update information and install the complete approved update set. It cannot remove packages or reboot the host.'
+ : 'The agent may clear only downloaded package data on the pressured filesystem. It cannot choose paths, remove installed packages, or reboot the host.',
+ facts,
+ nextStep,
+ };
+};
diff --git a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
index c6fc914d69..c49953297e 100644
--- a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
+++ b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
@@ -112,6 +112,7 @@ describe('aiIntelligenceStore', () => {
vi.mocked(getPatrolFindings).mockResolvedValueOnce([
{
id: 'patrol-finding-1',
+ key: 'apt-host-updates',
severity: 'warning',
category: 'reliability',
resource_id: 'instance:node:100',
@@ -135,6 +136,7 @@ describe('aiIntelligenceStore', () => {
expect(aiIntelligenceStore.patrolFindings).toHaveLength(1);
expect(aiIntelligenceStore.patrolFindings[0]).toMatchObject({
id: 'patrol-finding-1',
+ key: 'apt-host-updates',
source: 'ai-patrol',
isThreshold: false,
status: 'active',
diff --git a/frontend-modern/src/stores/aiIntelligence.ts b/frontend-modern/src/stores/aiIntelligence.ts
index 6d7b3f7cef..71c35542e2 100644
--- a/frontend-modern/src/stores/aiIntelligence.ts
+++ b/frontend-modern/src/stores/aiIntelligence.ts
@@ -143,6 +143,7 @@ function normalizeFindingStatus(item: FindingStatusInput, now: number): UnifiedF
export interface UnifiedFinding {
id: string;
+ key?: string;
source: 'threshold' | 'ai-patrol' | 'ai-chat' | 'anomaly' | 'correlation' | 'forecast';
resourceId: string;
resourceName: string;
@@ -280,6 +281,7 @@ function normalizeUnifiedFindingRecord(item: UnifiedFindingRecord, now: number):
function normalizePatrolFindingRecord(item: PatrolFinding, now: number): UnifiedFinding {
return {
id: item.id,
+ key: item.key,
source: 'ai-patrol',
resourceId: item.resource_id,
resourceName: item.resource_name || item.resource_id,
diff --git a/frontend-modern/src/utils/__tests__/aiFindingPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiFindingPresentation.test.ts
index 45ce144c4a..ad19b22d52 100644
--- a/frontend-modern/src/utils/__tests__/aiFindingPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/aiFindingPresentation.test.ts
@@ -2,10 +2,47 @@ import { describe, expect, it } from 'vitest';
import type { UnifiedFinding } from '@/stores/aiIntelligence';
import {
+ getFindingEvidencePresentation,
getFindingResourceCriticalitySortOrder,
sortFindingsForAttentionQueue,
} from '@/utils/aiFindingPresentation';
+describe('getFindingEvidencePresentation', () => {
+ it('presents bounded update evidence without package inventory or fingerprints', () => {
+ const evidence = getFindingEvidencePresentation(makeFinding({ key: 'apt-host-updates', evidence: 'pending_updates=6 inventory=sha256:secret checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z reboot_required=true' }));
+ expect(evidence).toContain('6 operating system updates were pending');
+ expect(evidence).toContain('Pulse received that observation');
+ expect(evidence).toContain('reboot required: Yes');
+ expect(evidence).toContain('No reboot is authorized by this finding or action');
+ expect(evidence).not.toContain('sha256');
+ expect(evidence).not.toContain('inventory');
+ });
+
+ it('presents cleanup pressure without exposing the raw fingerprint', () => {
+ const evidence = getFindingEvidencePresentation(makeFinding({ key: 'apt-package-cache-pressure', evidence: 'reclaimable_bytes=104857600 filesystem_usage=91.5 fingerprint=sha256:secret checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z' }));
+ expect(evidence).toContain('100 MB of downloaded package data');
+ expect(evidence).toContain('91.5% full');
+ expect(evidence).not.toContain('fingerprint');
+ expect(evidence).not.toContain('sha256');
+ });
+
+ it('fails closed instead of partially interpreting malformed APT evidence', () => {
+ expect(getFindingEvidencePresentation(makeFinding({ key: 'apt-host-updates', evidence: 'pending_updates=6 inventory=leaked' }))).toContain('could not safely present');
+ });
+
+ it.each([
+ ['unsafe update count', 'apt-host-updates', 'pending_updates=999999999999999999999 inventory=sha256:x checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z reboot_required=false'],
+ ['invalid update timestamp', 'apt-host-updates', 'pending_updates=6 inventory=sha256:x checked_at=not-a-time received_at=2026-07-12T10:05:00Z reboot_required=false'],
+ ['dotted usage', 'apt-package-cache-pressure', 'reclaimable_bytes=100 filesystem_usage=9.1.5 fingerprint=sha256:x checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z'],
+ ['NaN usage', 'apt-package-cache-pressure', 'reclaimable_bytes=100 filesystem_usage=NaN fingerprint=sha256:x checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z'],
+ ['usage above 100', 'apt-package-cache-pressure', 'reclaimable_bytes=100 filesystem_usage=100.1 fingerprint=sha256:x checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z'],
+ ['unsafe reclaimable bytes', 'apt-package-cache-pressure', 'reclaimable_bytes=999999999999999999999 filesystem_usage=91.5 fingerprint=sha256:x checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z'],
+ ['invalid cleanup timestamp', 'apt-package-cache-pressure', 'reclaimable_bytes=100 filesystem_usage=91.5 fingerprint=sha256:x checked_at=2026-07-12T10:00:00Z received_at=not-a-time'],
+ ] as const)('uses the bounded fallback for %s', (_name, key, evidence) => {
+ expect(getFindingEvidencePresentation(makeFinding({ key, evidence }))).toContain('could not safely present');
+ });
+});
+
function makeFinding(overrides: Partial<UnifiedFinding>): UnifiedFinding {
return {
id: overrides.id ?? 'finding',
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 7d3c439a55..8ffad1d862 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -5,6 +5,7 @@ import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
import { isLivePendingApproval } from '@/utils/approvalState';
import { getPatrolProviderSettingsAction } from '@/utils/patrolRuntimeActions';
import { formatIdentifierLabel } from '@/utils/textPresentation';
+import { formatBytes } from '@/utils/format';
const DEFAULT_BADGE_CLASSES = 'border-border bg-surface-alt text-muted';
const DEFAULT_LOOP_STATE_CLASSES = 'border-border bg-surface-alt text-muted';
@@ -685,6 +686,41 @@ export interface PatrolFindingRowScaffold {
items: PatrolFindingRowScaffoldItem[];
}
+const formatBoundedFindingTime = (value: string): string | undefined => {
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(value)) return undefined;
+ const parsed = new Date(value);
+ return Number.isNaN(parsed.valueOf()) ? undefined : parsed.toLocaleString();
+};
+
+export function getFindingEvidencePresentation(
+ finding: Pick<UnifiedFinding, 'evidence' | 'key'>,
+): string {
+ const evidence = String(finding.evidence || '').trim();
+ if (finding.key === 'apt-host-updates') {
+ const match = evidence.match(
+ /^pending_updates=(\d+) inventory=\S+ checked_at=(\S+) received_at=(\S+) reboot_required=(true|false)$/,
+ );
+ const count = match ? Number(match[1]) : Number.NaN;
+ const checkedAt = match ? formatBoundedFindingTime(match[2]) : undefined;
+ const receivedAt = match ? formatBoundedFindingTime(match[3]) : undefined;
+ if (!match || !Number.isSafeInteger(count) || count < 0 || !checkedAt || !receivedAt) return 'Pulse could not safely present the bounded host-update observation. Refresh before acting.';
+ const rebootBoundary = match[4] === 'true' ? 'Yes. No reboot is authorized by this finding or action.' : 'No.';
+ return `${count} operating system update${count === 1 ? '' : 's'} ${count === 1 ? 'was' : 'were'} pending when the agent checked at ${checkedAt}. Pulse received that observation at ${receivedAt}. The host already reported reboot required: ${rebootBoundary}`;
+ }
+ if (finding.key === 'apt-package-cache-pressure') {
+ const match = evidence.match(
+ /^reclaimable_bytes=(\d+) filesystem_usage=([0-9.]+) fingerprint=\S+ checked_at=(\S+) received_at=(\S+)$/,
+ );
+ const bytes = match ? Number(match[1]) : Number.NaN;
+ const usage = match ? Number(match[2]) : Number.NaN;
+ const checkedAt = match ? formatBoundedFindingTime(match[3]) : undefined;
+ const receivedAt = match ? formatBoundedFindingTime(match[4]) : undefined;
+ if (!match || !Number.isSafeInteger(bytes) || bytes < 0 || !Number.isFinite(usage) || usage < 0 || usage > 100 || !checkedAt || !receivedAt) return 'Pulse could not safely present the bounded package-cleanup observation. Refresh before acting.';
+ return `${formatBytes(bytes)} of downloaded package data was reclaimable while the filesystem was ${usage}% full. The agent checked at ${checkedAt}, and Pulse received that observation at ${receivedAt}.`;
+ }
+ return evidence;
+}
+
export function getPatrolFindingActionableState(
finding: Pick<UnifiedFinding, 'status' | 'investigationStatus' | 'investigationOutcome'>,
): PatrolActionableStatePresentation | undefined {
@@ -850,7 +886,7 @@ export function getPatrolFindingRowScaffold(
id: 'checked',
label: 'What Pulse checked',
value: getNonEmptyPresentationText(
- finding.evidence,
+ getFindingEvidencePresentation(finding),
'Patrol recorded this from the current check.',
),
},
diff --git a/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts b/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
index b3a2d70784..50876dd7f3 100644
--- a/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
+++ b/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
@@ -669,4 +669,69 @@ test.describe("Monitor-first Patrol workbench browser contract", () => {
page.getByRole("heading", { name: /^Pulse Assistant$/ }),
).toHaveCount(0);
});
+
+ test("Patrol presents bounded APT findings without package-manager internals", async ({ page }, testInfo) => {
+ test.skip(testInfo.project.name.startsWith("mobile-"), "Phone action review is covered by the Actions journey");
+ await mockMonitorFirstPatrolWorkbench(page, { findingCount: 1, runStatus: "issues_found" });
+ const updateFinding = {
+ id: "apt-updates-active", key: "apt-host-updates", alertIdentifier: `${monitoredProxmoxResource.id}::apt/updates`, severity: "warning", category: "maintenance",
+ resource_id: monitoredProxmoxResource.id, resource_name: monitoredProxmoxResource.displayName, resource_type: monitoredProxmoxResource.type,
+ title: "Operating system updates need review", description: "Patrol found a bounded host-maintenance action for review.", impact: "Unapplied updates can leave the host behind its intended maintenance posture.",
+ evidence: "pending_updates=6 inventory=sha256:must-not-render checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z reboot_required=true",
+ recommendation: "Review the governed update action. A reboot, if required later, is a separate action.", detected_at: "2026-07-12T10:00:00Z", last_seen_at: "2026-07-12T10:05:00Z", auto_resolved: false, times_raised: 1, suppressed: false, investigation_attempts: 1,
+ investigation_status: "completed", investigation_outcome: "verification_failed",
+ };
+ const cleanupFinding = {
+ id: "apt-cleanup-active", key: "apt-package-cache-pressure", alertIdentifier: `${monitoredProxmoxResource.id}::apt/cache`, severity: "warning", category: "storage",
+ resource_id: monitoredProxmoxResource.id, resource_name: monitoredProxmoxResource.displayName, resource_type: monitoredProxmoxResource.type,
+ title: "Downloaded package data is using needed space", description: "Patrol measured reclaimable downloaded package data on the pressured filesystem.", impact: "The host may run short of operational disk space.",
+ evidence: "reclaimable_bytes=104857600 filesystem_usage=91.5 fingerprint=sha256:must-not-render checked_at=2026-07-12T10:00:00Z received_at=2026-07-12T10:05:00Z",
+ recommendation: "Review the governed cleanup action and rescan after any inconclusive attempt.", detected_at: "2026-07-12T10:00:00Z", last_seen_at: "2026-07-12T10:05:00Z", auto_resolved: false, times_raised: 1, suppressed: false, investigation_attempts: 1,
+ investigation_status: "completed", investigation_outcome: "fix_failed",
+ };
+ const findings = [updateFinding];
+ await page.route("**/api/ai/patrol/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(findings) }));
+ await page.route("**/api/ai/unified/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ findings, count: 2, active_count: 2 }) }));
+ await page.goto("/patrol", { waitUntil: "domcontentloaded" });
+ await expect(page.getByRole("heading", { level: 1, name: "Patrol" })).toBeVisible();
+ await expect(page.getByText("Operating system updates need review").first()).toBeVisible();
+ await expect(page.getByText("6 operating system updates were pending when the agent checked", { exact: false })).toBeVisible();
+ await expect(page.getByText("reboot required: Yes", { exact: false })).toBeVisible();
+ await expect(page.getByText("sha256:must-not-render")).toHaveCount(0);
+ await expect(page.getByText("inventory=", { exact: false })).toHaveCount(0);
+ await page.unroute("**/api/ai/patrol/findings*");
+ await page.unroute("**/api/ai/unified/findings*");
+ await page.route("**/api/ai/patrol/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify([cleanupFinding]) }));
+ await page.route("**/api/ai/unified/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ findings: [cleanupFinding], count: 1, active_count: 1 }) }));
+ await page.reload({ waitUntil: "domcontentloaded" });
+ const cleanupTitle = page.getByText("Downloaded package data is using needed space").first();
+ await expect(cleanupTitle).toBeVisible();
+ await cleanupTitle.locator("xpath=ancestor::*[@role='button'][1]").click();
+ await expect(page.getByText("100 MB of downloaded package data was reclaimable", { exact: false }).first()).toBeVisible();
+ await expect(page.getByText("91.5% full", { exact: false }).first()).toBeVisible();
+ await expect(page.getByText("fingerprint=", { exact: false })).toHaveCount(0);
+ await testInfo.attach("apt-bounded-patrol-findings", { body: await page.screenshot(), contentType: "image/png" });
+
+ const resolvedFinding = {
+ ...updateFinding,
+ id: "apt-updates-resolved",
+ title: "Operating system updates confirmed complete",
+ auto_resolved: true,
+ resolved_at: "2026-07-12T10:06:00Z",
+ investigation_outcome: "fix_verified",
+ evidence: "pending_updates=0 inventory=sha256:must-not-render checked_at=2026-07-12T10:01:00Z received_at=2026-07-12T10:06:00Z reboot_required=false",
+ };
+ await page.unroute("**/api/ai/patrol/findings*");
+ await page.unroute("**/api/ai/unified/findings*");
+ await page.route("**/api/ai/patrol/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify([resolvedFinding]) }));
+ await page.route("**/api/ai/unified/findings*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ findings: [resolvedFinding], count: 1, active_count: 0 }) }));
+ await page.reload({ waitUntil: "domcontentloaded" });
+ await page.getByRole("button", { name: "Resolved" }).click();
+ const resolvedTitle = page.getByText("Operating system updates confirmed complete").first();
+ await expect(resolvedTitle).toBeVisible();
+ await resolvedTitle.locator("xpath=ancestor::*[@role='button'][1]").click();
+ await expect(page.getByText("0 operating system updates were pending", { exact: false }).first()).toBeVisible();
+ await expect(page.getByText("Operating system updates need review")).toHaveCount(0);
+ await testInfo.attach("apt-confirmed-postcondition-resolved", { body: await page.screenshot(), contentType: "image/png" });
+ });
});
diff --git a/tests/integration/tests/81-actions-inbox.spec.ts b/tests/integration/tests/81-actions-inbox.spec.ts
index f5749234d9..b56fba93f7 100644
--- a/tests/integration/tests/81-actions-inbox.spec.ts
+++ b/tests/integration/tests/81-actions-inbox.spec.ts
@@ -1,7 +1,8 @@
import fs from "node:fs";
import path from "node:path";
+import { createHash } from "node:crypto";
import { fileURLToPath } from "node:url";
-import { expect, test as base } from "@playwright/test";
+import { expect, test as base, type Page } from "@playwright/test";
import { createAuthenticatedStorageState } from "./helpers";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -25,6 +26,74 @@ const action = {
verificationOutcome: { status: "unknown" },
};
+type CanonicalResultFixture = {
+ execution: { status: string; reasonCode?: string };
+ verification: { status: string; evidenceClass: string; reasonCode?: string; evidence?: unknown[] };
+ compensation: { support: string; status: string };
+};
+
+const assertCanonicalResultFixture = (truth: CanonicalResultFixture): void => {
+ if (truth.execution.status !== "succeeded" && !truth.execution.reasonCode) throw new Error("non-success execution fixture requires reasonCode");
+ if (truth.verification.status === "inconclusive" && !truth.verification.reasonCode) throw new Error("inconclusive verification fixture requires reasonCode");
+ const evidenceCount = truth.verification.evidence?.length ?? 0;
+ const conclusive = truth.verification.status === "confirmed" || truth.verification.status === "contradicted";
+ if (conclusive && (truth.verification.evidenceClass === "none" || evidenceCount === 0)) throw new Error("conclusive verification fixture requires sourced evidence");
+ if (truth.verification.evidenceClass === "none" && evidenceCount !== 0) throw new Error("no-source verification fixture cannot carry evidence");
+ if (truth.verification.evidenceClass !== "none" && evidenceCount === 0) throw new Error("declared evidence source fixture requires evidence");
+ if (truth.verification.evidenceClass === "independent") throw new Error("APT browser fixtures cannot claim tier-6 independent evidence");
+ if (truth.verification.status === "not_attempted" && (truth.verification.evidenceClass !== "none" || evidenceCount !== 0)) throw new Error("not-attempted verification fixture cannot carry evidence");
+ if (truth.compensation.support !== "unavailable" || truth.compensation.status !== "not_available") throw new Error("APT fixture cannot claim rollback or compensation");
+};
+
+const aptAction = ({ id, capabilityName, state = "completed", summary, execution = "succeeded", verification = "confirmed", evidenceClass, verificationReasonCode, elevated = true, params = {} }: {
+ id: string;
+ capabilityName: "install_os_updates" | "clean_package_cache";
+ state?: string;
+ summary?: string;
+ execution?: string;
+ verification?: string;
+ evidenceClass?: string;
+ verificationReasonCode?: string;
+ elevated?: boolean;
+ params?: Record<string, unknown>;
+}) => {
+ const aptScope = { orgId: "org-1", resourceId: "proxmox:node:pve-1", capabilityName };
+ const requiresApproval = state === "pending_approval";
+ const executionReasonCode = execution === "inconclusive" ? "possible_partial_effect" : execution === "failed" ? "execution_failed" : execution === "not_run" ? "preflight_refused" : undefined;
+ const resolvedEvidenceClass = evidenceClass ?? (verification === "confirmed" || verification === "contradicted" ? "agent_attested" : "none");
+ const resolvedVerificationReason = verificationReasonCode ?? (verification === "inconclusive" ? "agent_readback_inconclusive" : undefined);
+ const evidenceEnvelope = { version: 1, id: `${id}-evidence`, observerId: "agent:pve-1", observerKind: "unified_agent", observerTrustDomain: "agent:pve-1", executorTrustDomain: "agent:pve-1", method: "typed_read_after_write", subjectId: aptScope.resourceId, observedAt: "2026-07-12T10:01:00Z", receivedAt: "2026-07-12T10:05:00Z", digest: "" };
+ const evidence = resolvedEvidenceClass === "none" ? undefined : [{ ...evidenceEnvelope, digest: `sha256:${createHash("sha256").update(JSON.stringify(evidenceEnvelope)).digest("hex")}` }];
+ const actionResultV2 = summary ? {
+ version: 2 as const,
+ execution: { status: execution, ...(executionReasonCode ? { reasonCode: executionReasonCode } : {}), summary },
+ verification: { status: verification, evidenceClass: resolvedEvidenceClass, ...(resolvedVerificationReason ? { reasonCode: resolvedVerificationReason } : {}), summary: verification === "confirmed" ? "The executing agent observed the canonical postcondition." : "The canonical postcondition was not confirmed.", ...(evidence ? { evidence } : {}) },
+ compensation: { support: "unavailable", status: "not_available", summary: "No rollback is available for this typed workflow." },
+ } : undefined;
+ if (actionResultV2) assertCanonicalResultFixture(actionResultV2);
+ return {
+ id, createdAt: "2026-07-12T10:00:00Z", updatedAt: "2026-07-12T10:05:00Z", state, decisionRevision: 0,
+ request: { requestId: `${id}-request`, resourceId: aptScope.resourceId, capabilityName, params, reason: capabilityName === "install_os_updates" ? "Resolve the current operating system update finding" : "Relieve package data pressure reported by Patrol", requestedBy: "pulse_patrol" },
+ plan: { actionId: id, requestId: `${id}-request`, allowed: true, requiresApproval, approvalPolicy: requiresApproval ? "admin" : "none", approvalRequirement: { ...requirement, floor: requiresApproval ? "admin" : "none" }, rollbackAvailable: false, plannedAt: "2026-07-12T10:00:00Z", expiresAt: "2099-07-12T10:10:00Z", resourceVersion: "resource:sha256:apt", policyVersion: "policy:sha256:apt", planHash: `sha256:${id}`, policyDecision: { version: 1, status: "resolved", decisionId: `policy-decision:${id}`, actionId: id, scope: aptScope, approvalRequirement: { ...requirement, floor: requiresApproval ? "admin" : "none" }, planningAllowed: true, requiresApproval, authorities: [{ kind: "capability_registry", sourceId: `capability-registry:${capabilityName}`, revision: "policy:sha256:apt", status: "consulted", scope: aptScope, approvalFloor: requiresApproval ? "admin" : "none", reasonCodes: [requiresApproval ? "capability_approval_admin" : "capability_approval_none", elevated ? "capability_auto_elevated" : "capability_auto_low_risk"] }] } },
+ ...(actionResultV2 ? { result: { success: execution === "succeeded", actionResultV2 } } : {}),
+ verificationOutcome: { status: verification === "confirmed" ? "verified" : verification === "contradicted" ? "failed" : verification === "inconclusive" ? "unverified" : "unknown" },
+ };
+};
+
+const routeActionFixtures = async (page: Page, pending: ReturnType<typeof aptAction>[], settled: ReturnType<typeof aptAction>[]) => {
+ const all = [...pending, ...settled];
+ await page.route("**/api/actions?*", async (route) => {
+ const view = new URL(route.request().url()).searchParams.get("view");
+ const actions = view === "pending" ? pending : settled;
+ await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ view, actions, count: actions.length }) });
+ });
+ await page.route("**/api/actions/*", async (route) => {
+ const id = decodeURIComponent(new URL(route.request().url()).pathname.split("/").pop() || "");
+ const audit = all.find((candidate) => candidate.id === id);
+ await route.fulfill({ status: audit ? 200 : 404, contentType: "application/json", body: JSON.stringify(audit ? { audit, events: [], attempt: { id: `${id}-attempt`, actionId: id, state: "receipt_recorded", createdAt: audit.createdAt, updatedAt: audit.updatedAt, dispatchCount: 1 }, receipt: { attemptId: `${id}-attempt`, actionId: id, transportRequestId: `${id}-transport`, receivedAt: "2026-07-12T10:05:00Z" } } : { error: "not found" }) });
+ });
+};
+
test("Actions inbox exposes the canonical decision packet and durable calm history", async ({ page }, testInfo) => {
await page.route("**/api/actions?*", async (route) => {
const view = new URL(route.request().url()).searchParams.get("view");
@@ -52,3 +121,103 @@ test("Actions inbox gives a recoverable error without presenting stale authority
await expect(page.getByTestId("actions-calm-state")).toHaveCount(0);
await testInfo.attach("actions-recoverable-error", { body: await page.screenshot(), contentType: "image/png" });
});
+
+test("APT plans expose exact empty authority and elevated versus low-risk posture", async ({ page }, testInfo) => {
+ const update = aptAction({ id: "apt-update-pending", capabilityName: "install_os_updates", state: "pending_approval", elevated: true });
+ const cleanup = aptAction({ id: "apt-cleanup-planned", capabilityName: "clean_package_cache", state: "planned", elevated: false });
+ await routeActionFixtures(page, [update, cleanup], []);
+ await page.goto("/actions", { waitUntil: "domcontentloaded" });
+
+ await page.getByRole("button", { name: /Install operating system updates.*proxmox:node:pve-1/ }).click();
+ const updateDialog = page.getByRole("dialog", { name: "Install operating system updates" });
+ await expect(updateDialog.getByText("Elevated change")).toBeVisible();
+ await expect(updateDialog.getByText(/accepts no command, path, package selection, removal choice, or reboot request/)).toBeVisible();
+ await expect(updateDialog.getByText(/cannot remove packages or reboot the host/)).toBeVisible();
+ await expect(updateDialog.getByRole("button", { name: "Approve" })).toBeVisible();
+ await expect(updateDialog.getByRole("button", { name: /reboot/i })).toHaveCount(0);
+ await page.keyboard.press("Escape");
+
+ await page.getByRole("button", { name: /Clear downloaded package data.*proxmox:node:pve-1/ }).click();
+ const cleanupDialog = page.getByRole("dialog", { name: "Clear downloaded package data" });
+ await expect(cleanupDialog.getByText("Low-risk automation eligible")).toBeVisible();
+ await expect(cleanupDialog.getByText(/clear only downloaded package data/)).toBeVisible();
+ await expect(cleanupDialog.getByRole("button", { name: "Run action" })).toBeVisible();
+ await testInfo.attach("apt-empty-authority-and-policy-posture", { body: await page.screenshot(), contentType: "image/png" });
+});
+
+test("APT history keeps update execution verification recovery and delayed receipt truth separate", async ({ page }, testInfo) => {
+ const confirmed = aptAction({ id: "apt-update-confirmed", capabilityName: "install_os_updates", summary: "APT package updates: phase=complete; 6 pending before, 0 pending after; package manager health: healthy; recovery required: false; reboot required: true" });
+ const partial = aptAction({ id: "apt-update-partial", capabilityName: "install_os_updates", summary: "APT package updates: phase=install; 6 pending before, 3 pending after; package manager health: unhealthy; recovery required: true; reboot required: false", execution: "inconclusive", verification: "contradicted" });
+ const delayed = aptAction({ id: "apt-update-delayed", capabilityName: "install_os_updates", summary: "APT package updates: phase=verify; 4 pending before, 4 pending after; package manager health: unknown; recovery required: false; reboot required: false", execution: "inconclusive", verification: "inconclusive", evidenceClass: "none", verificationReasonCode: "package_manager_health_unknown" });
+ await routeActionFixtures(page, [], [confirmed, partial, delayed]);
+ await page.goto("/actions", { waitUntil: "domcontentloaded" });
+ await page.getByRole("tab", { name: "History" }).click();
+
+ await page.getByRole("button", { name: /Install operating system updates.*proxmox:node:pve-1/ }).first().click();
+ let dialog = page.getByRole("dialog", { name: "Install operating system updates" });
+ await expect(dialog.getByText("Confirmed by executing agent")).toBeVisible();
+ await expect(dialog.getByText("Source: Executing agent")).toBeVisible();
+ await expect(dialog.getByText("Yes — fact only; no reboot was authorized")).toBeVisible();
+ await expect(dialog.getByTestId("action-execution-truth")).toBeVisible();
+ await expect(dialog.getByTestId("action-verification-truth")).toBeVisible();
+ await expect(dialog.getByTestId("action-compensation-truth")).toBeVisible();
+ await expect(dialog.getByTestId("action-delivery-truth")).toHaveCount(1);
+ await expect(dialog.getByText("Agent observation")).toBeVisible();
+ await expect(dialog.getByText("Receipt recorded by Pulse")).toBeVisible();
+ await expect(dialog.getByText("Legacy check passed (source unclassified)")).toHaveCount(0);
+ await page.keyboard.press("Escape");
+
+ await page.getByRole("button", { name: /Install operating system updates.*proxmox:node:pve-1/ }).nth(1).click();
+ dialog = page.getByRole("dialog", { name: "Install operating system updates" });
+ await expect(dialog.getByTestId("action-execution-truth")).toContainText("Inconclusive");
+ await expect(dialog.getByTestId("action-verification-truth")).toContainText("Outcome contradicted");
+ await expect(dialog.getByText("Install updates")).toBeVisible();
+ await expect(dialog.getByText("Known unhealthy")).toBeVisible();
+ await expect(dialog.getByText("Do not retry. Repair the host update system")).toBeVisible();
+ await page.keyboard.press("Escape");
+
+ await page.getByRole("button", { name: /Install operating system updates.*proxmox:node:pve-1/ }).nth(2).click();
+ dialog = page.getByRole("dialog", { name: "Install operating system updates" });
+ await expect(dialog.getByText("Unknown", { exact: true })).toBeVisible();
+ await expect(dialog.getByText("Do not retry automatically. Run a fresh host scan")).toBeVisible();
+ await testInfo.attach("apt-update-truth-and-receipt-recovery", { body: await page.screenshot(), contentType: "image/png" });
+});
+
+test("APT cleanup history shows measured bytes and irreversible rescan recovery", async ({ page }, testInfo) => {
+ const confirmed = aptAction({ id: "apt-cleanup-confirmed", capabilityName: "clean_package_cache", elevated: false, summary: "APT package cache: phase=complete; 104857600 bytes before, 52428800 bytes after, 52428800 bytes reclaimed; rollback available: false; rescan required: false" });
+ const failed = aptAction({ id: "apt-cleanup-failed", capabilityName: "clean_package_cache", elevated: false, summary: "APT package cache: phase=clean; 104857600 bytes before, 52428800 bytes after, 52428800 bytes reclaimed; rollback available: false; rescan required: true", execution: "failed", verification: "inconclusive" });
+ await routeActionFixtures(page, [], [confirmed, failed]);
+ await page.goto("/actions", { waitUntil: "domcontentloaded" });
+ await page.getByRole("tab", { name: "History" }).click();
+ await page.getByRole("button", { name: /Clear downloaded package data.*proxmox:node:pve-1/ }).first().click();
+ let dialog = page.getByRole("dialog", { name: "Clear downloaded package data" });
+ await expect(dialog.getByText("100 MB")).toBeVisible();
+ await expect(dialog.getByText("50.0 MB")).toHaveCount(2);
+ await expect(dialog.getByText("Unavailable — cleanup is irreversible")).toBeVisible();
+ await page.keyboard.press("Escape");
+ await page.getByRole("button", { name: /Clear downloaded package data.*proxmox:node:pve-1/ }).nth(1).click();
+ dialog = page.getByRole("dialog", { name: "Clear downloaded package data" });
+ await expect(dialog.getByTestId("action-execution-truth")).toContainText("Failed");
+ await expect(dialog.getByTestId("action-verification-truth")).toContainText("Outcome inconclusive");
+ await expect(dialog.getByText("Fresh rescan required")).toBeVisible();
+ await expect(dialog.getByText("Do not retry automatically. Run a fresh scan")).toBeVisible();
+ await testInfo.attach("apt-cleanup-measurement-and-recovery", { body: await page.screenshot(), contentType: "image/png" });
+});
+
+test("APT action review remains keyboard reachable and actionable at a phone viewport", async ({ page }, testInfo) => {
+ await page.setViewportSize({ width: 390, height: 844 });
+ const partial = aptAction({ id: "apt-phone-partial", capabilityName: "install_os_updates", summary: "APT package updates: phase=install; 6 pending before, 3 pending after; package manager health: unhealthy; recovery required: true; reboot required: false", execution: "inconclusive", verification: "contradicted" });
+ await routeActionFixtures(page, [], [partial]);
+ await page.goto("/actions", { waitUntil: "domcontentloaded" });
+ await page.getByRole("tab", { name: "History" }).click();
+ await page.getByRole("button", { name: /Install operating system updates/ }).focus();
+ await page.keyboard.press("Enter");
+ const dialog = page.getByRole("dialog", { name: "Install operating system updates" });
+ await expect(dialog).toBeVisible();
+ await expect(dialog.getByText("What to do next")).toBeVisible();
+ await expect(dialog.getByRole("button", { name: "Close action review" })).toBeVisible();
+ const box = await dialog.boundingBox();
+ expect(box?.x ?? -1).toBeGreaterThanOrEqual(0);
+ expect((box?.x ?? 0) + (box?.width ?? 999)).toBeLessThanOrEqual(390);
+ await testInfo.attach("apt-phone-action-review", { body: await page.screenshot(), contentType: "image/png" });
+});