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.

Bind mobile actions to reviewed plans

rcourtman92864222633c
diff --git a/docs/release-control/v6/internal/records/mobile-governed-action-parity-2026-07-13.md b/docs/release-control/v6/internal/records/mobile-governed-action-parity-2026-07-13.md
new file mode 100644
index 0000000000..f269d4eae5
--- /dev/null
+++ b/docs/release-control/v6/internal/records/mobile-governed-action-parity-2026-07-13.md
@@ -0,0 +1,68 @@
+# Pulse Mobile governed action parity — 2026-07-13
+
+## Outcome
+
+Pulse Mobile now preserves the canonical governed-action boundary instead of
+compressing permission and execution into one approval gesture. Pending plans
+are reviewed and decided first. An approved plan remains visible as active work
+until the operator chooses **Run action** and passes a second local
+authentication gate. Denial remains non-executing.
+
+## Identity and transport safety
+
+- Mobile reads the durable action inbox, including approved-but-not-run and
+ executing actions, rather than the decision-only compatibility queue.
+- The displayed plan identity is projected from the canonical `planHash` and is
+ required locally before approve, deny, or execute can reach the API.
+- Decision and execution requests carry that plan identity. Core rejects a
+ presented mismatch with `action_plan_identity_mismatch` before decision
+ persistence or executor dispatch while preserving compatibility for clients
+ that do not yet present the optional transport field.
+- The app no longer models or renders command-shaped approval data. Review is
+ based on typed capability, target, preflight, blast radius, safety, rollback,
+ verification, and plan identity facts.
+
+## Operator truth
+
+- Approval policy and operational risk remain distinct facts. Admin, operator,
+ MFA, no-approval, and dry-run policies are no longer rendered as unknown risk.
+- Approval copy states that permission does not run the action. Execution copy
+ states that the approved plan will run now and produces a verification result.
+- Active counts and cross-source routing include both pending decisions and
+ approved plans ready to run, so reload or source switching cannot hide the
+ second step.
+
+## Revoked access recovery
+
+Terminal Relay authorization errors and proxied HTTP 401 responses still fail
+closed by removing rejected credentials and instance-scoped state. They now
+also persist a bounded recovery explanation containing the affected source
+name, entitlement-aware guidance when applicable, and a **Pair Again** action.
+The explanation survives restart and appears above the main tabs until the
+operator acts or dismisses it; repeated terminal signals cannot overwrite the
+better source-specific record after credentials have already been removed.
+
+## Proof
+
+- Core action handler tests prove mismatched client plan identities cannot
+ record decisions or reach an executor.
+- Pulse Mobile typecheck passes.
+- All Pulse Mobile application tests pass, including plan projection, separate
+ decision/execution API calls, truthful posture, active-inbox projection,
+ second-step recovery, and durable revoked-access recovery.
+- Release-script tests pass and pin separate decision and execution gestures in
+ the iOS and Android native proof drivers.
+- The focused Release-arm64 iOS simulator proof executed one XCUITest with zero
+ failures in 74.381 seconds. It observed the approval-recorded/not-run state,
+ the distinct **Run action** control, the completed execution result, and the
+ denial path. The result bundle and summary are retained locally under
+ `pulse-mobile/artifacts/proof/mobile-approval-parity-2026-07-13-rerun/`.
+- The physical-device readiness probe passes against an unlocked iPad running
+ iOS 26.5.2 with Developer Mode and developer disk-image services available.
+
+## Residual
+
+This closes the governed-action parity slice. The broader
+`lane-followup:mobile-post-rc-hardening` remains planned because public store
+publication is a separate human-triggered release operation and future post-GA
+hardening remains deliberately open.
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 2a8fdbd2a1..e6e5d74d68 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -8028,7 +8028,7 @@
},
{
"id": "mobile-post-rc-hardening",
- "summary": "Track explicit Pulse Mobile store-publication execution and post-GA mobile hardening beyond the current proof floor. Build 4 has current physical Android and iOS companion-role proof; public rollout still requires a separate human-triggered release operation, and future mobile hardening must not reopen the GA readiness gate unless new evidence regresses.",
+ "summary": "Track explicit Pulse Mobile store-publication execution and remaining post-GA mobile hardening beyond the current proof floor. Governed action parity now keeps approval and execution separately authenticated, binds both gestures to the reviewed plan identity, preserves approved work in the durable inbox, removes command-shaped presentation, renders approval posture truthfully, and persists revoked-access recovery. Build 4 retains physical Android and iOS companion-role proof; public rollout still requires a separate human-triggered release operation, and future hardening must not reopen the GA readiness gate unless new evidence regresses.",
"owner": "project-owner",
"status": "planned",
"recorded_at": "2026-03-13",
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index b9c73eaad2..16bd89b9e8 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1374,6 +1374,11 @@ the intentionally sparse public response.
Approval-gated command execution must expose stable rejection reasons for
invalid approval grants so fleet operators can distinguish missing, expired,
mismatched, and signature-invalid grants through agent metrics.
+ Interactive action clients may additionally present the reviewed `planHash`
+ on decision and execution requests. The shared `internal/api/actions.go`
+ boundary must reject a mismatch before it records approval state or dispatches
+ to an agent; lifecycle consumers must never reinterpret a stale client plan as
+ command authority merely because the action id is still valid.
The server must not mint that grant from a nonempty approval id alone.
`internal/agentexec` accepts approval-gated arbitrary commands only with a
non-serializable server-owned authorization context and a verifier that
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index abf66d8932..081de579e0 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -7356,12 +7356,22 @@ inventory and router allowlist, and queue failures use the shared
`agentcapabilities` vocabulary. Pending rows are oldest-first and expose the
same action audit shape, including requester and origin, used by desktop and
mobile. The mobile client must approve by recording an approved decision and
-then calling execute, and must reject through the decision endpoint; legacy
+must not treat that decision as execution. A later explicit Run action gesture,
+with its own local authentication gate, calls execute. Interactive clients bind
+both requests to the exact reviewed plan by sending `planHash`; the REST fields
+remain optional for transport compatibility, but any presented hash that differs
+from the authoritative persisted plan fails with
+`action_plan_identity_mismatch` before a decision write or executor dispatch.
+Mobile uses the durable pending inbox so approved-but-not-run and executing
+actions survive refresh and remain visible. It must reject through the decision
+endpoint; legacy
`/api/ai/approvals` routes are readable history only and are not a live Patrol
action path. `ActionPlanInfo` carries canonical preflight detail across the
broker boundary. Transition publication is org-scoped, persistence precedes
publication, and API reconciliation treats the callback payload only as an id
to re-read from the action lifecycle store.
+The 2026-07-13 mobile parity proof is recorded in
+`docs/release-control/v6/internal/records/mobile-governed-action-parity-2026-07-13.md`.
The same plan and audit projection carries the unified-resource-owned
`policyDecision` object unchanged through plan responses, action list/detail,
audit, and Patrol action-reference boundaries. Public plan requests cannot
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index b4df4c4e6b..60de70b934 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -3912,6 +3912,11 @@ storage mutation grant. Per-resource capability allowlists and recurring
windows may admit only capabilities whose canonical resource contract declares
eligibility; storage-pressure remediation remains approval-bound until a
complete capability and verification workflow explicitly declares otherwise.
+Interactive decisions and executions may carry the exact reviewed `planHash`;
+the shared `internal/api/actions.go` boundary must reject a presented mismatch
+before audit mutation or executor dispatch. Storage and recovery consumers must
+preserve that binding and must not treat an approved row or matching action id
+alone as authority for a recovery or storage mutation.
That same shared `internal/api/` boundary also owns hosted browser-session
precedence for adjacent protected reads. Storage- and recovery-adjacent hosted
surfaces may run without local auth configured, but a valid tenant
diff --git a/internal/api/actions.go b/internal/api/actions.go
index 3aef0c3689..dc3d0082f9 100644
--- a/internal/api/actions.go
+++ b/internal/api/actions.go
@@ -32,6 +32,11 @@ type ActionAvailabilityChecker = actionlifecycle.AvailabilityChecker
type actionDecisionRequest struct {
Outcome unified.ApprovalOutcome `json:"outcome"`
Reason string `json:"reason,omitempty"`
+ // PlanHash is an optional transport-level binding supplied by interactive
+ // clients that displayed a specific plan. Older clients may omit it; when
+ // present it must match the authoritative persisted plan before Pulse
+ // records the decision.
+ PlanHash string `json:"planHash,omitempty"`
}
type publicActionPlanRequest struct {
@@ -52,7 +57,8 @@ type actionDecisionResponse struct {
}
type actionExecutionRequest struct {
- Reason string `json:"reason,omitempty"`
+ Reason string `json:"reason,omitempty"`
+ PlanHash string `json:"planHash,omitempty"`
}
type actionExecutionResponse struct {
@@ -297,6 +303,7 @@ func (h *ResourceHandlers) HandleDecideAction(w http.ResponseWriter, r *http.Req
}
decision.Outcome = unified.ApprovalOutcome(strings.TrimSpace(string(decision.Outcome)))
decision.Reason = strings.TrimSpace(decision.Reason)
+ decision.PlanHash = strings.TrimSpace(decision.PlanHash)
if decision.Outcome != unified.OutcomeApproved && decision.Outcome != unified.OutcomeRejected {
writeJSONErrorWithDetails(w, http.StatusBadRequest, agentcapabilities.AgentErrCodeInvalidActionDecision, "Invalid action decision request", map[string]string{
"outcome": "outcome must be approved or rejected",
@@ -322,6 +329,10 @@ func (h *ResourceHandlers) HandleDecideAction(w http.ResponseWriter, r *http.Req
writeJSONErrorWithDetails(w, http.StatusNotFound, agentcapabilities.AgentErrCodeActionNotFound, "Action not found", map[string]string{"actionId": actionID})
return
}
+ if decision.PlanHash != "" && decision.PlanHash != record.Plan.PlanHash {
+ writeJSONError(w, http.StatusConflict, "action_plan_identity_mismatch", "The reviewed action plan changed; reload it before deciding")
+ return
+ }
canonicalDecision := unified.ActionDecision{
Actor: actor,
Outcome: decision.Outcome,
@@ -389,6 +400,7 @@ func (h *ResourceHandlers) HandleExecuteAction(w http.ResponseWriter, r *http.Re
return
}
execution.Reason = strings.TrimSpace(execution.Reason)
+ execution.PlanHash = strings.TrimSpace(execution.PlanHash)
orgID := GetOrgID(r.Context())
actor, err := actionActorForRequest(h.cfg, r, orgID)
@@ -396,6 +408,23 @@ func (h *ResourceHandlers) HandleExecuteAction(w http.ResponseWriter, r *http.Re
writeJSONError(w, http.StatusForbidden, agentcapabilities.AgentErrCodeActionActorUnavailable, "Authenticated action actor is unavailable")
return
}
+ if execution.PlanHash != "" {
+ record, found, err := h.ActionLifecycle().Get(orgID, actionID)
+ if err != nil {
+ writeActionLifecycleReadError(w, err, func() {
+ writeJSONError(w, http.StatusInternalServerError, "action_audit_query_failed", "Failed to query action audit")
+ })
+ return
+ }
+ if !found {
+ writeJSONErrorWithDetails(w, http.StatusNotFound, agentcapabilities.AgentErrCodeActionNotFound, "Action not found", map[string]string{"actionId": actionID})
+ return
+ }
+ if execution.PlanHash != record.Plan.PlanHash {
+ writeJSONError(w, http.StatusConflict, "action_plan_identity_mismatch", "The approved action plan changed; reload it before execution")
+ return
+ }
+ }
completed, err := h.ActionLifecycle().Execute(r.Context(), orgID, actionID, actor, execution.Reason)
if err != nil {
writeActionLifecycleReadError(w, err, func() {
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index a01b76cbe3..acf710437e 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -95,6 +95,81 @@ func TestContract_ActionExecutorAdmissionRequiresDurableAttemptAndSendCAS(t *tes
}
}
+func TestContract_ActionMutationsRejectMismatchedPresentedPlanIdentity(t *testing.T) {
+ now := time.Now().UTC().Truncate(time.Second)
+ h := newActionTestResourceHandlers(t, &config.Config{DataPath: t.TempDir()})
+ executor := &stubActionExecutor{result: &unifiedresources.ExecutionResult{Success: true}}
+ h.SetActionExecutor(executor)
+ store, err := h.getStore("default")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ pending := unifiedresources.ActionAuditRecord{
+ ID: "act_contract_plan_decision", CreatedAt: now, UpdatedAt: now, State: unifiedresources.ActionStatePending,
+ Request: boundActionTestRequest("req-contract-plan-decision", "vm:42", "restart", "Recover workload", "pulse_patrol"),
+ Plan: unifiedresources.ActionPlan{
+ ActionID: "act_contract_plan_decision", RequestID: "req-contract-plan-decision", Allowed: true,
+ RequiresApproval: true, ApprovalPolicy: unifiedresources.ApprovalAdmin,
+ ApprovalRequirement: unifiedresources.ApprovalRequirementForFloor(unifiedresources.ApprovalAdmin),
+ PlannedAt: now, ExpiresAt: now.Add(time.Hour), ResourceVersion: "resource:v1",
+ PolicyVersion: "policy:v1", PlanHash: "sha256:authoritative",
+ },
+ }
+ approved := unifiedresources.ActionAuditRecord{
+ ID: "act_contract_plan_execution", CreatedAt: now, UpdatedAt: now, State: unifiedresources.ActionStateApproved,
+ Request: boundActionTestRequest("req-contract-plan-execution", "vm:43", "restart", "Recover workload", "pulse_patrol"),
+ Plan: unifiedresources.ActionPlan{
+ ActionID: "act_contract_plan_execution", RequestID: "req-contract-plan-execution", Allowed: true,
+ RequiresApproval: true, ApprovalPolicy: unifiedresources.ApprovalAdmin,
+ ApprovalRequirement: unifiedresources.ApprovalRequirementForFloor(unifiedresources.ApprovalAdmin),
+ PlannedAt: now, ExpiresAt: now.Add(time.Hour), ResourceVersion: "resource:v1",
+ PolicyVersion: "policy:v1", PlanHash: "sha256:authoritative",
+ },
+ Approvals: []unifiedresources.ActionApprovalRecord{
+ boundActionTestApproval("act_contract_plan_execution", "sha256:authoritative", "[email protected]", now),
+ },
+ }
+ for _, record := range []unifiedresources.ActionAuditRecord{pending, approved} {
+ if err := store.RecordActionAudit(record); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ decisionRecorder := httptest.NewRecorder()
+ decisionRequest := httptest.NewRequest(http.MethodPost, "/api/actions/act_contract_plan_decision/decision", bytes.NewBufferString(`{
+ "outcome":"approved",
+ "planHash":"sha256:reviewed-stale"
+ }`))
+ decisionRequest.SetPathValue("id", pending.ID)
+ h.HandleDecideAction(decisionRecorder, actionHandlerTestRequest(decisionRequest, "[email protected]"))
+ if decisionRecorder.Code != http.StatusConflict || !strings.Contains(decisionRecorder.Body.String(), `"error":"action_plan_identity_mismatch"`) {
+ t.Fatalf("decision status=%d body=%s", decisionRecorder.Code, decisionRecorder.Body.String())
+ }
+
+ executionRecorder := httptest.NewRecorder()
+ executionRequest := httptest.NewRequest(http.MethodPost, "/api/actions/act_contract_plan_execution/execute", bytes.NewBufferString(`{
+ "planHash":"sha256:reviewed-stale"
+ }`))
+ executionRequest.SetPathValue("id", approved.ID)
+ h.HandleExecuteAction(executionRecorder, actionHandlerTestRequest(executionRequest, "[email protected]"))
+ if executionRecorder.Code != http.StatusConflict || !strings.Contains(executionRecorder.Body.String(), `"error":"action_plan_identity_mismatch"`) {
+ t.Fatalf("execution status=%d body=%s", executionRecorder.Code, executionRecorder.Body.String())
+ }
+ if executor.calls != 0 {
+ t.Fatalf("mismatched client plan reached executor: calls=%d", executor.calls)
+ }
+
+ decisionAudit, found, err := store.GetActionAudit(pending.ID)
+ if err != nil || !found || decisionAudit.State != unifiedresources.ActionStatePending || len(decisionAudit.Approvals) != 0 {
+ t.Fatalf("mismatched decision changed audit: found=%v err=%v audit=%#v", found, err, decisionAudit)
+ }
+ executionAudit, found, err := store.GetActionAudit(approved.ID)
+ if err != nil || !found || executionAudit.State != unifiedresources.ActionStateApproved || executionAudit.Result != nil {
+ t.Fatalf("mismatched execution changed audit: found=%v err=%v audit=%#v", found, err, executionAudit)
+ }
+}
+
type resourceContractSnapshot struct {
ID string
Name string