feat(worktree): let slot worktrees be collected under a configured root - #64
Open
msabel-lang wants to merge 1 commit into
Open
feat(worktree): let slot worktrees be collected under a configured root#64msabel-lang wants to merge 1 commit into
msabel-lang wants to merge 1 commit into
Conversation
Slot worktrees are cut as siblings of the repo, `../<repo>-spar-<run>-<slot>`. That keeps them next to the thing they belong to, but it also means every run scatters directories into whatever holds the project — which for a machine that keeps its repos in one place is the same directory the user reads every day, and already shares with unrelated worktrees. Add `worktree.root`. Unset, nothing changes: the sibling path is still the default and the existing `path_shape` test still pins it. Set, runs are collected at `<root>/<repo>/<run>-<slot>`, so a project's parent stays clean and every worktree spar owns has one place to be inspected, and one place to be swept. `worktree_path` takes the root as an argument rather than reading config itself. Resolving it inside would make a path helper depend on ambient user config, and its own tests would then pass or fail based on whether the machine running them happens to have the setting — which is exactly the trap `path_shape` would fall into. The two production call sites already hold the run's config, so the caller resolves it via `worktree_root` and the helper stays a pure function of its arguments. Read through the run's config snapshot, so a run keeps the root it was created with. Moving the setting mid-run would otherwise strand worktrees already on disk, and the recovery path in `prepare_isolation` would not find them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optional, and off by default — unlike #62 and #63, this is a feature request rather than a bug, so ignore it freely if the sibling layout is a deliberate call.
Slot worktrees are cut as siblings of the repo,
../<repo>-spar-<run>-<slot>. That keeps them next to the thing they belong to, which is a reasonable default. But on a box that keeps all its repos in one directory, every run scatters directories into the folder the user reads every day — and in my case one that already held 22 unrelated git worktrees.worktree.rootmakes that a choice:Unset, nothing changes — the sibling path is still the default and the existing
path_shapetest still pins it. Set, every worktree spar owns has one place to be inspected and one place to be swept, andrm -rfon it is never dangerous.Design note
worktree_pathtakes the root as an argument rather than reading config itself.My first cut resolved it inside the function via
Config::for_run. That was wrong: it made a path helper depend on ambient user config, sopath_shapewould pass or fail based on whether the machine running it happened to have the setting — the exact trap #62 is about. The two production call sites already hold the run's config, so the caller resolves it viaworktree_rootand the helper stays a pure function of its arguments. Costs a few more edits; keeps the tests hermetic.It's read through the run's config snapshot, so a run keeps the root it was created with. Moving the setting mid-run would otherwise strand worktrees already on disk and the recovery path in
prepare_isolationwouldn't find them.Dry-run is unaffected — it never calls
create_worktree, it makes ephemeral cwds under.spar/runs/<id>/.Verified
Three new unit tests (configured root, unset default,
~expansion), plus a live run on a real project: worktrees landed at<root>/<repo>/<run>-<slot>with nothing beside the repo. Full suite 463 passed, 0 failed.