fix(mt): worktree lifecycle і mt run резолвлять головний корінь репо, не linked worktree - #20
Merged
Conversation
…nked worktree `mt worktree create|remove|list|prune` required an MT task graph (`.mt.json`/`mt/`) even though only Git access is needed, and both they and `mt run`/`mt auto` resolved the repo root via `gix::discover(cwd).workdir()` — which returns the *current* linked worktree's own root instead of the shared main root when invoked from inside a dev-worktree, silently nesting new worktrees under the one you're standing in. - worktree create|remove|list|prune no longer require .mt.json/mt/; inventory falls back to an empty task association when no task graph exists. - `mt worktree create` returns a stable JSON contract (name/branch/path) and rolls back the worktree/branch if the description step fails. - Added `GitRepository::main_worktree_root()` (via gix's `main_repo()`) and `discover_main_worktree_root()`, and wired it into worktree create/remove/list/prune, `mt check`'s stale-worktree scan, `mt run`'s ephemeral run-worktree placement, and the mt-napi worktree bindings. Co-Authored-By: Claude Sonnet 5 <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.
Summary
mt worktree create|remove|list|pruneбільше не вимагають MT task graph (.mt.json/mt/) — лише Git-репозиторій.inventoryбез графа задач повертає список worktree без task-асоціації замість помилки.mt worktree createповертає стабільний JSON contract (name/branch/path) і робить rollback щойно створеного worktree/branch, якщо крок--descriptionпровалюється.gix::discover(cwd).workdir()повертав корінь поточного linked worktree замість спільного головного репо, коли команда викликалась зсередини dev-worktree — новий worktree/run-worktree вкладався рекурсивно (.worktrees/devwork/.worktrees/...) замість того, щоб лягти поруч під головним.worktrees/. Виправлено черезGitRepository::main_worktree_root()(gixRepository::main_repo()) +discover_main_worktree_root(), підключено до:mt worktree create|remove|list|prune,mt check's stale-worktree scan,mt run/mt auto's розміщення ephemeral run-worktree,worktree_create/remove/status.plan/fact/verify/done/audit/status/scan— кожен linked worktree має власний checkoutmt/-файлів задач), лишились незмінними.Test plan
cargo test -p mt-core worktree— зеленоcargo test -p mt --test cli— зеленоcargo test --workspace— 142 тести в mt-core (+1 новий regression), усі решта — зеленоcargo fmt --all -- --check/cargo clippy --all-targets --all-features -- -D warnings— чисто.mt.json/mt/:create→ JSON зbranch: "mt/smoke"і реальним path →listзнаходить →remove --force→git worktree list --porcelain/git show-refпідтверджують повне прибиранняworktree createзсередини лінкованого worktree тепер кладе новий worktree поруч під головним.worktrees/, а не вкладеноmt run, викликаний зсередини лінкованого worktree — підтверджено, що тест ловить регресію (тимчасово повернув баг, тест почервонів)npx @7n/rules lint changelog— exit 0 (зміни лише в Rust crates поза JS/Python workspaces — changelog не потрібен за конвенцією репо)🤖 Generated with Claude Code