Repository navigation
feat(workers): snapshot prepared projects before session enrollment - #133447
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 30, 2026, 6:28 PM ET / 22:28 UTC. ClawSweeper reviewWhat this changesThe branch snapshots a Git project and node runtime before cloud-worker enrollment so Crabbox can capture and reuse prepared worker images, while adding warm-state migration and teardown handling. Merge readiness⛔ Blocked until stronger real behavior proof is added - 6 items remain The branch remains necessary and source review supports its provider-owned lifecycle direction, but merge review is incomplete: the new pre-enrollment artifact capability lacks final-I/O revocation proof and its Codex remote-exec dependency contract cannot be inspected locally. Priority: P2 Review scores
Verification
How this fits togetherCloud-worker provisioning converts a session workspace into a provider allocation, prepared node runtime, enrolled node, and synchronized session. The added preparation stage lets a provider capture a clean project and runtime before node credentials exist. flowchart LR
A[Session workspace] --> B[Gateway project snapshot]
B --> C[Cloud provider allocation]
C --> D[Runtime preparation]
D --> E[Image capture]
E --> F[Node enrollment]
F --> G[Workspace synchronization]
G --> H[Worker session]
Decision needed
Why: The change creates a reusable provider lifecycle capability and changes durable upgrade behavior; source review cannot determine whether that public plugin and operational tradeoff is desired. Before merge
Agent review detailsSecurityNone. PR surfaceSource +1590, Tests +2036, Docs +30. Total +3656 across 79 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one provider-owned preparation flow, prove revocation at the artifact HTTP final effect, and obtain explicit maintainer acceptance of the provider API and warm-state upgrade contract. Do we have a high-confidence way to reproduce the issue? No; focused tests exercise the component lifecycle, but the PR describes the final project flow as pending and provides no final-head live reproduction. Is this the best way to solve the issue? Unclear; the source follows the provider-owned lifecycle, but absent Codex contract inspection and final-I/O authority proof prevent a best-solution verdict. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7504a3b3c453. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Give providers a bounded teardown budget for reclaim and bootstrap cleanup. Keep queue ownership checks and explicit service overrides in the shared owner lifecycle. Account for Crabbox capture, maintenance, lease removal, and process settlement without extending native command timeouts. Let Control UI Stop wait for the Gateway outcome. Cover both teardown entrances, invalid budgets, override precedence, and stale queued owners.
|
@clawsweeper re-review The final head adds the provider-owned teardown deadline and UI wait behavior, beyond the previously reviewed scope. The PR body now includes direct installed-Crabbox contract links, the successful real cold/capture/warm flow, observed lease policy, seeded workspace reuse, sanitized screenshots, and the timing caveats. All task cloud resources were cleaned up; local checks and the final packaged build pass. The PR remains draft while exact-head CI runs and the separate durable allocation-choice/class/enrollment refactor in #133436 awaits maintainer design acceptance. No persistent-state implementation is included in this head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The final code head is The full packaged build, owner regressions, and merged Stop/dispatch integration tests passed. Exact-head CI and the new overlapping-session live proof are still running; the body explicitly separates them from the earlier Stop-and-capture evidence. I will add the new measured flow and confirmed cleanup before landing. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…penclaw#133447) * fix(workers): preserve warm lease policy and defer workspace packing * fix(crabbox): recognize verified native image readiness * fix(workers): honor provider snapshot teardown deadlines Give providers a bounded teardown budget for reclaim and bootstrap cleanup. Keep queue ownership checks and explicit service overrides in the shared owner lifecycle. Account for Crabbox capture, maintenance, lease removal, and process settlement without extending native command timeouts. Let Control UI Stop wait for the Gateway outcome. Cover both teardown entrances, invalid budgets, override precedence, and stale queued owners. * test(ui): align cloud worker stop deadline assertions * docs(plugins): document provider teardown budgets * feat(workers): capture prepared project snapshots before enrollment * perf(workers): skip runtime preparation on project snapshot hits * fix(workers): fence project setup and cleanup after runtime grants * test(workers): align lifecycle and release navigation expectations * test: use canonical release navigation coverage from main
Reuse worker-confirmed empty SQLite plugin-state observations through the existing bounded receipt-invalidated cache, retain Reef read operations, and retain successful Crabbox legacy readiness at its manager. Keep TTL expiry, mutation settlement, first-handler validation, failure retries, generic snapshots and PostgreSQL external-write visibility. No schema or public SDK signature changes. Synthetic Gateway counts: Reef steady 21 to 17 SQL and 13 to 9 requests per minute; Crabbox 15 to 11 SQL and 10 to 6 requests per two minutes. Runtime main-thread SQL remains zero. Focused owner and SDK tests, isolated review rounds and exact-head CI including all three PostgreSQL shards pass. The retired Crabbox legacy writer was removed in #133447.
…law#183223) Reuse worker-confirmed empty SQLite plugin-state observations through the existing bounded receipt-invalidated cache, retain Reef read operations, and retain successful Crabbox legacy readiness at its manager. Keep TTL expiry, mutation settlement, first-handler validation, failure retries, generic snapshots and PostgreSQL external-write visibility. No schema or public SDK signature changes. Synthetic Gateway counts: Reef steady 21 to 17 SQL and 13 to 9 requests per minute; Crabbox 15 to 11 SQL and 10 to 6 requests per two minutes. Runtime main-thread SQL remains zero. Focused owner and SDK tests, isolated review rounds and exact-head CI including all three PostgreSQL shards pass. The retired Crabbox legacy writer was removed in openclaw#133447.
Closes #133450
Closes #133436
What Problem This Solves
Fixes an issue where users starting another cloud session for the same project still waited for repository cloning, or received a cold machine despite an existing usable snapshot. Capturing only when the first session stopped also meant a second session could not benefit while that first session remained open.
The first eligible Git project now prepares its committed checkout and node runtime, then captures a reusable machine image before node enrollment. A later session can fork that image, reuse its Git objects, and receive its own current file changes without cloning or downloading the full repository again. The first dispatch pays the preparation/capture cost; later sessions do not need to wait for the first session to stop.
Why This Change Was Made
The Gateway owns project identity, the pinned commit, bounded Git packing, and preparation authority. The provider owns transport to its operation-owned machine, native capture, and allocation. The node owns materializing the current session manifest from validated cached objects. This keeps repository policy out of Crabbox and uses one Git-pack builder for project preparation, node transfer, and SSH transfer.
Project identity combines the Gateway namespace with the canonical shared Git directory, so linked session worktrees share a cache while separate clones and Gateways remain distinct. The environment intent pins the preparation commit across retries; each seed identifies that exact commit. Native capture runs after pristine checkout and any required runtime-only installation, followed by scrubbing and fresh enrollment. A usable image skips duplicate runtime-only preparation and the SSH refresh needed after a capture. Configured profile/desktop setup and normal enrollment retain their existing per-provision behavior.
The provider records the cold/checkpoint choice and effective class before allocation, then tracks preparation and enrollment. A timeout or Gateway restart replays that same choice; an uncertain fork cannot switch to another image or silently become a cold allocation. Selected checkpoints remain pinned until confirmed provider stop. Replacement publication preserves the previous image and its deletion obligation; failed retirement remains durable and cannot delete an image still needed by another allocation.
This also preserves the earlier fixes in this PR:
ACTIVEresponses, while retaining Docker'savailable/deletecontract.resolveDestroyTimeoutMs(profile)for both normal teardown and bootstrap-failure cleanup. Crabbox accounts for its bounded capture, maintenance, stop, and process-settlement phases; native command limits are unchanged. Control UI Stop waits for the Gateway result instead of imposing a shorter timeout.User Impact
Matching project snapshots work with private repositories and unpublished commits because preparation transfers committed Git objects without forwarding repository credentials or local Git configuration. Session edits, eligible untracked files, attachments, author metadata, and fresh node identity are applied afterward. Workspace transfer copies only validated Git objects into a fresh repository, so cached worktree files, hooks, configuration, and alternates cannot enter the next session. Missing seeds use the existing bounded pack transfer; invalid seeds fail visibly without replacing the prior workspace.
Changed commits refresh the same project's image; they do not create another project identity. Seeds retain the existing six-entry/30-day policy, with one-hour staging cleanup and protection for the current seed. Images retain the 24-hour refresh and 14-day unused-image policy. Outstanding allocations, captures, and retirements keep their ownership slots: the 128-profile and 256-allocations-per-profile bounds reject new admission with cleanup guidance rather than evicting replay or cleanup obligations. Non-Git workspaces keep the existing sync path and eligible capture at teardown.
Upgrade: this introduces a version-2 envelope in the existing plugin-state namespace, without a SQLite schema/version change or new configuration option. Stop the owning Gateway/capture processes and run
openclaw doctor --fix. Doctor preserves old images, capture selectors, and retirement obligations without inventing missing allocation choices. Legacy lease rows whose original choice is unknown require the exact cleanup acknowledgement reported by Doctor before warm allocation resumes. Runtime accepts canonical state only; do not mix old/new writers or downgrade with unresolved ownership. See warm-image upgrade and recovery.Evidence
The overlapping project-session live flow and final integration CI passed. The complete runtime/UI build at
0098afe0c47passed. After successful CI on9303b6397e1, main added bootstrap failure diagnostics in the same provider files. Final headac89e409f07resolves that conflict; its own CI run and required merge gate both passed. All 301 focused integration tests passed, with one platform skip, and a fresh full-change Codex P0 review found no actionable findings.The live candidate remains accurately identified as
0098afe0c47: 39 of the 43 recorded runtime files are byte-identical toac89e409f07. Main's integrations add reclaim coordination, Unicode-safe enrollment display names, bootstrap diagnostic phase labels, and an equivalent error-constructor inline in the extracted provisioning owner; the obsolete error wrapper was removed outside that original 43-file manifest. Successful allocation/capture/enrollment decisions remain unchanged. Runtime-only preparation still returns before identity activation. Earlier merged coverage passed 74 worker concurrency/recovery cases and 28 enrollment/startup cases; the latest 301-case run covers generated bootstrap scripts, truncated downloads, provider/project lifecycle, and UI integration. This distinguishes actual live behavior from the additional merged-source proof.The real Machine0/Gateway run captured checkpoint
chk_f6e4741a3958786abefore first enrollment. A second session forked that exact image while the first remained active. Both independent audits verified all 64 corpus files (16 MiB), the exact committed Git tree, pristine cached seed, distinct tracked/untracked session overlays, and identical runtime digests. Both remote workers completed assistant turns. Public node inspection independently showed two distinct paired and connected nodes at the same time.The warm trace recorded zero origin requests, full-pack downloads, project uploads/installs, runtime-only installs or artifact downloads, recaptures, and cold fallbacks. Each session downloaded only its manifest and two changed-file blobs. Cold runtime installation made one artifact request; warm made none. Allocation policy matched on both leases: requested class
tiny, actual native size overridelarge, four-hour TTL, one-hour idle timeout, public network, no Tailscale, and keep enabled.Timing limits: this is one pair using a 16 MiB synthetic unpublished Git project and real cloud/Gateway/worker execution; only model responses were mocked. Cold dispatch includes up to 508.677 seconds of first-Gateway local bootstrap assembly, which the warm session shares through the existing process cache. Native allocation itself took essentially the same time in both sessions. The overall ratio therefore does not isolate snapshot speed. The first capture's cost is deliberately paid before enrollment. A macOS
/tmpalias bug in the external audit helper was corrected during a bounded pause after cold dispatch; the same VM/image were retained and both audits passed, without changing production code or dispatch timings. Both exact native VMs were confirmed absent from successful provider inventory, and the exact image was explicitly not found. The unrelated preexisting VM was untouched; task Gateway and rig processes stopped.The runtime optimization passed all 87 focused snapshot/project cases. The final owner fix rejects late runtime grants and cleanup after ownership changes; both regressions failed before the fix and all 11 project and 20 protocol cases passed afterward. Core/plugin production and test typechecks, selected static checks, and focused lint passed through the recorded reruns. Fresh full-change and final test-only Codex reviews found no actionable P0 findings. The earlier live run does not establish the new capture-before-enrollment flow or its speedup.
Initial CI exposed stale provision-budget and cancellation-signal expectations, plus a release-navigation fixture changed concurrently on main. Those are corrected; the navigation fixture now uses main's canonical version. One unrelated full docs-copy test exceeded its existing 120-second limit locally; its assertions and timeout are unchanged, and final CI passed. Live QA startup also exceeded its local CLI wrapper during isolated repair; normal standalone repair completed successfully before using the public Gateway launcher against that repaired state. No cloud resources were allocated by the failed setup attempts.
Two subsequent attempts completed cold capture before enrollment but failed in the external audit harness before reaching a warm session: the first audit command competed for the lease claim; the replacement expected SSH fields omitted by read-only inspection. Both VMs and images were confirmed removed. The corrected harness uses source-verified host/user/key metadata, asynchronous direct SSH with existing strict host trust, complete stdout draining, and bounded resource preservation on audit failure. Its connection metadata was tested against the saved real response, and its exact content assertions passed a resource-free two-workspace Git fixture. These partial attempts establish capture ordering only; they are not warm-flow or speedup proof.
Completed project validation:
Earlier live evidence: prior stop-and-capture flow only
The earlier real Machine0 flow completed cold session → UI Stop/capture → verified image fork → warm session, with assistant replies in both sessions. Full dispatch measured 542.9 seconds cold and 202.7 seconds warm; native capture took 200.4 seconds and UI Stop completed in 216.9 seconds. Cold dispatch included about 221 seconds of local artifact preparation, and native forking itself was slower, so this pair does not isolate snapshot speed. Both sessions issued zero fallback-pack requests, the warm session used the recorded Git seed, and task VMs/image were verified removed.
These screenshots document that prior flow and the earlier UI Stop fix, not the new project-snapshot implementation:
Earlier regression runs also covered readiness, lazy packing, and both teardown paths timing out at 300,001 ms before their fixes. The final affected UI follow-through passed 459 tests. Those results support the earlier changes only.
Review decisions and dependency contract
The maintainer accepted the optional
resolveDestroyTimeoutMsprovider contract and the durable allocation/project-preparation direction implemented here. The hook remains optional, provider-agnostic, validated before effects, and subordinate to an explicit service override. Both SDK overview and worker-provider reference document it.The latest ClawSweeper review and rank-up requests, updated August 30 at 22:29 UTC against
0098afe0c47, ask for production HTTP revocation proof, prepared-project and Doctor recovery proof, and matching Codex contract inspection. The owner direction above is accepted. All three requests are addressed by the live pair above and the HTTP, Doctor, and dependency evidence below. The bot has not yet rerated that evidence; no new source finding is being skipped.Runtime artifact final-I/O proof: on exact head
9303b6397e1, the real SQLite store, runtime preparation manager, transfer callback, and production HTTP handler served requests over TCP. An authorized grant delivered the exact 1,049,369-byte synthetic archive, verified byte for byte. Separate unused grants returned HTTP 404 with zero archive bytes after runtime closure and after authoritativerequestDestroy; the latter retained an un-aborted runtime signal, exercising the owner predicate. Closing the real grant after its file descriptor opened but before response headers also returned 404 with zero archive bytes. A retained bearer after that closure was rejected. Five requests passed with no handler failures; server, temporary state, and archive were cleaned up. Only archive production was synthetic. This proves rejection at final HTTP delivery, including the after-open window; it does not claim revocation after bytes have already streamed.Doctor recovery proof: the actual packaged CLI used isolated SQLite and synthetic resource IDs. All four Doctor/recovery owner files match
9303b6397e1byte for byte. Legacy inspection failed with the Doctor instruction;openclaw doctor --fix --non-interactivemigrated four rows while preserving image metadata, capture ownership, retirement obligations, and the unknown-choice lease. Recovery without acknowledgement failed without changing any row. Exact acknowledged recovery preserved three images and the pending retirement. Separate-process reopen and an idempotent second Doctor run passed. Canonical v2 admission/release then passed with only its native command runner replaced by an in-memory fake. No cloud resources or normal operator state were touched.Crabbox v0.47.0 source was independently inspected: fork lease flags, allocation policy application, common native readiness, and Machine0 verification. Native capture stops, saves, waits for readiness, and restarts the source, which is why project capture precedes enrollment.
The acting maintainer agent personally inspected the matching Codex
rust-v0.151.0source at commit78c290807ce710180111df227df3b7a4fe845452: platform-native launcher selection, per-session/process execution parameters, process shutdown, and per-request environment construction. OpenClaw's managed binary, node exec-server, and bootstrap artifact owners were also checked: destination-native dependencies remain exact pins; fresh executor/session identity and temporary home remain outside the reusable project seed. No Codex protocol or archive-format change is introduced. This is source-contract proof, not a claim of live Codex remote-exec execution.Size and release note
Named performance follow-up: Reduce first-Gateway node bootstrap artifact assembly I/O. Live process/file inspection identified cold local preparation in
node-bootstrap-artifact.tscopying the built distribution into its immutable package, including declaration files, before any provider allocation. The second session shares this process-owned artifact cache. Keep that local cost separate from native allocation and snapshot savings; changing the packaging contract is outside this snapshot repair.At final head
ac89e409f07, the effective change against integrated main3ef446c7b6bis production +2,639/-1,066 (net +1,573); tests/test support +2,456/-400 (net +2,056); docs +57/-27 (net +30), across 81 effective files. Upstream-only changes are excluded; moves cancel in the net figures. Production growth supplies the newly accepted project-preparation capability, durable allocation/capture/retirement ownership, and Doctor migration/recovery. The refactor removes duplicate pack construction, separates admission and Git initialization into their owners, and stops treating the former enrolled-lease registry as allocation-choice authority. No configuration option, SQLite table, or schema version is added; persisted envelope and retention/admission semantics do change as described above.Release note for the release-only changelog generator: Cloud workers: capture pristine project checkouts before enrollment, reuse snapshots across subsequent sessions without cloning, preserve allocation choices across retries, and let provider-owned capture finish during safe reclaim. Existing warm-image state migrates through Doctor.