Repository navigation
fix(exec): preserve sandbox cleanup outcomes and Linux group retirement - #139948
Conversation
Keep reusable sandbox lifetimes with the backend, join command finalizers, and retain their cleanup failures while requiring host tree settlement. Reject unsupported owned PTY requests before spawning so exec falls back once. Use procfs for Linux group retirement without a fixed ps executable path. Follow-up to #135868 after #139517 and #139657. Move the three related exec-runtime test roots to the existing tools typecheck graph, preserving the 720-root cap and complete coverage.
|
🦞👀 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: blocked before merge. Reviewed September 6, 2026, 4:48 AM ET / 08:48 UTC. ClawSweeper reviewWhat this changesThe PR preserves reusable sandbox lifetimes, joins command finalizers, retains cleanup failures, and uses Linux procfs to determine when owned process groups can retire. Merge readiness⛔ Blocked before merge - 2 items remain This remains useful follow-up work absent from the supplied main revision. No actionable correctness defect was found; the maintainer-authored PR explicitly documents its terminal compatibility tradeoff. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s exec tools send host and sandbox commands through a process supervisor. Cleanup results tell the surrounding agent invocation when command resources have settled and whether releasing its state is safe. flowchart TD
A[Agent command] --> B[Cleanup policy]
B --> C[Owned host process tree]
B --> D[Sandbox command transport]
C --> E[Native cleanup confirmation]
D --> F[Backend finalizer]
E --> G[Joined cleanup outcome]
F --> G
G --> H[Release state or retain uncertainty]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +74, Tests +473, Docs +11. Total +558 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep sandbox lifetimes backend-owned and cleanup outcomes truthful, retaining the documented terminal fallback wherever native PTY cannot provide process-tree closure evidence. Do we have a high-confidence way to reproduce the issue? Yes, from source: supplied main applies strict tree cleanup to reusable sandbox execution, omits cleanup-receipt recording on finalizer failure, and requires /bin/ps for Linux retirement. No runtime reproduction was executed during this review. Is this the best way to solve the issue? Yes. The patch repairs the existing cleanup owners and registry join, preserves strict outer executors, and leaves kernel extinction confirmation intact; its terminal limitation is explicitly documented. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 279d42d4be3f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Keep reusable sandbox lifetimes with the backend, join command finalizers, and retain their cleanup failures while requiring host tree settlement. Reject unsupported owned PTY requests before spawning so exec falls back once. Use procfs for Linux group retirement without a fixed ps executable path. Follow-up to openclaw#135868 after openclaw#139517 and openclaw#139657. Move the three related exec-runtime test roots to the existing tools typecheck graph, preserving the 720-root cap and complete coverage.
Related: #135868, #139517, #139657
What Problem This Solves
Fixes an issue where one-shot agent commands could report uncertain cleanup after a successful command in a reusable sandbox. A backend finalizer failure could conversely leave the cleanup outcome marked closed. On Linux installations without
/bin/ps, normal owned command cleanup could not observe that its process group was ready to retire.This is a focused follow-up to the landed process and runtime stages of #135868. The active update and recovery stages remain separate.
Why This Change Was Made
The supervisor now distinguishes cleanup of all execution, locally owned execution, and command transport. Ordinary one-shot tools preserve the backend's configured sandbox lifetime while still joining command finalization and requiring host process-tree cleanup. Strict outer executors retain their requirement. Backend-finalizer errors record uncertainty at the finalizer owner before the exec registry retires the session.
Host commands requiring tree cleanup reject the unsupported native PTY capability before starting it, allowing the existing exec fallback to run the command once as an owned child and show a warning. Linux group observation reads procfs, sharing the existing zombie/thread decision; the external host still owns proof that the kernel process group has disappeared. Darwin keeps its existing process census.
User Impact
Reusable sandbox commands can complete without a false cleanup failure, actual finalizer failures remain visible to the cleanup owner, and Linux group retirement works without a fixed
psexecutable path. Terminal-dependent commands may fail when the existing non-PTY fallback is required; this behavior is documented.Evidence
The focused tests use controlled adapters and finalizers; they are not live Docker, SSH, or NixOS installation proof. No configuration, SQLite schema, protocol, public plugin SDK, or MCP cleanup API changes are introduced.
Production delta: +112/-38 (net +74). Linux procfs support accounts for +48; explicit cleanup ownership, joining the existing finalizer registry, and preserving failure facts account for +26. Tests and support: +509/-36; docs: +11/-0.
Maintainer review resolution
Retain the documented PTY fallback for scopes requiring process-tree cleanup. It refuses an unsupported cleanup capability before execution and runs once through the existing owned-child path with a visible warning. Unscoped and transport-only PTY execution remain available and covered; terminal-dependent commands in strict scopes retain the stated limitation. A native PTY tree owner is separate work, not a compatibility shim in this repair.
No stored data model changes:
service-child-group-ownership.tsonly reads the kernel's transient/procprocess census (or existing Darwinpsoutput). ItsGroupMembervalues are local iteration results; they are neither serialized nor persisted. No database, table, schema version, record shape, migration, configuration format, or upgrade reader/writer changes. The automated data-model classification is a false positive, so no migration is required. The native state-schema guard and all core/test typecheck graphs passed.