Metagit Agent Coordination Layer (ACL)
Use when more than one agent may edit the same repository, or when an
orchestrator must give each agent an exclusive checkout.
Full reference: docs/reference/agent-coordination.md
Task graphs (metagit task …) can store ACL command hints on nodes via
metagit task bind-acl without running git — see
docs/reference/task-graph.md.
Merge orchestration (metagit merge …) records conflicts with ACL command
hints only; it does not allocate branches or worktrees automatically.
The agent scheduler (metagit schedule next) scores ready task nodes and
returns dispatch hints without launching models or mutating git — see
docs/reference/agent-scheduler.md.
For a composed operator snapshot and next-work envelope across ACL + task
graph + optional 0009–0012, use skill metagit-aos
(metagit aos|coord status|doctor|next) — see
docs/reference/aos.md.
When to use
- Dispatching parallel subagents on the same repo
handoff.acl_commands appears in metagit agent dispatch-plan
- Preventing two agents from sharing a working directory
- Declaring intended file paths before coding (advisory claims)
- Cleaning up expired leases / orphan worktrees
Do not confuse with handoff leases
| Concept |
Command |
Owns |
| Handoff claim TTL |
metagit context handoff claim --ttl |
Task-queue row |
| ACL branch lease |
metagit lease acquire |
agent/* branch |
Happy path
export METAGIT_AGENT_MODE=true
# 1. Allocate an exclusive agent branch
metagit branch allocate \
--repository project/repo \
--agent-id agent-1 \
--task-id 412 \
--description auth \
--json
# 2. Lease it (default TTL 30m; renew while working)
metagit lease acquire \
--repository project/repo \
--agent-id agent-1 \
--task-id 412 \
--allocate \
--ttl 30m \
--json
# 3. Create an isolated worktree (requires active lease)
metagit worktree create \
--repository project/repo \
--agent-id agent-1 \
--task-id 412 \
--branch agent/412-auth \
--json
# 4. Optional: advisory file claims before editing
metagit claim declare \
--repository project/repo \
--agent-id agent-1 \
--pattern 'src/auth/*' \
--json
# 5. Show execution manifest written on create
metagit worktree manifest agent-1
Or allocate + lease in one step with --allocate on lease acquire.
Paths
- Metadata:
.metagit/{branches,leases,worktrees,claims,agents,events}/ under the manifest/session root
- Checkouts:
<session-root>/<worktrees_path>/<agent-id>/<project>/<repo>/
- Default
worktrees_path: .worktrees
- Appconfig:
workspace.worktrees_path
- Env:
METAGIT_WORKSPACE_WORKTREES_PATH
- Path basenames (e.g.
worktrees, .worktrees, campaigns, _campaigns) are reserved and cannot be workspace project names
MCP tools (ACTIVE gate)
| Area |
Tools |
| Branch |
metagit_branch_allocate, metagit_branch_list, metagit_branch_release |
| Lease |
metagit_lease_acquire, metagit_lease_renew, metagit_lease_release, metagit_lease_list |
| Worktree |
metagit_worktree_create, metagit_worktree_destroy, metagit_worktree_status, metagit_worktree_list |
| Claim |
metagit_claim_declare, metagit_claim_check, metagit_claim_list, metagit_claim_release |
Events appear in metagit context events / metagit_events with source=acl.
Conflict handling
- Branch already allocated — choose a different
task-id / description, or wait for release
- Lease held by another agent — wait, renew is owner-only; do not force unless authorized
- Claim overlap — advisory; response includes
owner + overlapping patterns; subdivide, wait, or override with --strict off (default allows declare with conflict event)
- Worktree already exists for agent+repo — destroy/gc first; one active worktree per
(agent_id, repository)
Cleanup
metagit lease renew --lease-id <id> --agent-id agent-1 --ttl 1h
metagit lease release --lease-id <id> --agent-id agent-1 --release-branch
metagit worktree destroy --worktree-id <id> --force
metagit worktree gc
metagit branch cleanup
Anti-patterns
- Two agents editing the same sync-root checkout
- Using handoff
--ttl instead of metagit lease for branch ownership
- Naming a workspace project
worktrees or campaigns
- Skipping lease acquire before
worktree create
- Leaving expired leases / orphan worktrees without
gc
Related skills
metagit-control-center — orchestrator dispatch; run this skill when isolating subagents
metagit-multi-repo — cross-repo delivery; use ACL per repo before parallel edits
metagit-sharing-state — shared objectives/handoffs across machines (orthogonal to git isolation)
metagit-cli — short ACL command cheat sheet
1---2name: metagit-agent-coordination-23description: Isolate concurrent agents with RFC-0007 ACL primitives: allocate agent/* branches, acquire branch leases, create exclusive git worktrees, and declare advisory file claims. Use when launching multiple agents, avoiding shared checkouts, preventing branch collisions, or coordinating file ownership before coding. Distinct from handoff claim TTL leases.4---5# Metagit Agent Coordination Layer (ACL)67Use when **more than one agent** may edit the same repository, or when an8orchestrator must give each agent an exclusive checkout.910Full reference: [docs/reference/agent-coordination.md](../../../../docs/reference/agent-coordination.md)1112<!-- modality:acl_branch -->13<!-- modality:acl_lease -->14<!-- modality:acl_worktree -->15<!-- modality:acl_claim -->16<!-- modality:acl_manifest -->17<!-- modality:task_graph -->18<!-- modality:semantic_ownership -->19<!-- modality:merge_orchestrator -->20<!-- modality:agent_scheduler -->21<!-- modality:aos_status -->2223Task graphs (`metagit task …`) can store ACL command hints on nodes via24`metagit task bind-acl` without running git — see25[docs/reference/task-graph.md](../../../../docs/reference/task-graph.md).2627Merge orchestration (`metagit merge …`) records conflicts with ACL command28hints only; it does not allocate branches or worktrees automatically.2930The agent scheduler (`metagit schedule next`) scores ready task nodes and31returns dispatch hints without launching models or mutating git — see32[docs/reference/agent-scheduler.md](../../../../docs/reference/agent-scheduler.md).3334For a composed operator snapshot and next-work envelope across ACL + task35graph + optional 0009–0012, use skill **`metagit-aos`**36(`metagit aos|coord status|doctor|next`) — see37[docs/reference/aos.md](../../../../docs/reference/aos.md).3839## When to use4041- Dispatching parallel subagents on the same repo42- `handoff.acl_commands` appears in `metagit agent dispatch-plan`43- Preventing two agents from sharing a working directory44- Declaring intended file paths before coding (advisory claims)45- Cleaning up expired leases / orphan worktrees4647## Do not confuse with handoff leases4849| Concept | Command | Owns |50|---------|---------|------|51| **Handoff claim TTL** | `metagit context handoff claim --ttl` | Task-queue row |52| **ACL branch lease** | `metagit lease acquire` | `agent/*` branch |5354## Happy path5556```bash57export METAGIT_AGENT_MODE=true5859# 1. Allocate an exclusive agent branch60metagit branch allocate \61 --repository project/repo \62 --agent-id agent-1 \63 --task-id 412 \64 --description auth \65 --json6667# 2. Lease it (default TTL 30m; renew while working)68metagit lease acquire \69 --repository project/repo \70 --agent-id agent-1 \71 --task-id 412 \72 --allocate \73 --ttl 30m \74 --json7576# 3. Create an isolated worktree (requires active lease)77metagit worktree create \78 --repository project/repo \79 --agent-id agent-1 \80 --task-id 412 \81 --branch agent/412-auth \82 --json8384# 4. Optional: advisory file claims before editing85metagit claim declare \86 --repository project/repo \87 --agent-id agent-1 \88 --pattern 'src/auth/*' \89 --json9091# 5. Show execution manifest written on create92metagit worktree manifest agent-193```9495Or allocate + lease in one step with `--allocate` on `lease acquire`.9697## Paths9899- **Metadata:** `.metagit/{branches,leases,worktrees,claims,agents,events}/` under the manifest/session root100- **Checkouts:** `<session-root>/<worktrees_path>/<agent-id>/<project>/<repo>/`101 - Default `worktrees_path`: `.worktrees`102 - Appconfig: `workspace.worktrees_path`103 - Env: `METAGIT_WORKSPACE_WORKTREES_PATH`104- Path basenames (e.g. `worktrees`, `.worktrees`, `campaigns`, `_campaigns`) are **reserved** and cannot be workspace project names105106## MCP tools (ACTIVE gate)107108| Area | Tools |109|------|-------|110| Branch | `metagit_branch_allocate`, `metagit_branch_list`, `metagit_branch_release` |111| Lease | `metagit_lease_acquire`, `metagit_lease_renew`, `metagit_lease_release`, `metagit_lease_list` |112| Worktree | `metagit_worktree_create`, `metagit_worktree_destroy`, `metagit_worktree_status`, `metagit_worktree_list` |113| Claim | `metagit_claim_declare`, `metagit_claim_check`, `metagit_claim_list`, `metagit_claim_release` |114115Events appear in `metagit context events` / `metagit_events` with `source=acl`.116117## Conflict handling118119- **Branch already allocated** — choose a different `task-id` / description, or wait for release120- **Lease held by another agent** — wait, renew is owner-only; do not force unless authorized121- **Claim overlap** — advisory; response includes `owner` + overlapping patterns; subdivide, wait, or override with `--strict` off (default allows declare with conflict event)122- **Worktree already exists for agent+repo** — destroy/gc first; one active worktree per `(agent_id, repository)`123124## Cleanup125126```bash127metagit lease renew --lease-id <id> --agent-id agent-1 --ttl 1h128metagit lease release --lease-id <id> --agent-id agent-1 --release-branch129metagit worktree destroy --worktree-id <id> --force130metagit worktree gc131metagit branch cleanup132```133134## Anti-patterns135136- Two agents editing the same sync-root checkout137- Using handoff `--ttl` instead of `metagit lease` for branch ownership138- Naming a workspace project `worktrees` or `campaigns`139- Skipping lease acquire before `worktree create`140- Leaving expired leases / orphan worktrees without `gc`141142## Related skills143144- `metagit-control-center` — orchestrator dispatch; run this skill when isolating subagents145- `metagit-multi-repo` — cross-repo delivery; use ACL per repo before parallel edits146- `metagit-sharing-state` — shared objectives/handoffs across machines (orthogonal to git isolation)147- `metagit-cli` — short ACL command cheat sheet