Skip to content

feat(workspace): adopt existing local worktrees safely - #120

Merged
morluto merged 7 commits into
mainfrom
feature/adopt-external-worktree
Jul 23, 2026
Merged

feat(workspace): adopt existing local worktrees safely#120
morluto merged 7 commits into
mainfrom
feature/adopt-external-worktree

Conversation

@morluto

@morluto morluto commented Jul 23, 2026

Copy link
Copy Markdown
Owner

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

  1. internal/workspace/adopt.go for adoption and per-operation identity revalidation.
  2. internal/corpus/workflow.go for atomic path binding.
  3. internal/app/workspace.go for repository/investigation ownership.
  4. CLI/MCP wiring and security/regression tests.

Testing

  • make verify
  • make test-race
  • Regression coverage for idempotent adoption, concurrent binding, mismatched remotes, non-root paths, replaced paths, ownership reporting, and external-worktree inspection

Compatibility and scope

  • Storage and side-effect invariants remain intact
  • No unrelated cleanup or generated-output churn is included

Managed workspace behavior is unchanged. No adopted path is deleted, fetched, checked out, or otherwise mutated by adoption.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto force-pushed the feature/adopt-external-worktree branch 2 times, most recently from bc39945 to ab4bbbd Compare July 23, 2026 06:52
@morluto
morluto force-pushed the feature/adopt-external-worktree branch from 8de3325 to 45e6043 Compare July 23, 2026 07:01
@morluto
morluto merged commit 9faac44 into main Jul 23, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Adopt existing local Git worktrees into contribution investigations

1 participant