Repository navigation
fix(cloud-workers): first turn after a Gateway update fails with a missing worker bundle - #160820
Conversation
Runtime refresh installs the Gateway's current worker bundle before it records the new bootstrap receipt. A retain pass processed by the node after that install acknowledged the new install generation while the Gateway's keep set still held only the old receipt, so the next pass pruned the refreshed bundle and the next worker launch failed with ENOENT, the same failure #160730 fixed for cold provisioning. Provisioning and refresh share one cause: both install the current build before recording it. The retain coordinator now keeps the current build on a node until every live environment there has recorded it, which completes the reachability snapshot instead of suspending retention. This replaces the provisioning-only special case from #160730. Persistent hosts keep their existing current-build pin and status target; cloud nodes keep reporting their environment receipt. The installer regression now covers both phases with the real node installer and coordinator. The runtime-refresh phase reproduces ENOENT on the previous code and also proves the previous bundle is pruned once the new receipt is recorded.
|
🦞👀 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. Reviewed September 29, 2026, 9:30 PM ET / September 30, 2026, 01:30 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch changes Gateway retention so cloud nodes keep the current worker bundle until live environments record it, and adds regression coverage and lifecycle documentation. Merge readiness✅ Ready for maintainer review Current main protects cold provisioning but still leaves the runtime-refresh retention window open. The current head addresses that window and the earlier review finding; I found no new blocking defect. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway sends connected nodes a snapshot of workspaces and worker bundles to retain. Node cleanup uses that snapshot before a later worker turn launches from the bundle named in its environment receipt. flowchart LR
A[Gateway worker build] --> C[Retention coordinator]
B[Environment receipts] --> C
C --> D[Node retain request]
D --> E[Bundle cleanup]
E --> F[Next worker turn]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +75, Docs 0. Total +85 across 4 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep bundle retention tied to live environment receipts, preserve workspace-only cleanup when build preparation fails, and retain the installer-to-launch regression. Do we have a high-confidence way to reproduce the issue? Yes, from source and the reported baseline regression: current main can acknowledge retention before the refreshed bundle has a recorded receipt. This read-only review did not run the test or a live Gateway update. Is this the best way to solve the issue? Yes. The change extends the existing retention owner across both receipt-publication windows and preserves workspace retention if build preparation fails. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 06e816331cc6. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…d-workers-refresh-bundle-retain # Conflicts: # src/gateway/worker-environments/node-workspace-retain-coordinator.ts
…ails Cloud nodes now resolve the Gateway's current build for bundle retention. If that preparation rejects, send workspace-only retention without a bundle keep set, generation acknowledgement, or status query, and warn instead of failing the whole pass. Workspace retention previously did not depend on bundle preparation for cloud nodes.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…d-workers-refresh-bundle-retain
…ssing worker bundle (openclaw#160820) * fix(cloud-workers): retain refreshed bundles until receipts record them Runtime refresh installs the Gateway's current worker bundle before it records the new bootstrap receipt. A retain pass processed by the node after that install acknowledged the new install generation while the Gateway's keep set still held only the old receipt, so the next pass pruned the refreshed bundle and the next worker launch failed with ENOENT, the same failure openclaw#160730 fixed for cold provisioning. Provisioning and refresh share one cause: both install the current build before recording it. The retain coordinator now keeps the current build on a node until every live environment there has recorded it, which completes the reachability snapshot instead of suspending retention. This replaces the provisioning-only special case from openclaw#160730. Persistent hosts keep their existing current-build pin and status target; cloud nodes keep reporting their environment receipt. The installer regression now covers both phases with the real node installer and coordinator. The runtime-refresh phase reproduces ENOENT on the previous code and also proves the previous bundle is pruned once the new receipt is recorded. * fix(cloud-workers): keep workspace retention when build preparation fails Cloud nodes now resolve the Gateway's current build for bundle retention. If that preparation rejects, send workspace-only retention without a bundle keep set, generation acknowledgement, or status query, and warn instead of failing the whole pass. Workspace retention previously did not depend on bundle preparation for cloud nodes.
Related: #160730
What Problem This Solves
Fixes: after a Gateway update, a cloud worker's first turn could fail with
ENOENT ... realpath '<node-host>/gateway-<ns>/bundles/<bundleHash>'because node cleanup deleted the worker bundle the in-place runtime refresh had just installed.User Impact
User impact: cloud machines that are refreshed in place after a Gateway update, and cold-provisioned machines, keep the newly installed worker bundle until the environment records it, so the next turn launches instead of failing with a missing bundle.
Why This Change Was Made
#160730 fixed this failure for cold provisioning and explicitly left runtime refresh open. Refresh has the same window:
provider-runtime-refresh.tsinstalls the new bundle, then records the new receipt afterwards (store.refreshBootstrapReceipt). Throughout that window the environment staysready/idle/attachedwith its old receipt.The node marks each finished install with a new generation. It protects that bundle only until the Gateway acknowledges the generation, and the Gateway acknowledges whatever generation the previous retain pass returned. A retain pass that the node queues behind the install (its per-namespace queue serializes them) returns the new generation, even though the Gateway built its keep set from the old receipt. The next pass then prunes the refreshed bundle.
This is reachable after every Gateway update. The node reconnects, and its first retain pass lands behind the refresh install. The first bundle-status acceptance on a new connection (
undefined -> installed) reschedules the same node, so a second pass races the receipt write. The 60 s placement reconcile and node inventory changes can also supply that pass during long installs.Persistent hosts were already safe because the coordinator always pins the Gateway's current build there. Environment-owned cloud nodes were deliberately excluded from that pin (#140449), so they were exposed.
Provisioning and refresh share one cause: both install the Gateway's current build (the same memoized
prepareInstallation("bundle")artifact thatbundleRetention.currentBuild()returns) before recording it. The retain coordinator now applies one rule: keep the current build on a node until every live environment there has recorded it. This completes the reachability snapshot instead of suspending retention, and it replaces the provisioning-onlybundleRetentionReadyspecial case from #160730. Pruning of other bundles continues during provisioning and refresh.If preparing the current build fails, the coordinator now sends a workspace-only retain request (no bundle keep set, generation acknowledgement or status query) and warns. Workspace retention on cloud nodes therefore still does not depend on bundle preparation; this addresses ClawSweeper's P2 on the first head.
Other behavior is unchanged:
currentBuild()when bundle retention is supported. The provider reconcile loop already prepares that artifact for every ready, idle or attached environment.Evidence
src/node-host/node-worker-bundle-installer.test.tsextends the fix(cloud-workers): retain bundles through provisioning #160730 pattern to two phases: cold provisioning and runtime refresh. It uses the real node installer, the real retain coordinator, a queued retain pass during the install, receipt recording and the real launch-path resolver.ENOENT: no such file or directory, realpath '.../gateway-test/bundles/8450792f...'. The provisioning phase passes, as expected with fix(cloud-workers): retain bundles through provisioning #160730 in place.node-worker-bundle-installer.test.ts: 27/27 pass.node-workspace-retain-coordinator.test.ts: 20/20 pass.server-worker-placement-startup-maintenance.test.ts: 7/7 pass.--maxWorkers=1, verbose reporter):node scripts/check-changed.mjson the touched files passed conflict markers, line-cap/max-lines/assertion ratchets, format, plugin boundaries, wrapper shadowing, core tsgo graph boundary and core typecheck.typecheck core testsfailed only in untouchedui/src/components/*files, because this worktree has a gateway-only install without UI packages (@panzoom/panzoom,@modelcontextprotocol/client) and resolves@types/markdown-itfrom a parent checkout.oxlintandoxfmton the touched files are clean.pnpm tsgo:core, targeted oxlint, oxfmt,git diff --checkand the touched test-graph typecheck shards pass. The new preparation-failure regression takes 40 ms and failed before the fallback.checks-node-changed-compact-large-15-2) is unrelated to this change.src/gateway/server.agent.rpc-contracts.test.tsfailed inbeforeAllGateway startup (Startup failed: required secrets are unavailable ... Shared-state worker opening path changed,STATE_DATABASE_READ_ADMISSION_INVALIDATED). The preceding file in the same Vitest worker had just retired the shared-state worker owner. This PR touches no state-database, secrets or startup code.checks-node-changed-compact-small-7-3failed insrc/cron/service.failure-alert-notifications.test.tsandsrc/cron/service.heartbeat-busy-poll.test.ts.checks-node-changed-compact-small-3-1failed insrc/infra/update-candidate-canary.test.ts(streamed candidate progress). Locally the cron suites passed and the canary failure reproduced on the merged main content, which this PR does not touch. I merged current main (clean merge, PR diff unchanged) to pick up that fix.server.agent.rpc-contracts.test.tsstartup failure did not recur on the second head. A local two-file replay in the CI order failed both Gateway suites in this gateway-only worktree install. I did not capture enough output to tell that apart from the environment, so the cause is unconfirmed and I claim no fix here.ENOENTat the installer–coordinator boundary.