Repository navigation
fix: revoke CLI tool access when a run is canceled - #149154
Conversation
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 10:58 AM ET / 14:58 UTC (Revision 3). ClawSweeper reviewWhat this changesMakes CLI backend Gateway tool grants expire on cancellation or timeout while preserving accepted-result draining after successful execution. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main and v2026.9.4. Source inspection and the reported boundary proof support the approach; no blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherCLI backends use a local MCP bridge to call OpenClaw’s Gateway tools. Host-owned grants connect those requests to the originating run and authorize tool effects, including filesystem writes. flowchart TD
A[CLI execution attempt] --> B[Host-owned tool grant]
C[Cancellation or timeout] --> D[Attempt liveness check]
B --> E[Gateway tool request]
D --> E
E --> F{Authority still current?}
F -->|Yes| G[Authorized tool effect]
F -->|No| H[Reject before effect]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +74, Tests +318. Total +392 across 21 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep final tool effects bound to both caller and attempt liveness, using the existing grant owner while retaining successful-result accounting. Do we have a high-confidence way to reproduce the issue? Yes: the real HTTP fixture pauses filesystem preparation and cancels only the CLI source while admission remains live. Current main's grant predicate explains the reported failure; this read-only review did not execute it. Is this the best way to solve the issue? Yes: extending the existing grant predicate and cancellation owners closes the authority gap without introducing another policy owner, configuration option, or persistent format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 22743d42a514. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Fixed: canceled CLI runs can no longer use their Gateway tool grants while process cleanup is pending. |
Stop canceled CLI sources and execution attempts from retaining Gateway tool access through delayed process cleanup, while preserving accepted tool results during normal completion.
What Problem This Solves
A CLI backend can leave a Gateway tool request pending while its originating run is canceled. The HTTP request and outer run admission can remain open while the subprocess stops and accepted results drain. During that interval, the tool grant previously stayed valid: an already prepared, rooted file write could still overwrite a report after its source had been canceled.
User Impact
Canceling the caller or execution attempt now stops that CLI grant from authorizing further work, including writes already waiting on filesystem preparation. Timeouts and supervisor cancellation take effect before native termination finishes, including attempts queued behind another process. Successful runs continue to drain accepted tool results so completed work is recorded correctly.
Why This Change Was Made
The host-private grant now retains the original caller/source checks and the active attempt's liveness assertion alongside its existing admission and capture identity. The same current-authority check serves fresh requests, retained tools, and native-tool capture callbacks. Capture rotation and warm-process token transfer replace the attempt assertion, preserving the new turn's authority without reviving the previous turn.
CLI execution supplies that assertion at capture activation. The supervisor notifies its caller when cancellation starts, before waiting for startup or sending the termination signal. Plugin execution distinguishes cancellation from the cleanup abort used after normal completion, keeping accepted results valid during the existing drain.
The change uses the existing in-memory grant and cancellation owners. It adds no tool capabilities, provider policy, configuration, protocol, persistence, or plugin SDK changes.
Evidence
stale write; the candidate preservesoriginal reportand returns an authority error.