Repository navigation
fix(sandbox): resume btrfs workspaces after atomic checkpoint capture - #196662
Conversation
Keep command finalization awaiting canonical acceptance and retain paused imports and recovery. Resume only after the newly captured export has a durable Git result; later guest writes remain available for the next checkpoint.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review Please review head 2705620, especially the distinction between newly captured command exports and paused import/recovery settlement. Command finalization still awaits canonical acceptance; the new regression covers a later guest write during both normal and interrupted acceptance. Native Podman+btrfs performance comparison remains pending and will be added before merge. |
|
🦞👀 Re-review progress:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs maintainer review before merge. What this changesThis PR resumes eligible btrfs sandboxes after snapshot capture while canonical synchronization continues. Example: A command edits a provisioned btrfs workspace containing 62,000 files.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a concrete sandbox freeze, and the previous import-cycle finding is fixed; no new actionable code defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSandbox command finalization exports private workspace changes through the leased checkpoint owner into the canonical managed worktree. flowchart LR
A[Guest command] --> B[Checkpoint lease]
B --> C[Paused snapshot capture]
C --> D[Resumed guest]
C --> E[Captured manifest and Git result]
E --> F[Canonical acceptance]
F --> G[Command completion]
Technical reviewBest possible solution: Keep capture and canonical acceptance under the existing checkpoint lease, using atomic snapshots where complete and durable Git capture elsewhere. Do we have a high-confidence way to reproduce the issue? Current-main source keeps changed-workspace scanning inside quiescence, and the submitted native parent comparison records the resulting guest pauses; no target code was executed during this review. Is this the best way to solve the issue? The change reuses existing snapshot, lease, staging, and acceptance owners; its fallback and cleanup serve the same invariant without adding another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d290127ec675. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +199, Tests +245, Docs +197, Other +259. Total +900 across 20 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 November 10, 2026, 9:26 AM ET / 14:26 UTC (Revision 3). |
|
Performance acceptance is not met by the current head. The first matched native Podman/btrfs pair measured pause median 1600.88 → 1582.71 ms (-1.1%), versus 1.1% spread between baseline control medians; complete command median rose 2323.88 → 2490.04 ms (+7.2%). Manifest scanning dominates the pause. All read-after-command assertions passed, but these measurements do not justify claiming the long-freeze issue is solved. I am revising the implementation to use the existing atomic btrfs snapshot primitive for provisioned subvolumes, with nested-subvolume omission detection before acceptance and a paused retry when needed. Snapshot disposal cost will be measured outside the pause. The current PR is held as draft until this path and its native proof are complete. No merge is requested. |
|
The PR now implements atomic btrfs capture at head @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressing every open item in the latest review on
The previous CI failure was introduced by this PR, not inherited. Fresh exact-head CI is required. Native comparison and final fallback proof remain merge gates. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…openclaw#196662) * fix(sandbox): resume captured commands before canonical synchronization Keep command finalization awaiting canonical acceptance and retain paused imports and recovery. Resume only after the newly captured export has a durable Git result; later guest writes remain available for the next checkpoint. * test(sandbox): measure checkpoint manifest owner phases * fix(sandbox): capture btrfs checkpoints before resuming synchronization * fix(sandbox): keep checkpoint capture types out of runtime owners
What Problem This Solves
Changed sandbox commands freeze the guest throughout workspace discovery, Git capture, and canonical reconciliation. With large workspaces, scanning alone can take seconds while every process in the container is paused.
User Impact
For provisioned btrfs subvolumes, checkpoint now pauses for the existing native snapshot operation, resumes the guest, and synchronizes canonical state from that captured tree. Command completion still waits for canonical acceptance, preserving read-after-command consistency. Initial recovery and imports retain their existing pause boundaries. No configuration, schema, dependency, or cache is added.
Why This Change Was Made
The checkpoint owner reuses the template backend's native copy primitive under its existing lease. Snapshot fingerprints translate only the proven snapshot device back to the source identity, preserving unchanged probes. Btrfs omits nested subvolumes: the manifest walker detects its inode-2 placeholders before accepting a receipt, then re-pauses under the same lease and uses the existing complete Git capture. Unsupported backends and ordinary directories also retain that path, resuming after durable capture.
The owner removes its private capture after resume and removes leftovers on the next lease. Native removal now repairs inaccessible directories only after a permission failure; it does not follow symlinks or change live source permissions. This is required for snapshots containing ordinary read-only workspace directories.
Snapshot creation can wait for btrfs dirty-data writeback, so this bounds the paused work rather than promising a fixed wall-clock limit. Recursive snapshot cleanup adds work after resume; the native comparison will report that cost explicitly.
Evidence
The real Podman+btrfs comparison completed all five counterbalanced pairs: 50 measured mutating commands per arm, plus two A/A controls. Every command passed canonical and subsequent guest read checks. The fixture contains 62,000 synthetic files / 1.1 GB, 10,001 session metadata rows, and a 33.65 GiB synthetic database. No production data was used.
Median pause improves 88%; median command latency and whole-cgroup CPU increase 28%. A/A pause, command and CPU spread was about 1–1.3%; allocation spread was 9.4%, so no allocation benefit is claimed. All pairs, including the slower first candidate arm, are retained. The 1.36–1.42 s manifest scan runs paused on the parent and unpaused on the candidate in all 50 commands. Native snapshot copy takes 106 ms median; recursive cleanup takes 511 ms after resume. Cleanup explains most of the extra command latency. The maximum guest heartbeat gap falls from 4.43 s to 243 ms.
Timing uses parent
3f17d921f6cc1cf03d52054a74ba3a5e885f5c35and implementation64147937916763407221bef031a138af43dd40a8, with the same frozen harness. Final head32b8f86f7fc49989f7ae6ab5c1346831b82b5be6changes only type placement and emits byte-identical JavaScript. The harness runs on a task-owned Linux ARM64 rig with four CPUs and 12 GiB memory, Podman 4.3.1, btrfs 6.2, and Node 26.12.1 for allocation accounting. CPU includes native helpers, Git and the guest; allocation covers only the main V8 isolate. Separate baseline/candidate profiles passed and are excluded from these timing distributions. Final-head native nested-subvolume fallback also passed: two pauses of 180.84 and 5,387.44 ms, complete nested canonical contents, correct next guest read, preserved 0555 source permissions, and no capture artifact. The matching baseline paused 5,947.87 ms; both perform full hashing because the existing fingerprint format rejects mixed-device reuse. This single diagnostic pair is excluded from performance statistics and is not a timing-improvement claim. An oversized 20-command functional run hit its 240-second deadline after at least 17 completed commands; that partial run is retained, and the bounded follow-up changed only the proof driver loop count to one.pnpm check:changed --base 3f17d921f6cc1cf03d52054a74ba3a5e885f5c35: all categories pass except the exact inherited unused-export set below. These are existing main regressions, not passing checks.Production delta: +199 lines, including snapshot lifecycle/cleanup, nested-subvolume fallback, and source identity preservation. Moving the existing projection operation whole keeps one lifecycle owner within the line cap. Test delta: +245 lines for ordering, recovery, fingerprint reuse, fallback, authority loss, and artifact permissions. Benchmark code is proof-only.
CI on
64147937916763407221bef031a138af43dd40a8found one introduced static type-import cycle. The repair moves the capture contract into the existing workspace types module and imports it directly. The exact failing guard is red on that head and green after repair; targeted typechecking passes. All six changed files emit byte-identical JavaScript, so the native comparison remains runtime-equivalent. The repair is committed as32b8f86f7fc49989f7ae6ab5c1346831b82b5be6and passes fresh Codex review. Final exact-head CI 42832460455 passed. ClawSweeper re-reviewed this head with zero findings and zero open items; item 1 response. No admin exception or CI rerun was needed.Exact-parent unused-export regression attribution
Both Knip scans exit 1 on parent
3f17d921f6cc1cf03d52054a74ba3a5e885f5c35; normalized symbol sets match the final candidate check exactly, with no module-resolution failures. Owner history and consumer-removal patches identify these sources:The full-scan set is the heading helper, client-cap facade, four provider auth types, spawnWithInheritedOomScore facade, and browser constant. This identifies unused export surfaces, not necessarily unused implementations.