Skip to content

v0.8.68 WhaleFlow: worktree pool management for parallel agent isolation #4016

Description

@Hmbown

Problem

Today worktree creation is manual (git worktree add ...) and error-prone. The worktree=true agent parameter fails when the workspace root is not a git repo (e.g., /Volumes/VIXinSSD/CW contains codewhale/ as the git repo). Worktrees accumulate indefinitely — after a 40-agent session, 40 worktrees with their own build artifacts consume significant disk space.

Scope

Add a worktree pool manager that:

  1. Auto-detect git root — Walk up from the agent's cwd to find the actual .git directory, even if the workspace root isn't a git repo
  2. Worktree lifecycle — Create on agent start, auto-delete on agent completion (with configurable TTL for inspection)
  3. Shared build cache — All worktrees share a single target/ directory via CARGO_TARGET_DIR to avoid 40× build artifact duplication
  4. Name collision resolution — Auto-generate unique worktree names, no manual fix-3985w3-3984 gymnastics
  5. Concurrency limits — Cap simultaneous worktrees to avoid filesystem pressure
  6. Cleanup on session end — Prune all session worktrees when the parent exits

Non-goals

  • Not changing git-worktree semantics. This is a management layer, not a git replacement.
  • Not auto-committing or pushing from worktrees. Agents still control their own git operations.

Acceptance

  • worktree=true works regardless of whether the workspace root is a git repo
  • 30+ concurrent agents each get an isolated worktree without name collisions
  • Build artifacts are shared via a common target directory
  • Worktrees are auto-cleaned within 5 minutes of agent completion
  • Disk usage for 30 concurrent agents is <2× single-worktree usage
  • Tests: create/destroy 10 worktrees in parallel, verify isolation and cleanup

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestv0.8.68Targeting v0.8.68whaleflowWhaleFlow branch/leaf workflow runtime and workflow mode

    Projects

    Status
    Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions