Cleave Orchestrator

Cleave decomposes complex tasks into independent subtasks and executes them in parallel across isolated git worktree branches. Each child runs in its own worktree with its own branch, its own agent process, and its own provider routing. Results are merged back with per-file conflict detection, dependency-ordered merge, and optional adversarial review.

Cleave architecture: split plan feeds orchestrator, which dispatches waves into isolated git worktrees. Completed branches merge with conflict detection, pass through adversarial review, and land on main.

How Is This Different from Subagents?

Claude Code's subagents and similar tools run child agents in the same working directory with the same file system. Two subagents editing the same file produce race conditions. There's no isolation, no merge strategy, and no conflict detection — it's optimistic concurrency without the concurrency control.

Cleave is fundamentally different:

Subagents (Claude Code, etc.)Cleave (Omegon)
Children share the working directoryEach child gets its own git worktree on its own branch — fully isolated file system
No file scope enforcementFile scope declarations prevent children from touching the same files. Violations are caught at plan time.
No dependency orderingChildren declare depends_on relationships. The orchestrator dispatches in dependency waves — a child won't start until its dependencies complete.
No merge strategyGit merge with per-file conflict detection. Conflicts are never bulk-resolved — each conflicted file is reviewed individually.
No post-merge verificationAdversarial review checks each child's output for bugs, security issues, and spec compliance. Churn detection bails if the same issues keep reappearing.
Single providerEach child can route to a different provider. The orchestrator uses the routing engine to assign providers based on capability tier and availability.
Implicit parallelismExplicit plan: labels, descriptions, file scopes, dependencies, max parallelism (default 4). The operator sees and approves the plan before execution.
Results lost on errorEach child's branch persists in the worktree. If a child fails, its partial work is preserved. The operator can inspect, fix, and re-merge manually.

The short version: subagents are cooperative multitasking with no isolation. Cleave is preemptive multitasking with full isolation, a merge protocol, and a verification gate.

How It Works

  1. Assesscleave_assess evaluates task complexity. The formula is systems x (1 + 0.5 x modifiers). If the score exceeds the threshold (default 2.0), decomposition is recommended.
  2. Plan — the agent creates a split plan: children with labels, descriptions, file scopes, and dependency ordering. The operator sees and can modify this plan before execution.
  3. Dispatch — the orchestrator creates git worktrees, assigns branches (clv-<label>), enriches each child with task context, and dispatches waves in dependency order. Up to 4 children execute in parallel by default.
  4. Execute — each child is a full agent process running in its isolated worktree. It has access to the same tools (read, edit, write, bash) but can only see its own branch's files. It receives design context from OpenSpec if a change is bound.
  5. Merge — completed children are merged back in dependency order. Conflicts are detected per-file. The orchestrator never uses --ours or --theirs — every conflict requires explicit resolution.
  6. Review — if enabled, an adversarial reviewer checks each child's diff for bugs, security issues, and spec compliance. Severity-gated fix iterations with churn detection prevent infinite loops.

Usage

# The agent suggests cleave when complexity is high:
"Implement the provider routing engine with routing.rs, ollama.rs, and per-child config"
# Agent runs cleave_assess, gets complexity 3.0, recommends decomposition

# Or trigger explicitly:
/cleave

# The agent produces a plan with children, scopes, and dependencies.
# You review the plan, then it executes in parallel.

With OpenSpec

When an OpenSpec change exists (from design_tree_update(implement)), cleave integrates with the spec lifecycle:

Child Isolation

Each child runs in a separate git worktree on its own branch. This is real file system isolation, not namespace tricks:

Adversarial Review

Enable with review: true on cleave_run. After each child completes, a separate reviewer agent examines the diff:

Failure Handling

If a child fails: