Repository navigation
refactor(agents): split exec tool pipeline - #113807
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 4:02 PM ET / 20:02 UTC. ClawSweeper reviewWhat this changesThe PR moves OpenClaw’s agent shell-execution pipeline out of one large module into focused modules for script analysis, safe preflight, request preparation, and policy/host/process execution, while preserving the existing public facade. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 3 items remain Keep this active refactor open for normal owner review. The branch is current, labeled Priority: P2 Review scores
Verification
How this fits togetherThe agent exec tool receives a shell request from an agent, derives workdir and environment facts, applies command policy and approval rules, then launches on an allowed host and reports process output and lifecycle state. This refactor separates those internal stages while keeping the original exec entry point for callers. flowchart LR
A[Agent tool request] --> B[Exec public facade]
B --> C[Script target and ambiguity analysis]
C --> D[Safe preflight]
D --> E[Workdir and environment preparation]
E --> F[Policy approval and host dispatch]
F --> G[Process output and lifecycle result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +68, Other -1. Total +67 across 7 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the existing facade and land the split only after redacted real-run evidence demonstrates that representative allowed execution and a protected rejection/preflight case preserve their prior outcomes and ordering. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a behavior-neutral refactor rather than a report of failing existing behavior. The review question is equivalence of the command-execution path, not reproduction of a user bug. Is this the best way to solve the issue? Yes, conditionally: keeping the public facade while splitting cohesive internal stages is a maintainable direction, provided the extracted security and lifecycle boundaries are proven equivalent with focused runtime evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ad7f927e4038. LabelsLabel changes:
Label justifications:
EvidenceWhat 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
|
|
@clawsweeper re-review |
|
Merged via squash.
|
* refactor(agents): split exec tool pipeline * chore(agents): keep exec prep type private
What Problem This Solves
src/agents/bash-tools.exec.tsmixed script parsing, safe file preflight, request preparation, policy resolution, host dispatch, and process lifecycle in one 2,166-line module. That kept a high-consequence command-execution surface on the max-lines suppression baseline and made focused review unnecessarily difficult.Why This Change Was Made
This behavior-neutral refactor leaves the original path as the public facade, separates script-target parsing from ambiguity analysis, isolates safe script reads and shell-bleed validation, moves workdir/environment request preparation behind one helper, and keeps exec policy, approval, host dispatch, and lifecycle ordering together. Static and dynamic import behavior is preserved, including the lazy
fs-safeboundary.Three pre-existing defects were found during the audit: an unbounded output-update backlog under consumer lag, a pre-spawn session-record leak, and permissive negative timeout handling. They were deliberately not fixed here so this split remains reviewable, and they are tracked separately in dedicated fix work.
Beyond the split
None. No behavior, policy, timeout, cleanup, approval, environment-filtering, allowlist, or execution-order change is included.
User Impact
No user-visible behavior change. Maintainers get smaller, cohesive modules for reviewing and evolving the exec surface, and
src/agents/bash-tools.exec.tsleaves the max-lines baseline.Evidence
createExecToolpipeline with no mocks:allowed={"status":"completed","exitCode":0,"output":"proof-ok"}protected={"blocked":true,"message":"exec preflight: detected likely shell variable injection ($DM_JSON) in node script: bad.js:1."}tbx_01kyd93s65qdznxpydsvs3yd9v:pnpm tsgo:coreandpnpm buildpassed; build emitted no[INEFFECTIVE_DYNAMIC_IMPORT]warning.tbx_01kyd9dj1nss6qv981gc5zh757: rebased-headpnpm check:changedpassed, including max-lines ratchet, formatting, core/core-test types, core lint, runtime import cycles, and boundary guards.git diff --check: clean.AI-assisted: yes. I reviewed the complete execution path and understand the resulting module boundaries.