Repository navigation
fix: restore managed worktrees from bare primary repositories - #208922
Conversation
Managed worktrees created from a linked checkout record its primary repository. Resolve that registration during inspection, removal, and snapshot restore while keeping new checkout creation strict.
* commit 'c5c1dc278a6f789d739d70afe192c4d1e37058f5': (64 commits) fix(ci): include provider rejection text in PR tooling (#208891) feat: let plugins bring their own sidebar icon (#208885) docs: clarify node pairing and credentials on PostgreSQL gateways (#208850) fix(ui): show a confirmed subagent stop once in chat (#208533) fix(ui): keep collapsed work close to the reply in long chats (#207843) fix(update): finish failed recovery startup records (#208794) chore(ci): inventory media worker lifecycles (#208888) fix: use the same clock icon for Automations (#208539) improve(ci): reduce compiler round trips in database checks (#208878) fix(ci): preserve complete adaptive test observations (#208874) test(gateway): isolate usage context database fixtures (#208304) fix: avoid false worker cleanup failures (#208861) fix: let Git upgrade acceptance fetch its missing baseline (#208746) fix: isolate scheduled Processes reads in the Control UI config-change test (#208205) fix: make plugin hash worker tests independent of runner memory (#208860) fix(update): preserve serving state during candidate plugin maintenance (#208776) test(ui): preserve exact session keys in older chat links (#208873) docs(cli): say what bounds a yielded agent turn's subagent wait without --timeout (#208858) test(ui): keep real exports in the channel settings distribution mock (#208855) test(normalization): preserve inline code in quoted previews (#208857) ...
|
🦞👀 ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
Codex review: passed. What this changesThis PR lets managed-worktree recovery resolve a recorded bare primary repository while keeping creation restricted to checkouts. Example: Create a managed worktree from a linked checkout of remote.git and change README.md to "retained edits\n".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored draft open: it repairs a current repository-resolution mismatch, and no actionable patch defect was found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe managed-worktree service translates checkout paths and stored repository bindings into Git identities used by creation, cleanup, prewarming, and snapshot recovery. flowchart TD
A[Source checkout] --> B[Strict creation resolver]
B --> C[Managed worktree registry]
C --> D[Registered repository resolver]
D --> E[Git primary and common directory]
E --> F[Cleanup and snapshot recovery]
Technical reviewBest possible solution: Use the existing repository-path owner to distinguish creation sources from recorded recovery repositories while preserving identity checks. Do we have a high-confidence way to reproduce the issue? The producer stores Git's primary root, and current-main recovery passes that root through checkout-only validation; the added real-Git fixture targets this exact path, but no reproduction was executed during this read-only review. Is this the best way to solve the issue? The change addresses the shared resolution boundary, updates its registered-path consumers, and preserves strict creation validation without adding state or another identity owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 122cac7d494f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +26, Tests +19. Total +45 across 8 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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 November 30, 2026, 2:04 AM ET / 07:04 UTC. |
|
Merged via squash.
|
What Problem This Solves
When a managed worktree is created from a linked checkout of a bare Git repository, OpenClaw records the bare primary repository as its owner. Cleanup and restore later try to open that recorded path as a checkout. Git rejects it, so a valid worktree can be preserved as a cleanup failure and its snapshot cannot be restored through the same path.
User Impact
Managed worktrees created from these linked checkouts can use the normal removal and snapshot restoration flows. The original registered repository and its fingerprint still have to match where those flows require them.
Why This Change Was Made
Git distinguishes the checkout used to create a worktree from the primary repository that owns it. Resolve stored paths as bare repositories only when the real path equals both Git's primary registration and its common directory. Other registered paths still go through checkout and HEAD validation. Worktree creation continues to require a checkout.
Evidence
git diff --checkpassed. The Ubuntu service-test job passed onf19a2a3dea2. The bare-primary recovery regression passed in 5.2 seconds. CI for the published head passed. Its build-artifacts job was skipped. The published revision passed a separatepnpm run build:ci-artifactsbuild and all 22 canonical-path service tests on macOS.