Skip to content

fix: shorten sandbox freezes during initial PR preparation - #197298

Closed
steipete wants to merge 1 commit into
mainfrom
steipete/perf-2411-consistency-pause-staging
Closed

steipete wants to merge 1 commit into
mainfrom
steipete/perf-2411-consistency-pause-staging

Conversation

@steipete

@steipete steipete commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #197243

What Problem This Solves

Fixes long sandbox freezes when initially preparing an existing PR in a managed workspace, even after source downloads finish.

User Impact

The guest keeps running while OpenClaw prepares the initial PR's immutable source checkouts, manifests, and staged file payload. Pristine-workspace checks, file application, and interrupted-transfer recovery still pause the guest. Refreshes that merge existing guest work retain their current consistency contract. No configuration or migration is required.

A universal freeze deadline remains deliberately deferred: completing or undoing a partially applied transfer must preserve the existing recovery contract.

Why This Change Was Made

The initial import already knows both immutable source commits. Prepare their admitted payload in the existing live-guest source phase, then freshly observe the guest and verify the host identity, staged Git object, and accepted baseline before applying it. The staged object and baseline checks protect the real custody gap required by guest command admission. Working files and PR acceptance remain untouched during preparation.

Reuse the staging implementation for later merge-based refreshes and remove an initial-import index snapshot whose result was only consumed by noninitial refreshes. No new state store, cache, schema, dependency, or runtime configuration is introduced.

Evidence and current landing status

Held: the performance acceptance gate is not met. The source remains at fad34886eeeee5e90ae5d4b557a54efde64e8407; no merge request is pending. Correctness, static review and exact-head CI pass, but moving preparation outside the pause has not yet produced a qualified total-frozen reduction on the measured shared host.

The prospective contract requires two native local Docker fixture sizes (31,000 files / 550,002,000 bytes and 62,000 files / 1,100,004,000 bytes), each fetching 512 MiB of historical Git objects. At each size: A/A controls then ABBA, identical contents/HEAD/index/resume, both candidate frozen durations below both baselines, and median reduction approximately explained by moved preparation plus the removed snapshot within the larger of 25% of moved work or A/A spread. All outcomes are retained. This qualifies APFS/native Docker only, not btrfs or a 35 GiB agent database.

The completed 31k cohort fails that rule:

Arm Total frozen seconds Process CPU seconds
A/A 1 29.412 45.626
A/A 2 33.034 54.174
A1 32.954 51.201
B1 33.006 85.098
B2 29.747 75.394
A2 29.207 42.850

ABBA median frozen time changed 31.080→31.377 s, despite 11.999 s of expected moved preparation/deleted snapshot work. Median process CPU increased 47.025→80.246 s (+70.6%). All six arms passed contents, HEAD, canonical index, live fetch and resume checks. Candidate immutable preparation had zero frozen overlap and host snapshots dropped three→two. Base-refresh hashed exactly 62,020 files / 1,100,004,493 bytes in every arm; total counters varied only by existing short-path age memo reuse, with no added full-tree pass.

A separately declared quiet replication admitted each arm only below load 12. Its A1 measured 32.064 s frozen / 46.369 s CPU; B1 measured 90.874 s frozen / 132.958 s CPU. Load rose from about 10 to 40 during B1, so quiet admission did not maintain comparable conditions. All correctness checks passed. B2/A2 and the larger-size acceptance block were held, not silently retried or pooled.

A diagnostic-only A/B pair then instrumented existing worker execution and full idle GC without changing GC policy. It measured A 32.628 s frozen / 47.487 s CPU, B 33.219 s / 84.747 s. The increase was mostly system CPU (31.022→63.779 s), while user CPU rose 16.465→20.967 s. Explicit idle GC was only 25.842 ms total wall in A and 55.999 ms in B, ruling out those synchronous collections as the seconds-scale cause. CPU before moved preparation was nearly identical (4.494/4.540 s). Samples captured substantial activity outside the fixture process tree, including a separate compiler; this supports contention as a confounder but does not prove the complete CPU cause. A local native sampler stalled during symbolication and was terminated without usable stacks, so diagnostic B has unquantified capture overhead and is not acceptance proof. All temporary observer source was restored and hash-verified. No further benchmark is active.

The standard Blacksmith Testbox route returned a queued allocation, which was immediately stopped and verified completed; no remote payload ran. The timing gate remains two qualified fixture sizes. A quiet local window is needed before another declared cohort. No GC-policy or production change is justified by these diagnostics alone. Sampled allocation has not run; heap endpoints are not allocation evidence, process CPU excludes Git children, and worker/native allocation remains uncovered.

Completed validation:

  • The staging regression fails on exact parent 3a6cc659 because the guest is frozen, and passes with the candidate while preserving an index-only guest edit. A separate registered-action case rejects replacement of the shared staging ref across custody.
  • All 47 focused tests pass: 15 acquisition and 32 preparation/refresh cases. These exercise real Git, registered dispatch, authority and reconciliation. No changed production module is imported by ui/src.
  • pnpm check:changed --base 3a6cc6597d1d1d32a4bef83fd3041fedf5f48e76 --timed passes every gate except 57 production / 32 full-tree unused exports. Exact parent reproduces every finding; there are no candidate additions or newly appearing inherited failures. Introducers are below; no ignore/baseline was relaxed.
  • Independent isolated Codex autoreview is scoped-clean through P2 on unchanged source/index fingerprints. Failed earlier review attempts are not counted as clean reviews.
  • Production LOC is +71 to reuse staging in the live phase and carry/verify object and baseline identities across custody. Regression coverage is +48 lines. No new configuration, cache, schema or dependency.
  • Normal PR CI 43068015396 completed successfully on exact fad34886, all 61 jobs complete. Final-head ClawSweeper has zero findings/open items. The earlier superseded run is not counted as approval.
  • Artifact build passed on verified exact target fad34886. Its separate newer-main manual MLX workflow called a script absent from both this target and exact parent, reproducing exit 2 before any MLX test. Introducer: 42204208e993a4486d0414c36175f23137fc20c5 / fix(macos): preserve MLX model config cache reuse #187742. This is a main workflow compatibility regression, not test noise; normal PR CI verifies the newer combined context.

Earlier evidence is retained separately: one 62k diagnostic attributed 31.427 s to immutable preparation within a 67.151 s consistency pause; unchanged full-size controls varied 63.91/135.88 s frozen and cannot support a comparison. Small native smoke passes with zero preparation overlap and three→two snapshots. Eight obsolete task-owned capsules were cleaned after preserving reconstructable overlays, recovering about 6.72 GiB. None of these observations substitutes for the unmet two-size gate.

Inherited main unused-export regressions

These are existing main regressions, not waived candidate failures. Exact-parent and candidate lists match. The earlier script finding was fixed by b110c2259f07 / #197244.

Current finding group Introducing commit PR
Knowledge contract/tool-results/rowDate 9b7dcdc7a66dc1bbcb0767b8109e798eb826954e #196767
TelegramWidgetMessage,formatTelegramWidgetRequestText b22f35f7ed76552778bc185cc65a6177e8ad8b02 #196991
nestRequiredSummaryHeadings c7152f3bda8e52c24fc2fda83911e7e1c24fb0f2 #196207
models-config,openclaw-tools,session auth/model registry,linux-oom-score exports 625945b7ae01d5eea91aba5285da1a327b2a5f9f #192552
MAX_MCP_TOOL_DIRECTORY_BYTES,sanitizeMcpToolDirectoryDescription 80ba593b8b14bb3f5ddd6634a92805e04707b25c #196252
projectLeaseDiagnosticFrames 2c4e34a72f490c710bc155319fcabf872f482b3e #196724
BoundKeys,nextBindingSeq,TunnelStagedMessage 5f2f21a7ee193fdd4aa8ac42a407eefc04905255 #196388
createKeyFile 37a3b162a0c58aaceb1634aaef726d0e178a529c #196380
replyWithBillingRouteWarnings 56617cd00086481212d29745ed71f5feb8a40b9e #191326
provider-runtime and provider-external-auth exports f63e5cd0f6d38f1d0438978255d9e244183864c3 #190205
Four provider-auth facade types cf1ae7bb6a729a7f13a28ca2ef9d6f108c00566f #190544

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts docker Docker and sandbox tooling size: M labels Nov 11, 2026
@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 11, 2026
@steipete
steipete marked this pull request as ready for review November 11, 2026 17:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T17:27:52.798729Z fad3488 Draft marked ready
ℹ️ 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prepares initial PR source payloads while the sandbox guest runs and verifies them before applying files.

Example: Prepare an existing PR in a managed workspace containing 62,000 files and 1,100,004,000 bytes.

  • Before: Immutable checkouts, manifest preparation, and payload staging hold the guest paused after downloads finish.
  • After: Those preparation steps run with the guest resumed; pristine checks, file application, and recovery retain their consistency pauses.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation with useful boundary regressions and reported native smoke; comparative performance qualification remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: A sandbox guest remains frozen during expensive immutable preparation after an initial PR's downloads have finished.
Reason: The maintainer-authored direction addresses measured frozen work without changing configuration, permissions, or recovery semantics.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses remaining initial-import freezes on main, reuses the existing staging owner, and introduces no concrete defect found in this review.

Priority: P2
Reviewed head: fad34886eeeee5e90ae5d4b557a54efde64e8407

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Complete the declared two-size native Docker comparison with preserved contents, HEAD, index, resume behavior, and unchanged hash/read work; the body reports the staging regression red on the parent and green on this head.
Agent review details

How this fits together

The Gateway's GitHub preparation action receives a verified PR source, stages admitted source bytes through the workspace owner, and applies them to canonical and sandbox files while preserving guest Git state.

flowchart TD
  A[Verified PR source] --> B[Live guest source preparation]
  B --> C[Existing staged payload owner]
  C --> D[Reacquire workspace custody]
  D --> E[Check guest state and payload identity]
  E --> F[Apply and settle workspace transfer]
  F --> G[Prepare sandbox review base]
Loading

Technical review

Best possible solution:

Keep immutable initial-source staging in the existing preparation owner while retaining pristine-workspace checks and the existing transfer recovery contract.

Do we have a high-confidence way to reproduce the issue?

Current main visibly performs immutable checkout, manifest, and staging work inside the paused integration callback; the PR also reports native attribution and a base-failing staging regression, but this read-only review ran no target code.

Is this the best way to solve the issue?

The patch follows the smallest complete fix: move immutable initial-import work into the existing live phase, reuse its staging implementation, and verify retained identities before applying files.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f19f6c02b97c.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3a6cc65 adds src/gateway/github-publication-source-preparation.ts:50 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3a6cc6597d1d; files: src/gateway/github-publication-source-preparation.ts)
  • Shakker: Raw commit 9218dca adds src/gateway/github-publication-base-refresh.ts:239 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9218dca35cbf; files: src/gateway/github-publication-base-refresh.ts)

PR surface

Source +71, Tests +48, Docs +2, Other +90. Total +211 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 149 78 +71
Tests 1 49 1 +48
Docs 1 8 6 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 93 3 +90
Total 6 299 88 +211

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 +71 net lines; regression tests +48 net lines Growth carries staged object and baseline identities across custody and covers two distinct failures while sharing the existing staging implementation.

Labels

Label changes:

  • add P2: Long pauses interrupt large managed-workspace PR preparation, with a focused optimization and limited affected workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Long pauses interrupt large managed-workspace PR preparation, with a focused optimization and limited affected workflow.
  • 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.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Publish the completed declared native comparison, including frozen durations, work counts, consistency checks, and retained unfavorable outcomes.

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.

Reviewed November 11, 2026, 12:40 PM ET / 17:40 UTC.

@steipete
steipete marked this pull request as draft November 11, 2026 18:48
@steipete

Copy link
Copy Markdown
Contributor Author

Closing per maintainer decision. On the 31k-file A/A + ABBA fixture, median frozen time did not improve (31.080→31.377 s), while process CPU increased 47.025→80.246 s. Consistency checks passed, but the measured benefit does not justify landing this change. The failed comparisons and diagnostics remain documented in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 size: M 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