feat(workspace): adopt existing local worktrees safely - #120
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
morluto
force-pushed
the
feature/adopt-external-worktree
branch
2 times, most recently
from
July 23, 2026 06:52
bc39945 to
ab4bbbd
Compare
morluto
force-pushed
the
feature/adopt-external-worktree
branch
from
July 23, 2026 07:01
8de3325 to
45e6043
Compare
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.
Description
Contribution investigations could only create GitContribute-owned worktrees. Reusing an existing checkout required cloning again or bypassing workspace identity and ownership checks.
This adds explicit adoption for existing local Git worktrees. Adoption canonicalizes the path, verifies it is the exact worktree root, records Git administrative identities and base/head/merge-base revisions, checks the GitHub origin against the investigation repository, and atomically prevents one external path from being assigned to conflicting workspace records.
External ownership is preserved as a first-class invariant: GitContribute may inspect adopted worktrees but never treats them as removable managed files. Every later status, diff, merge, validation, and contribution operation revalidates the canonical path plus Git dir/common-dir identity before running Git, preventing a replaced or retargeted path from inheriting prior authority.
CLI and MCP expose adoption as a local-write/process capability with no network access. Repeated adoption of the same path is idempotent when the investigation and requested identity agree.
Closes #117.
Suggested review order
internal/workspace/adopt.gofor adoption and per-operation identity revalidation.internal/corpus/workflow.gofor atomic path binding.internal/app/workspace.gofor repository/investigation ownership.Testing
make verifymake test-raceCompatibility and scope
Managed workspace behavior is unchanged. No adopted path is deleted, fetched, checked out, or otherwise mutated by adoption.