Repository navigation
fix: confirm Stop after managed sandbox checkpoint cleanup - #172800
Conversation
|
ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment |
|
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR retains managed-workspace custody until accepted command cleanup and checkpointing finish after Stop or parent disposal. Example: A guest command edits source.txt in a managed Docker workspace, then the user clicks Stop.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current managed-sandbox cancellation defect, preserves live settlement authority, and has no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe sandbox adapter binds command execution and file operations to a session-owned private checkout; finalization reconciles accepted edits into the canonical managed worktree under live session, operator, and Gateway authority. flowchart TD
A[Guest run] --> B[Sandbox adapter]
B --> C[Execution admission]
C --> D[Docker or Podman command]
D --> E[Retained finalizer]
E --> F[Live workspace authority]
F --> G[Canonical checkpoint]
Technical reviewBest possible solution: Land the focused lifetime repair using the existing workspace owner, reconciliation lease, and live authority checks. Do we have a high-confidence way to reproduce the issue? Current-main source shows finalization calling checkpoint through the canceled run assertion; the submitted reproductions report the matching OPENCLAW_DIRECT_ABORT failure and a separate parent-disposal failure, but no target code was executed during this review. Is this the best way to solve the issue? The repair addresses the owning lifetime invariant without reacquiring replacement authority or swallowing checkpoint failures; inspected callers already carry the opaque finalization token, and execution admission retains its original checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4542896b10d1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +73, Tests +354, Docs +6. Total +433 across 7 files. Added test files: 1. View PR surface stats
Review metrics
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 HistoryReviewed October 15, 2026, 1:11 AM ET / 05:11 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Fixed: Stop now confirms cancellation after accepted managed-workspace command cleanup finishes. |
…172800) Preserve managed-workspace settlement authority until accepted command cleanup finishes, so Stop confirms cancellation after checkpointing while new execution and revoked authority remain blocked. Fixes openclaw#172723.
Fixes #172723.
What Problem This Solves
Stopping a guest run with an active command in a managed Docker or Podman workspace can report incomplete command cleanup after the process has already terminated. Command finalization then checkpoints the private checkout, but the checkpoint retains the run assertion that Stop has canceled. A helper that finishes cleanup after its parent exits can also lose the workspace owner before that checkpoint completes.
User Impact
Stop can settle accepted workspace changes after the request-owned command terminates, including when the parent exits first. New commands and file operations remain blocked. Conflicting edits, replaced session/worktree bindings, lost Gateway or operator authority, and real process cleanup failures still surface as errors. The repair uses the existing configuration and persisted formats.
Why This Change Was Made
The managed-workspace owner already holds the exact session incarnation, lifecycle revision, worktree binding, and database custody needed for reconciliation. Preparation now separates execution admission from settlement, and the sandbox context captures the original operator authority and existing Gateway ownership guard for settlement.
Accepted commands retain that same workspace owner through the backend's existing opaque finalization-token handoff. Parent disposal closes admission immediately; the finalizer releases retained custody after backend cleanup and checkpointing finish. File mutations likewise retain their owner through their checkpoint. Failed preparation and failed finalization release custody while preserving the failure. The existing reconciliation lease, conflict recovery, and process termination remain responsible for their operations.
The canonical workspace documentation describes this lifetime and its failure boundaries.
Evidence
The initial reproduction on
7e823106a77c63640806c0646c9dc8a21b35871freaches the real Git/SQLite projection through the bound backend'sfinalizeExecand fails withAbortError: agent run aborted, codeOPENCLAW_DIRECT_ABORT. A second deterministic reproduction on 976e58c disposes the parent workspace before finalization and fails withLocal sandbox workspace authority changed. Both regression scenarios pass with this correction; no timer race is used.The projection suite passed 25 tests, with its existing opt-in real Podman case skipped. It covers settlement after parent disposal, refusal of new shell/exec/file work, multiple accepted finalizers, real reconciliation conflicts, and replacement-session rejection.
pnpm test src/gateway/worker-environments/local-workspace-projection.test.ts --maxWorkers=1took 83.95 seconds; the original Stop and parent-disposal cases took 6.77 and 0.83 seconds. The exact-head main CI run passed in 837 seconds across 70 jobs; that is full-run wall time, not an estimate for this individual suite.Two further cases enter through the real workspace/sandbox-context path with captured operator/profile authority, prepared run admission, and Gateway state ownership. Accepted output checkpoints after cancellation and foreground closure. A committed role revocation or released Gateway owner then rejects a pending finalizer before it changes the canonical file. These cases took 9.26 and 1.59 seconds. Only container execution is substituted in this harness; the authority and filesystem reconciliation owners are real.
Changed-file formatting/lint, the line-cap ratchet, refreshed type-graph discovery, and the affected production/test graphs passed. Five related caller and process-cleanup files passed 24 tests. Applicable unchanged consumer coverage is retained from the earlier 31-file run. The complete independent engineering and adversarial review is clean, including the original-owner lifetime correction and live runtime binding. The corrected full runtime build passed in 30 minutes 17 seconds, followed by the native private-QA build; the sandbox configuration E2E file passed all six tests in 31.25 seconds. A prior UI Stop diagnostic where the child and helper completed naturally is excluded from cancellation proof.
The corrected live guest UI run used the normal Stop button while the native reviewer was running and its request-owned helper was waiting. The click began 38 ms after the reviewer model event.
chat.abortreturnedok: true, aborted: true; the child was killed with zero pending descendants and no active children. The helper settled askilled/manual-cancel, exit 0, and its private output directory was empty. The UI showed Interrupted and the stopped child, with no incomplete-cancellation warning. Exit 0 here confirms cancellation cleanup, not a successful review verdict.The served build was composition
3c24a1948fa984a3ee87ab971ee81a799923b807, with the two changed production files and UI tree identical to candidate81c67bd539d91def9e47331981c5b56768af1cec. The remaining composition delta was inspected for the request, process, session and checkpoint contracts; it does not change this behavior. Build and restart succeeded with unchanged configuration. The recording includes the actual click sequence and clearly labels its end at +0.455 seconds before displaying a separately captured settled screenshot. Raw native receipts supply the later settlement facts.Visual evidence
Actual Stop interaction, followed by an explicitly labeled later settled screenshot
stop-proof.mp4
Visual verification
3c24a1948fa984a3ee87ab971ee81a799923b807