Repository navigation
fix: cancel Guest work when its original access is revoked - #156106
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 23, 2026, 2:47 AM ET / 06:47 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR cancels commands when their original Guest access ends, stops eligible private containers without deleting saved files, and prevents reuse after interrupted setup. Merge readiness✅ Ready for maintainer review This remains a necessary fix with no blocking findings. Earlier review concerns are resolved, and the supplied production-path evidence covers the changed authority boundary. Priority: P0 Review scores
Verification
How this fits togetherOpenClaw's exec runtime launches commands using authority captured from an admitted agent run. Its sandbox backend manages container allocation, process cleanup, and readiness records used by subsequent runs. flowchart TD
A[Original Guest access] --> B[Agent run admission]
B --> C[Registered command]
B --> D[Container lifecycle owner]
A --> E[Access revoked]
E --> C
C --> F[Targeted process cleanup]
E --> D
D --> G[Stop eligible private container]
D --> H[Persist setup readiness]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +674, Tests +1278, Docs +33. Total +1985 across 38 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep cancellation tied to original access through physical cleanup, preserve independent work and saved data, and require explicit recovery for incomplete setup. Do we have a high-confidence way to reproduce the issue? Yes, at the source boundary: current main lacks retention and revocation subscription for background exec, matching the linked report's failing controlled-process regression. This review did not execute it. Is this the best way to solve the issue? Yes. The patch extends the existing process, container, and registry owners, reuses the existing cleanup capability, and supplies physical evidence for revocation and safe reuse. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f2521d666de4. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Fixed: Guest access revocation now cancels its registered commands and stops exclusively owned sandboxes while preserving saved files and independent work. |
* commit '3ab93b4ea59804b34d02a696382db16dc95189bb': (80 commits) fix(gateway): keep session refreshes moving during unrelated writes (openclaw#156286) chore(deps): update fs-safe to 0.18.2 (openclaw#156262) refactor(plugins): extract ClawHub plugin archives once (openclaw#156246) improve(llm-core): avoid unnecessary tool validation sets (openclaw#152066) fix(backup): verification accepts archives missing captured databases (openclaw#156211) fix: cancel Guest work when its original access is revoked (openclaw#156106) fix(test): classify drained legacy migration refusals fix(anthropic): finish Opus 5.5 defaults and thinking display (openclaw#156093) refactor(agents): share native harness tool execution (openclaw#154217) fix(ui): carry typed ownership through short-route resolution test(worktrees): accept additive gc result fields (openclaw#156127) test(tasks): close sqlite borrowers before registry reload (openclaw#156131) chore(autoreview): sync Astra high defaults (openclaw#156175) refactor(node-host): await prepared workspace storage (openclaw#149519) improve: speed up cold Node test planning (openclaw#156234) fix(doctor): avoid slow legacy ownership repair in source checkouts (openclaw#156238) improve: speed up native build artifact validation (openclaw#156219) fix(ui): preserve short-route resolution ownership fix(doctor): name retained session metadata conflicts (openclaw#156162) perf(tasks): bound creation selection to matching runs (openclaw#156183) ...
…156106) Cancel registered Guest commands when their original access is revoked, and verify physical termination of sandboxes private to that access. Preserve saved files, independent work, and cancellation tracking across authorized reuse; keep interrupted setup out of ready admission. Closes openclaw#156098.
What Problem This Solves
Guest commands can outlive the original access that authorized them. The builtin exec path retained only a startup guard, and sandbox lifetime was disconnected from that access after foreground work ended. Cancelling the local Docker client also did not establish that its registered in-container payload had stopped.
Closes #156098.
User Impact
Registered exec now retains its original source through process finalization, cancels its exact managed run, and joins the backend's targeted process cleanup. Independently authorized work in a shared environment continues.
Docker and Podman containers created under one original invitation and profile also stop when their retained access ends. Multiple connections of that same invitation remain private; losing one device preserves another valid source. Saved workspace files and the container's writable layer survive. Authorized same-invitation reuse retains cancellation tracking across stop/restart.
Different invitations or profiles, staff access, and unknown history permanently exclude that physical container from whole-container revocation cleanup. Explicit shared scope, preexisting containers, sandbox browsers, and other backends keep their existing lifecycles. Arbitrary detached descendants in shared or unclassified environments remain outside this guarantee. Normal foreground completion, browser disconnection, and Stop of one turn do not revoke the whole environment.
Implementation
The existing allocation lock now hands off the immutable container ID selected during admission. Source retention, setup, reuse, replacement, and removal share that owner. Revocation joins kill, wait, and strict terminated-state inspection; failed or uncertain cleanup keeps custody. Verified stops preserve inert invitation/profile history, while each new authorized lifetime gets a fresh source record. Old process-cleanup handles retain only their own lifetime's termination receipt, so same-ID reuse cannot redirect old cleanup or inherit its success.
If access ends during one-time setup, the retained container stays pending. A later admission rejects it before restarting or replacing it, including when the setup command was removed from configuration. The operator can inspect or explicitly recreate it; setup is never silently replayed. A failed allocation that left no container can recover, and legacy containers without a readiness marker keep their existing behavior. Pending, ready, and removal intent use the existing registry field and SQLite worker; no schema or configuration option is added. Cleanup targets the captured ID and preserves concurrent management removal intent.
The builtin coding-tool factory forwards the existing backend process-cleanup capability into exec. Finalization joins targeted termination and artifact cleanup before releasing authority. Normal successful completion does not scan for processes. Existing diagnostics, inspection helpers, and test support were moved to focused sibling files to meet the repository's size limits.
Evidence
Physical proof used the real
prepareAgentRunAdmission→ workspace sandbox →createCoreCodingTools→ builtinexecpath on isolated Linux/Docker 28 with host-issued synthetic source signals. It observed process identities and kernel pidfds, rather than treating client settlement as process extinction.Running=false,Paused=false,Pid=0, and extinction of the newly captured process identities.Joined registered cancellation took 2067 ms in this observation; independent normal completion took 76 ms. These are individual observations. The fixture did not exercise live invitation RPCs or Guest-role ingress. Physical observations are Docker-specific; Podman target binding and dispatch have unit coverage. Fixture containers, image tags, and temporary state were verified removed.
The registered-process and reuse engine run used
6a37ffdfc8bc7502b72d17aba70e22e796058a68; its source-cancellation and process-finalization paths are unchanged by this setup-readiness correction. The intervening unused type-export removal emits identical runtime code. The interrupted-setup engine check passed on the exact tree committed as0283978db618d2d4f78fd79a764bcc98a271d7e2. Revocation left the same container and saved/partial workspace bytes, with all original process identities extinct. A fresh Node process rejected both matching configuration and configuration with setup removed, with unchanged engine timestamps, restart count, registry row, and setup invocation count. Ordinary setup ran once; the legacy readiness fixture reused its existing container without replay. Both fixture containers, registry entries, image tag, and temporary state were verified removed. The later correction only routes the unchanged attachment fixture through the existing database-worker pool and moves two byte-identical Podman inspection helpers to the existing inspection module; the same physical behavior proof remains applicable.The 192 tests across eleven affected test files passed remotely, combining the unchanged consumer evidence with the four affected setup/registry files. The final lazy worker-import correction also passes all 13 real SQLite registry cases, including input capture, FIFO, completion refusal, and removal-intent preservation. Regressions were also observed failing before their fixes: missing original-source retention/cancellation, missing builtin cleanup forwarding, lost private reuse tracking, old cleanup racing same-ID restart, and four mixed-history cases spanning queued/stopped reuse and changed invitation/profile. Additional regressions reproduce interrupted setup being admitted as ready, absent-container recovery retaining stale pending state, and failed setup erasing concurrent management removal intent. Core types and the import-cycle check pass after the helper move, with the affected test-type graph and complete earlier type-graph evidence retained. The attachment fixture reproduces the missing-broker failure under its old thread routing and passes unchanged in the existing database-worker pool; reservation tests also pass. Final P2 review found no actionable defects. The final deadcode and strict line-cap checks also pass.
The current-head CI run passes the affected tests and integrated Gateway wait, asynchronous transcript persistence, failure-report, requester-wake cancellation, cancellation rollback, registry, reservation, and attachment cases. The attachment fixture uses the existing database-worker pool, and the source line-cap check passes after the unchanged inspection helper move. Final hosted review of this head is Diamond (5/6), with no findings.
Per-file cost was measured on a four-CPU remote runner with
pnpm test <file> --maxWorkers=1. Paths below are relative tosrc/agents/. Command wall includes preparation; CI test time is the sum of reported passing-case durations and excludes setup/transform time. CI cost measurements below are from the final head095466b6.bash-tools.exec-runtime.cleanup.test.tsbash-tools.exec-runtime.test.tsbash-tools.exec-source-authority.test.tsbash-tools.exec-task-tracking.test.tscore-coding-tools.exec-workdir.test.tssandbox/docker-backend.test.tssandbox/docker.access-lifetime.test.tssandbox/docker.config-hash-recreate.test.tssandbox/docker.partial-create-cleanup.test.tssandbox/registry.test.tssandbox.context.attachments.test.ts