Repository navigation
fix: shorten long sandbox freezes during workspace reconciliation - #196835
Conversation
Prepare immutable staged results and Git patches while ordinary reconcile keeps the guest running, then fence imports before confirming and applying. Reuse checkpoint capture for btrfs exports and remove the duplicate accepted target scan under an owned freeze. Preserve recovery and base-refresh custody. Log reason, duration and dominant phase when quiescence releases a runtime, including truthful observed-only timing for recovered pauses. Add an owner regression for guest progress, concurrent-edit preservation and capture count. Validation: 86 projection, 20 quiescence and 60 sibling tests passed; 19 extraction-affected cases passed again. Codex review clean. check:changed passes except 34 production/10 full-tree unused exports reproduced on exact parent 6d81179; all source/type/lint/schema/import-cycle gates pass.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Integrate main to resolve capture-owner conflicts with #196807. Preserve checkpoint capture diagnostics and use its resume wrapper to clear reconcile pause state only after a successful resume. All 31 affected projection tests, core and affected-test typechecking, targeted lint and line-cap checks pass. Codex review has no actionable P0-P2 findings. Existing unrelated unused-export failures retain their exact-parent investigation; native measurement is still in progress.
|
@clawsweeper review Please review head b3521d0, including pause/freeze ordering, concurrent-edit preservation, checkpoint capture fallback/recovery, and the integrated checkpoint diagnostics from #196807. The PR remains draft while native performance measurements finish; the focused production-path tests and Codex review are complete. |
|
🦞👀 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 shortens sandbox freezes by preparing immutable reconciliation results while guests run and pausing again before imports are confirmed and applied. Example: Import 20,000 changed files into a 62,000-file workspace using native Podman.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR has no actionable findings. The completed native measurements and explicit maintainer acceptance resolve the previous performance hold, and CI passes on the final head. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway workspace projection owner reconciles canonical and sandbox files through immutable Git results and SQLite receipts, coordinating guest pauses around capture, mutation, and recovery. flowchart TD
A[Canonical and guest edits] --> B[Projection lease owner]
B --> C[Immutable capture and staging]
C --> D[Preparation with guest running]
D --> E[Pause and confirming preflight]
E --> F[Apply and durable acceptance]
F --> G[Resume and cleanup]
Technical reviewBest possible solution: Retain the existing projection, capture, and quiescence owners with the reviewed pause handoff and accepted performance tradeoff. Do we have a high-confidence way to reproduce the issue? The base owner holds quiescence across materialization and patch preparation; the supplied native comparison reproduces long freezes, and the committed owner regression reportedly fails on that ordering before the fix. Is this the best way to solve the issue? The change uses existing owners, removes a redundant frozen-target verification, preserves confirming preflight and recovery custody, and records the explicitly accepted overhead. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3c49dfcd6f12. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +172, Tests +141, Docs +52, Other +118. Total +483 across 12 files. Added test files: 0. 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, 3:51 PM ET / 20:51 UTC (Revision 3). |
Mark the phase at the inspection owner so post-apply preflight time cannot be charged to capture. This changes telemetry only, preserving filesystem operations and their order. The extended owner regression fails before the fix with capture instead of preflight and passes afterward. Focused test, core/test typechecks, targeted lint and line caps pass; Codex review is clean. The18 added test lines have 18 matching allocation, preserving the separately attributed128-line main debt rather than hiding it.
|
@clawsweeper re-review Please review final head 60c5cda. The previous report had no numbered findings. Native phase measurements exposed a telemetry error: post-apply preflight was charged to capture. The phase marker now lives in Large native comparisons are completing. The prior small-workspace tradeoff remains explicitly recorded; the final performance assessment will include all pairs and allocation evidence before any merge. |
|
🦞👀 Re-review progress:
|
|
The native campaign is complete and the PR body now contains the five-pair/A-A comparison, allocation scope, tails, adverse samples and explicit tradeoff decision. Under the requested maintainer scope, I accept the bounded small-workspace cost and observed CPU/tail overhead for this repair. Median total freeze falls28.78→7.44s (−74.15%), longest28.78→7.21s, with identical accepted bytes and later-write freshness in every arm. Median owner wall29.62→29.43s and process CPU34.19→33.04s are not claimed as speedups. Main-thread CPU rises6.86%; first-pair main-thread CPU rises39.64%, and the small smoke owner cost rises305ms. These are explicit accepted tradeoffs, not discarded samples: two extra native pause/resume round trips preserve the outer callback's existing frozen contract. Sampled main-isolate allocation is unchanged (−0.48%), excluding workers/native helpers. Warm unchanged/checkpoint fast paths are unchanged. Native timings remain pinned to3786ffc, with subsequent input equivalence inspected; no native btrfs or exact214.8s production attribution is claimed. Final60c corrects phase attribution and has red/green owner regression plus clean Codex review. The prior review has no numbered findings or open checkboxes to address. Please include the completed evidence and this decision in the in-progress exact-head review; if it has already finished, @clawsweeper re-review the final head60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d. Merge remains held for the final-head zero-open-items result and exact CI accounting. |
|
Addressing every open item from the final-head review:
The cost comes from retaining the existing opaque callback freeze contract: projection pause/capture handoff, lines100–148. The benefit is the existing owner's patch preparation before freeze and confirming preflight, lines208–224. No code change is needed to resolve this decision item. The updated body labels prior-head native measurements, no native btrfs proof and no exact production-incident attribution. Owner-level native proof is not described as a shipped Gateway/session replay. The review's statement that comparisons/allocation remain pending is now stale: both profiles finished, all native artifacts are saved and the owned lease is confirmed completed. There are no code findings or other open items in that review. @clawsweeper re-review final head60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d using the completed body and this explicit acceptance; merge stays held until the final-head review shows zero open items. |
|
@clawsweeper re-review Final head60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d. The single open performance-decision item is addressed by number, with code links and explicit acceptance, in #196835 (comment) . The PR body contains the completed five-pair/A-A native results and allocation scope. Please reassess that item against the completed evidence; no source changed since your latest review. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…enclaw#196835) * fix: shorten sandbox freezes during workspace reconciliation Prepare immutable staged results and Git patches while ordinary reconcile keeps the guest running, then fence imports before confirming and applying. Reuse checkpoint capture for btrfs exports and remove the duplicate accepted target scan under an owned freeze. Preserve recovery and base-refresh custody. Log reason, duration and dominant phase when quiescence releases a runtime, including truthful observed-only timing for recovered pauses. Add an owner regression for guest progress, concurrent-edit preservation and capture count. Validation: 86 projection, 20 quiescence and 60 sibling tests passed; 19 extraction-affected cases passed again. Codex review clean. check:changed passes except 34 production/10 full-tree unused exports reproduced on exact parent c7e2657; all source/type/lint/schema/import-cycle gates pass. * fix: attribute every reconcile preflight to its pause phase Mark the phase at the inspection owner so post-apply preflight time cannot be charged to capture. This changes telemetry only, preserving filesystem operations and their order. The extended owner regression fails before the fix with capture instead of preflight and passes afterward. Focused test, core/test typechecks, targeted lint and line caps pass; Codex review is clean. The18 added test lines have 18 matching allocation, preserving the separately attributed128-line main debt rather than hiding it.
What Problem This Solves
Fixes long sandbox freezes during ordinary workspace reconciliation, which held the container pause across staged-file materialization, Git patch preparation, and temporary-file cleanup.
User Impact
The guest can keep running while reconciliation prepares immutable results. Imports pause again before confirming the target and applying changes; concurrent edits remain saved and produce a visible conflict. Each released pause now records its reason, duration, and dominant phase at the quiescence owner.
Why This Change Was Made
Reuse the existing checkpoint snapshot owner for btrfs exports, and delay the import freeze until the existing confirming preflight. Remove the immediate duplicate full-tree verification when the target's writers are already frozen. Host callers retain their verification, and journal recovery and two-sided base refresh retain their pause requirements.
The bounded telemetry distinguishes newly owned pauses from recovered pauses with an unknown earlier start. Failed resumes do not log success. No configuration, schema, cache, or retention change is introduced. Production delta is +172 lines for telemetry and the pause/capture handoff, including a typed extraction of existing acceptance callbacks to respect file-size limits; test delta is +141 lines.
Evidence
The production-path projection/SQLite/Git regression fails on the original code because patch preparation observes a paused guest. It passes here, verifies mutation stays paused, counts one accepted-target inventory capture, and rejects an injected concurrent guest edit before journaling without losing bytes. A second red/green assertion ensures every actual preflight receives the correct phase label.
Focused proof: 86 projection, 20 quiescence and 60 reconcile/recovery/publication tests passed, with two existing filesystem-platform skips. The acceptance extraction passed 19 affected tests; integration with #196807 passed 31 capture/checkpoint cases. Final telemetry correction passed its owner regression, core/test typechecks, lint and independent Codex review.
pnpm check:changed --stagedpassed all gates except the independently reproduced inherited Knip set: 33 production/9 full-tree findings on integrated parent9c0b1b44bd438c3bbb57cda5856ab4270da27ead. The additional main regression is the diagnostics export from #196724 (2c4e34a72f490). Exact-head CI 42896338687 passed on60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d: 56 successful, 28 skipped jobs, including security, both UI-e2e shards and the aggregate gate. The earlier run failed only on 128 inherited test-line debt from #196346, subsequently repaired on main by #196370; final CI needs no admin exception. Final-head ClawSweeper re-review has zero findings and zero open checkboxes; the completed measurements and explicit acceptance resolved the performance hold.Native performance and explicit tradeoff decision
The declared protocol uses the real projection owner, Git/SQLite and native Podman, with 62,000 files (1,100,004,000 bytes), 20,000 changed files, 10,001 synthetic sessions and an actual 35.20 GiB agent database. No production data was copied. Five serial counterbalanced A/B pairs follow two A/A controls; setup, warmup and separate allocation profiling are excluded from timing. Every changed byte, subsequent guest read and later-write freshness passed.
Baseline
6d811790acb43c46e3a7c950f22c3bed22b17f17; measured candidate3786ffc96c66b915c4ce313e57a72f38ceb121fc. This is prior-head evidence: later main integration and the final phase-marker fix were inspected for input equivalence; measured import staging, patch preparation and mutation work/order are unchanged. No final-head native timing is claimed. Linux, 4 CPUs, 16.56 GB RAM, Node 24.22.1, Podman 5.8.4, ordinary filesystem. The host lacks btrfs kernel support, so snapshot behavior has focused owner proof but no native btrfs performance claim.Five samples per arm; nearest-rank p95 is the observed maximum, not a stable tail estimate. Total-freeze ranges were 26.48–31.59 s versus 6.23–9.22 s; owner ranges 26.56–32.77 s versus 26.64–35.39 s. A/A variation: freeze 7.54%, owner 5.12%, process CPU 6.81%, main-thread CPU 12.13%, cgroup CPU 7.94%. No overall CPU or throughput speedup is claimed. The first pair increased owner time 18.84%, cgroup CPU 19.80% and main-thread CPU 39.64%; these unfavorable samples are retained. Separate sampled main-isolate allocation was 1,444,981,416 → 1,438,093,912 bytes (−0.48%); This sampled main-isolate measurement covers the whole measured burst, including fixed correctness reads and cleanup; it is not isolated owner allocation. Node 24 provides no total-allocation counter, and all six worker counters and native-helper allocations are unavailable, not zero.
The first baseline pair held the pause during a 7.82 s patch-construction await, 3.54 s staged-manifest work and 3.25 s staging. Equivalent candidate work ran with the guest resumed. These are overlapping phase intervals and must not be summed. A native guest heartbeat independently measured its maximum stall falling from 26.45 to 8.37 s. One duplicate accepted-target inventory is deleted; final confirming preflight remains.
Decision under the requested maintainer scope: accept the observed overhead in exchange for the consistent large-workspace freeze reduction. The 100-file/10-change setup smoke increased total frozen time from 202.83 to 284.41 ms and owner time from 255.17 to 560.47 ms, while longest freeze fell to 107.66 ms. This is one smoke per arm, not a statistical small-workload benchmark. Two extra native pause/resume round trips preserve the opaque outer callback's existing frozen contract. The bounded 305 ms owner cost, +6.86% median main-thread CPU and unfavorable observed tails are accepted for this repair; they are not dismissed as noise. Warm unchanged and checkpoint fast paths remain unchanged. The declared byte/conflict/freeze-reduction acceptance rule is met; this decision explicitly addresses the ≥20% regression stop.
Reproduce through the committed harness (same harness in both source revisions):
The supplied 214.8 s production incident cannot be assigned to a specific syscall or queue from the old logs. This fixture reproduces the same broad frozen-owner defect at 26–32 s. Base-refresh callback network preparation remains outside this ordinary-reconciliation fix. No production access or deployment was performed. The new unpause log enables post-deployment verification.