Repository navigation
fix(workers): protect in-flight workspace manifests from concurrent retention - #130449
Conversation
…etention At high completion concurrency, 12/50 turns failed with 'Cloud worker finished, but its workspace result could not be reconciled' (#129979): between a worker's manifest upload and its verification, a sibling completion could trigger retention with a snapshot holding only the old base manifest — the terminal worker no longer protected the workspace, so cleanup deleted the just-uploaded manifest and verification died on ENOENT. The node workspace runtime now pins the latest transferred manifest per generation and includes it in every cleanup's reachable set (cleared with its generation), and gateway retention snapshots treat unsettled results — an active claim or a pending-result fence — as protection, which also preserves it across restarts when node-local pins are gone. Capture errors retain bounded redacted stderr so this failure class can never be faceless again. No deadlines, protocol, or completion-semantics changes; deterministic 1-turn and 50-turn reproductions fail pre-fix.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:26 PM ET / 22:26 UTC. ClawSweeper reviewWhat this changesThis PR preserves in-flight worker workspace manifests through concurrent cleanup, adds restart-safe pending-result retention, and reports bounded redacted manifest-capture failures. Merge readinessKeep open: current main still has the unprotected retention behavior, while this branch adds a coherent two-owner repair for the manifest-loss race. No concrete patch defect was found; exact-head CI and normal maintainer review remain before landing. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherA cloud worker uploads its workspace result to the Gateway, then the Gateway verifies and reconciles it into the managed worktree. Node-side retention must not delete either the transfer result or its manifest before that reconciliation has safely settled. flowchart LR
A[Completed worker turn] --> B[Workspace manifest upload]
B --> C[Node transfer pin]
B --> D[Gateway pending-result fence]
C --> E[Retention reachability]
D --> E
E --> F[Manifest verification]
F --> G[Workspace reconciliation]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +25, Tests +373, Docs +2, Other 0. Total +400 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the node transfer pin and Gateway durable-fence repair, then validate it on the rebased merge head with exact-head CI and the planned concurrent lifecycle run. Do we have a high-confidence way to reproduce the issue? Yes—source provides a deterministic one- and fifty-turn ordering harness that reproduces cleanup after upload but before verification; this review did not execute it because the checkout is read-only. Is this the best way to solve the issue? Yes—the node-local pin covers the command gap, while the durable Gateway fence covers restart after node-local state is lost; neither owner alone covers both cases. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b10beeee7c24. LabelsLabel changes:
Label justifications:
EvidenceWhat 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
|
|
Rank-up moves before landing:
|
|
Merged via squash.
|
* origin/main: (26 commits) fix(plugins): preserve registry epoch on activation rollback (#129232) refactor(plugins): make discovery invocation-owned (#130486) feat(ui): save appearance preferences per user profile (#130340) fix: Buzz bots recover relay stalls and reject revoked senders (#130467) fix(code-mode): serialize catalog handles nested in final values (#130276) fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427) fix(agents): read the published model catalog owner from session_status (#130277) fix(channels): preserve long presentation text (#130368) fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325) refactor(plugins): unify setup registration and artifact selection (#130474) fix(memory): prevent forgotten session content from returning (#130451) refactor(outbound): consolidate transport completion (#130460) fix(workers): protect in-flight workspace manifests from concurrent retention (#130449) fix(portals): keep worker previews reachable and owned by the active environment (#130434) fix(config): keep core channels keys in the generated config schema (#120736) chore(deps): refresh dependencies after seven-day cooldown (#130296) fix(agents): remind exec models to quote shell metacharacters (#125485) fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437) fix(openshell): preserve file writes during concurrent mirror commands (#130447) fix(workers): report full nodes as at capacity, not offline (#130445) ...
…etention (openclaw#130449) At high completion concurrency, 12/50 turns failed with 'Cloud worker finished, but its workspace result could not be reconciled' (openclaw#129979): between a worker's manifest upload and its verification, a sibling completion could trigger retention with a snapshot holding only the old base manifest — the terminal worker no longer protected the workspace, so cleanup deleted the just-uploaded manifest and verification died on ENOENT. The node workspace runtime now pins the latest transferred manifest per generation and includes it in every cleanup's reachable set (cleared with its generation), and gateway retention snapshots treat unsettled results — an active claim or a pending-result fence — as protection, which also preserves it across restarts when node-local pins are gone. Capture errors retain bounded redacted stderr so this failure class can never be faceless again. No deadlines, protocol, or completion-semantics changes; deterministic 1-turn and 50-turn reproductions fail pre-fix.
What Problem This Solves
In the 50-session cross-machine farm run (#129979), 12/50 turns ended with "Cloud worker finished, but its workspace result could not be reconciled" — the worker did its job and the result was silently lost, the worst failure class in this repo.
Why This Change Was Made
Root cause is a manifest-retention race. Between a worker's manifest upload and its verification, a sibling completion can trigger workspace retention with a snapshot that only knows the old base manifest. The just-finished worker no longer protects the workspace, so cleanup deletes the newly uploaded manifest, and verification fails with ENOENT at
src/gateway/worker-environments/workspace-sync-scripts.ts:301.The repair closes the race at both owners:
src/node-host/node-worker-workspace.ts) and includes it in every cleanup's reachable set; the pin is cleared with its generation.src/gateway/worker-environments/node-workspace-retain-coordinator.ts), which also covers restarts where node-local pins are gone.src/gateway/worker-environments/node-worker-workspace-fallback.ts) so this failure class can never be faceless again.No deadlines, protocol, schema, or completion semantics changed. Production delta +11 lines.
User Impact
Operators running many parallel worker sessions on one node no longer lose completed work to concurrent cleanup; capture failures that do occur carry actionable stderr.
Evidence
pnpm check:changedgreen.Part of the #129979 worker-mortality follow-up campaign. A combined live rig run with the lifecycle lane (#130446) follows before the campaign closes.