Repository navigation
refactor(gateway): check exec approval authority once at request start - #201812
Conversation
- Delete the runtime-authority re-checks in the exec approval manager (registration, observation, resolve gate, store mutation guard, error recovery, standing-grant retention, prepared and allow-once consumption), the consumption authority callback, the expiry re-validation and the pre-creation tombstone re-check. - Keep run-end cancellation of pending approvals as cleanup driven by the run-closure observer, signal-closure listeners, request-entry checks, record ownership, expiry, consumption CAS, binding and manager-retirement checks. - forceDenyIfRuntimeAuthorityClosed stays for system-agent reconciliation (its chain). - Add a regression: an approval granted before its run ended is consumed once.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
…start - Move the abort-marker check to request start, right after the run id is derived. It is the only start check for clients without an agent runtime identity. - Restore its regression test in exec-approval.admission.test.ts (line cap).
|
Codex review: needs changes before merge. What this changesThis PR checks approval-request authority at admission and removes repeated run-authority checks during approval handling and consumption. Example: An operator grants allow-once for
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored PR implements the accepted admission policy, but three approval-consumer suites still expect the removed behavior and fail on the reviewed head. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway approval handlers admit requests, the approval manager persists and settles decisions, and effect owners consume those decisions through the existing store. flowchart TD
A[Agent request] --> B[Gateway admission]
B --> C[Approval manager]
C --> D[Approval store]
E[Operator decision] --> C
F[Run closure observer] --> C
C --> G[Effect owner consumption]
Technical reviewBest possible solution: Keep request-start admission and event-driven cancellation, and migrate the remaining consumer tests without restoring repeated run-authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source rejects consumption when the requesting run closes after approval; the added regression exercises that sequence, but no shipped-entry-point reproduction was supplied or run during this read-only review. Is this the best way to solve the issue? Removing repeated checks from the existing manager is the smallest coherent implementation of the accepted policy; admission, cancellation events, exact bindings, expiry, and consumption CAS retain their existing owners. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d902b29bce59. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -64, Tests -99, Other -1. Total -164 across 13 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 8:22 AM ET / 13:22 UTC. |
- Permission change: register the run-closure observer and assert the pending approval is cancelled; prove a lease claim with the aborted signal is refused. - Tool cancellation: assert the signal-closed record after it settles. - Cron stream revoke: wire the run-closure observer and assert the cancelled stream.
…provals (#201911) Problem: operator-approval-placement-grants.test.ts "skips the second launch and re-prompts after the placement generation changes" failed on main since #201812. It expected resolve(allow-always) to be refused after the run's placement-grant authority closed mid-request, which came from the resolve-time run re-check #201812 deleted on purpose. CI's changed-file shards did not select it for that PR. Fix: test only. The resolve now records the decision. The started launch is still refused because grant retention checks the placement owner (node-invoke-placement-grant.ts), so no stale standing grant survives. A later request while authority is closed re-prompts without allow-always or a placement binding. Every other assertion is unchanged. Proof: the target test plus every approval, standing-grant, placement-grant and consumption test file (86 files, 2,163 tests) pass; tsgo, test types, oxlint, format and the lifetime-check and line-cap ratchets pass. Co-authored-by: Ayaan Zaidi <[email protected]>
openclaw#201812) Problem: the exec approval manager re-checked the requesting run's authority at every step an approval went through: registration, observation, resolve, the store's mutation guard, storage-error recovery, standing-grant retention, and both consumption points. An approval granted while the run was live could then be refused, or silently dropped, at consumption, even though the request that asked for it had already started. Fix: run authority for an approval is checked once, when the approval request starts: the entry checks, the aborted-run check (now right after the run id is derived, so it also covers clients without an agent runtime identity), and the Gateway's pre-dispatch admission. A pending approval whose run ends is still cancelled. That is cleanup driven by the run-closure observer and the signal-closure listeners, without per-call re-validation. The per-step runtime re-checks, the consumption authority callback and the expiry re-validation are deleted. Record ownership, expiry, the consumption CAS, binding and manager-retirement checks are unchanged. forceDenyIfRuntimeAuthorityClosed stays for system-agent reconciliation, which is its own chain. User impact: an approval granted while the run was live is honored by the request that asked for it. A pending approval for an ended run is still cancelled, and a request for an already-aborted run is refused at start. Proof: new regressions (an approval granted before its run ended is consumed once; a request for an already-aborted run is refused); all 22 approval-related test files; tsgo and test types; the lifetime-check, line-cap, session-identity, mock-export and max-lines ratchets; ocx build --dts plus a packed install smoke on the head. Co-authored-by: Ayaan Zaidi <[email protected]>
…provals (openclaw#201911) Problem: operator-approval-placement-grants.test.ts "skips the second launch and re-prompts after the placement generation changes" failed on main since openclaw#201812. It expected resolve(allow-always) to be refused after the run's placement-grant authority closed mid-request, which came from the resolve-time run re-check openclaw#201812 deleted on purpose. CI's changed-file shards did not select it for that PR. Fix: test only. The resolve now records the decision. The started launch is still refused because grant retention checks the placement owner (node-invoke-placement-grant.ts), so no stale standing grant survives. A later request while authority is closed re-prompts without allow-always or a placement binding. Every other assertion is unchanged. Proof: the target test plus every approval, standing-grant, placement-grant and consumption test file (86 files, 2,163 tests) pass; tsgo, test types, oxlint, format and the lifetime-check and line-cap ratchets pass. Co-authored-by: Ayaan Zaidi <[email protected]>
#201812) Problem: the exec approval manager re-checked the requesting run's authority at every step an approval went through: registration, observation, resolve, the store's mutation guard, storage-error recovery, standing-grant retention, and both consumption points. An approval granted while the run was live could then be refused, or silently dropped, at consumption, even though the request that asked for it had already started. Fix: run authority for an approval is checked once, when the approval request starts: the entry checks, the aborted-run check (now right after the run id is derived, so it also covers clients without an agent runtime identity), and the Gateway's pre-dispatch admission. A pending approval whose run ends is still cancelled. That is cleanup driven by the run-closure observer and the signal-closure listeners, without per-call re-validation. The per-step runtime re-checks, the consumption authority callback and the expiry re-validation are deleted. Record ownership, expiry, the consumption CAS, binding and manager-retirement checks are unchanged. forceDenyIfRuntimeAuthorityClosed stays for system-agent reconciliation, which is its own chain. User impact: an approval granted while the run was live is honored by the request that asked for it. A pending approval for an ended run is still cancelled, and a request for an already-aborted run is refused at start. Proof: new regressions (an approval granted before its run ended is consumed once; a request for an already-aborted run is refused); all 22 approval-related test files; tsgo and test types; the lifetime-check, line-cap, session-identity, mock-export and max-lines ratchets; ocx build --dts plus a packed install smoke on the head. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit de680e3) Companion audit: Full production diff reviewed: request admission checks abort once; pending signals still cancel, binding/persistence/expiry and consumption CAS stay. Later 59ca885/4ea2deb are separate system-agent/node-plugin owners assigned other ledger rows; 2b5f1a8 adds collaborator guardrails, no exec-manager hunk. No schema change; identity allowlist only removes retired checks. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f0b90bc058d8cd83cb59178d83a344e588fc6778) (cherry picked from commit 0483b94eeb98cd37476e3e828bca81856d4659bf)
What problem this solves
The exec approval manager re-checked the requesting run's authority at many points while an approval existed: when it registered, when observed, before a non-deny resolution, inside the store's mutation guard, in storage-error recovery, before keeping a standing grant, and at both consumption points. An approval that was granted while the run was live could then be refused, or silently dropped, at consumption, even though the request that asked for it had already started.
The repo rule (AGENTS.md, "Choose good compromises") is to check authority one time, when work starts. Revocation applies to the next request, and a started request may finish.
Change
exec.approval.request/plugin.approval.requestentry check, and the Gateway's pre-dispatch admission since refactor(gateway): check agent runtime authority once at request start #201697.cancelled/run-aborted). That is cleanup of work nobody can resume, and the run-closure observer is its only cause (server-aux-handlers->approval-run-cancellation). A later "allow" finds a terminal record. The per-call re-validation is deleted.isExecApprovalRuntimeActivein the approval manager (registration, observation, resolve, store mutation guard, error recovery, standing-grant retention, prepared consumption,consumeAllowOnce), the consumption authority callback, and the expiry re-validation. The aborted-run (tombstone) check moves to request start.isExecApprovalRuntimeActivekeeps one reader,forceDenyIfRuntimeAuthorityClosed, which system-agent reconciliation uses. It is deleted with the system-agent chain (a separate PR).Accepted edges, no code:
isPending/isPendingDeliveryCurrentcan still return true, so a prompt may still be delivered for a moment.Both are rare, visible and recoverable.
User impact
An approval granted while the run was live is honored by the request that asked for it. A pending approval for a run that has ended is still cancelled.
Evidence
Proof tier: source (
ocx test).exec.approval.requestfor a run whose abort marker is already set is refused at request start ("approval run already aborted"). The check moved from just before record creation to right after the run id is derived, before preparation. That covers clients without an agent runtime identity, which the entry validator skips. Its regression test stays.pnpm tsgo,pnpm check:test-types, oxlint, format, and the lifetime-check, line-cap, session-identity, mock-export and max-lines ratchets: pass. The session-identity baseline is pruned (manager 4→2, consumption 1→0).refuses to apply a delegated change after its run authority closesused a standalone manager without the run-closure observer, so it depended on the deleted per-call check. It now drives the retainedforceDenyIfRuntimeAuthorityClosedand still proves the approval is cancelled and the change is not applied. System-agent production code is unchanged. Its other refusal paths (observer,afterDecision,applyDecision, reconciliation) remain.approvalSignalsare kept as closure events, because system-agent, MCP app and environments records are not always lease-backed. Only their re-validation is removed.Production −75 lines, tests −137 lines.