Repository navigation
fix(gateway): close ask-fallback replay to cancelled approvals - #124381
Conversation
consumeAskFallback gated only on decision-less resolved records, so run-aborted cancellations and dispatch-fencing revocations — which also end decision-less — satisfied the timed-out predicate and could be replayed as ask-fallback. Require the expired/no-route terminal so only genuinely unanswered approvals re-admit. Dispatch fencing now records its closure honestly: worker-dispatch revocation routes through forceDenyDetailed(run-aborted, cancelled) instead of expire(), which persisted a false 'timeout' terminal. Rider cleanup: delete the write-only PendingEntry.reject/rejectPromise plumbing and the lookupPendingId alias (single test caller moved to lookupApprovalId).
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 15, 2026, 11:37 PM ET / August 16, 2026, 03:37 UTC. ClawSweeper reviewWhat this changesThis PR limits ask-fallback replay to genuinely unanswered approvals and records worker-dispatch fencing as a run-aborted cancellation instead of a timeout. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessThe fallback gate correctly rejects cancelled approvals, but the new worker-dispatch cancellation path drops the existing exec/plugin terminal-publication flow. That leaves native approval clients and iOS push paths unaware that their pending prompt was cancelled, so this PR needs a focused repair before merge. Priority: P1 Review scores
Verification
How this fits togetherGateway approval managers retain exec and plugin approval requests until a decision or terminal event. Worker-dispatch fencing closes requests for a session, and terminal publication notifies gateway clients, native forwarders, and iOS push delivery. flowchart LR
A[Pending exec or plugin approval] --> B[Worker dispatch fence]
B --> C[Cancel approval authority]
C --> D[Terminal approval record]
D --> E[Gateway publication]
E --> F[Native forwarder and iOS push]
D --> G[Ask-fallback eligibility check]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -2, Tests +24. Total +22 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Route worker-dispatch fencing through one canonical cancel-and-publish path for both approval kinds, preserving cancelled/run-aborted records while publishing the winning terminal transition. Do we have a high-confidence way to reproduce the issue? Yes, from source: fence a session with a pending exec or plugin approval; the new loop records cancellation but does not invoke the terminal publisher that reaches native clients and iOS push. Is this the best way to solve the issue? No: the ask-fallback gate is the right repair, but worker-dispatch fencing must also preserve the established terminal-publication behavior for both approval kinds. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a0498f7a9c8a. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…law#124381) consumeAskFallback gated only on decision-less resolved records, so run-aborted cancellations and dispatch-fencing revocations — which also end decision-less — satisfied the timed-out predicate and could be replayed as ask-fallback. Require the expired/no-route terminal so only genuinely unanswered approvals re-admit. Dispatch fencing now records its closure honestly: worker-dispatch revocation routes through forceDenyDetailed(run-aborted, cancelled) instead of expire(), which persisted a false 'timeout' terminal. Rider cleanup: delete the write-only PendingEntry.reject/rejectPromise plumbing and the lookupPendingId alias (single test caller moved to lookupApprovalId).
Port from openclaw/openclaw#124381: stale interactive approval controls must not resolve a later approval in the same session.
What Problem This Solves
consumeAskFallbackre-admits a timed-outsystem.runapproval exactly once (the documented ask-fallback bridge until the strict exec-timeout cutover). Its gate only checked "resolved and decision-less" — but run-aborted cancellations and worker-dispatch fencing revocations also end decision-less, so a deliberately closed approval could satisfy the timed-out predicate and be replayed as ask-fallback. That violates the closure-bound-authority invariant: terminal state and fencing must fail closed.A second dishonesty compounded it: worker-dispatch fencing revoked approvals via
expire(), which persists a durabletimeoutterminal — the audit trail claimed the operator never answered when in fact the gateway deliberately fenced the run.Why This Change Was Made
consumeAskFallbacknow requires the record's terminal to be genuinely unanswered:status === "expired"(timeout) orterminalReason === "no-route". Cancelled/fenced records fail closed.workerDispatchAuthority.revokeroutes throughforceDenyDetailed(id, "run-aborted", {kind:"system", id:"worker-dispatch"}, "cancelled")so the durable row records what actually happened. Both managers share one loop.PendingEntry.reject/rejectPromisewere write-only (no caller ever rejects the decision promise) andlookupPendingIdwas a pure alias oflookupApprovalIdwith a single test caller — both deleted.User Impact
An operator who fences a worker dispatch or aborts a run can no longer have that run's exec approval replayed through the ask-fallback path, and
approvals list/audit surfaces showcancelled/run-abortedinstead of a falsetimeoutfor fenced approvals.Evidence
rejects ask-fallback replay of a run-aborted cancellation(exec-approval-manager.expiry.test.ts) fails pre-fix via stash proof, passes post-fix.node scripts/run-vitest.mjs run src/gateway/exec-approval-manager.test.ts src/gateway/exec-approval-manager.expiry.test.ts src/gateway/node-invoke-system-run-approval.test.ts— 110/110.node scripts/run-vitest.mjs run src/gateway/server-methods/server-methods.test.ts— green.