Repository navigation
fix(workers): retain repository commits across reclaim - #182387
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a452d7dae9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| gitHistoryNote = await restoreWorkerWorkspaceHistory({ | ||
| root: params.workspaceDir, | ||
| gitHistory: params.transfer.checkpointGitHistory, | ||
| gitPackPath, | ||
| assertCurrent: () => params.signal?.throwIfAborted(), |
There was a problem hiding this comment.
Bind the replacement repository branch before adopting history
For replacement workers and forks without source.prepared, checkoutAndCapture() explicitly runs git checkout --detach --force, and syncRepository() never binds source.branch before this restoration call. Consequently, restoreWorkerWorkspaceHistory() reaches adoptWorkerWorkspaceHistory() with detached HEAD and returns “the Gateway checkout has no managed branch” instead of adopting the retained commits (git symbolic-ref -h identifies detached refs as “non-symbolic”). Files are restored, but HEAD remains at the pinned base; a subsequent checkpoint can then replace the retained history with that base-only state. Bind the session's managed branch before restoring its Git history.
Useful? React with 👍 / 👎.
|
Codex review: blocked before merge. What this changesThis PR retains bounded worker Git history in repository checkpoints and restores it on replacement workers, forks, and Gateway moves. Example: A worker commits hello.txt containing "committed\n", then appends "dirty\n" before Stop.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this owner-approved change addresses repository-session history loss, but the restore pack can collide with valid workspace paths. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherWorker uploads enter the Gateway checkpoint owner as file manifests and bounded Git packs; checkpoint restoration fetches the upstream base, restores files, and safely advances the managed branch. flowchart LR
A[Worker repository] --> B[Native workspace transfer]
B --> C[Repository checkpoint]
C --> D[Replacement worker or Gateway move]
D --> E[Pinned upstream base]
E --> F[Git import and branch adoption]
F --> G[Commits and dirty files]
Technical reviewBest possible solution: Keep bounded history in the existing checkpoint owner and download restore packs into a separately owned temporary location outside workspace paths. Do we have a high-confidence way to reproduce the issue? Current main's repository upload and checkpoint handoff omit worker history, establishing the loss path from source; this read-only review ran no target code. Is this the best way to solve the issue? Reusing bounded export, immutable checkpoints, strict import, and compare-and-swap adoption is appropriate; transport artifacts must remain outside manifest-controlled paths. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a834a45b2689. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +417, Tests +207, Docs 0. Total +624 across 27 files. Added test files: 1. View PR surface stats
Review metrics
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 24, 2026, 4:24 AM ET / 08:24 UTC. |
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
Follow-up to #182140.
What Problem This Solves
Repository-session reclaim kept file contents but silently discarded unpushed worker commits, even after the Gateway-source fix in #182140.
User Impact
Repository checkpoints now retain bounded worker Git deltas. Replacement workers, forks, and Gateway materialization restore those commits onto the fetched pinned base while preserving dirty files. Missing, oversized, non-descending, or unavailable history preserves file recovery and records why commits were not adopted. A moved branch is never force-updated.
The compact-store contract stays intact: upstream history and unchanged base files are not stored in the Gateway's bare artifact repository. Restoration still requires access to the pinned upstream base. No configuration or database migration is needed.
Why This Change Was Made
Repository uploads skipped Git-history negotiation and the checkpoint handoff dropped the history payload. Reclaim also skipped repository workspaces entirely. The existing bounded exporter and strict importer now serve this path: checkpoints retain the delta as an opaque Git blob in a synthetic parent, so Git garbage collection and checkpoint lifetime already own it. Restore fetches the base first, verifies ancestry, and uses the existing compare-and-swap branch/index adoption policy. Publication retains its separate commit ownership.
The change also extracts existing HTTP download and repository restore code into their owning modules to keep the modified files within their size limits. Production: +665/-248 lines (net +417); tests: +209/-3. The added production code owns opaque retention, restoration transport, and visible failure outcomes; it adds no new state store or exporter.
Evidence
73c77aa3f99: repository reclaim/restore regression returned the base instead of the worker commit; 85.45 s command wall.pnpm test src/gateway/worker-environments/workspace-result-repository-history.test.ts --maxWorkers=1: 6/6 passed, 65.59 s command wall. Its 41 s of test work exercises real Git, native HTTP transfer, SQLite custody, reclaim, and restart/fork.pnpm run tsgo:core: passed, 4.55 s wall. Changed-fileoxfmt --checkpassed. Type-awarenode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed TypeScript files>andgit diff --checkpassed.gateway-database-workersproject but out of lexical order ingatewayDatabaseWorkerTestFiles. This caused all eight CLI ownership failures inchecks-node-compact-small-2; local reproduction: 8 failed, 2 passed, 28.72 s wall. Moved the single entry into order without changing membership or assertions.OPENCLAW_VITEST_RUNTIME=node pnpm test test/vitest-cli-ownership.test.ts test/vitest-projects-config.test.ts --maxWorkers=1: 42/42 passed, 141.67 s command wall. Changed-file formatting, type-aware lint, whitespace checks, and independent review passed. The initial CI run settled with no other failing test jobs; both red CI gates reflected this ownership failure. CI for the follow-up head is pending.