Repository navigation
feat: configure a global managed worktree storage root - #134872
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed September 1, 2026, 3:16 AM ET / 07:16 UTC. ClawSweeper reviewWhat this changesThe PR adds a global Merge readinessKeep open: the current head fixes the earlier live-record nested-root case, but a former nested custom root becomes unprotected after its 30-day snapshot record is pruned, allowing a later default-root orphan sweep to delete unrelated contents. Priority: P0 Review scores
Verification
How this fits togetherManaged worktrees create isolated Git checkouts for manual commands, sessions, and Workboard work. The shared service reads Gateway configuration, records each checkout in the state database, and later restores or garbage-collects registered worktrees. flowchart LR
A[Gateway configuration] --> B[Managed worktree service]
C[Manual session and Workboard requests] --> B
B --> D[Checkout path selection]
D --> E[Git worktree]
B --> F[Shared state registry]
F --> G[Restore and cleanup]
E --> G
Decision needed
Why: The PR explicitly tests nested-root support, but the advertised unregistered-content safety guarantee cannot survive record retention expiry with the present model. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +43, Tests +215, Docs +35, Generated 0. Total +293 across 19 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the cleanup boundary by rejecting configured roots inside the default managed-worktree directory, or define and retain a durable ownership marker that keeps every former nested custom root out of default orphan reconciliation. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: configure a root beneath the default root, remove its registered worktree, advance beyond the 30-day retention window, then run GC twice after changing the setting. Is this the best way to solve the issue? No: root selection belongs in the shared service, but protection based only on retained records cannot uphold the custom-root cleanup contract after retention expiry. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d1c9e4880b22. LabelsLabel 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
HistoryReview history (2 earlier review cycles)
|
|
Maintainer decision confirmed: the approved contract is one top-level global Both ClawSweeper rank-up moves are addressed. Commit 13e3b046d9d clarifies bare |
|
The release-inventory overflow is now fixed on main by #134824 (merge eaaa6da). This PR was rebased over that landed fix; git range-diff confirms all four feature/test/documentation patches are unchanged. Required checks are running on head 8f40daa before native landing. No changes were made to #134824's branch. |
13e3b04 to
8f40daa
Compare
|
Addressed the P1 nested-root orphan-cleanup finding in d02b4ad. The scanner now protects canonical overlaps with both the configured root and roots retained by registry records, so changing the setting does not expose existing checkouts. Default-root debris cleanup remains covered. Before the repair, all three new cases failed: nested, deeper nested, and symlinked roots. Afterward, all 36 configured-root, orphan, and GC tests pass. The real CLI source entry also passed creation in a symlinked deep root, GC before/after a root change, preserved unsnapshotted edits and unrelated files, live registry retention, and remove/restore. The prior built CLI plus real Gateway lifecycle proof still covers the complete feature. Independent Codex autoreview is scoped-clean at the configured P0 threshold. The global option approval remains recorded above. Both the earlier bare-home documentation move and the new nested-root safety move are resolved. Required CI is running on the new head: 33479926104. The preceding run's sole test failure was an unrelated Doctor source-startup readiness timeout; it is being independently investigated, without weakening its deadline or modifying another writer's branch. |
|
Verified the feature and lifecycle behavior for head The shared managed-worktree service owns the global root. Existing registry paths remain authoritative for reuse/removal/restore; names remain repository-scoped across roots. Custom-root cleanup leaves unrelated folders alone. Removed the old parent-walking cleanup helper and unused registry path lookup. Production +102/-59 (net +43), tests/test support +221/-6. The one added config option is explicitly approved, defaults unchanged, and requires no SQLite migration. Local verification: pnpm build
node scripts/check-changed.mjs
node --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts
node scripts/run-vitest.mjs src/agents/worktrees/service.configured-root.test.ts src/agents/worktrees/service.canonical-paths.test.ts src/agents/worktrees/service.naming.test.ts src/agents/worktrees/service.orphans.test.ts src/agents/worktrees/service.capacity.test.ts src/config/zod-schema.worktree-root.test.ts src/config/normalize-paths.test.ts src/config/schema.hints.test.ts src/config/schema.help.quality.test.ts
node scripts/run-vitest.mjs src/agents/worktrees/service.configured-root.test.ts src/agents/worktrees/service.gc.test.ts
node scripts/run-vitest.mjs src/agents/worktrees/registry.test.tsAll gate components passed. The dead-export gate initially found the obsolete lookup, which was removed and the gate rerun to green. A regression test initially used the pre-restore idle timestamp; it was corrected to the actual recorded timestamp and the configured-root plus GC suites passed. Independent Codex autoreview passed for the feature and subsequent deletion-only cleanup at the configured P0 threshold. The built CLI and an isolated real Gateway passed this sequence using synthetic local Git repositories:
All assertions passed. No external provider was invoked; no production Gateway was changed. Documentation includes the setting, default, global scope, retained old paths, and cleanup ownership boundary. Native review artifacts validate with no findings. CI run 33473773081 exposed a stale session-fixture config snapshot: real IO could pin an incomplete roster before the fixture published reply runtimes. The fixture now clears that snapshot before forced publication, keeping production ownership enforcement intact. The full session test file ( Both ClawSweeper rank-up moves are addressed: bare The later P1 nested-root GC finding is fixed by canonical overlap protection for configured and recorded roots. Three nested/deep/symlink regressions fail before repair and all 36 owner/sibling tests pass afterward. Real CLI source execution preserves live dirty worktrees and unrelated files before/after changing roots, then removes/restores the original snapshot successfully. Proof response: #134872 (comment). Final exact-head CI is green: 33479926104, completed successfully for |
|
Merged via squash.
|
* feat: configure a global managed worktree storage root * refactor: remove obsolete managed worktree path lookup * test: refresh session fixture config before runtime publication * docs: clarify bare home directory worktree roots * fix: protect nested worktree roots during orphan cleanup
Closes #134848
What Problem This Solves
Operators could not place managed worktree checkouts on another disk without relocating the rest of their OpenClaw state. Large repositories can exhaust the disk holding the Gateway state directory.
Why This Change Was Made
Add the approved top-level
worktreeRootoption, defaulting to<state-dir>/worktrees. Accept absolute host paths, bare~, and~/expansion. The shared managed-worktree service owns this setting for manual, session, and Workboard allocations, with no per-agent override.Changing the root affects new allocations. Existing records retain their absolute paths for reuse, removal, and snapshot restore, even when the new allocation root is unavailable. Repository-scoped names remain unique across roots. Custom-root cleanup acts only on registered worktrees and leaves unrelated folders alone. Default orphan scanning excludes overlapping custom roots, including nested roots and symlink aliases; recorded roots remain protected after changing the setting.
The shared SQLite registry, allocation lease, capacity limits, and snapshot storage stay unchanged; no schema migration or automatic checkout move is introduced. Types, validation, normalization, configuration help, generated baselines, and operator documentation are aligned. The retired
worktreesnamespace remains invalid.User Impact
Set
worktreeRootto a writable directory on the Gateway host to store all new managed worktrees there. Existing installations keep their default behavior. Existing worktrees remain usable at their recorded locations, so their original storage must remain available until those records are no longer needed.Release note: Managed worktrees can now use a global custom storage root while preserving existing checkout paths and restore behavior.
Evidence
pnpm buildpasses. Changed-file gates pass, including core/test type checks and the dead-export scan (the latter identified and verified removal of one obsolete helper).tbx_01m1dqwys3hvcn29zsq25y419r(exit 0; lease stopped). Production dispatch ownership is unchanged.Production LOC: +102/-59 (net +43), providing the new config capability and path-independent lifecycle behavior while deleting the old parent-pruning and obsolete path-lookup helpers. Tests/test support: +221/-6. Documentation/generated metadata: +42/-7. Generated channel/plugin baseline hashes also refresh to their existing metadata; their config counts are unchanged, while the core count increases by one.