Repository navigation
perf(crabbox): reuse warm images for empty workspaces - #168371
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesEmpty 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.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests +46, Docs +2. Total +57 across 15 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 10, 2026, 7:32 AM ET / 11:32 UTC (Revision 4). |
|
Merged via squash.
|
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.
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.refreshAfterinterval (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
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:docsandpnpm 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:changedstopped at existing unused-export failures:isPollVoteEchoText,PUBLIC_SESSION_ENTRY_SCRIPT, andisClaudeLikeLiveAgent. 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.timeout 40m node scripts/watch-pr-ci.mjs 168371 4ee4b728a71a4f9b0b767aba744512981bdd5a50exited 15 on CI run 38042030448. The run completed as cancelled after fail-fast: UI E2E shard 1/2 failed two unchangedsession-dashboard.e2e.test.tscases because.chat-gutter-stack--detailsintercepts 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.Landing follow-up — head
44b0904e0f270a3c87d367e43f9e9d42c4468728:check-lint-extensions-1(114184629542) was cancelled during Checkout, andcheck-lint-extensions-3(114184629551) during dependency-cache restore. Neither executed a lint rule. The successfulpr-fail-fastjob cancelled them following the UI failure; they were cancellation fallout, not introduced or inherited lint diagnostics.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.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.session-dashboard.e2e.test.ts8/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.06c6e83f4351fextracted a regex capture without narrowingundefined, causing TS2345 incontrol-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 as8420f82cbbf8bd0114cacc39fa51299f92851a6f, which is now merged into this branch without rebasing.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 for9044c746e28bbf6f7f505aca8effef8903a15ad7; native squash landing uses the normal required-check path, with no inherited-failure exception.