Repository navigation
fix(workers): preserve cloud commits on reclaim - #182140
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: blocked before merge. What this changesThis PR transfers worker Git history and adopts safe fast-forward commits when reclaiming Gateway-source worktrees. Example: A worker commits tracked.txt with content "worker change", then leaves an additional uncommitted edit.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this maintainer-approved capability addresses lost worker history, but the patch introduces a reconciliation failure for oversized history and breaks the extracted PR wrapper. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherCloud-worker transfers deliver workspace snapshots to Gateway staging; reconciliation preserves files, and reclaim optionally imports retained commits into the managed branch before worker teardown. flowchart LR
A[Worker Git workspace] --> B[Native HTTP or SSH transfer]
B --> C[Gateway staged result and Git objects]
C --> D[File reconciliation]
D --> E[Reclaim ancestry and index checks]
E --> F[Managed branch and transcript]
Technical reviewBest possible solution: Retain history through the existing staging and reclaim owners, preserve file recovery when history exceeds its bound, and include the wrapper’s new runtime dependency. Do we have a high-confidence way to reproduce the issue? Current main’s staging and lifecycle documentation establish file-only reclaim, and the linked issue records a live worker commit returning as file changes; this review ran no target code. Is this the best way to solve the issue? Bounded ancestry-verified transfer and compare-and-swap adoption fit the existing owners, but optional history retention must not prevent otherwise valid file recovery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9cf739b6c0da. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +645, Tests +704, Docs +4. Total +1353 across 44 files. Added test files: 3. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
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 Reviewed October 23, 2026, 11:21 PM ET / October 24, 2026, 03:21 UTC. |
# Conflicts: # test/vitest/vitest.gateway-server-paths.mjs
#182140 carried worker commits back on reclaim, but repository sessions never used it: their upload and checkpoint handoff did not request Git history, the Gateway's compact bare store deliberately holds no upstream history (so it lacks the base the worker's delta pack builds on), and adoption returned silently. Repository sessions now capture the worker's bounded, strictly verified delta pack and retain it as an opaque object with the existing checkpoint; restore, restart, fork and Gateway materialization fetch the pinned base as before, import the delta, verify ancestry, and put the managed branch at the worker head when the base is unchanged. Commits that cannot be retained (oversize, missing history, non-descending) now record the visible not-adopted note instead of disappearing. The store still keeps no upstream history. Live: on main a worker commit in an octocat/Hello-World session vanished after reclaim (parentless result commits only); with this change the checkpoint records base 7fd1a60 -> head 7cf381c and the next turn, restored onto a fresh AWS worker, showed git log '7cf381c cloudmatrix proof1024b-repo-aws' on top of '7fd1a60 Merge pull request #6'. Refs #110498 #182140.
Commits a cloud worker made in its workspace were lost when the environment was reclaimed: only the working-tree result came back, so worker-authored history disappeared. Reclaim now carries the worker's commits back as a bounded, verified Git pack (index-pack --strict, 256 MiB cap enforced at each stage) and adopts them into the local result history with a compare-and-swap update-ref against the recorded base commit, only when the local branch has not moved and after a dry-run merge proves the result applies. Divergent or oversized results stay visible as the existing workspace-result outcome instead of overwriting local work. Also fixes the full-suite ownership audit, which counted the opt-in control-UI retention probe that landed on main as an unowned test file.
openclaw#182140 carried worker commits back on reclaim, but repository sessions never used it: their upload and checkpoint handoff did not request Git history, the Gateway's compact bare store deliberately holds no upstream history (so it lacks the base the worker's delta pack builds on), and adoption returned silently. Repository sessions now capture the worker's bounded, strictly verified delta pack and retain it as an opaque object with the existing checkpoint; restore, restart, fork and Gateway materialization fetch the pinned base as before, import the delta, verify ancestry, and put the managed branch at the worker head when the base is unchanged. Commits that cannot be retained (oversize, missing history, non-descending) now record the visible not-adopted note instead of disappearing. The store still keeps no upstream history. Live: on main a worker commit in an octocat/Hello-World session vanished after reclaim (parentless result commits only); with this change the checkpoint records base 7fd1a60 -> head 7cf381c and the next turn, restored onto a fresh AWS worker, showed git log '7cf381c cloudmatrix proof1024b-repo-aws' on top of '7fd1a60 Merge pull request openclaw#6'. Refs openclaw#110498 openclaw#182140.
Fixes #110498
What Problem This Solves
Reclaiming a cloud worker currently keeps its files but drops unpushed worker-authored commits.
User Impact
Stop and reclaim now preserve worker commits in Gateway-source managed worktrees when they can fast-forward safely. Dirty working files and unrelated staged changes survive. Divergent worker history, a moved Gateway branch, or conflicting staged changes keep file reconciliation and produce a visible transcript note. Older workers and Gateways retain v1 behavior; repository-only restoration and publication behavior are unchanged.
Why This Change Was Made
Capability-negotiated result upload v2 carries worker HEAD, ancestry metadata, and a Git pack capped at 256 MiB. The existing staged result retains the imported history until reclaim verifies ancestry and advances the branch with an expected-old-value ref update. A two-tree index merge preserves staged-only content. Ordinary turn reconciliation and recovery remain file-only.
The change stays within the existing transfer, staging, and reclaim owners. Both native and SSH transports use the same history capture and adoption policy. Production: +708/-59 lines; tests: +707/-5; docs: +6/-2. The necessary growth covers negotiated transport and reclaim together, without adding a state store.
Evidence
Final validation used Node 24.22.1 with
OPENCLAW_VITEST_RUNTIME=nodeand--maxWorkers=1.Second CI follow-up: the ownership failure names
scripts/control-ui-retention/dependency-retention.test.ts, introduced on main by0076083eba1(fix(ui): release disposed settings and Workboard views #182101). It belongs to the documented opt-in retention census, so the normal full-suite audit now excludes that directory. The three worker tests added by this PR already have exactly one owner; their registrations are unchanged.Ownership reproduction on main
6f323c428768: failed with that exact missing file in 21.27 s. Applying only the two-line census exclusion made the same audit pass in 21.43 s. Fullpnpm test test/vitest-projects-config.test.ts --maxWorkers=1on the fixed PR branch: 32/32 passed, 97.32 s wall.Lifecycle CI diagnosis: the failed assertion is
workerNode.publishInventory()at line 834; the precedingrecoveryErrorassertion passed. The requested unchanged lifecycle case passes under Node 24.22.1 on both main6f323c428768(587.41 s command wall, 217.49 s test) and PR85e012d0d744(633.50 s command wall, 249.81 s test). Command times include fresh isolated runtime builds; one unrelated case was filtered out in each run. The CI log used Bun. Its inventory-publication rejection failure was not reproduced in these Node runs, so no worker production code or lifecycle expectations were changed; that CI failure remains unverified rather than claimed fixed.Second follow-up checks:
oxfmt --check, type-awarenode scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json test/vitest-projects-config.test-support.ts,pnpm run tsgo:core(10.00 s wall),git diff --check, and independent review all passed. Follow-up scope: two added test-helper lines, no production changes.CI follow-up: reproduced the missing transfer-protocol dependency in the trusted PR-wrapper closure, then moved the v2 constant and shared history schema into existing inventory owners.
scripts/pr-lib/wrapper-components.txtis unchanged.Follow-up
pnpm test test/scripts/eager-import-closure.test.ts --maxWorkers=1: 19/19 passed, 144.33 s wall, including both previously failing wrapper extraction checks. The pre-fix inventory regression failed as expected in 27.65 s.Follow-up inventory, connection, real native v1/v2 HTTP transfer, negotiation, upload-reader, tunnel, Git-history and SSH tests: 117 passed, 1 existing platform skip, 291.27 s wall across 8 files. Format, type-aware lint,
tsgo:core(6.00 s) and independent review passed.pnpm test workspace-result-history.test.ts placement-reclaim-history.test.ts: 8 passed, 323.08 s wall. Covers retained ancestry through Git GC, adoption, dirty edits, staged-only content, moved/divergent fallback, and empty commits.Focused transport/reconciliation/recovery run: 197 passed, 1 existing platform skip, 508.90 s wall. Its sole failure was the new SSH status assertion encountering deliberately invalid submodule metadata in the fixture. Scoped that assertion to ignore submodule status;
pnpm test src/gateway/worker-environments/workspace-sync-tunnel.test.ts --maxWorkers=1then passed 11/11, 48.64 s wall, including the 1,800-file round trip.That focused run included
node-worker-transfer-client.git,connection,node-worker-result-negotiation,node-workspace-upload-reader,placement-dispatch-reclaim,placement-reclaim-history,worker-workspace-recovery-transcript,workspace-reconcile,workspace-result-staging.reads,workspace-local-reconciliation,node-worker-tunnel, andnode-worker-tunnel.device-folder. It proves real v1/v2 HTTP uploads, pack bounds, visible notes, and all three lifecycle cases: direct reclaim and reclaim recovery adopt before destruction; ordinary recovery leaves HEAD unchanged.Red-on-base proof at
094bbd6b153: the new reclaim lifecycle regression fails at the pre-destroy HEAD assertion, 308.33 s wall. The fixed lifecycle cases pass.Changed-file
oxfmt --check, type-awarenode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json,pnpm run tsgo:core(5.91 s final wall), andgit diff --checkpassed.An earlier default-runtime Bun attempt hit the 60-second large-workspace timeout and a large-upload worker heap limit before being interrupted. Both cases passed under the required Node runtime; that preliminary attempt is not counted as final validation.
Independent Codex review: no actionable P0–P2 findings after repairs. No live cloud/model E2E was run; PR CI supplies broad proof.