Skip to content

perf(crabbox): reuse warm images for empty workspaces - #168371

Merged
steipete merged 3 commits into
mainfrom
steipete/cloud-worker-warm-path-20261010
Oct 10, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/cloud-worker-warm-path-20261010

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated cold starts and unnecessary project-pack transfers when new cloud sessions use empty workspaces, and prevents repeated native checkpoint attempts after a backend refuses capture.

User Impact

Empty-workspace sessions can share their profile's runtime image instead of creating a different project image for every session. They skip the pre-enrollment Git pack transfer and project capture; their isolated Git metadata and session files still synchronize normally. A retained native-capture refusal suppresses attempts for the existing warmImages.refreshAfter interval (24 hours by default), including after Gateway restart. Existing compatible images remain usable.

Nonempty project capture still runs before enrollment. This PR deliberately uses the requested escape hatch for moving that capture off the activation path; it does not claim to complete that design change or measure new live dispatch latency. Existing allocations retain their frozen choices, and older empty-project images follow ordinary cleanup. Empty repositories cannot build a prepared project until they contain committed files.

Why This Change Was Made

The two observed dispatches had identical empty commits, runtimes, plugins, OS, and class, but their generated empty Git repositories had different common directories. Project admission treated both as reusable projects, so the project identity, preparation cache key, and Crabbox image key differed. Both completed captures were recorded as available with successful demand; this was an identity mismatch, not an availability-parser or fork-argument defect. Rejecting empty committed trees at the project snapshot owner removes both the unnecessary transfer and the accidental per-session image identity. Nonempty repositories keep their isolation and commit pinning.

The existing refusal marker was informational only. Capture now consumes its existing expiry policy before runtime preparation, scrubbing, or native creation. CLI, Doctor, UI, and documentation describe the same behavior. After expiry, the next eligible worker retries so changed backend capabilities can take effect. No schema, credential, or capture-recovery contract changes.

Proposal for goal 1: extend the existing service-owned prepared-worker/build lifecycle with a separate capture-only source lease for the same compatibility key. The foreground lease can enroll and activate without waiting for capture. The source lease alone owns runtime preparation, scrubbing, the capture reservation, and unresolved-outcome custody; it must never receive node enrollment or mutable session credentials. Publish through the existing warm-image manager, then stop the source only after the capture settles. Cancellation, restart, and uncertain outcomes must drain or retain that source under the service owner. Simply backgrounding capture on the enrolled session lease would violate the current credential-isolation boundary. This proposal needs a follow-up design decision, including the extra source-lease cost.

Evidence

  • New empty-workspace regression uses two real managed empty repositories through the environment service. It failed on the baseline because both reached the provider as projects, and passes with identical project-free allocation profiles.
  • Capture/reallocation proof asserts the next provider allocation requests the captured checkpoint, performs no cold warmup, and creates no duplicate capture. Existing project reuse, runtime compatibility, pinned/retiring generations, and uncertain-capture enrollment fencing also pass.
  • Refusal regression failed on the baseline because the second worker repeated runtime preparation. It now proves restart-persistent suppression, normal enrollment, and capture resumption after expiry.
  • pnpm test src/gateway/worker-environments/provider-project-preparation.test.ts src/gateway/worker-environments/workspace-git-base.test.ts extensions/crabbox/src/crabbox-worker-project.test.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts extensions/crabbox/src/crabbox-worker-warm-image-cli.test.ts extensions/crabbox/src/crabbox-worker-warm-image-allocation.test.ts extensions/crabbox/src/crabbox-worker-prepared-image.test.ts --maxWorkers=1: 207 passed, 183.23 seconds wall. These existing integration files exercise real SQLite state, provider command assembly, and lifecycle custody; smaller predicate tests would miss the owner/transport behavior.
  • pnpm test extensions/crabbox/src/doctor.test.ts --maxWorkers=1: 19 passed, 46.46 seconds wall including a cold compiled-worker preparation; test execution was about 3.4 seconds.
  • pnpm test ui/src/pages/cloud-workers/cloud-worker-snapshots.test.ts --maxWorkers=1: 7 passed, 4.13 seconds wall. Synthetic Control UI screenshots were rendered and inspected before/after; capture runs took 10.89 and 10.99 seconds.
  • pnpm check:docs and pnpm ui:i18n:baseline: passed. All selected type checks and formatting passed. Independent Codex review against the pinned branch base: scoped-clean at P1, no actionable findings.
  • check:changed stopped at existing unused-export failures: isPollVoteEchoText, PUBLIC_SESSION_ENTRY_SCRIPT, and isClaudeLikeLiveAgent. Their files are unchanged from this branch's original base; the first export has already been removed on newer main. Remaining touched-file lint and owner guards were run directly. This patch does not hide or change the unrelated failures.
  • Live evidence was read-only. No Gateway or provider state was changed, and no cloud leases were allocated for this patch.
  • The requested timeout 40m node scripts/watch-pr-ci.mjs 168371 4ee4b728a71a4f9b0b767aba744512981bdd5a50 exited 15 on CI run 38042030448. The run completed as cancelled after fail-fast: UI E2E shard 1/2 failed two unchanged session-dashboard.e2e.test.ts cases because .chat-gutter-stack--details intercepts clicks on Pin to dashboard. Both failures reproduced locally in one bounded run (108.65 seconds wall); the failing tests, Chat/widget renderer and CSS are unchanged from the branch base. The changed Cloud workers string is not consumed by that flow. The subsequent landing request authorized integrating the upstream repair and obtaining fresh CI.
  • The Crabbox extension test bundle passed in 170 CI job seconds. Recorded CI test execution: project provisioning 20.838 s / 57 tests, warm-image lifecycle 31.963 s / 69 tests, warm-image CLI 2.821 s / 10 tests, Doctor 3.461 s / 19 tests. UI E2E shard 1 took 176 CI job seconds (118.95 s Vitest, 92 passed / 2 failed); shard 2 passed. Docs, UI i18n, UI performance, and security-fast passed. Other core/UI checks were cancelled by fail-fast, so their exact-head CI proof is incomplete. Local proof above remains valid.

Landing follow-up — head 44b0904e0f270a3c87d367e43f9e9d42c4468728:

  • Read both original extension lint job logs once: check-lint-extensions-1 (114184629542) was cancelled during Checkout, and check-lint-extensions-3 (114184629551) during dependency-cache restore. Neither executed a lint rule. The successful pr-fail-fast job cancelled them following the UI failure; they were cancellation fallout, not introduced or inherited lint diagnostics.
  • Confirmed both dashboard failures on recent full main CI run 38041823802 / job 114183486675, at db6449d3f6091740dbddcf02fdc0e34dc94ca424. Both time out because the Details gutter intercepts the pin button. Test, renderer and CSS blobs matched the original PR's tested merge. The earlier green main runs were security-only and were not used as dashboard proof.
  • Main subsequently landed #168328, commit dd036a4b1d855c366c7b3148a1814c83da765e50, moving the above-card pin controls clear of Details. Merged that main revision into this branch without rebasing. The PR delta against that base remains the same 15 files.
  • On the merged candidate: 233 focused tests passed in 521.25 seconds wall; full session-dashboard.e2e.test.ts 8/8 passed in 116.29 seconds wall, including the two former failures in 969 ms and 890 ms. Fresh independent Codex review is P1 scoped-clean. Goal 1 remains a proposal, with no trust-boundary implementation added.
  • That run also exposed a later main regression: 06c6e83f4351f extracted a regex capture without narrowing undefined, causing TS2345 in control-ui-public-session-refresh.test.ts. All other newly reported red jobs were fail-fast cancellations. Reproduced the exact type stripe on isolated main; upstream then landed the equivalent repair as 8420f82cbbf8bd0114cacc39fa51299f92851a6f, which is now merged into this branch without rebasing.
  • Final head 9044c746e28bbf6f7f505aca8effef8903a15ad7: exact gateway-root type stripe passed (42.96 seconds), public-session tests passed 4/4 (17.18 seconds wall), dashboard E2E passed 8/8 again (85.30 seconds wall), and fresh Codex P1 review is scoped-clean. The task delta remains 15 files. Exact-head CI run 38048326212 is green for 9044c746e28bbf6f7f505aca8effef8903a15ad7; native squash landing uses the normal required-check path, with no inherited-failure exception.

Before: repeated native-capture retry guidance

After: bounded native-capture retry guidance

Skip empty committed trees during project preparation so new empty sessions share runtime images and avoid project-pack transfer. Honor retained native-capture refusals until the existing refresh interval expires. Preserve capture-before-enrollment custody and document the separate-source proposal in the PR.
@clawsweeper

clawsweeper Bot commented Oct 10, 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 app: web-ui App: web-ui gateway Gateway runtime extensions: crabbox size: S labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Empty workspaces share runtime images, and native-capture refusals suppress repeated attempts for the existing refresh interval.

Example: Two empty session repositories use a Hetzner standard Linux profile.

  • Before: Separate Git directories produce different project-image identities and unnecessary project transfers.
  • After: Both use the profile runtime-image identity while session files and Git metadata synchronize separately.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, useful changes with meaningful boundary coverage and no findings; runtime confidence remains limited to harness evidence.
Proof confidence 🦐 gold shrimp (3/6) Under the supplied MEMBER author context, ordinary external-contributor proof gating does not apply; inspected screenshots establish the changed UI guidance, while runtime evidence consists of reported production-owner harness runs with mocked provider commands.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Empty-workspace sessions repeat unnecessary project preparation, and unsupported backends repeat avoidable native-capture work.
Reason: The established feature owner's focused optimization explicitly accepts bounded capability-retry delay and does not claim to implement asynchronous capture.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes unnecessary cloud-worker preparation still present on main, with no actionable introduced defects found; remaining CI is pending.

Priority: P2
Reviewed head: 9044c746e28bbf6f7f505aca8effef8903a15ad7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-entry-point run demonstrates empty-session image reuse and refusal suppression across restart; baseline failures and passing harness execution are author-reported.
Agent review details

How this fits together

Gateway project admission produces allocation profiles; the Crabbox plugin owns worker allocation, image capture, enrollment, reuse, and cleanup.

flowchart TD
A[Session workspace] --> B[Gateway project admission]
B --> C[Crabbox allocation]
C --> D[Warm image manager]
D --> E[Crabbox CLI]
C --> F[Fresh node enrollment]
F --> G[Workspace synchronization]
Loading

Technical review

Best possible solution:

Keep these optimizations in the existing admission and capture owners, leaving asynchronous capture to its separate design follow-up.

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

Current-main source shows both unnecessary project admission and repeated capture attempts; reported baseline failures match those paths, but this read-only review ran no target code.

Is this the best way to solve the issue?

The patch fixes project identity at its producer and reuses the existing refusal-expiry policy without adding competing state or weakening capture custody.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Project snapshot admission changes intended behavior with a stated reason (c753bbd: Share committed project content across linked worktrees while keeping separate repositories and mutable session state isolated.)
  • Unsupported capture retries changes intended behavior with a stated reason (32b683c: Retry each eligible worker so opaque backend configuration changes take effect immediately.)
  • Prepared-project validation keeps the original intent (e5acecf: Admit explicit prepared builds from usable committed local projects.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c753bbd adds src/gateway/worker-environments/workspace-git-base.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c753bbd1ced5; files: src/gateway/worker-environments/workspace-git-base.ts)
  • Galin Iliev: Raw commit db01f6d adds src/gateway/worker-environments/workspace-git-base.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: db01f6d520b8; files: src/gateway/worker-environments/workspace-git-base.ts)

PR surface

Source +9, Tests +46, Docs +2. Total +57 across 15 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 14 5 +9
Tests 6 60 14 +46
Docs 3 12 10 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 86 29 +57

Review metrics

Metric Value Why it matters
Production versus test changes Production +14/-5 lines; tests +60/-14 lines Small owner-local changes receive distinct coverage for empty-workspace admission, restart-persistent suppression, and checkpoint reuse.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Avoids repeated preparation and capture costs within a bounded cloud-worker 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.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rank-up moves

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

  • Optionally add a redacted shipped-entry-point trace covering empty-session image reuse and refusal suppression across restart.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-10T09:42:45.013Z sha 4ee4b72 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T09:57:39.983Z sha 4ee4b72 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T10:55:40.525Z sha 44b0904 :: needs changes before merge. :: none

Reviewed October 10, 2026, 7:32 AM ET / 11:32 UTC (Revision 4).

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete
steipete merged commit aef080b into main Oct 10, 2026
135 checks passed
@steipete
steipete deleted the steipete/cloud-worker-warm-path-20261010 branch October 10, 2026 11:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
Skip empty committed trees during project preparation so new empty sessions share runtime images and avoid project-pack transfer. Honor retained native-capture refusals until the existing refresh interval expires. Preserve capture-before-enrollment custody and document the separate-source proposal in the PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: crabbox gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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