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.

Fix Patrol autonomy and refusal reporting

rcourtmana7646e5f8609
diff --git a/docs/PRIVACY.md b/docs/PRIVACY.md
index f953af622e..2509873659 100644
--- a/docs/PRIVACY.md
+++ b/docs/PRIVACY.md
@@ -184,6 +184,9 @@ Every field is listed below with the reason it exists. Nothing else is included
| Pulse Intelligence approved action refusals plan stale 30d | `1` | Count pre-dispatch refusals caused by an expired, drifted, or legacy-unbound plan without sending plan or resource details |
| Pulse Intelligence approved action refusals: policy 30d | `1` | Count pre-dispatch refusals caused by an operator or policy safety control without sending policy, actor, resource, or command details |
| Pulse Intelligence approved action refusals: capability 30d | `1` | Count pre-dispatch refusals caused by a dry-run-only or unavailable capability without sending capability names, targets, or command details |
+| Pulse Intelligence approved action refusals: target changed 30d | `1` | Count pre-dispatch refusals caused by target or inventory drift after planning without sending target, inventory, or command details |
+| Pulse Intelligence approved action refusals: prerequisite 30d | `1` | Count pre-dispatch refusals caused by an unavailable inspection, busy or unhealthy package manager, or failed bounded preflight without sending raw errors, targets, or command details |
+| Pulse Intelligence approved action refusals: contract 30d | `1` | Count pre-dispatch refusals caused by an invalid typed action contract without sending payloads, targets, or command details |
| Pulse Intelligence approved action refusals: other 30d | `1` | Count pre-dispatch refusals not covered by the fixed categories without sending raw error or action content |
| Pulse Intelligence verified finding resolutions 30d | `1` | Count approved Patrol-origin actions whose execution succeeded and whose linked finding postcondition was independently confirmed, without sending finding IDs, action IDs, evidence, resources, or fix details |
| Pulse Intelligence approved action last failure reason 30d | `plan_drift` | See one fixed machine reason code for the most recent approved-action failure in the current 30-day telemetry window without sending error text, action output, command text, resource IDs, or actors |
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index a58617a58b..5c5b04634b 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -5612,6 +5612,15 @@ originally authorized expected value when validating the admitted request
digest. The generic receipt store continues to bind completion and replay to
the exact admitted attempt/action/operation/digest/agent identity, while the
drift observation records why mutation was refused and replan is required.
+Typed APT, storage-cleanup, and Docker result payloads carry an optional bounded
+`reason_code` for pre-mutation refusal. Codes distinguish invalid contracts,
+missing agent capabilities, target drift, unavailable inspection, package
+manager contention or health, and bounded preflight failure without exposing
+stderr, commands, paths, package names, or provider text. Older agents may omit
+the field and remain valid; the server projects that legacy absence to
+`preflight_refused`. A refusal code cannot accompany a started mutation or a
+successful result. An already-empty package cache is a verified no-op success,
+because the requested postcondition is already satisfied.
Callback loss and a reopened server store reconcile both APT actions by query
only; the original typed dispatch is never resent. Legacy APT v1 terminal
payloads that predate additive package-manager health facts remain
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 6ec703cc50..d0453bb428 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2198,11 +2198,15 @@ a new API state machine, queue contract, or verification-accounting field.
endpoint keeps calling plain `Plan`, so an HTTP request body can never
claim a first-party origin. Enterprise still has no decision or execution
method. After planning, core may auto-authorize only when the capability's
- declared eligibility, the persisted resource capability allowlist and
- optional recurring window, `NeverAutoRemediate`, and the tenant's effective
- Patrol mode all allow it. Assisted mode admits only `low_risk`; unlocked full
- mode may also admit `elevated`; monitor, approval, dry-run-only, MFA, missing,
- and unknown policy fail closed. Automatic admission is lifecycle-owned:
+ declared eligibility and the tenant's effective Patrol mode allow it, the
+ resource is not locked by `NeverAutoRemediate`, and any persisted resource
+ capability limit or recurring window admits it. Absence of a resource
+ policy inherits those tenant and capability bounds; an enabled per-resource
+ capability/window policy may only narrow them, and `NeverAutoRemediate`
+ remains the explicit opt-out. Assisted mode admits only `low_risk`; unlocked full
+ mode may also admit `elevated`; monitor, approval, dry-run-only, MFA, and a
+ missing or unknown tenant policy fail closed. Automatic admission is
+ lifecycle-owned:
`ExecuteUnderPolicy` re-reads the complete tenant, capability, resource,
window, unlock, license, and emergency-stop posture under the shared policy
admission coordinator, binds it to a typed versioned lease, then persists
@@ -2211,10 +2215,11 @@ a new API state machine, queue contract, or verification-accounting field.
Lazy initialization of that shared coordinator must be concurrency-safe:
simultaneous first policy writers on one lifecycle service must converge on
one coordinator and cannot enter parallel admission or mutation sections.
- Missing, malformed, stale, unreadable, or revoked policy records a stable
+ Malformed, stale, unreadable, or revoked policy records a stable
refused-before-dispatch failure with no executor call. Human approval stays
- a distinct path: automatic-mode, allowlist, and recurring-window changes do
- not revoke a human decision, while plan drift, `NeverAutoRemediate`, and the
+ a distinct path: automatic-mode, resource-limit, and recurring-window
+ changes do not revoke a human decision, while plan drift,
+ `NeverAutoRemediate`, and the
action emergency stop remain universal. The executing transition is the
admission linearization point; a later emergency stop is best-effort
cancellation and never claims rollback. Proposals
@@ -9096,6 +9101,14 @@ together: `type Ping struct` in `internal/telemetry/telemetry.go`, the
Retired columns stay in the live receiver database rather than being dropped:
migrations only add, the columns hold real rows from the schema-v6 window, and
nothing writes them once the receiver struct loses the fields.
+### Telemetry payload parity spans three surfaces at schema v8
+
+Schema v8 preserves the same three-surface parity requirement and adds
+content-free approved-action refusal counters for target change, prerequisite
+failure, and invalid typed contracts. These counters partition agent-side
+pre-mutation refusals that previously accumulated in `other`; no raw error,
+command, target, resource identifier, or action payload is exported.
+
### Per-tenant resource stores are released on offboarding and shutdown
`ResourceHandlers.getStore` opens a SQLite handle per org and caches it for the
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index ef7084668d..883c42c9f2 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -68,6 +68,66 @@ sources, and retains the note as operator context.
## Extension Points
+### Model-authored operational objectives
+
+Patrol's long-term operator contract is a retained operations brief, not a
+catalog of application-specific automations and not repeated model polling. An
+operator may describe an outcome such as keeping media playback free of
+buffering or keeping camera streams available. Pulse must not hard-code every
+application, API, log format, event source, or remedy implied by those examples.
+The model owns investigating the environment and designing the smallest useful
+observer from the tools and evidence actually available there.
+
+The brief is deliberately value- and outcome-oriented. The operator should not
+need to prescribe metrics, polling intervals, implementation steps, or a guessed
+root cause. The model derives a measurable interpretation and observer plan from
+the brief and current environment, exposes that translation for correction, and
+may revise the implementation as evidence changes while preserving the brief's
+intent. More implementation detail is accepted as optional context, not treated
+as a script that displaces model reasoning.
+
+Pulse's durable advantage in this loop is operational context and trusted
+reach, not a competing hard-coded intelligence layer. The canonical resource
+graph, live metrics, history, relationships, changes, findings, operator intent,
+local observers, governed capabilities, outcome evidence, and prior attempts
+form one compact estate state that an improving model can use immediately. A
+Patrol feature should therefore improve context, continuity, access, or trust;
+logic whose only value is reproducing reasoning the model can perform from that
+state should not become a permanent product subsystem.
+
+MCP may be the model-facing transport for this compact estate state and its
+governed tools, including stateless request/response implementations, but it is
+an adapter rather than Patrol's control plane. Protocol statelessness must not
+erase product continuity: Pulse owns and persists the objective, canonical
+resource graph, observer artifacts and health, evidence history, permissions,
+action lifecycle, verification, and audit record. Each model request can be
+self-contained while resolving those durable records through canonical Pulse
+contracts. No Patrol workflow may depend on an MCP session as its memory,
+scheduler, event queue, or source of authorization, and the underlying contracts
+must remain usable by first-party UI, API, CLI, and future model transports.
+
+The corresponding execution boundary is a constrained monitor-building tool,
+not arbitrary mutation authority. The model may propose a versioned local
+observer bundle: event, webhook, log, file, socket, API, or bounded-interval
+triggers; a probe artifact and digest; declared network, filesystem, secret,
+runtime, and resource requirements; health and failure outputs; resource
+budgets; and the evidence that should wake Patrol. Core validates, tests,
+sandboxes, installs, updates, disables, and audits that bundle. An observer is
+read-only by construction and cannot acquire infrastructure-action authority;
+any response to its findings still goes through the canonical capability,
+autonomy, approval, dispatch, and verification kernel.
+
+After installation, the cheap local observer runs continuously or on events and
+the model wakes only for objective creation, observer redesign, an evidence
+transition, or a finding that needs reasoning. A timer may be one generated
+trigger when no event source exists, but it runs the local probe rather than
+calling a model on every interval. Objective status must distinguish covered,
+degraded, and uncovered monitoring so Patrol never claims protection merely
+because an instruction was saved. Generated observers are durable artifacts
+with bounded provenance and rollback; app-named integration code is an
+optimization only when repeated evidence justifies productizing it, never a
+prerequisite for a new objective.
+
Desktop Autopilot activation consumes the server-owned acknowledgement
contract through `frontend-modern/src/api/patrol.ts` and
`PatrolAutopilotAcknowledgementDialog.tsx`. The UI displays requested versus
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index b1e531fb3e..c0500c543d 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -1765,10 +1765,11 @@ they cannot supply requester identity, origin, approval policy, capability
catalog entries, or verification outcome. Legacy command-shaped investigation
history is never exposed as an executable payload in desktop or mobile review.
Core-owned Patrol policy authorization is additive to that boundary, not a new
-caller grant. It requires an eligible capability, an explicit persisted
-per-resource capability allowlist (and any configured recurring window), an
-effective tenant Patrol mode that admits the eligibility class, and an absent
-Never-auto-remediate lock. Missing or unknown state denies automatic execution.
+caller grant. It requires an eligible capability, an effective tenant Patrol
+mode that admits the eligibility class, and an absent Never-auto-remediate
+lock. An absent or empty per-resource policy inherits those server-owned global
+bounds; an enabled per-resource capability limit and recurring window can only
+narrow them. Unreadable or malformed state denies automatic execution.
The policy actor/method are server-stamped and cannot be supplied by the model,
enterprise orchestrator, browser, relay, or action-proposal payload.
@@ -2057,9 +2058,11 @@ actor, and every audit row read stay on the install.
### Telemetry ingestion matches the released sender while storage stays compatible
-The active outbound contract remains schema v7. The draft schema-v8
-`business_estate` field was reverted before release and must not remain in the
-license server's accepted ping struct merely because a private receiver build
+The active outbound contract is schema v8. It adds content-free approved-action
+refusal counters for target change, prerequisite failure, and invalid typed
+contract so agent-side pre-mutation failures no longer collapse into `other`.
+The earlier draft schema-v8 `business_estate` field was reverted and must not
+remain in the license server's accepted ping struct merely because a private receiver build
and database migration briefly carried it. Existing deployed databases need no
destructive column migration, while new databases do not recreate the retired
column. Incoming draft-field values are ignored and can never enter adoption
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 93369207b6..f1a53eed2b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1950,10 +1950,13 @@ downstream finding-suppression and severity-weighting logic has a stable
contract to honor. `ValidateResourceOperatorState` rejects malformed
records with a stable `ErrResourceOperatorStateInvalid` sentinel
(empty canonical id, partial maintenance window, end ≤ start, unknown
-criticality, enabled automatic-action policy without a capability allowlist,
+criticality, enabled automatic-action limit without a capability allowlist,
unknown timezone, or invalid recurring-window minute). The automatic-action
-policy is opt-in and names exact capability IDs; its optional daily IANA-timezone
-window may cross midnight. `NeverAutoRemediate` always wins. Capability-owned
+policy is an optional per-resource narrowing control: an empty policy inherits
+the tenant Patrol mode and capability eligibility, while an enabled policy
+names the only capability IDs allowed automatically on that resource and may
+add a daily IANA-timezone window that crosses midnight. `NeverAutoRemediate`
+is the explicit per-resource opt-out and always wins. Capability-owned
`ResourceCapability.AutoAuthorization` independently declares whether a
capability is never eligible, low-risk eligible, or elevated eligible; it does
not lower `MinimumApprovalLevel`. The first eligible vertical is Docker/Podman
@@ -1975,7 +1978,7 @@ persisting the server-owned policy approval and typed
`ActionPolicyAuthorizationLease` in the same transaction. Memory and SQLite
implement identical semantics. The lease binds org/action/resource/capability,
plan and capability-policy hashes, safety and approval floors, tenant
-mode/license/unlock version, resource allowlist/window/Never version, expiry,
+mode/license/unlock version, optional resource limit/window/Never version, expiry,
and digest. A policy approval without that lease is historical-only and cannot
admit a nonterminal action after restart.
The same
@@ -1997,9 +2000,11 @@ controls, the drawer offers automatic actions only for backend-advertised
eligible capabilities. The operator-state section itself remains available for
every canonical resource id, including stopped containers and resources with
no auto-authorizable capability; only the automatic-actions subsection is
-capability-gated. Enabling it requires selecting exact capabilities and
-may add a recurring daily time/timezone window; copy must state that this is a
-resource allowlist and that the tenant Patrol mode remains the upper bound.
+capability-gated. By default the resource follows the tenant Patrol mode.
+Enabling the optional limit requires selecting exact capabilities and may add a
+recurring daily time/timezone window; copy must state that the control narrows
+the tenant mode, while `NeverAutoRemediate` disables automatic action for the
+resource.
The UI must never infer eligibility from capability names, severity, or the
human approval floor.
diff --git a/frontend-modern/public/docs/PRIVACY.md b/frontend-modern/public/docs/PRIVACY.md
index f953af622e..2509873659 100644
--- a/frontend-modern/public/docs/PRIVACY.md
+++ b/frontend-modern/public/docs/PRIVACY.md
@@ -184,6 +184,9 @@ Every field is listed below with the reason it exists. Nothing else is included
| Pulse Intelligence approved action refusals plan stale 30d | `1` | Count pre-dispatch refusals caused by an expired, drifted, or legacy-unbound plan without sending plan or resource details |
| Pulse Intelligence approved action refusals: policy 30d | `1` | Count pre-dispatch refusals caused by an operator or policy safety control without sending policy, actor, resource, or command details |
| Pulse Intelligence approved action refusals: capability 30d | `1` | Count pre-dispatch refusals caused by a dry-run-only or unavailable capability without sending capability names, targets, or command details |
+| Pulse Intelligence approved action refusals: target changed 30d | `1` | Count pre-dispatch refusals caused by target or inventory drift after planning without sending target, inventory, or command details |
+| Pulse Intelligence approved action refusals: prerequisite 30d | `1` | Count pre-dispatch refusals caused by an unavailable inspection, busy or unhealthy package manager, or failed bounded preflight without sending raw errors, targets, or command details |
+| Pulse Intelligence approved action refusals: contract 30d | `1` | Count pre-dispatch refusals caused by an invalid typed action contract without sending payloads, targets, or command details |
| Pulse Intelligence approved action refusals: other 30d | `1` | Count pre-dispatch refusals not covered by the fixed categories without sending raw error or action content |
| Pulse Intelligence verified finding resolutions 30d | `1` | Count approved Patrol-origin actions whose execution succeeded and whose linked finding postcondition was independently confirmed, without sending finding IDs, action IDs, evidence, resources, or fix details |
| Pulse Intelligence approved action last failure reason 30d | `plan_drift` | See one fixed machine reason code for the most recent approved-action failure in the current 30-day telemetry window without sending error text, action output, command text, resource IDs, or actors |
diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.ts
index 8919cfb167..384dec00aa 100644
--- a/frontend-modern/src/api/__tests__/settings.test.ts
+++ b/frontend-modern/src/api/__tests__/settings.test.ts
@@ -152,6 +152,9 @@ const mockTelemetryPreviewPayload = {
pulse_intelligence_approved_action_refusals_plan_stale_30d: 0,
pulse_intelligence_approved_action_refusals_policy_30d: 0,
pulse_intelligence_approved_action_refusals_capability_30d: 0,
+ pulse_intelligence_approved_action_refusals_target_changed_30d: 0,
+ pulse_intelligence_approved_action_refusals_prerequisite_30d: 0,
+ pulse_intelligence_approved_action_refusals_contract_30d: 0,
pulse_intelligence_approved_action_refusals_other_30d: 0,
pulse_intelligence_verified_finding_resolutions_30d: 0,
pulse_intelligence_approved_action_last_failure_reason_30d: undefined,
diff --git a/frontend-modern/src/api/resourceOperatorState.ts b/frontend-modern/src/api/resourceOperatorState.ts
index 34191853ff..1b0f641b09 100644
--- a/frontend-modern/src/api/resourceOperatorState.ts
+++ b/frontend-modern/src/api/resourceOperatorState.ts
@@ -47,7 +47,7 @@ export interface ResourceOperatorState {
* record with `resource_remediation_locked:` prefix on the error.
*/
neverAutoRemediate: boolean;
- /** Explicit capability allowlist; tenant mode and backend eligibility remain upper bounds. */
+ /** Optional narrowing policy; an empty policy inherits the tenant Patrol mode. */
autoRemediationPolicy?: AutoRemediationPolicy;
/**
* Maintenance window — when present and `now` falls within it, all
diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.ts
index e899d2ab0e..9da1094a3c 100644
--- a/frontend-modern/src/api/settings.ts
+++ b/frontend-modern/src/api/settings.ts
@@ -153,6 +153,9 @@ export interface TelemetryPingPreview {
pulse_intelligence_approved_action_refusals_plan_stale_30d: number;
pulse_intelligence_approved_action_refusals_policy_30d: number;
pulse_intelligence_approved_action_refusals_capability_30d: number;
+ pulse_intelligence_approved_action_refusals_target_changed_30d: number;
+ pulse_intelligence_approved_action_refusals_prerequisite_30d: number;
+ pulse_intelligence_approved_action_refusals_contract_30d: number;
pulse_intelligence_approved_action_refusals_other_30d: number;
pulse_intelligence_verified_finding_resolutions_30d: number;
pulse_intelligence_approved_action_last_failure_reason_30d?: string;
diff --git a/frontend-modern/src/components/Infrastructure/ResourceOperatorStateSection.tsx b/frontend-modern/src/components/Infrastructure/ResourceOperatorStateSection.tsx
index a4a9c8a1e8..933a3372eb 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceOperatorStateSection.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceOperatorStateSection.tsx
@@ -701,10 +701,11 @@ export const ResourceOperatorStateSection: Component<ResourceOperatorStateSectio
<div class="space-y-3 border-t border-border-subtle pt-3" aria-label="Automatic actions">
<div class="flex items-start justify-between gap-3">
<div class="min-w-0 flex-1">
- <label class="text-sm font-medium text-base-content">Automatic actions</label>
+ <label class="text-sm font-medium text-base-content">Automatic action limits</label>
<p class="mt-0.5 text-[11px] leading-tight text-muted">
- Choose exactly which actions Patrol may run on this resource. Your Patrol mode, live
- safety checks, remediation locks, and verification still apply.
+ This resource follows your Patrol mode by default. Turn this on only to limit
+ automatic work to selected actions or daily hours. Live safety checks and
+ verification always apply.
</p>
</div>
<Toggle
@@ -716,7 +717,9 @@ export const ResourceOperatorStateSection: Component<ResourceOperatorStateSectio
<Show when={autoRemediationEnabled()}>
<fieldset class="space-y-2 rounded border border-border bg-surface-alt/40 px-3 py-2.5">
- <legend class="px-1 text-xs font-semibold text-base-content">Allowed actions</legend>
+ <legend class="px-1 text-xs font-semibold text-base-content">
+ Actions allowed by this limit
+ </legend>
<For each={eligibleAutoCapabilities()}>
{(capability) => (
<label class="flex items-start gap-2 text-xs text-base-content">
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceOperatorStateSection.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/ResourceOperatorStateSection.test.ts
index a39347511d..bd381b04a1 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceOperatorStateSection.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceOperatorStateSection.test.ts
@@ -44,8 +44,9 @@ describe('ResourceOperatorStateSection', () => {
expect(sectionSource).toContain('setNote');
});
- it('requires explicit capability scope and preserves the backend eligibility ceiling', () => {
- expect(sectionSource).toContain('Automatic actions');
+ it('presents resource action policy as an optional limit on global Patrol autonomy', () => {
+ expect(sectionSource).toContain('Automatic action limits');
+ expect(sectionSource).toContain('follows your Patrol mode by default');
expect(sectionSource).toContain("capability.autoAuthorization !== 'never'");
expect(sectionSource).toContain('Select at least one eligible capability.');
expect(sectionSource).toContain('Restrict to daily hours');
diff --git a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
index 0db2ebeb30..8b07ee1a07 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.test.ts
@@ -158,6 +158,9 @@ const buildTelemetryPreviewPayload = (
pulse_intelligence_approved_action_refusals_plan_stale_30d: 0,
pulse_intelligence_approved_action_refusals_policy_30d: 0,
pulse_intelligence_approved_action_refusals_capability_30d: 0,
+ pulse_intelligence_approved_action_refusals_target_changed_30d: 0,
+ pulse_intelligence_approved_action_refusals_prerequisite_30d: 0,
+ pulse_intelligence_approved_action_refusals_contract_30d: 0,
pulse_intelligence_approved_action_refusals_other_30d: 0,
pulse_intelligence_verified_finding_resolutions_30d: 0,
pulse_intelligence_approved_action_last_failure_reason_30d: undefined,
diff --git a/frontend-modern/src/features/actions/ActionDecisionPacket.tsx b/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
index 3ff659670d..35b522f62d 100644
--- a/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
+++ b/frontend-modern/src/features/actions/ActionDecisionPacket.tsx
@@ -236,7 +236,7 @@ export const ActionDecisionPacket: Component<{
<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'
+ ? 'Skipped before execution'
: formatActionName(truth().execution.status)}
</div>
<Show when={truth().execution.reasonCode}>
diff --git a/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx b/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
index 86f96300b8..3440290000 100644
--- a/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
+++ b/frontend-modern/src/features/actions/__tests__/ActionDecisionPacket.test.tsx
@@ -140,7 +140,7 @@ describe('ActionDecisionPacket', () => {
'not_run',
'not_attempted',
'none',
- 'Did not run',
+ 'Skipped before execution',
'Outcome not verified',
'Source: No evidence source',
],
diff --git a/frontend-modern/src/utils/__tests__/actionAuditPresentation.branchcov0712c.test.ts b/frontend-modern/src/utils/__tests__/actionAuditPresentation.branchcov0712c.test.ts
index 33517227de..5818f7c63c 100644
--- a/frontend-modern/src/utils/__tests__/actionAuditPresentation.branchcov0712c.test.ts
+++ b/frontend-modern/src/utils/__tests__/actionAuditPresentation.branchcov0712c.test.ts
@@ -80,14 +80,14 @@ describe('getActionAuditResultPresentation — actionResultV2 execution truth pa
});
});
- it('maps a not_run execution to the neutral "did not run" badge and collapses whitespace summary to undefined', () => {
+ it('maps a not_run execution to a neutral pre-execution skip and collapses whitespace summary to undefined', () => {
// `truth.summary?.trim()` -> '' -> `|| undefined` (trim-to-empty falsy arm).
const presentation = getActionAuditResultPresentation(
auditWithExecutionTruth({ status: 'not_run', summary: ' ' }),
);
expect(presentation).toStrictEqual({
- kind: 'failure',
- label: 'Execution did not run',
+ kind: 'refusal',
+ label: 'Skipped before execution',
detail: undefined,
reasonLabel: undefined,
className: 'border-border bg-surface text-base-content',
diff --git a/frontend-modern/src/utils/actionAuditPresentation.ts b/frontend-modern/src/utils/actionAuditPresentation.ts
index c4aab8e48e..115071f215 100644
--- a/frontend-modern/src/utils/actionAuditPresentation.ts
+++ b/frontend-modern/src/utils/actionAuditPresentation.ts
@@ -291,8 +291,8 @@ export const getActionAuditResultPresentation = (
'border-red-200 bg-red-50 text-red-800 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300',
},
not_run: {
- kind: 'failure' as const,
- label: 'Execution did not run',
+ kind: 'refusal' as const,
+ label: 'Skipped before execution',
className: 'border-border bg-surface text-base-content',
},
inconclusive: {
diff --git a/internal/agentexec/docker_lifecycle_codec.go b/internal/agentexec/docker_lifecycle_codec.go
index 3232599e94..6ec1c170ec 100644
--- a/internal/agentexec/docker_lifecycle_codec.go
+++ b/internal/agentexec/docker_lifecycle_codec.go
@@ -144,6 +144,7 @@ func ValidateDockerContainerLifecycleResultPayload(result *DockerContainerLifecy
result.RequestDigest = strings.TrimSpace(result.RequestDigest)
result.ContainerID = strings.ToLower(strings.TrimSpace(result.ContainerID))
result.ExecutionPhase = strings.TrimSpace(result.ExecutionPhase)
+ result.ReasonCode = strings.TrimSpace(result.ReasonCode)
result.Error = strings.TrimSpace(result.Error)
if result.RequestID == "" || len(result.RequestID) > maxRequestIDLength || result.ActionID == "" || len(result.ActionID) > maxRequestIDLength {
return fmt.Errorf("invalid docker lifecycle result identity")
@@ -160,6 +161,12 @@ func ValidateDockerContainerLifecycleResultPayload(result *DockerContainerLifecy
if len(result.Error) > 1024 || result.Before.RestartCount < 0 || result.After.RestartCount < 0 {
return fmt.Errorf("docker lifecycle result exceeds bounded contract")
}
+ if result.ReasonCode != "" && !IsActionRefusalReasonCode(result.ReasonCode) {
+ return fmt.Errorf("invalid docker lifecycle refusal reason code")
+ }
+ if result.ReasonCode != "" && result.MutationStarted {
+ return fmt.Errorf("docker lifecycle refusal reason conflicts with mutation state")
+ }
for _, snapshot := range []DockerContainerLifecycleSnapshot{result.Before, result.After} {
if snapshot.ContainerID != "" && !dockerContainerIDPattern.MatchString(strings.ToLower(strings.TrimSpace(snapshot.ContainerID))) {
return fmt.Errorf("docker lifecycle result has invalid container id")
diff --git a/internal/agentexec/docker_update_codec.go b/internal/agentexec/docker_update_codec.go
index fd9c685dcd..179c73a0ac 100644
--- a/internal/agentexec/docker_update_codec.go
+++ b/internal/agentexec/docker_update_codec.go
@@ -130,6 +130,7 @@ func ValidateDockerContainerUpdateResultPayload(result *DockerContainerUpdateRes
result.NewImageDigest = strings.TrimSpace(result.NewImageDigest)
result.BackupContainer = strings.TrimSpace(result.BackupContainer)
result.ExecutionPhase = strings.TrimSpace(result.ExecutionPhase)
+ result.ReasonCode = strings.TrimSpace(result.ReasonCode)
result.Error = strings.TrimSpace(result.Error)
if result.RequestID == "" || len(result.RequestID) > maxRequestIDLength || result.ActionID == "" || len(result.ActionID) > maxRequestIDLength {
return fmt.Errorf("invalid docker update result identity")
@@ -149,6 +150,12 @@ func ValidateDockerContainerUpdateResultPayload(result *DockerContainerUpdateRes
if len(result.Error) > 1024 || len(result.ContainerName) > maxDockerContainerNameLength || len(result.BackupContainer) > maxDockerContainerNameLength {
return fmt.Errorf("docker update result exceeds bounded contract")
}
+ if result.ReasonCode != "" && !IsActionRefusalReasonCode(result.ReasonCode) {
+ return fmt.Errorf("invalid docker update refusal reason code")
+ }
+ if result.ReasonCode != "" && result.MutationStarted {
+ return fmt.Errorf("docker update refusal reason conflicts with mutation state")
+ }
if len(result.OldImageDigest) > maxDockerImageDigestLength || len(result.NewImageDigest) > maxDockerImageDigestLength {
return fmt.Errorf("docker update result digest exceeds bounded contract")
}
diff --git a/internal/agentexec/server.go b/internal/agentexec/server.go
index 5469883bae..0336f26740 100644
--- a/internal/agentexec/server.go
+++ b/internal/agentexec/server.go
@@ -621,6 +621,7 @@ func validateHostUpdateResultPayload(result *HostUpdateResultPayload) error {
}
result.RequestID = strings.TrimSpace(result.RequestID)
result.Verification = strings.TrimSpace(result.Verification)
+ result.ReasonCode = strings.TrimSpace(result.ReasonCode)
if result.RequestID == "" || len(result.RequestID) > maxRequestIDLength {
return fmt.Errorf("invalid request id")
}
@@ -647,6 +648,12 @@ func validateHostUpdateResultPayload(result *HostUpdateResultPayload) error {
if len(result.Error) > 1024 {
return fmt.Errorf("host update error exceeds bounded limit")
}
+ if result.ReasonCode != "" && !IsActionRefusalReasonCode(result.ReasonCode) {
+ return fmt.Errorf("invalid host update refusal reason code")
+ }
+ if result.ReasonCode != "" && (result.MutationStarted || result.Success) {
+ return fmt.Errorf("host update refusal reason conflicts with execution state")
+ }
return nil
}
@@ -695,6 +702,7 @@ func validateHostStorageCleanupResultPayload(result *HostStorageCleanupResultPay
}
result.RequestID = strings.TrimSpace(result.RequestID)
result.Verification = strings.TrimSpace(result.Verification)
+ result.ReasonCode = strings.TrimSpace(result.ReasonCode)
if result.RequestID == "" || len(result.RequestID) > maxRequestIDLength {
return fmt.Errorf("invalid request id")
}
@@ -714,7 +722,11 @@ func validateHostStorageCleanupResultPayload(result *HostStorageCleanupResultPay
if !result.Success || !result.After.Supported || result.After.Provider != "apt-package-cache" || result.After.Error != "" || result.After.Fingerprint == "" {
return fmt.Errorf("verified storage cleanup lacks a valid postcondition")
}
- if result.Before.ReclaimableBytes <= 0 || result.ReclaimedBytes <= 0 || result.After.ReclaimableBytes >= result.Before.ReclaimableBytes || result.ReclaimedBytes != result.Before.ReclaimableBytes-result.After.ReclaimableBytes {
+ if result.Before.ReclaimableBytes == 0 {
+ if result.After.ReclaimableBytes != 0 || result.ReclaimedBytes != 0 {
+ return fmt.Errorf("already-satisfied storage cleanup has inconsistent byte counts")
+ }
+ } else if result.ReclaimedBytes <= 0 || result.After.ReclaimableBytes >= result.Before.ReclaimableBytes || result.ReclaimedBytes != result.Before.ReclaimableBytes-result.After.ReclaimableBytes {
return fmt.Errorf("verified storage cleanup did not reclaim reported bytes")
}
case HostStorageCleanupVerificationFailed, HostStorageCleanupVerificationInconclusive:
@@ -724,6 +736,12 @@ func validateHostStorageCleanupResultPayload(result *HostStorageCleanupResultPay
if len(result.Error) > 1024 {
return fmt.Errorf("host storage cleanup error exceeds bounded limit")
}
+ if result.ReasonCode != "" && !IsActionRefusalReasonCode(result.ReasonCode) {
+ return fmt.Errorf("invalid host storage cleanup refusal reason code")
+ }
+ if result.ReasonCode != "" && (result.MutationStarted || result.Success) {
+ return fmt.Errorf("host storage cleanup refusal reason conflicts with execution state")
+ }
return nil
}
diff --git a/internal/agentexec/server_test.go b/internal/agentexec/server_test.go
index bdbee2fc82..83a6d4dfab 100644
--- a/internal/agentexec/server_test.go
+++ b/internal/agentexec/server_test.go
@@ -22,6 +22,43 @@ func TestHostStorageCleanupPayloadIsClosedAndSelectorFree(t *testing.T) {
}
}
+func TestActionRefusalReasonCodeContractAndAlreadySatisfiedCleanup(t *testing.T) {
+ for _, code := range []string{
+ ActionRefusalTargetStateChanged,
+ ActionRefusalPackageManagerBusy,
+ ActionRefusalContractInvalid,
+ } {
+ if !IsActionRefusalReasonCode(code) {
+ t.Fatalf("stable refusal code %q was rejected", code)
+ }
+ }
+ for _, code := range []string{"", "Target Changed", strings.Repeat("a", 65)} {
+ if IsActionRefusalReasonCode(code) {
+ t.Fatalf("unsafe refusal code %q was accepted", code)
+ }
+ }
+
+ now := time.Now().UTC()
+ result := HostStorageCleanupResultPayload{
+ RequestID: "attempt-1", ActionID: "action-1", Success: true,
+ ExecutionPhase: HostStorageCleanupPhaseComplete,
+ Verification: HostStorageCleanupVerificationVerified,
+ Before: HostStorageCleanupSnapshot{
+ Supported: true, Provider: "apt-package-cache", Fingerprint: "sha256:" + strings.Repeat("a", 64), CheckedAt: now,
+ },
+ After: HostStorageCleanupSnapshot{
+ Supported: true, Provider: "apt-package-cache", Fingerprint: "sha256:" + strings.Repeat("a", 64), CheckedAt: now,
+ },
+ }
+ if err := ValidateHostStorageCleanupResultPayload(&result); err != nil {
+ t.Fatalf("already-satisfied cleanup should be a verified no-op: %v", err)
+ }
+ result.ReasonCode = ActionRefusalCleanupPreflightFailed
+ if err := ValidateHostStorageCleanupResultPayload(&result); err == nil {
+ t.Fatal("a successful result carried a refusal reason")
+ }
+}
+
func allowAllTestTokens(string, string, string) bool { return true }
func TestNewServerRequiresValidateToken(t *testing.T) {
diff --git a/internal/agentexec/types.go b/internal/agentexec/types.go
index 92c4fc59ff..7610352837 100644
--- a/internal/agentexec/types.go
+++ b/internal/agentexec/types.go
@@ -205,6 +205,7 @@ type DockerContainerLifecycleResultPayload struct {
ReadbackRan bool `json:"readback_ran"`
Before DockerContainerLifecycleSnapshot `json:"before"`
After DockerContainerLifecycleSnapshot `json:"after"`
+ ReasonCode string `json:"reason_code,omitempty"`
Error string `json:"error,omitempty"`
Duration int64 `json:"duration_ms"`
}
@@ -258,6 +259,7 @@ type DockerContainerUpdateResultPayload struct {
RollbackAttempted bool `json:"rollback_attempted"`
RolledBack bool `json:"rolled_back"`
After DockerContainerLifecycleSnapshot `json:"after"`
+ ReasonCode string `json:"reason_code,omitempty"`
Error string `json:"error,omitempty"`
Duration int64 `json:"duration_ms"`
}
@@ -331,6 +333,7 @@ type HostUpdateResultPayload struct {
PackageManagerHealthy bool `json:"package_manager_healthy"`
RecoveryRequired bool `json:"recovery_required"`
Verification string `json:"verification"`
+ ReasonCode string `json:"reason_code,omitempty"`
Error string `json:"error,omitempty"`
Duration int64 `json:"duration_ms"`
}
@@ -387,6 +390,7 @@ type HostStorageCleanupResultPayload struct {
After HostStorageCleanupSnapshot `json:"after"`
ReclaimedBytes int64 `json:"reclaimed_bytes"`
Verification string `json:"verification"`
+ ReasonCode string `json:"reason_code,omitempty"`
Error string `json:"error,omitempty"`
Duration int64 `json:"duration_ms"`
}
@@ -398,6 +402,43 @@ const (
HostStorageCleanupPhaseComplete = "complete"
)
+// Stable pre-mutation refusal codes cross the Unified Agent boundary without
+// exposing command output, package names, paths, or provider error text. The
+// server uses these codes for operator presentation and aggregate telemetry;
+// model reasoning continues to consume the typed capability catalog rather
+// than a hard-coded diagnostic tree.
+const (
+ ActionRefusalContractInvalid = "action_contract_invalid"
+ ActionRefusalCapabilityUnavailable = "agent_capability_unavailable"
+ ActionRefusalTargetInspectionUnavailable = "target_inspection_unavailable"
+ ActionRefusalTargetStateChanged = "target_state_changed"
+ ActionRefusalTargetPreconditionFailed = "target_precondition_failed"
+ ActionRefusalPackageManagerBusy = "package_manager_busy"
+ ActionRefusalPackageIndexRefreshFailed = "package_index_refresh_failed"
+ ActionRefusalPackagePreflightFailed = "package_preflight_failed"
+ ActionRefusalPackageInventoryChanged = "package_inventory_changed"
+ ActionRefusalPackageManagerUnhealthy = "package_manager_unhealthy"
+ ActionRefusalCleanupPreflightFailed = "cleanup_preflight_failed"
+ ActionRefusalCleanupInventoryChanged = "cleanup_inventory_changed"
+)
+
+// IsActionRefusalReasonCode validates the bounded machine-code shape accepted
+// from an agent result. It intentionally validates shape rather than a closed
+// enum so a newer agent can report a new safe category to an older server.
+func IsActionRefusalReasonCode(code string) bool {
+ code = strings.TrimSpace(code)
+ if len(code) == 0 || len(code) > 64 {
+ return false
+ }
+ for _, r := range code {
+ if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '_' {
+ continue
+ }
+ return false
+ }
+ return true
+}
+
// ConnectedAgent represents an agent connected via WebSocket
type ConnectedAgent struct {
OrganizationID string
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 1ce07c4885..6011206a5a 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -21363,7 +21363,7 @@ func TestContract_HostUpdatesUseTypedFingerprintBoundAgentOperation(t *testing.T
"beforeBound := result.Before.InventoryHash == resource.Agent.PackageUpdates.InventoryHash",
"agentexec.ValidateHostUpdateResultForRequestAt(req, *result, receivedAt)",
"receivedAt := e.currentTime()",
- "hostAPTExecutionResult(record.Request.ResourceID, agentID, agentexec.HostUpdateOperationInstall, output, result.Success, result.MutationStarted, result.Verification, beforeBound, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)",
+ "hostAPTExecutionResult(record.Request.ResourceID, agentID, agentexec.HostUpdateOperationInstall, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, beforeBound, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)",
"query.Record.TerminalAt, receivedAt)",
} {
if !strings.Contains(executorSrc, snippet) {
@@ -21441,7 +21441,7 @@ func TestContract_HostStorageCleanupIsTypedFingerprintBoundAndPathFree(t *testin
"agentexec.ValidateHostStorageCleanupResultForRequestAt(req, *result, receivedAt)",
"hostStorageCleanupResultSummary(*result)",
"receivedAt := e.currentTime()",
- "hostAPTExecutionResult(record.Request.ResourceID, resource.Agent.AgentID, agentexec.HostStorageCleanupOperationPackageCache, output, result.Success, result.MutationStarted, result.Verification, beforeBound, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)",
+ "hostAPTExecutionResult(record.Request.ResourceID, resource.Agent.AgentID, agentexec.HostStorageCleanupOperationPackageCache, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, beforeBound, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)",
"query.Record.TerminalAt, receivedAt)",
} {
if !strings.Contains(executorSrc, snippet) {
diff --git a/internal/api/docker_container_action_result.go b/internal/api/docker_container_action_result.go
index ceda50e05e..e72828545f 100644
--- a/internal/api/docker_container_action_result.go
+++ b/internal/api/docker_container_action_result.go
@@ -12,7 +12,7 @@ import (
func dockerContainerExecutionResult(resourceID, agentID string, req agentexec.DockerContainerLifecyclePayload, facts agentexec.DockerContainerLifecycleResultPayload, independent *dockerContainerPostconditionObservation, receivedAt time.Time) (*unified.ExecutionResult, error) {
summary := dockerContainerFactSummary(facts)
- execution := unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: "preflight_refused", Summary: summary}
+ execution := unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: actionPreflightReasonCode(facts.ReasonCode), Summary: summary}
if facts.MutationCompleted {
execution = unified.ActionExecutionTruth{Status: unified.ActionExecutionSucceeded, Summary: summary}
} else if facts.MutationStarted {
@@ -88,7 +88,7 @@ func dockerContainerExecutionResult(resourceID, agentID string, req agentexec.Do
func dockerContainerUpdateExecutionResult(resourceID, agentID string, facts agentexec.DockerContainerUpdateResultPayload, independent *dockerContainerPostconditionObservation, receivedAt time.Time) (*unified.ExecutionResult, error) {
summary := dockerContainerUpdateFactSummary(facts)
- execution := unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: "preflight_refused", Summary: summary}
+ execution := unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: actionPreflightReasonCode(facts.ReasonCode), Summary: summary}
if facts.MutationCompleted {
execution = unified.ActionExecutionTruth{Status: unified.ActionExecutionSucceeded, Summary: summary}
} else if facts.MutationStarted {
@@ -205,6 +205,16 @@ func dockerContainerUpdateFactSummary(facts agentexec.DockerContainerUpdateResul
return summary
}
+// actionPreflightReasonCode preserves typed agent refusals while retaining the
+// legacy aggregate for older agents that do not yet send a reason_code.
+func actionPreflightReasonCode(reasonCode string) string {
+ reasonCode = strings.TrimSpace(reasonCode)
+ if agentexec.IsActionRefusalReasonCode(reasonCode) {
+ return reasonCode
+ }
+ return "preflight_refused"
+}
+
func shortDockerDigest(digest string) string {
digest = strings.TrimSpace(digest)
const previewLen = 19 // "sha256:" + 12 hex characters
diff --git a/internal/api/docker_container_action_result_test.go b/internal/api/docker_container_action_result_test.go
index ae37cad818..390f94bcfe 100644
--- a/internal/api/docker_container_action_result_test.go
+++ b/internal/api/docker_container_action_result_test.go
@@ -39,6 +39,26 @@ func TestDockerContainerExecutionResultDerivesTruthOnlyFromFacts(t *testing.T) {
}
}
+func TestDockerContainerExecutionResultPreservesTypedPreflightRefusal(t *testing.T) {
+ now := time.Now().UTC()
+ facts := dockerResultFacts(now, false, false, false, true)
+ facts.ReasonCode = agentexec.ActionRefusalTargetStateChanged
+ result, err := dockerContainerExecutionResult(
+ "app-container:fixture",
+ "agent-1",
+ agentexec.DockerContainerLifecyclePayload{Operation: agentexec.DockerContainerOperationRestart},
+ facts,
+ nil,
+ now,
+ )
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got := result.ActionResultV2.Execution.ReasonCode; got != agentexec.ActionRefusalTargetStateChanged {
+ t.Fatalf("execution reason = %q, want %q", got, agentexec.ActionRefusalTargetStateChanged)
+ }
+}
+
func TestDockerContainerExecutionResultStaleReadbackIsInconclusive(t *testing.T) {
now := time.Now().UTC()
facts := dockerResultFacts(now.Add(-time.Hour), true, true, true, true)
diff --git a/internal/api/host_apt_action_result.go b/internal/api/host_apt_action_result.go
index ae38048860..cd5097581f 100644
--- a/internal/api/host_apt_action_result.go
+++ b/internal/api/host_apt_action_result.go
@@ -9,14 +9,14 @@ import (
unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
)
-func hostAPTExecutionResult(resourceID, agentID, operation, output string, success, mutationStarted bool, verification string, beforeStateBound, packageManagerHealthRequired, healthChecked, packageManagerHealthy, recoveryRequired bool, beforeObservedAt, afterObservedAt, observationBoundaryAt, receivedAt time.Time) (*unified.ExecutionResult, error) {
+func hostAPTExecutionResult(resourceID, agentID, operation, output, refusalReasonCode string, success, mutationStarted bool, verification string, beforeStateBound, packageManagerHealthRequired, healthChecked, packageManagerHealthy, recoveryRequired bool, beforeObservedAt, afterObservedAt, observationBoundaryAt, receivedAt time.Time) (*unified.ExecutionResult, error) {
output = strings.TrimSpace(output)
execution := unified.ActionExecutionTruth{Status: unified.ActionExecutionSucceeded, Summary: output}
if !success {
if mutationStarted {
execution = unified.ActionExecutionTruth{Status: unified.ActionExecutionInconclusive, ReasonCode: "possible_partial_effect", Summary: output}
} else {
- execution = unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: "preflight_refused", Summary: output}
+ execution = unified.ActionExecutionTruth{Status: unified.ActionExecutionNotRun, ReasonCode: actionPreflightReasonCode(refusalReasonCode), Summary: output}
}
}
diff --git a/internal/api/host_apt_action_result_test.go b/internal/api/host_apt_action_result_test.go
index 89f2cc1309..212af99712 100644
--- a/internal/api/host_apt_action_result_test.go
+++ b/internal/api/host_apt_action_result_test.go
@@ -10,11 +10,11 @@ import (
func TestHostAPTActionResultRefreshFailureIsNotRunBeforeInstallMutation(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "refresh failed", false, false, agentexec.HostUpdateVerificationInconclusive, true, true, false, false, false, time.Time{}, time.Time{}, now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "refresh failed", agentexec.ActionRefusalPackageIndexRefreshFailed, false, false, agentexec.HostUpdateVerificationInconclusive, true, true, false, false, false, time.Time{}, time.Time{}, now, now)
if err != nil {
t.Fatal(err)
}
- if result.ActionResultV2.Execution.Status != unified.ActionExecutionNotRun || result.ActionResultV2.Execution.ReasonCode != "preflight_refused" {
+ if result.ActionResultV2.Execution.Status != unified.ActionExecutionNotRun || result.ActionResultV2.Execution.ReasonCode != agentexec.ActionRefusalPackageIndexRefreshFailed {
t.Fatalf("canonical execution truth = %#v", result.ActionResultV2.Execution)
}
if result.ActionResultV2.Compensation.Support != unified.ActionCompensationUnavailable || result.ActionResultV2.Compensation.Status != unified.ActionCompensationNotAvailable {
@@ -25,7 +25,7 @@ func TestHostAPTActionResultRefreshFailureIsNotRunBeforeInstallMutation(t *testi
func TestHostAPTActionResultPreservesAgentObservedAndServerReceivedTimes(t *testing.T) {
checkedAt := time.Date(2026, 7, 12, 8, 59, 0, 0, time.UTC)
observedAt := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, checkedAt.Add(-time.Second), checkedAt, observedAt, observedAt)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", "", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, checkedAt.Add(-time.Second), checkedAt, observedAt, observedAt)
if err != nil {
t.Fatal(err)
}
@@ -43,7 +43,7 @@ func TestHostAPTActionResultPreservesAgentObservedAndServerReceivedTimes(t *test
func TestHostAPTActionResultFutureVerifiedClaimFailsClosed(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, now, now.Add(unified.HostAPTTelemetryMaxClockSkew+time.Second), now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", "", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, now, now.Add(unified.HostAPTTelemetryMaxClockSkew+time.Second), now, now)
if err != nil {
t.Fatal(err)
}
@@ -54,7 +54,7 @@ func TestHostAPTActionResultFutureVerifiedClaimFailsClosed(t *testing.T) {
func TestHostAPTActionResultBoundsPermittedPositiveClockSkewToReceipt(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostStorageCleanupOperationPackageCache, "cleanup complete", true, true, agentexec.HostStorageCleanupVerificationVerified, true, false, false, false, false, now.Add(-time.Second), now.Add(time.Second), now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostStorageCleanupOperationPackageCache, "cleanup complete", "", true, true, agentexec.HostStorageCleanupVerificationVerified, true, false, false, false, false, now.Add(-time.Second), now.Add(time.Second), now, now)
if err != nil {
t.Fatal(err)
}
@@ -69,7 +69,7 @@ func TestHostAPTActionResultBoundsPermittedPositiveClockSkewToReceipt(t *testing
func TestHostAPTActionResultStaleReadbackFailsClosed(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, now.Add(-time.Hour-time.Minute), now.Add(-time.Hour), now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "updates complete", "", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, true, false, now.Add(-time.Hour-time.Minute), now.Add(-time.Hour), now, now)
if err != nil {
t.Fatal(err)
}
@@ -81,7 +81,7 @@ func TestHostAPTActionResultStaleReadbackFailsClosed(t *testing.T) {
func TestHostAPTActionResultBeforeStateMismatchCannotBecomeContradictionEvidence(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostStorageCleanupOperationPackageCache, "cleanup contradicted", true, true, agentexec.HostStorageCleanupVerificationFailed, false, false, false, false, false, now.Add(-time.Minute), now, now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostStorageCleanupOperationPackageCache, "cleanup contradicted", "", true, true, agentexec.HostStorageCleanupVerificationFailed, false, false, false, false, false, now.Add(-time.Minute), now, now, now)
if err != nil {
t.Fatal(err)
}
@@ -93,7 +93,7 @@ func TestHostAPTActionResultBeforeStateMismatchCannotBecomeContradictionEvidence
func TestHostAPTActionResultExplicitUnhealthyManagerCannotConfirmVerifiedClaim(t *testing.T) {
now := time.Date(2026, 7, 12, 9, 0, 0, 0, time.UTC)
- result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "phase=complete; package manager health: unhealthy", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, false, false, now.Add(-time.Second), now, now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "host-1", agentexec.HostUpdateOperationInstall, "phase=complete; package manager health: unhealthy", "", true, true, agentexec.HostUpdateVerificationVerified, true, true, true, false, false, now.Add(-time.Second), now, now, now)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/api/host_apt_partial_truth_test.go b/internal/api/host_apt_partial_truth_test.go
index b7b9b9bef4..354fbb6074 100644
--- a/internal/api/host_apt_partial_truth_test.go
+++ b/internal/api/host_apt_partial_truth_test.go
@@ -57,7 +57,7 @@ func TestHostUpdatePartialTruthProjectsPhaseHealthRemainingAndRecovery(t *testin
t.Fatalf("valid typed result rejected: %v", err)
}
summary := hostUpdateResultSummary(tc.payload)
- result, err := hostAPTExecutionResult("agent:host-1", "agent-1", agentexec.HostUpdateOperationInstall, summary, tc.payload.Success, tc.payload.MutationStarted, tc.payload.Verification, true, true, tc.payload.HealthChecked, tc.payload.PackageManagerHealthy, tc.payload.RecoveryRequired, tc.payload.Before.CheckedAt, tc.payload.After.CheckedAt, now, now)
+ result, err := hostAPTExecutionResult("agent:host-1", "agent-1", agentexec.HostUpdateOperationInstall, summary, tc.payload.ReasonCode, tc.payload.Success, tc.payload.MutationStarted, tc.payload.Verification, true, true, tc.payload.HealthChecked, tc.payload.PackageManagerHealthy, tc.payload.RecoveryRequired, tc.payload.Before.CheckedAt, tc.payload.After.CheckedAt, now, now)
if err != nil {
t.Fatal(err)
}
@@ -107,7 +107,7 @@ func TestHostStorageCleanupPartialTruthIsNonRollbackableAndRequiresRescan(t *tes
t.Fatal(err)
}
summary := hostStorageCleanupResultSummary(payload)
- result, err := hostAPTExecutionResult("agent:host-cleanup", "agent-1", agentexec.HostStorageCleanupOperationPackageCache, summary, payload.Success, true, payload.Verification, true, false, false, false, false, payload.Before.CheckedAt, payload.After.CheckedAt, now, now)
+ result, err := hostAPTExecutionResult("agent:host-cleanup", "agent-1", agentexec.HostStorageCleanupOperationPackageCache, summary, payload.ReasonCode, payload.Success, true, payload.Verification, true, false, false, false, false, payload.Before.CheckedAt, payload.After.CheckedAt, now, now)
if err != nil {
t.Fatal(err)
}
@@ -164,7 +164,7 @@ func TestHostAPTActionTruthRedactsRawAgentAndPackageDetail(t *testing.T) {
After: agentexec.HostPackageUpdateSnapshot{PendingCount: 1, Packages: []agentexec.HostPackageUpdate{{Name: "private-package"}}, Error: "stderr /private/cache/path", CheckedAt: now},
Verification: agentexec.HostUpdateVerificationInconclusive, Error: "raw stderr token secret",
}
- result, err := hostAPTExecutionResult("agent:host", "agent", agentexec.HostUpdateOperationInstall, hostUpdateResultSummary(payload), false, true, payload.Verification, true, true, false, false, true, payload.Before.CheckedAt, payload.After.CheckedAt, now, now)
+ result, err := hostAPTExecutionResult("agent:host", "agent", agentexec.HostUpdateOperationInstall, hostUpdateResultSummary(payload), payload.ReasonCode, false, true, payload.Verification, true, true, false, false, true, payload.Before.CheckedAt, payload.After.CheckedAt, now, now)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/api/host_storage_cleanup_action_executor.go b/internal/api/host_storage_cleanup_action_executor.go
index d6337d744a..882f0dc30f 100644
--- a/internal/api/host_storage_cleanup_action_executor.go
+++ b/internal/api/host_storage_cleanup_action_executor.go
@@ -121,7 +121,7 @@ func (e hostStorageCleanupActionExecutor) ExecuteAction(ctx context.Context, rec
output := hostStorageCleanupResultSummary(*result)
beforeBound := result.Before.Fingerprint == resource.Agent.StorageCleanup.Fingerprint
- return hostAPTExecutionResult(record.Request.ResourceID, resource.Agent.AgentID, agentexec.HostStorageCleanupOperationPackageCache, output, result.Success, result.MutationStarted, result.Verification, beforeBound, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)
+ return hostAPTExecutionResult(record.Request.ResourceID, resource.Agent.AgentID, agentexec.HostStorageCleanupOperationPackageCache, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, beforeBound, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)
}
func (e hostStorageCleanupActionExecutor) ReconcileActionDispatch(ctx context.Context, record unified.ActionAuditRecord, attempt unified.ActionDispatchAttempt) (*unified.ExecutionResult, unified.ActionDispatchReceipt, bool, error) {
@@ -157,7 +157,7 @@ func (e hostStorageCleanupActionExecutor) ReconcileActionDispatch(ctx context.Co
return nil, unified.ActionDispatchReceipt{}, false, err
}
output := hostStorageCleanupResultSummary(result)
- execution, buildErr := hostAPTExecutionResult(record.Request.ResourceID, attempt.AgentID, attempt.OperationKind, output, result.Success, result.MutationStarted, result.Verification, true, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, query.Record.TerminalAt, receivedAt)
+ execution, buildErr := hostAPTExecutionResult(record.Request.ResourceID, attempt.AgentID, attempt.OperationKind, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, true, false, false, false, false, result.Before.CheckedAt, result.After.CheckedAt, query.Record.TerminalAt, receivedAt)
if buildErr != nil {
return nil, unified.ActionDispatchReceipt{}, false, buildErr
}
diff --git a/internal/api/host_update_action_executor.go b/internal/api/host_update_action_executor.go
index c9baa115b1..2868e03fc0 100644
--- a/internal/api/host_update_action_executor.go
+++ b/internal/api/host_update_action_executor.go
@@ -126,7 +126,7 @@ func (e hostUpdateActionExecutor) ExecuteAction(ctx context.Context, record unif
output := hostUpdateResultSummary(*result)
beforeBound := result.Before.InventoryHash == resource.Agent.PackageUpdates.InventoryHash
- return hostAPTExecutionResult(record.Request.ResourceID, agentID, agentexec.HostUpdateOperationInstall, output, result.Success, result.MutationStarted, result.Verification, beforeBound, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)
+ return hostAPTExecutionResult(record.Request.ResourceID, agentID, agentexec.HostUpdateOperationInstall, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, beforeBound, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, receivedAt, receivedAt)
}
func (e hostUpdateActionExecutor) ReconcileActionDispatch(ctx context.Context, record unified.ActionAuditRecord, attempt unified.ActionDispatchAttempt) (*unified.ExecutionResult, unified.ActionDispatchReceipt, bool, error) {
@@ -162,7 +162,7 @@ func (e hostUpdateActionExecutor) ReconcileActionDispatch(ctx context.Context, r
return nil, unified.ActionDispatchReceipt{}, false, err
}
output := hostUpdateResultSummary(result)
- execution, buildErr := hostAPTExecutionResult(record.Request.ResourceID, attempt.AgentID, attempt.OperationKind, output, result.Success, result.MutationStarted, result.Verification, true, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, query.Record.TerminalAt, receivedAt)
+ execution, buildErr := hostAPTExecutionResult(record.Request.ResourceID, attempt.AgentID, attempt.OperationKind, output, result.ReasonCode, result.Success, result.MutationStarted, result.Verification, true, true, result.HealthChecked, result.PackageManagerHealthy, result.RecoveryRequired, result.Before.CheckedAt, result.After.CheckedAt, query.Record.TerminalAt, receivedAt)
if buildErr != nil {
return nil, unified.ActionDispatchReceipt{}, false, buildErr
}
diff --git a/internal/api/patrol_action_broker.go b/internal/api/patrol_action_broker.go
index 5ab07bb0ec..f3333d82b0 100644
--- a/internal/api/patrol_action_broker.go
+++ b/internal/api/patrol_action_broker.go
@@ -267,9 +267,7 @@ func (b *patrolActionBroker) loadPatrolActionPolicyInputs(ctx context.Context, p
}
}
inputs.resourceState, inputs.resourceFound, inputs.resourceErr = b.lifecycle().ResourceOperatorState(b.orgID, proposal.ResourceID)
- if inputs.resourceFound {
- inputs.resourceState = unified.NormalizeResourceOperatorState(inputs.resourceState)
- }
+ inputs.resourceState = unified.NormalizeResourceOperatorState(inputs.resourceState)
return inputs
}
@@ -311,7 +309,7 @@ func evaluatePatrolActionPolicy(inputs patrolActionPolicyInputs, orgID string, p
evaluation.err = inputs.resourceErr
return evaluation
}
- if !inputs.tenantLoaded || inputs.capability == nil || !inputs.resourceFound || inputs.snapshot.EmergencyStop {
+ if !inputs.tenantLoaded || inputs.capability == nil || inputs.snapshot.EmergencyStop {
return evaluation
}
capability := *inputs.capability
@@ -357,11 +355,11 @@ func tenantPolicyReasonCodes(snapshot PatrolActionPolicySnapshot) []unified.Acti
func resourcePolicyReasonCodes(state unified.ResourceOperatorState, capabilityName string, now time.Time) []unified.ActionPolicyReasonCode {
reasons := make([]unified.ActionPolicyReasonCode, 0, 3)
- if state.NeverAutoRemediate {
+ if state.BlocksRemediation() {
reasons = append(reasons, unified.PolicyReasonResourceNeverAuto)
}
policy := unified.NormalizeAutoRemediationPolicy(state.AutoRemediationPolicy)
- allowed := false
+ allowed := !policy.Enabled && len(policy.CapabilityNames) == 0 && policy.Window == nil
for _, name := range policy.CapabilityNames {
if name == strings.TrimSpace(capabilityName) {
allowed = policy.Enabled
@@ -403,9 +401,6 @@ func (b *patrolActionBroker) policyAuthorizationLease(ctx context.Context, propo
if inputs.capability == nil {
return unified.ActionPolicyAuthorizationLease{}, "", unified.ErrActionPolicyAuthorizationRevoked
}
- if !inputs.resourceFound {
- return unified.ActionPolicyAuthorizationLease{}, "", unified.ErrActionPolicyAuthorizationInvalid
- }
capability := *inputs.capability
state := inputs.resourceState
tenantVersion := policySnapshotVersion(inputs.snapshot)
diff --git a/internal/api/patrol_action_broker_test.go b/internal/api/patrol_action_broker_test.go
index 58effa25b5..d853067ccb 100644
--- a/internal/api/patrol_action_broker_test.go
+++ b/internal/api/patrol_action_broker_test.go
@@ -442,7 +442,7 @@ func TestPatrolActionBrokerCapabilitiesCatalog(t *testing.T) {
}
}
-func TestPatrolActionBrokerAutoAuthorizesOnlyExplicitScopedEligibleCapability(t *testing.T) {
+func TestPatrolActionBrokerOptionalResourceScopeStillAuthorizesEligibleCapability(t *testing.T) {
h, executor := newPatrolBrokerTestHandlers(t, unified.ApprovalAdmin)
store, err := h.getStore("default")
if err != nil {
@@ -491,6 +491,33 @@ func TestPatrolActionBrokerAutoAuthorizesOnlyExplicitScopedEligibleCapability(t
}
}
+func TestPatrolActionBrokerGlobalAutonomyDoesNotRequirePerResourceOptIn(t *testing.T) {
+ tests := []struct {
+ name string
+ eligibility unified.ActionAutoAuthorizationClass
+ snapshot PatrolActionPolicySnapshot
+ }{
+ {name: "assisted low risk", eligibility: unified.AutoAuthorizeLowRisk, snapshot: PatrolActionPolicySnapshot{EffectiveAutonomyLevel: "assisted"}},
+ {name: "unlocked full elevated", eligibility: unified.AutoAuthorizeElevated, snapshot: PatrolActionPolicySnapshot{EffectiveAutonomyLevel: "full", FullModeUnlocked: true}},
+ }
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ h, executor := newPatrolBrokerTestHandlersWithEligibility(t, unified.ApprovalAdmin, tc.eligibility)
+ broker := NewPatrolActionBroker("default", h, func(context.Context, string) (PatrolActionPolicySnapshot, error) {
+ return tc.snapshot, nil
+ })
+
+ disposition, err := broker.Submit(context.Background(), patrolTestProposal())
+ if err != nil {
+ t.Fatalf("Submit: %v", err)
+ }
+ if disposition.State != string(unified.ActionStateCompleted) || executor.calls != 1 {
+ t.Fatalf("global autonomy did not execute without a resource override: disposition=%#v calls=%d", disposition, executor.calls)
+ }
+ })
+ }
+}
+
func TestPatrolActionBrokerPolicyScopeAndWindowFailClosed(t *testing.T) {
h, executor := newPatrolBrokerTestHandlers(t, unified.ApprovalAdmin)
store, err := h.getStore("default")
diff --git a/internal/api/telemetry_pulse_intelligence.go b/internal/api/telemetry_pulse_intelligence.go
index 262d12ada3..4427a03668 100644
--- a/internal/api/telemetry_pulse_intelligence.go
+++ b/internal/api/telemetry_pulse_intelligence.go
@@ -134,6 +134,12 @@ func accumulatePulseIntelligenceApprovedActionOutcomes(snapshot *telemetry.Pulse
snapshot.ApprovedActionRefusalsPolicy30d++
case "capability":
snapshot.ApprovedActionRefusalsCapability30d++
+ case "target_changed":
+ snapshot.ApprovedActionRefusalsTargetChanged30d++
+ case "prerequisite":
+ snapshot.ApprovedActionRefusalsPrerequisite30d++
+ case "contract":
+ snapshot.ApprovedActionRefusalsContract30d++
default:
snapshot.ApprovedActionRefusalsOther30d++
}
@@ -189,8 +195,15 @@ func pulseIntelligenceApprovedActionRefusalCategory(reason string) string {
case "resource_remediation_locked", "policy_authorization_expired",
"policy_authorization_invalid", "policy_authorization_revoked", "action_emergency_stop":
return "policy"
- case "action_dry_run_only", "action_execution_unavailable":
+ case "action_dry_run_only", "action_execution_unavailable", "agent_capability_unavailable":
return "capability"
+ case "target_state_changed", "target_precondition_failed", "package_inventory_changed", "cleanup_inventory_changed":
+ return "target_changed"
+ case "target_inspection_unavailable", "package_manager_busy", "package_index_refresh_failed",
+ "package_preflight_failed", "package_manager_unhealthy", "cleanup_preflight_failed":
+ return "prerequisite"
+ case "action_contract_invalid":
+ return "contract"
default:
return "other"
}
diff --git a/internal/api/telemetry_pulse_intelligence_test.go b/internal/api/telemetry_pulse_intelligence_test.go
index 7b7e28271d..167d04f2cd 100644
--- a/internal/api/telemetry_pulse_intelligence_test.go
+++ b/internal/api/telemetry_pulse_intelligence_test.go
@@ -337,12 +337,18 @@ func TestGetPulseIntelligenceActionTelemetry_AttributesApprovedActionFailureCaus
if got.ApprovedActionRefusalsPlanStale30d != 1 ||
got.ApprovedActionRefusalsPolicy30d != 0 ||
got.ApprovedActionRefusalsCapability30d != 0 ||
+ got.ApprovedActionRefusalsTargetChanged30d != 0 ||
+ got.ApprovedActionRefusalsPrerequisite30d != 0 ||
+ got.ApprovedActionRefusalsContract30d != 0 ||
got.ApprovedActionRefusalsOther30d != 0 {
t.Fatalf(
- "refusal categories = %d/%d/%d/%d, want 1/0/0/0",
+ "refusal categories = %d/%d/%d/%d/%d/%d/%d, want 1/0/0/0/0/0/0",
got.ApprovedActionRefusalsPlanStale30d,
got.ApprovedActionRefusalsPolicy30d,
got.ApprovedActionRefusalsCapability30d,
+ got.ApprovedActionRefusalsTargetChanged30d,
+ got.ApprovedActionRefusalsPrerequisite30d,
+ got.ApprovedActionRefusalsContract30d,
got.ApprovedActionRefusalsOther30d,
)
}
@@ -435,15 +441,27 @@ func TestGetPulseIntelligenceActionTelemetry_LastFailureReasonUsesCanonicalReaso
func TestPulseIntelligenceApprovedActionRefusalCategory(t *testing.T) {
tests := map[string]string{
- "plan_drift": "plan_stale",
- "action_plan_expired": "plan_stale",
- "action_replan_required": "plan_stale",
- "resource_remediation_locked": "policy",
- "policy_authorization_expired": "policy",
- "action_emergency_stop": "policy",
- "action_dry_run_only": "capability",
- "action_execution_unavailable": "capability",
- "future_reason": "other",
+ "plan_drift": "plan_stale",
+ "action_plan_expired": "plan_stale",
+ "action_replan_required": "plan_stale",
+ "resource_remediation_locked": "policy",
+ "policy_authorization_expired": "policy",
+ "action_emergency_stop": "policy",
+ "action_dry_run_only": "capability",
+ "action_execution_unavailable": "capability",
+ "agent_capability_unavailable": "capability",
+ "target_state_changed": "target_changed",
+ "target_precondition_failed": "target_changed",
+ "package_inventory_changed": "target_changed",
+ "cleanup_inventory_changed": "target_changed",
+ "target_inspection_unavailable": "prerequisite",
+ "package_manager_busy": "prerequisite",
+ "package_index_refresh_failed": "prerequisite",
+ "package_preflight_failed": "prerequisite",
+ "package_manager_unhealthy": "prerequisite",
+ "cleanup_preflight_failed": "prerequisite",
+ "action_contract_invalid": "contract",
+ "future_reason": "other",
}
for reason, want := range tests {
if got := pulseIntelligenceApprovedActionRefusalCategory(reason); got != want {
diff --git a/internal/hostagent/docker_lifecycle.go b/internal/hostagent/docker_lifecycle.go
index 0193f60bc3..ba6c075e01 100644
--- a/internal/hostagent/docker_lifecycle.go
+++ b/internal/hostagent/docker_lifecycle.go
@@ -45,16 +45,19 @@ func (m *localDockerLifecycleManager) Apply(ctx context.Context, req agentexec.D
}
defer func() { result.Duration = time.Since(started).Milliseconds() }()
if err := agentexec.ValidateDockerContainerLifecyclePayload(&req); err != nil {
+ result.ReasonCode = agentexec.ActionRefusalContractInvalid
result.Error = "typed container lifecycle preflight refused"
return result
}
before, err := m.inspect(ctx, req.Runtime, req.ContainerID)
result.Before = before
if err != nil {
+ result.ReasonCode = agentexec.ActionRefusalTargetInspectionUnavailable
result.Error = "container preflight inspect unavailable"
return result
}
if !dockerLifecycleBeforeMatches(req, before) {
+ result.ReasonCode = agentexec.ActionRefusalTargetStateChanged
result.Error = "container preflight state no longer matches the request"
return result
}
diff --git a/internal/hostagent/docker_update.go b/internal/hostagent/docker_update.go
index 1e4b25eb15..89c7f8904f 100644
--- a/internal/hostagent/docker_update.go
+++ b/internal/hostagent/docker_update.go
@@ -68,11 +68,13 @@ func (c *CommandClient) runDockerContainerUpdate(ctx context.Context, payload ag
if err := agentexec.ValidateDockerContainerUpdatePayload(&payload); err != nil {
c.logger.Warn().Err(err).Str("request_id", payload.RequestID).Msg("Docker update preflight refused: invalid payload")
+ result.ReasonCode = agentexec.ActionRefusalContractInvalid
result.Error = "typed container update preflight refused"
return result
}
if c.dockerUpdater == nil {
c.logger.Warn().Str("request_id", payload.RequestID).Msg("Docker update refused: no docker module bridge wired")
+ result.ReasonCode = agentexec.ActionRefusalCapabilityUnavailable
result.Error = "docker module is not available on this agent"
return result
}
@@ -82,6 +84,7 @@ func (c *CommandClient) runDockerContainerUpdate(ctx context.Context, payload ag
outcome, err := c.dockerUpdater.TypedContainerUpdate(ctx, payload.Runtime, payload.ContainerID, payload.ExpectedImageDigest, progress)
if err != nil {
c.logger.Warn().Err(err).Str("request_id", payload.RequestID).Str("container_id", payload.ContainerID).Msg("Docker update refused before mutation")
+ result.ReasonCode = agentexec.ActionRefusalTargetPreconditionFailed
result.Error = boundDockerUpdateError(err.Error())
return result
}
diff --git a/internal/hostagent/package_updates.go b/internal/hostagent/package_updates.go
index 1796c55844..d505adda18 100644
--- a/internal/hostagent/package_updates.go
+++ b/internal/hostagent/package_updates.go
@@ -113,12 +113,14 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
if strings.TrimSpace(req.Operation) != agentexec.HostUpdateOperationInstall {
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalContractInvalid
result.Error = "unsupported typed host update operation"
return result
}
release, err := m.lease.acquire(ctx)
if err != nil {
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackageManagerBusy
result.Error = "package manager lease unavailable"
return result
}
@@ -132,6 +134,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.Before = probe
result.After = probe
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalCapabilityUnavailable
result.Error = "host package updates are not supported by this agent"
return result
}
@@ -143,6 +146,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.After = probe
result.HealthChecked, result.PackageManagerHealthy = m.checkPackageManagerHealth(ctx)
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackageIndexRefreshFailed
result.Error = "package index refresh failed"
return result
}
@@ -153,6 +157,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.After = before
result.HealthChecked, result.PackageManagerHealthy = m.checkPackageManagerHealth(ctx)
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackagePreflightFailed
result.Error = "package update preflight failed"
return result
}
@@ -160,6 +165,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.After = before
result.HealthChecked, result.PackageManagerHealthy = m.checkPackageManagerHealth(ctx)
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackageInventoryChanged
result.Error = "package update inventory changed; replan required"
return result
}
@@ -168,6 +174,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.HealthChecked, result.PackageManagerHealthy = m.checkPackageManagerHealth(ctx)
if !result.HealthChecked || !result.PackageManagerHealthy {
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackageManagerUnhealthy
result.Error = "package manager health could not be established"
return result
}
@@ -181,6 +188,7 @@ func (m *packageUpdateManager) Apply(ctx context.Context, req agentexec.HostUpda
result.After = before
result.ExecutionPhase = agentexec.HostUpdatePhasePreflight
result.Verification = agentexec.HostUpdateVerificationInconclusive
+ result.ReasonCode = agentexec.ActionRefusalPackageManagerUnhealthy
result.Error = "package manager health check refused installation"
return result
}
diff --git a/internal/hostagent/storage_cleanup.go b/internal/hostagent/storage_cleanup.go
index 4552e0a9db..63ae13aa73 100644
--- a/internal/hostagent/storage_cleanup.go
+++ b/internal/hostagent/storage_cleanup.go
@@ -100,11 +100,13 @@ func (m *storageCleanupManager) Apply(ctx context.Context, req agentexec.HostSto
defer func() { result.Duration = time.Since(startedAt).Milliseconds() }()
if strings.TrimSpace(req.Operation) != agentexec.HostStorageCleanupOperationPackageCache {
+ result.ReasonCode = agentexec.ActionRefusalContractInvalid
result.Error = "unsupported typed host storage cleanup operation"
return result
}
release, err := m.lease.acquire(ctx)
if err != nil {
+ result.ReasonCode = agentexec.ActionRefusalPackageManagerBusy
result.Error = "package manager lease unavailable"
return result
}
@@ -117,22 +119,27 @@ func (m *storageCleanupManager) Apply(ctx context.Context, req agentexec.HostSto
result.Before = before
if !before.Supported {
result.After = before
+ result.ReasonCode = agentexec.ActionRefusalCapabilityUnavailable
result.Error = "host package-cache cleanup is not supported by this agent"
return result
}
if before.Error != "" {
result.After = before
+ result.ReasonCode = agentexec.ActionRefusalCleanupPreflightFailed
result.Error = "package cache cleanup preflight failed"
return result
}
if before.Fingerprint != strings.TrimSpace(req.ExpectedFingerprint) {
result.After = before
+ result.ReasonCode = agentexec.ActionRefusalCleanupInventoryChanged
result.Error = "package cache inventory changed; replan required"
return result
}
if before.ReclaimableBytes <= 0 {
result.After = before
- result.Error = "package cache is already empty; replan required"
+ result.Success = true
+ result.ExecutionPhase = agentexec.HostStorageCleanupPhaseComplete
+ result.Verification = agentexec.HostStorageCleanupVerificationVerified
return result
}
diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.go
index e993ec79a9..c0e2def87c 100644
--- a/internal/telemetry/telemetry.go
+++ b/internal/telemetry/telemetry.go
@@ -147,7 +147,10 @@ const (
// count measured background write volume; neither discriminated an install
// that uses audit logging from one that merely has it. Reaching a
// license-gated audit read does.
- TelemetrySchemaVersion = 7
+ // Schema v8 splits agent-side pre-mutation refusals into target-change,
+ // prerequisite, and invalid-contract categories so the legacy "other"
+ // bucket no longer hides actionable product failures.
+ TelemetrySchemaVersion = 8
)
type installIDRecord struct {
@@ -328,18 +331,21 @@ type Ping struct {
// Cause-coded approved-action failure counters. Together with successes
// and still-in-flight attempts these partition the attempt count, so the
// attempt/success gap is attributable without exporting action content.
- PulseIntelligenceApprovedActionFailuresPreDispatch30d int `json:"pulse_intelligence_approved_action_failures_pre_dispatch_30d"`
- PulseIntelligenceApprovedActionFailuresExecution30d int `json:"pulse_intelligence_approved_action_failures_execution_30d"`
- PulseIntelligenceApprovedActionFailuresUnverified30d int `json:"pulse_intelligence_approved_action_failures_unverified_30d"`
- PulseIntelligenceApprovedActionStuckExecuting30d int `json:"pulse_intelligence_approved_action_stuck_executing_30d"`
- PulseIntelligenceApprovedActionInFlight30d int `json:"pulse_intelligence_approved_action_in_flight_30d"`
- PulseIntelligenceApprovedActionUnclassified30d int `json:"pulse_intelligence_approved_action_unclassified_30d"`
- PulseIntelligenceApprovedActionRefusalsPlanStale30d int `json:"pulse_intelligence_approved_action_refusals_plan_stale_30d"`
- PulseIntelligenceApprovedActionRefusalsPolicy30d int `json:"pulse_intelligence_approved_action_refusals_policy_30d"`
- PulseIntelligenceApprovedActionRefusalsCapability30d int `json:"pulse_intelligence_approved_action_refusals_capability_30d"`
- PulseIntelligenceApprovedActionRefusalsOther30d int `json:"pulse_intelligence_approved_action_refusals_other_30d"`
- PulseIntelligenceVerifiedFindingResolutions30d int `json:"pulse_intelligence_verified_finding_resolutions_30d"`
- PulseIntelligenceApprovedActionLastFailureReason30d string `json:"pulse_intelligence_approved_action_last_failure_reason_30d,omitempty"`
+ PulseIntelligenceApprovedActionFailuresPreDispatch30d int `json:"pulse_intelligence_approved_action_failures_pre_dispatch_30d"`
+ PulseIntelligenceApprovedActionFailuresExecution30d int `json:"pulse_intelligence_approved_action_failures_execution_30d"`
+ PulseIntelligenceApprovedActionFailuresUnverified30d int `json:"pulse_intelligence_approved_action_failures_unverified_30d"`
+ PulseIntelligenceApprovedActionStuckExecuting30d int `json:"pulse_intelligence_approved_action_stuck_executing_30d"`
+ PulseIntelligenceApprovedActionInFlight30d int `json:"pulse_intelligence_approved_action_in_flight_30d"`
+ PulseIntelligenceApprovedActionUnclassified30d int `json:"pulse_intelligence_approved_action_unclassified_30d"`
+ PulseIntelligenceApprovedActionRefusalsPlanStale30d int `json:"pulse_intelligence_approved_action_refusals_plan_stale_30d"`
+ PulseIntelligenceApprovedActionRefusalsPolicy30d int `json:"pulse_intelligence_approved_action_refusals_policy_30d"`
+ PulseIntelligenceApprovedActionRefusalsCapability30d int `json:"pulse_intelligence_approved_action_refusals_capability_30d"`
+ PulseIntelligenceApprovedActionRefusalsTargetChanged30d int `json:"pulse_intelligence_approved_action_refusals_target_changed_30d"`
+ PulseIntelligenceApprovedActionRefusalsPrerequisite30d int `json:"pulse_intelligence_approved_action_refusals_prerequisite_30d"`
+ PulseIntelligenceApprovedActionRefusalsContract30d int `json:"pulse_intelligence_approved_action_refusals_contract_30d"`
+ PulseIntelligenceApprovedActionRefusalsOther30d int `json:"pulse_intelligence_approved_action_refusals_other_30d"`
+ PulseIntelligenceVerifiedFindingResolutions30d int `json:"pulse_intelligence_verified_finding_resolutions_30d"`
+ PulseIntelligenceApprovedActionLastFailureReason30d string `json:"pulse_intelligence_approved_action_last_failure_reason_30d,omitempty"`
}
// Snapshot holds the dynamic state gathered at ping time.
@@ -474,6 +480,9 @@ type Snapshot struct {
PulseIntelligenceApprovedActionRefusalsPlanStale30d int
PulseIntelligenceApprovedActionRefusalsPolicy30d int
PulseIntelligenceApprovedActionRefusalsCapability30d int
+ PulseIntelligenceApprovedActionRefusalsTargetChanged30d int
+ PulseIntelligenceApprovedActionRefusalsPrerequisite30d int
+ PulseIntelligenceApprovedActionRefusalsContract30d int
PulseIntelligenceApprovedActionRefusalsOther30d int
PulseIntelligenceVerifiedFindingResolutions30d int
PulseIntelligenceApprovedActionLastFailureReason30d string
@@ -513,10 +522,13 @@ type PulseIntelligenceActionSnapshot struct {
ApprovedActionUnclassified30d int
// The refusal category counters partition ApprovedActionFailuresPreDispatch30d
// into stable, content-free operator diagnostics.
- ApprovedActionRefusalsPlanStale30d int
- ApprovedActionRefusalsPolicy30d int
- ApprovedActionRefusalsCapability30d int
- ApprovedActionRefusalsOther30d int
+ ApprovedActionRefusalsPlanStale30d int
+ ApprovedActionRefusalsPolicy30d int
+ ApprovedActionRefusalsCapability30d int
+ ApprovedActionRefusalsTargetChanged30d int
+ ApprovedActionRefusalsPrerequisite30d int
+ ApprovedActionRefusalsContract30d int
+ ApprovedActionRefusalsOther30d int
// VerifiedFindingResolutions30d counts completed, approved Patrol-origin
// actions whose postcondition was independently confirmed. No finding or
// action identity leaves the runtime.
@@ -1063,6 +1075,9 @@ func applySnapshot(base Ping, fn SnapshotFunc) Ping {
ping.PulseIntelligenceApprovedActionRefusalsPlanStale30d = s.PulseIntelligenceApprovedActionRefusalsPlanStale30d
ping.PulseIntelligenceApprovedActionRefusalsPolicy30d = s.PulseIntelligenceApprovedActionRefusalsPolicy30d
ping.PulseIntelligenceApprovedActionRefusalsCapability30d = s.PulseIntelligenceApprovedActionRefusalsCapability30d
+ ping.PulseIntelligenceApprovedActionRefusalsTargetChanged30d = s.PulseIntelligenceApprovedActionRefusalsTargetChanged30d
+ ping.PulseIntelligenceApprovedActionRefusalsPrerequisite30d = s.PulseIntelligenceApprovedActionRefusalsPrerequisite30d
+ ping.PulseIntelligenceApprovedActionRefusalsContract30d = s.PulseIntelligenceApprovedActionRefusalsContract30d
ping.PulseIntelligenceApprovedActionRefusalsOther30d = s.PulseIntelligenceApprovedActionRefusalsOther30d
ping.PulseIntelligenceVerifiedFindingResolutions30d = s.PulseIntelligenceVerifiedFindingResolutions30d
ping.PulseIntelligenceApprovedActionLastFailureReason30d = s.PulseIntelligenceApprovedActionLastFailureReason30d
diff --git a/internal/telemetry/telemetry_test.go b/internal/telemetry/telemetry_test.go
index 7186c5d9c1..aedd8e017d 100644
--- a/internal/telemetry/telemetry_test.go
+++ b/internal/telemetry/telemetry_test.go
@@ -427,7 +427,10 @@ func TestApplySnapshot(t *testing.T) {
PulseIntelligenceApprovedActionRefusalsPlanStale30d: 4,
PulseIntelligenceApprovedActionRefusalsPolicy30d: 5,
PulseIntelligenceApprovedActionRefusalsCapability30d: 6,
- PulseIntelligenceApprovedActionRefusalsOther30d: 7,
+ PulseIntelligenceApprovedActionRefusalsTargetChanged30d: 7,
+ PulseIntelligenceApprovedActionRefusalsPrerequisite30d: 8,
+ PulseIntelligenceApprovedActionRefusalsContract30d: 9,
+ PulseIntelligenceApprovedActionRefusalsOther30d: 10,
PulseIntelligenceVerifiedFindingResolutions30d: 8,
}
}
@@ -535,7 +538,10 @@ func TestApplySnapshot(t *testing.T) {
ping.PulseIntelligenceApprovedActionRefusalsPlanStale30d != 4 ||
ping.PulseIntelligenceApprovedActionRefusalsPolicy30d != 5 ||
ping.PulseIntelligenceApprovedActionRefusalsCapability30d != 6 ||
- ping.PulseIntelligenceApprovedActionRefusalsOther30d != 7 ||
+ ping.PulseIntelligenceApprovedActionRefusalsTargetChanged30d != 7 ||
+ ping.PulseIntelligenceApprovedActionRefusalsPrerequisite30d != 8 ||
+ ping.PulseIntelligenceApprovedActionRefusalsContract30d != 9 ||
+ ping.PulseIntelligenceApprovedActionRefusalsOther30d != 10 ||
ping.PulseIntelligenceVerifiedFindingResolutions30d != 8 {
t.Fatalf("Pulse Intelligence counters not applied: %#v", ping)
}
diff --git a/internal/unifiedresources/resource_operator_state.go b/internal/unifiedresources/resource_operator_state.go
index a43fb51bfd..d73c266780 100644
--- a/internal/unifiedresources/resource_operator_state.go
+++ b/internal/unifiedresources/resource_operator_state.go
@@ -52,9 +52,11 @@ type AutoRemediationWindow struct {
EndMinute int `json:"endMinute"`
}
-// AutoRemediationPolicy is the operator's explicit per-resource allowlist.
-// Tenant Patrol mode and capability eligibility are independent upper bounds:
-// this record can only narrow them. Disabled or empty policy fails closed.
+// AutoRemediationPolicy is an optional per-resource narrowing policy. Tenant
+// Patrol mode and capability eligibility are the default authority; an empty
+// policy inherits those global bounds. When enabled, this policy narrows
+// automatic execution to the named capabilities and optional daily window.
+// NeverAutoRemediate remains the explicit resource-wide opt-out.
type AutoRemediationPolicy struct {
Enabled bool `json:"enabled"`
CapabilityNames []string `json:"capabilityNames"`
@@ -132,10 +134,10 @@ type ResourceOperatorState struct {
// operator must clear the flag to allow remediation.
NeverAutoRemediate bool `json:"neverAutoRemediate"`
- // AutoRemediationPolicy explicitly opts this resource and named
- // capabilities into policy authorization. It never overrides
- // NeverAutoRemediate, capability eligibility, tenant mode, MFA, dry-run,
- // or any execution-time safety gate.
+ // AutoRemediationPolicy optionally narrows automatic execution for this
+ // resource. An empty policy follows the tenant Patrol mode. It never
+ // overrides NeverAutoRemediate, capability eligibility, tenant mode, MFA,
+ // dry-run, or any execution-time safety gate.
AutoRemediationPolicy AutoRemediationPolicy `json:"autoRemediationPolicy"`
// MaintenanceStartAt and MaintenanceEndAt define a time-bounded
@@ -350,13 +352,19 @@ func ValidateAutoRemediationPolicy(policy AutoRemediationPolicy) error {
return nil
}
-// AllowsAutoRemediationAt evaluates only the explicit per-resource scope.
-// Tenant mode, capability class, and lifecycle gates remain separate checks.
+// AllowsAutoRemediationAt evaluates the optional per-resource narrowing scope.
+// An empty policy inherits the tenant mode and capability class. An explicit
+// policy must allow the capability and current time. Resource-wide locks and
+// retirement always win.
func (s ResourceOperatorState) AllowsAutoRemediationAt(capabilityName string, now time.Time) bool {
- if s.NeverAutoRemediate {
+ s = NormalizeResourceOperatorState(s)
+ if s.BlocksRemediation() {
return false
}
policy := NormalizeAutoRemediationPolicy(s.AutoRemediationPolicy)
+ if !policy.Enabled && len(policy.CapabilityNames) == 0 && policy.Window == nil {
+ return true
+ }
if !policy.Enabled {
return false
}
diff --git a/internal/unifiedresources/resource_operator_state_policy_test.go b/internal/unifiedresources/resource_operator_state_policy_test.go
index b08412a1cf..39bf772656 100644
--- a/internal/unifiedresources/resource_operator_state_policy_test.go
+++ b/internal/unifiedresources/resource_operator_state_policy_test.go
@@ -56,6 +56,22 @@ func TestResourceOperatorStateAllowsAutoRemediationInsideDailyWindow(t *testing.
}
}
+func TestResourceOperatorStateInheritsGlobalAutonomyWithoutOverrides(t *testing.T) {
+ now := time.Date(2026, 8, 13, 12, 0, 0, 0, time.UTC)
+ if !(ResourceOperatorState{}).AllowsAutoRemediationAt("restart", now) {
+ t.Fatal("an empty resource policy must inherit the tenant Patrol mode")
+ }
+ if (ResourceOperatorState{NeverAutoRemediate: true}).AllowsAutoRemediationAt("restart", now) {
+ t.Fatal("the explicit resource opt-out must override inherited autonomy")
+ }
+ if (ResourceOperatorState{LifecycleState: LifecycleStateRetired}).AllowsAutoRemediationAt("restart", now) {
+ t.Fatal("retired resources must not inherit automatic remediation")
+ }
+ if (ResourceOperatorState{AutoRemediationPolicy: AutoRemediationPolicy{CapabilityNames: []string{"restart"}}}).AllowsAutoRemediationAt("restart", now) {
+ t.Fatal("an explicitly disabled narrowing policy must deny its configured scope")
+ }
+}
+
func TestAutoRemediationPolicySQLiteRoundTrip(t *testing.T) {
store, err := NewSQLiteResourceStore(t.TempDir(), "default")
if err != nil {
diff --git a/pkg/server/telemetry_pulse_intelligence.go b/pkg/server/telemetry_pulse_intelligence.go
index 17776879f0..722d67363c 100644
--- a/pkg/server/telemetry_pulse_intelligence.go
+++ b/pkg/server/telemetry_pulse_intelligence.go
@@ -46,6 +46,9 @@ func applyPulseIntelligenceTelemetrySnapshot(
snap.PulseIntelligenceApprovedActionRefusalsPlanStale30d = actionSnapshot.ApprovedActionRefusalsPlanStale30d
snap.PulseIntelligenceApprovedActionRefusalsPolicy30d = actionSnapshot.ApprovedActionRefusalsPolicy30d
snap.PulseIntelligenceApprovedActionRefusalsCapability30d = actionSnapshot.ApprovedActionRefusalsCapability30d
+ snap.PulseIntelligenceApprovedActionRefusalsTargetChanged30d = actionSnapshot.ApprovedActionRefusalsTargetChanged30d
+ snap.PulseIntelligenceApprovedActionRefusalsPrerequisite30d = actionSnapshot.ApprovedActionRefusalsPrerequisite30d
+ snap.PulseIntelligenceApprovedActionRefusalsContract30d = actionSnapshot.ApprovedActionRefusalsContract30d
snap.PulseIntelligenceApprovedActionRefusalsOther30d = actionSnapshot.ApprovedActionRefusalsOther30d
snap.PulseIntelligenceVerifiedFindingResolutions30d = actionSnapshot.VerifiedFindingResolutions30d
snap.PulseIntelligenceApprovedActionLastFailureReason30d = actionSnapshot.ApprovedActionLastFailureReason30d
diff --git a/pkg/server/telemetry_pulse_intelligence_test.go b/pkg/server/telemetry_pulse_intelligence_test.go
index 2174fb6880..af2da749f7 100644
--- a/pkg/server/telemetry_pulse_intelligence_test.go
+++ b/pkg/server/telemetry_pulse_intelligence_test.go
@@ -110,19 +110,22 @@ func TestApplyPulseIntelligenceTelemetrySnapshot_AggregatesContentFreeLoopCounts
snap := telemetry.Snapshot{PaidLicense: true}
actions := telemetry.PulseIntelligenceActionSnapshot{
- ActionPlans30d: 4,
- ApprovalRequests30d: 2,
- RejectedActionDecisions30d: 1,
- ApprovedActionDecisions30d: 1,
- ApprovedActionAttempts30d: 1,
- ApprovedActionSuccesses30d: 1,
- ApprovedActionInFlight30d: 2,
- ApprovedActionUnclassified30d: 3,
- ApprovedActionRefusalsPlanStale30d: 4,
- ApprovedActionRefusalsPolicy30d: 5,
- ApprovedActionRefusalsCapability30d: 6,
- ApprovedActionRefusalsOther30d: 7,
- VerifiedFindingResolutions30d: 1,
+ ActionPlans30d: 4,
+ ApprovalRequests30d: 2,
+ RejectedActionDecisions30d: 1,
+ ApprovedActionDecisions30d: 1,
+ ApprovedActionAttempts30d: 1,
+ ApprovedActionSuccesses30d: 1,
+ ApprovedActionInFlight30d: 2,
+ ApprovedActionUnclassified30d: 3,
+ ApprovedActionRefusalsPlanStale30d: 4,
+ ApprovedActionRefusalsPolicy30d: 5,
+ ApprovedActionRefusalsCapability30d: 6,
+ ApprovedActionRefusalsTargetChanged30d: 7,
+ ApprovedActionRefusalsPrerequisite30d: 8,
+ ApprovedActionRefusalsContract30d: 9,
+ ApprovedActionRefusalsOther30d: 10,
+ VerifiedFindingResolutions30d: 1,
}
applyPulseIntelligenceTelemetrySnapshot(&snap, persistence, cfg, actions, now)
@@ -178,7 +181,10 @@ func TestApplyPulseIntelligenceTelemetrySnapshot_AggregatesContentFreeLoopCounts
snap.PulseIntelligenceApprovedActionRefusalsPlanStale30d != 4 ||
snap.PulseIntelligenceApprovedActionRefusalsPolicy30d != 5 ||
snap.PulseIntelligenceApprovedActionRefusalsCapability30d != 6 ||
- snap.PulseIntelligenceApprovedActionRefusalsOther30d != 7 ||
+ snap.PulseIntelligenceApprovedActionRefusalsTargetChanged30d != 7 ||
+ snap.PulseIntelligenceApprovedActionRefusalsPrerequisite30d != 8 ||
+ snap.PulseIntelligenceApprovedActionRefusalsContract30d != 9 ||
+ snap.PulseIntelligenceApprovedActionRefusalsOther30d != 10 ||
snap.PulseIntelligenceVerifiedFindingResolutions30d != 1 {
t.Fatalf("action telemetry counters were not copied: %#v", snap)
}