Skip to content

fix(sandbox): avoid full template checkouts on source changes - #195443

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-sandbox-template-rebuild-per-commit-20260919
Nov 8, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-sandbox-template-rebuild-per-commit-20260919

Conversation

@steipete

@steipete steipete commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a full sandbox template checkout on every selected source commit, even when the pnpm lockfile is unchanged.

User Impact

Idle sandbox templates now advance their private source checkout and retain installed dependencies. Lockfile or Git-attribute changes still build a fresh template, and concurrent callers share one preparation. No new configuration or schema changes.

Why This Change Was Made

Use the existing template owner's exclusive refresh operation. Keep exact commit identity: lifecycle scripts and local packages can depend on ordinary source files, so a lockfile-only key would publish stale installation output. Import the Git delta, preserve unchanged checkout files, rerun pnpm, validate, and publish. Remove obsolete private Git objects before another session receives the snapshot. Each refresh gets a distinct installer identity; the config-prefixed pnpm option prevents optimistic repeat install from skipping lifecycle scripts while preserving custom-image compatibility.

The existing coalescing works: mutation wait is inside template preparation; application is each caller's separate native clone. This change does not eliminate that clone or claim to fix slow native filesystem cloning.

Related overlap: #195433 changes the same checkout owner and tests for filtered fetches; preserve both behaviors when integrating. #193214 shares template tests but its production diagnostics owners are unchanged here.

Evidence

Five counterbalanced before/after pairs after two A/A controls, on native APFS with 62,000 distinct synthetic payload blobs (1.10 GB logical), a real pnpm lockfile, and sandboxed pnpm 12.15.0:

Source-change measurement Before median After median
Prepare + apply 10.066 s 3.836 s
Complete owner operation 10.079 s 3.855 s
Checkout, inside prepare 7.347 s 0.711 s
Process CPU, including JS workers 1.023 s 0.791 s
Main-thread V8 allocation 40.52 MiB 48.63 MiB

All five candidate prepare+apply samples were 2.799–4.026 s. All arms verified exact HEAD, clean tracked source, fresh lifecycle output and fresh local-package contents. Baseline retained two template generations; candidate advanced one in place. Both deliberately performed two installs across seed and source change.

Limits and tradeoff: A/A wall times were 11.395 and 23.989 s on this shared host. Allocation increased 20% by campaign median; one separate attribution probe did not reproduce a fixed increase (sampled allocation was nearly equal), so resource non-regression remains inconclusive. The fixture has synthetic compression (7.29 MiB packed Git) and a small dependency graph. Btrfs, full Gateway traffic and a large agent database are unqualified. These are owner-boundary results, not a production end-to-end latency claim.

The full sandbox/worktree suites passed on explicit Node (1,532 tests) and Bun (1,527 tests), with existing skips. Final owner/checkout/installer tests passed on both; the final command spelling also passed affected installer/lifecycle tests. Real-owner and real-Git regressions fail before the fix. Separate real-pnpm proof covers registry-only repeat installs, source-dependent lifecycle output, local dependencies, single-build concurrent waiters, lockfile rebuilding, and private-history removal. Fresh Codex review is scoped-clean.

pnpm check:changed: all checks passed except 20 historical changelog-attribution findings reproduced exactly on parent 465c110e4975690406b48709d58a581756c85b82. Commit 266a7aa0fe69 / #194364 introduced this finding set; its parent had a different 26-finding failure. This is an unresolved main regression, not a passing gate. The final option-spelling edit has separate affected-test, formatting and lint verification.

The reproducible driver is scripts/perf/sandbox-template-commit-measure.ts. Production growth is 57 lines for refresh, builder identity and private-history cleanup; the scoped allocation is exactly 109 lines for this PR’s net test growth. Main separately owns the 19-line #195382 debt; the ratchet passes with zero slack. Owner and independent Git boundary coverage remain. No changelog edit: release-note context is in this body.

CI follow-up: rebased onto ac26a0d7f1f8, including upstream type fix 3fa60aed. The test-line ratchet and previously failing root-other typecheck pass locally; focused checkout/template suites pass all 14 tests on both Node and Bun. Targeted formatting/lint and fresh Codex review are clean.

Allocation follow-up: rebased onto 826999cd5f76 and removed the duplicated inherited credit. node --import ./scripts/tsx.mjs scripts/check-test-lines-ratchet.mts --base origin/main --no-merge-base passes: 6,586,850 lines, equal ceiling, zero slack. Fresh Codex review is clean.

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 8, 2026
@steipete
steipete marked this pull request as ready for review November 8, 2026 22:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 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-08T22:50:54.493812Z f15a882 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 8, 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: f15a882141e7b45705926cbca9cd6052bf172770
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/dependency-template.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 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 8, 2026
@steipete
steipete force-pushed the steipete/perf-micro-sandbox-template-rebuild-per-commit-20260919 branch from 00b028c to afa6526 Compare November 8, 2026 22:44
@steipete
steipete force-pushed the steipete/perf-micro-sandbox-template-rebuild-per-commit-20260919 branch from afa6526 to f15a882 Compare November 8, 2026 22:48
@steipete
steipete merged commit 3b7e9c2 into main Nov 8, 2026
131 of 132 checks passed
@steipete
steipete deleted the steipete/perf-micro-sandbox-template-rebuild-per-commit-20260919 branch November 8, 2026 22:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
…aw#195443)

* fix(sandbox): avoid full template checkouts on source changes

* test(sandbox): consolidate refresh proof and reconcile line credit

* test(sandbox): remove inherited line credit now owned by main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant