Repository navigation
refactor(agents): remove captured tool source execution guards - #202522
Conversation
- Admit tools through their existing entry owners instead of capturing and rechecking authority during an invocation. - Remove guard-only plugin context, file mutation scopes, and stale mid-flight revocation expectations while retaining cancellation, recovery, and data fences.
|
🦞👀 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. |
- Remove authority rechecks after durable observation, polling, and stdin writes. - Retain action-start admission and selected-process identity/scope fences.
- Restore host write and mkdir abort propagation without restoring source-authority assertions. - Preserve signal-only cancellation at preparation, replay, launch, and deferred-media boundaries previously covered by the deleted guard. - Restore cancellation regressions for ordinary host writes, apply_patch commits, workspace native writes, and memory appends.
|
Codex review: needs changes before merge. What this changesThis PR removes captured authority rechecks from admitted tool work while retaining entry admission, cancellation, and data fences. Example: A write to notes.txt is admitted before its source authority retires during preparation.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep open: this maintainer-authored simplification follows the repository’s authority policy, but the test cutover is incomplete and introduces deterministic CI failures. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe agent tool adapter and bound-tool owners admit model-requested operations, which then reach filesystem, process, plugin, spawn, fetch, and media implementations and return tool results. flowchart TD
A[Model tool call] --> B[Adapter and bound tool admission]
B --> C[Preparation and hooks]
C --> D[Tool implementation]
D --> E[Filesystem process or transport]
D --> F[Deferred media admission]
F --> E
E --> G[Tool result]
Technical reviewBest possible solution: Complete the test migration around the existing admission owners, retaining cancellation, next-invocation refusal, and data-fence coverage without restoring captured mid-call authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source shows captured authority being reasserted within admitted operations, and exact-head CI supplies concrete failing consumer cases; no local reproduction was run. Is this the best way to solve the issue? Removing the redundant captures and scopes is the smallest coherent implementation using existing owners, but the affected consumer tests must migrate with it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 569c60bc2a5c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -308, Tests -562, Other -1. Total -871 across 45 files. Added test files: 0. 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. 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 20, 2026, 10:02 AM ET / 15:02 UTC. |
- Retire obsolete mid-flight authority refusal expectations while retaining queued admission checks, cancellation cleanup, process credential revocation, and parent reset fences. - Check the existing media resource owner after asynchronous reference preflight before handing work to a task. - Shrink the session-identity allowlist to the remaining source-owner marker.
- Check the invocation abort signal immediately before closing stdin after an awaited write. - Preserve signal-only cancellation before a provenance callback commits its filesystem write.
…law#202522) ## Problem Tool execution captured caller authority and reasserted it after asynchronous preparation and during already-started file, process, plugin, spawn, fetch, and media work. This contradicts the repository's “check authority one time, when work starts” rule. Scoped authority-simplification work requested by Ayaan. ## Fix - Delete `captureAgentToolSourceExecutionGuard`, its guard-only plugin async context, and its ratchet entry. - Remove 24 production capture calls plus two calls to the now-deleted adapter capture wrapper. - Keep tool entry admission with the existing bound-tool owner and keep deferred media admission at actual execution start. - Unwrap guard-only execution scopes. Preserve filesystem containment, worker/session data fences, explicit cancellation, and borrowed-handle rollback through the existing fs-safe write owner. ## Behavior An admitted tool invocation can finish after its source authority changes. New work still enters through existing admission owners; explicit cancellation and data/ownership fences remain in force. Removed obsolete authority-only rejection expectations and retained cancellation, input custody, provenance, and worker-generation coverage. Explicit cancellation regressions cover host write/apply_patch rollback preparation, native workspace writes, and memory append provenance preparation. Production delta, excluding tests and test support: **+582 / -885 (net -303)**. Most added lines are indentation changes from unwrapping scopes. No new helper, hook, schema, configuration, or error type. ## Evidence - `git grep captureAgentToolSourceExecutionGuard`: no references remain. - `pnpm exec oxfmt --write <touched files>`: passed. - `pnpm exec oxlint <touched files>`: passed. - No local tests or typechecks run, as requested. GitHub CI is the runtime/typecheck proof. - Simplified against existing owners; no replacement captured authority helper. - Addressed failures from CI run 44756051205: removed stale mid-flight refusal and dispatch-shape assertions; preserved explicit Stop, fork cleanup, parent-reset fences, queued channel recovery admission, credential revocation, and later-invocation coverage. Media preflight now rechecks its existing resource owner's open state after reference loading, before task handoff. Lowered the remaining session-identity allowance from two to one. ## Related work Approved overlap with openclaw#202513 includes the single ratchet entry, guard-only changes in both `src/gateway/server.agent-input-authority*.test.ts` files, and the specifically requested CI repair to `src/gateway/operator-run-recovery.channel.test.ts` (retains queued recovery refusal instead of in-flight I/O revocation). No skipped capture call sites. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#202607) Split Linux retired-tree removal into bounded passes with a serialized quiet interval and react to fresh or ongoing 500 ms btrfs commits. Preserve pending-path custody and the reservation low watermark across resumption. Remove unused spawn-test fixtures left by openclaw#202522.
Release adaptation: extract the independent mixed-requester repair and its queue regression. Stable already strips display/owner flags but copies requester origin and the private owner capability. The wider saved-requester cutover needs the newer fixed-request and Cron occurrence authorities and the durable queue owner; do not replace the stable custody or restart contract. Companions: #203468 and #203521 are separate selected start-grant repairs. #201334, #201377, #200533 and #202318 are missing full-cutover prerequisites; #203516, #202522 and #202520 are later distinct lifetime refactors, not needed by the isolated mixed-requester repair. (cherry picked from commit 3ad2cce) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a26e1e7b02425b94d31c3e6bc6add8d417dc3fda)
Problem
Tool execution captured caller authority and reasserted it after asynchronous preparation and during already-started file, process, plugin, spawn, fetch, and media work. This contradicts the repository's “check authority one time, when work starts” rule. Scoped authority-simplification work requested by Ayaan.
Fix
captureAgentToolSourceExecutionGuard, its guard-only plugin async context, and its ratchet entry.Behavior
An admitted tool invocation can finish after its source authority changes. New work still enters through existing admission owners; explicit cancellation and data/ownership fences remain in force.
Removed obsolete authority-only rejection expectations and retained cancellation, input custody, provenance, and worker-generation coverage. Explicit cancellation regressions cover host write/apply_patch rollback preparation, native workspace writes, and memory append provenance preparation.
Production delta, excluding tests and test support: +582 / -885 (net -303). Most added lines are indentation changes from unwrapping scopes. No new helper, hook, schema, configuration, or error type.
Evidence
git grep captureAgentToolSourceExecutionGuard: no references remain.pnpm exec oxfmt --write <touched files>: passed.pnpm exec oxlint <touched files>: passed.Related work
Approved overlap with #202513 includes the single ratchet entry, guard-only changes in both
src/gateway/server.agent-input-authority*.test.tsfiles, and the specifically requested CI repair tosrc/gateway/operator-run-recovery.channel.test.ts(retains queued recovery refusal instead of in-flight I/O revocation). No skipped capture call sites.