Skip to content

fix: shorten sandbox freezes when importing pull requests - #201410

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-base-refresh-pristine-in-pause-20260919
Nov 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-base-refresh-pristine-in-pause-20260919

Conversation

@steipete

@steipete steipete commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Importing a repository into a workspace can freeze its sandbox for several seconds while pull request preparation verifies that the workspace is pristine. The frozen phase included a settled canonical snapshot and two full filesystem manifests.

User Impact

The sandbox keeps running during canonical verification. In the synthetic 62,000-file workload, median pristine pause falls 62% and total guest pause falls 53%. Dirty files, staged-only edits, unexpected history, and projection differences still prevent an unsafe initial import. No configuration, schema, or migration changes are required.

Why This Change Was Made

The guest writes the projection; the Gateway owns the canonical checkout under its reconciliation lease. Move the canonical snapshot and manifest into the existing source-preparation lease, where the guest is running. Bind the prepared view to the accepted baseline so a checkpoint between phases causes a retry before integration. The final comparison retains the paused guest manifest. Git tree equality cannot replace raw filesystem equality, including authored empty directories.

The pristine phase now captures one full manifest instead of two, and performs zero settled canonical snapshots instead of one. Total capture work and the earlier per-entry Git batching remain unchanged. Production code grows by 13 lines to carry the prepared manifest and baseline identity across the existing phases.

Evidence

The pause-placement regression fails on the parent and passes with this change. All 83 focused publication tests pass, including dirty and staged-only edits during preparation, unexpected history, projection mismatch, and a checkpoint that changes canonical bytes without changing Git HEAD. pnpm check:changed passes. Independent Codex review found no actionable P0–P2 findings. ClawSweeper reviewed this exact head with zero findings and zero open items.

Five interleaved A/A/B groups used 62,000 synthetic files / 1.10 GB, 512 MiB of synthetic Git history, a real Docker guest heartbeat, and the registered publication owner. Every sample verified final contents. No samples were discarded. Each arm below has five samples; p95 is the nearest-rank estimate, which is the maximum at this sample count.

Metric, median / p95 A first (n=5) A repeat (n=5) B (n=5)
Pristine pause (s) 9.78 / 24.64 10.06 / 13.85 3.74 / 5.61
Total pause (s) 12.19 / 26.82 12.38 / 18.03 5.76 / 7.80
Longest pause (s) 10.86 / 25.51 10.98 / 16.14 4.48 / 6.43
Heartbeat gap (s) 10.81 / 25.48 10.97 / 16.07 4.45 / 6.40
Owner elapsed (s) 122.22 / 218.16 126.28 / 200.62 107.81 / 189.84
Node-process CPU (s) 32.56 / 47.02 35.48 / 42.26 32.73 / 37.52
Guest CPU (s) 23.05 / 42.64 23.87 / 29.53 22.17 / 28.51
Main V8 allocation (MB) 791.43 / 796.19 794.90 / 796.80 805.42 / 806.27

Against all ten baseline controls, median owner elapsed falls 13.2%, Node-process CPU falls 4.5%, and guest CPU falls 6.6%. Main-isolate allocation rises 1.5% (about 12.2 MB). Host contention produced large baseline and candidate outliers, retained above. The frozen source and committed candidate match byte for byte. A separate CPU/allocation profiling pass failed before reaching pristine verification because Git ran out of disk space during fetch; the Docker daemon then became unavailable during cleanup. Its partial profiles are excluded. A separate completed diagnostic profile used the same real Git, publication, and reconciliation owners with the harness’s supported simulated guest; contents verified, and its timings are excluded. The main isolate was predominantly idle waiting for workers and Git, with canonical-path selection the largest named application CPU frame. The ordinary-sample CPU and V8 allocation counters above remain valid.

The workload is scripts/perf/github-publication-pause-measure.ts, run serially against frozen parent and candidate source roots with --native-image set to the installed Node 26 image. CPU includes Node worker threads but excludes host native Git subprocess CPU; guest CPU is measured separately. Allocation is the main V8 isolate's exact counter. The host filesystem is APFS through the container runtime, not btrfs. The agent database is small and synthetic: this workload does not cover a 35 GiB database or thousands of sessions. No production data was used.

Exact-head dispatched CI passed. Normal ready-PR CI failed in Git setup for three Node jobs because the upstream Git PPA returned HTTP 503; no tests ran in those jobs. CodeQL and security review passed. Other tested lanes, including UI, typechecks, lint, and docs, passed. After the package endpoint recovered to HTTP 200, only the failed jobs were retried in attempt 2 at the unchanged PR head; attempt 2 and the aggregate CI gate passed. Both successful CI runs cover the unchanged reviewed head f031e939a47a73fe091cfaf72d11e537361699f9.

Two additional projection authority tests fail on exact parent 3da0bc802e100faebc8352f7398fea89410def27, introduced by #201334 (04cb8179ccd66c88f2b32eb8bca8c53d2e8b9cb5): “rejects canonical checkpoint writes after original operator authority ends” and “denies guest filesystem writes after role revocation and a late involvement receipt.” They still expect mid-request role revocation after that change made authority fixed per request. These are separately reported main test regressions, not passing proof or a CI waiver for this PR.

Prepare the canonical pristine snapshot and manifest while the guest runs under the existing reconciliation lease. Bind that prepared view to the accepted baseline and retain the paused guest manifest comparison, dirty and staged edit checks, and source history checks.
@clawsweeper

clawsweeper Bot commented Nov 18, 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 docker Docker and sandbox tooling size: S labels Nov 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please review the canonical pristine preparation and its accepted-baseline binding across the two existing reconciliation leases. The guest projection remains captured while paused. Focused regressions cover dirty and staged-only edits during preparation and a checkpoint that changes canonical bytes without changing Git HEAD. Performance measurements are continuing against this unchanged head.

@clawsweeper

clawsweeper Bot commented Nov 18, 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. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves first-import canonical verification into the existing preparation lease while retaining the paused guest comparison.

Example: Import a PR into a managed workspace containing 62,000 files and 1.10 GB of synthetic content.

  • Before: The author reports total guest pauses of 11.20 and 12.38 seconds on the parent.
  • After: The initial candidate sample reports a 5.72-second total pause with verified contents.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused regressions are coherent; initial native measurements support the change, with limited comparative performance confidence.
Proof confidence 🦐 gold shrimp (3/6) Maintainer authorship exempts this PR from contributor proof gating; the body reports the production publication owner with a real Docker heartbeat on APFS, but its comparative performance campaign remains unfinished.
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 stops running for several seconds while first-import preparation verifies the canonical workspace.
Reason: The maintainer-approved direction removes unnecessary frozen work while preserving pristine-import protection and existing recovery semantics.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses canonical verification still performed while paused on main, and inspection found no actionable correctness or security defects.

Priority: P2
Reviewed head: f031e939a47a73fe091cfaf72d11e537361699f9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Only initial A/A/B Docker results are published; the declared interleaved timing, CPU, and allocation campaign remains incomplete.
Agent review details

How this fits together

The Gateway publication owner receives a verified PR source, checks the canonical checkout and sandbox projection, and applies source through the existing reconciliation and recovery owners.

flowchart TD
  A[Verified PR source] --> B[Preparation lease]
  B --> C[Canonical snapshot and manifest]
  C --> D[Observe guest Git state]
  D --> E[Integration lease and baseline check]
  E --> F[Paused guest manifest comparison]
  F --> G[Existing source application and recovery]
Loading

Technical review

Best possible solution:

Prepare canonical verification under the existing lease, retain the paused guest comparison, and reject a changed accepted baseline before applying source.

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

Current-main source confirms canonical verification runs inside the paused first-import callback, and the author supplies a Docker reproduction; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is a small relocation through existing owners: it preserves filesystem equality beyond Git trees and binds the prepared view to the accepted baseline without adding another cache, lease, or persistence mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Initial-import pristine checks keeps the original intent (9218dca: Preserve dirty, staged, untracked, or unpublished work before installing a verified PR head; later published-project ancestry handling remains intact.)
  • Worker-owned raw manifest comparison keeps the original intent (baf76f9: Keep complete manifest preparation and comparison off the Gateway main thread while preserving output and admission policy.)
  • Live-guest source preparation keeps the original intent (3a6cc65: Prepare source under host custody with the guest running, then verify integration state across the custody gap while preserving recovery pauses.)

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:49 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:75 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 +13, Tests +95, Docs +7. Total +115 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 43 30 +13
Tests 1 99 4 +95
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 149 34 +115

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 +13 net lines; tests +95 net lines Production growth carries the prepared manifest and existing baseline identity; tests cover pause placement and distinct edit-preservation failures.

Labels

Label changes:

  • add P2: Several-second sandbox pauses affect large first-time PR imports, with a focused optimization and limited workflow scope.
  • 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: Several-second sandbox pauses affect large first-time PR imports, with a focused optimization and limited workflow scope.
  • 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.

Reviewed November 18, 2026, 2:39 PM ET / 19:39 UTC.

@steipete
steipete marked this pull request as ready for review November 18, 2026 19:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T20:00:55.872125Z f031e93 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.

@steipete
steipete merged commit 71ee556 into main Nov 18, 2026
355 of 365 checks passed
@steipete
steipete deleted the steipete/perf-micro-base-refresh-pristine-in-pause-20260919 branch November 18, 2026 21:28
@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 19, 2026
…01410)

Prepare the canonical pristine snapshot and manifest while the guest runs under the existing reconciliation lease. Bind that prepared view to the accepted baseline and retain the paused guest manifest comparison, dirty and staged edit checks, and source history checks.
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. size: S 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