Repository navigation
refactor(adapters): the state directory has one map and one forgiving read - #93
Merged
Merged
Conversation
… read `git.ts` derived the clone path, the checkout path, the session branch and the pull ref twice: once where a worktree is cut and once where one is taken away. The second copy exists because the first one fetches, and nothing that removes a directory may fetch first. Naming the four in `store.ts` keeps that rule and takes the copy away, and it puts them beside the walk that reads the same layout back off the disk. The forgiving read of the tool's own records was written seven times, each under its own paragraph saying the same thing about a cache. `remembered` states it once, and each record keeps only what forgetting it costs there. `weigh` and `inventory` fold a directory's entries the same way over different sets, so the fold is one function and both still walk what they walked. 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.
src/adapters/git.tsderives the clone path, the checkout path, the session branch and the pull ref in two places: once inwhereToCut, which cuts a worktree, and once inholding, which is asked before one is taken away. The second copy is not an oversight —whereToCutclones and fetches, and nothing that removes a directory may fetch first, or a machine that is offline is told its work is gone. Naming those four insrc/adapters/store.tskeeps that rule and takes the copy away, and it puts them beside the walk that already reads the same layout back off the disk.What changes
src/adapters/store.ts—cloneAt,cutAt,sessionBranchandpullRefare the map, andclonesOfparses it back through the same.gitsuffix. None of them reaches the network.src/adapters/store.ts—rememberedstates the state-directory bargain once: a record this version cannot read is forgotten rather than fatal (ADR 0010). The seven reads that each restated it keep only what forgetting costs them.src/adapters/store.ts—weighandinventoryfold a directory's entries the same way over different sets, so the fold is one function; both still walk what they walked, one recursively and one not.src/adapters/git.ts— reads the map instead of joining paths of its own, and drops back under 500 lines.Test plan
pnpm check— pass (51 files, 695 tests)Risk
Nothing on disk moves — the same paths, the same branch names, the same refs, the same keys — so a state directory written before this reads the same after it. If a path were wrong,
dw-mc fixwould cut a second worktree beside the standing one rather than reuse it;src/adapters/git.test.tsandsrc/cli/uninstall.test.tsdrive both sides of the map and are unchanged.Closes #86
🤖 Generated with Claude Code