Skip to content

fix: shorten long sandbox freezes during workspace reconciliation - #196835

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-reconcile-pause-holds-sandbox-20260919
Nov 10, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-reconcile-pause-holds-sandbox-20260919

Conversation

@steipete

@steipete steipete commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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 --staged passed all gates except the independently reproduced inherited Knip set: 33 production/9 full-tree findings on integrated parent 9c0b1b44bd438c3bbb57cda5856ab4270da27ead. The additional main regression is the diagnostics export from #196724 (2c4e34a72f490). Exact-head CI 42896338687 passed on 60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d: 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 candidate 3786ffc96c66b915c4ce313e57a72f38ceb121fc. 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.

Metric Baseline median Candidate median Change Baseline / candidate p95
Total frozen time per operation 28.78 s 7.44 s −74.15% 31.59 / 9.22 s
Longest continuous freeze 28.78 s 7.21 s −74.95% 31.59 / 8.89 s
Owner wall time 29.62 s 29.43 s −0.64% 32.77 / 35.39 s
Owner-period process CPU 34.19 s 33.04 s −3.36% 39.09 / 40.20 s
Main-thread CPU 2.78 s 2.97 s +6.86% 3.34 / 3.74 s
Cgroup CPU, including helpers 44.38 s 43.80 s −1.30% 51.54 / 54.36 s

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):

node --expose-gc --import ./scripts/tsx.mjs scripts/perf/local-workspace-checkpoint-measure.ts \
  --mode reconcile --reconcile-target projection --reconcile-changed-files 20000 \
  --native-turns --sandbox-backend podman --guest-image docker.io/library/node:24.22.1-trixie \
  --files 62000 --file-bytes 17742 --transcript-mib 12288 --requests 1 --burst 1 \
  --instrument timing --output <task-proof-directory> --report <arm>.json

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.

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.
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts docker Docker and sandbox tooling agents Agent runtime and tooling size: L labels Nov 10, 2026
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.
@steipete

Copy link
Copy Markdown
Contributor Author

@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.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@steipete
steipete marked this pull request as ready for review November 10, 2026 19:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T20:35:31.453765Z 60c5cda New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/local-workspace-quiescence.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Reported median total frozen time was 28.78 seconds.
  • After: Reported median total frozen time was 7.44 seconds, with accepted bytes and later-write freshness preserved.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with no actionable findings and successful final-head CI; native owner-level proof is substantial but remains harness-level and prior-head timing evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its completed native Podman campaign exercises the real projection/Git/SQLite owner, verifies bytes and later freshness, and measures shorter freezes on a prior head whose import ordering remains equivalent; native btrfs performance and a shipped Gateway replay are not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Running sandbox processes freeze while reconciliation performs lengthy work that can use immutable results.
Reason: The native campaign demonstrates materially shorter freezes, and the maintainer explicitly accepted the measured overhead; no further direction decision remains.

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
Reviewed head: 60c5cdaf88e00b5f1d52198317d5c89c5a7a6c2d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Projection pause custody changes intended behavior with a stated reason (28d8ee4: Managed-project sandbox reconciliation requires exact writer custody and preserved accepted edits.)
  • Checkpoint snapshot and cleanup owner keeps the original intent (10d6744: Immutable native capture permits resuming guests before scanning while retaining canonical acceptance.)
  • Journal and acceptance callbacks keeps the original intent (cd326f9: Worker-owned persistence retains live authority and acknowledged journal settlement under one reconciliation owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +172, Tests +141, Docs +52, Other +118. Total +483 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 241 69 +172
Tests 3 145 4 +141
Docs 2 52 0 +52
Config 0 0 0 0
Generated 0 0 0 0
Other 2 129 11 +118
Total 12 567 84 +483

Preflight source

Source 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

Metric Value Why it matters
Production versus regression growth Production net +172 lines; tests net +141 lines. Growth implements bounded pause telemetry and the existing-owner handoff, with focused ordering, concurrent-edit, and telemetry regressions.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Reduces substantial freezes during large sandbox workspace reconciliation without establishing a process outage or release-blocking onboarding failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-10T20:05:12.843Z sha b3521d0 :: ready, awaiting a maintainer decision. :: none
  • reviewed 2026-11-10T20:39:44.467Z sha 60c5cda :: blocked before merge. :: none

Reviewed 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.
@steipete

Copy link
Copy Markdown
Contributor Author

@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 inspectPaths, so every real preflight is labeled; the regression fails before this correction and passes afterward. Filesystem work and ordering are unchanged.

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.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressing every open item from the final-head review:

  1. Await maintainer action — final performance acceptance: resolved by the completed five-pair/A-A campaign and explicit decision in the updated PR body and decision comment. Under the requested maintainer scope, the observed small-workspace305ms owner overhead, +6.86% median main-thread CPU and unfavorable observed tails are accepted in exchange for a74.15% median reduction in total frozen time (28.78→7.44s), with every byte/freshness check passing. The39.64% first-pair main-thread CPU increase and small-smoke latency regression are retained and explicitly assessed, not called noise. Sampled main-isolate allocation is1.445→1.438GB and excludes unavailable worker/native allocations.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

@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.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. clawsweeper:intake:bug Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 10, 2026
@steipete
steipete merged commit 3bf03a6 into main Nov 10, 2026
201 of 203 checks passed
@steipete
steipete deleted the steipete/perf-micro-reconcile-pause-holds-sandbox-20260919 branch November 10, 2026 20:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant