fix: use fs-safe trash for agents delete#84394
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. from source and supplied Docker proof, though I did not execute it locally in this read-only review. Current main calls a PATH-resolved PR rating What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land this fs-safe helper route after maintainer review and CI, then close #83459 as fixed. Do we have a high-confidence way to reproduce the issue? Yes from source and supplied Docker proof, though I did not execute it locally in this read-only review. Current main calls a PATH-resolved Is this the best way to solve the issue? Yes. Reusing What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a002c416c7af. |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Neon Review Wisp Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
Summary
agents deletecleanup path shells out to a PATH-resolvedtrashbinary.trash-cli, so deleting an agent can leave owned workspace/session paths behind after config state says the agent is gone.moveToTrash()now reuses OpenClaw's existing filesystem-safemovePathToTrash()helper with explicit allowed roots, and focused tests assert the helper route plus shared-workspace retention.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
AI assistance
This PR was implemented with Codex assistance. I reviewed the change and understand the affected
agents deletecleanup path.Real behavior proof (required for external PRs)
agents deleteno longer depends on a PATH-resolvedtrashbinary when moving owned agent paths to trash.command -v trashwas absent.openclaw agents add bug_test --workspace /tmp/openclaw-workspace --non-interactive --jsonfollowed byopenclaw agents delete bug_test --force --jsoninside the container.Docker proof output
/tmp/openclaw-workspaceand moved under the container user's~/.Trasheven though notrashbinary was available.agents deletecleanup path.moveToTrash()invokesrunCommandWithTimeout(["trash", pathname]), while the Docker runtime package list does not installtrash-cli.Root Cause (if applicable)
trashexecutable instead of the existing in-process fs-safe trash helper.trashwas absent.movePathToTrash()style, so CLI and Gateway cleanup behavior diverged.Regression Test Plan (if applicable)
src/commands/onboard-helpers.test.tsandsrc/commands/agents.delete.test.ts.moveToTrash()callsmovePathToTrash()with explicit allowed roots instead of invoking PATHtrash, unique workspaces are trashed, and shared workspaces are retained.agents deletecaller without requiring broad Docker E2E for every run.User-visible / Behavior Changes
openclaw agents deletenow removes owned cleanup targets in Docker/minimal environments where the externaltrashcommand is absent. The behavior remains move-to-trash rather than hard-delete.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) YesYes/No) NoYes, explain risk + mitigation: this removes a PATH-resolved externaltrashcommand from cleanup and reuses the existing fs-safe helper with explicit allowed roots. It does not add a new command execution path.Repro + Verification
Environment
Steps
command -v trashis absent inside the container.openclaw agents add bug_test --workspace /tmp/openclaw-workspace --non-interactive --json.openclaw agents delete bug_test --force --json./tmp/openclaw-workspaceno longer exists and a matching workspace entry exists under~/.Trash.Expected
agents deleteremoves the owned workspace from its original path and moves it to Trash-style storage without requiring atrashbinary.Actual
trash binary absent as expected,PASS: workspace removed,PASS: workspace moved to trash,PROOF_STATUS=0, andsg_status=0.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
trashproof; Docker runtime proof with notrashbinary.pnpm test.Review Conversations
No bot review conversations exist yet for this PR.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
trashfailure path.Validation
OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree corepack pnpm test src/commands/onboard-helpers.test.ts src/commands/agents.delete.test.tsPATH=/tmp/openclaw-corepack-bin:$PATH OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree corepack pnpm check:changedcodex review --base origin/maintrashproof with isolated OpenClaw home/state/configtrashbinary available