Skip to content

A branch's worktree path is derived from git identity and the branch name alone — the primary checkout's sibling named with -wt, then the branch with its hierarchy kept — and is the same answer from every directory of every worktree, with nothing registered or configured

Given the repository and a branch name there is exactly one path for that branch's

guaranteed Deterministic and blocking. Implemented, and a behavioural test proves it.

The identity is the common git directory and the main worktree git lists first, never the current directory, so a linked worktree does not derive a container inside itself. The branch name is validated by git's reference rules and the derived path is proved on every call to stay below the container. Every registered worktree gets a standing and every condition a stable code with a remedy; the four worktree.* capabilities project the same typed topology to MCP, HTTP, OpenAPI, the Swagger UI and the Cockpit, and the pre-commit hook asks the guard.

What it means

Given the repository and a branch name there is exactly one path for that branch's worktree — <repo>-wt/<branch>, the primary checkout's sibling named with -wt, then the branch's components as directories — and every surface computes it the same way from git's own identity. No file, section, table or list records it, and adding a branch edits nothing.

How it works

RepositoryIdentity::discover reads git rev-parse --git-common-dir and git worktree list --porcelain; the first record is the primary checkout, whatever directory the command ran in. path::container_root appends the suffix to its name; path::expected_path joins the validated branch name and proves the result stays strictly below the container. WorktreeService::judge gives every registered worktree a standing — primary, canonical, misplaced, detached, ephemeral, missing — and every condition a DiagnosticCode with a remedy. The four worktree.* capabilities project the typed RepositoryTopology; the command line renders it; worktree guard decides for the pre-commit hook.

How to see it

majordomus worktree path feature/providers/streaming   # <repo>-wt/feature/providers/streaming
cd "$(majordomus worktree root)"/feature/x && majordomus worktree root   # the same container
majordomus worktree topology --format json | jq .worktrees[].standing

What it does not cover

A git hook is bypassed with --no-verify, and a CI runner cannot see a contributor's local directories: the gate holds the rule's machinery together, not this machine's filesystem. Bare repositories are refused by name.

Why it exists

Fifty-three worktrees in four shapes, eleven of them dirty, and no answer to "where is branch X" that did not involve looking or inventing. ADR 21 records the decision.

Detail rendered from docs/claims/worktree-topology-derived.md.

Provenance

defined in
read it on this site · docs/WORKTREES.md
implemented in
apps/majordomus-cli/src/worktree/path.rs
proved by
test/cases/96_worktree_topology.sh
claim id
worktree-topology-derived

Verify it yourself

The test runs in a disposable temporary repository and asserts the behaviour, not a string in the source.

from a clone of the repository
bash test/run.sh 96_worktree_topology

Where this claim is used

The moments this answers