Skip to content

[S5] Make --worktree real: dedicated worktree per loop + deterministic cleanup #158

@federiconeri

Description

@federiconeri

Summary

--worktree is currently exposed in CLI/API but does not create or run loops in a dedicated git worktree. For Phase 4/S5 parallel loops (and outcomes expected from #39 / #59), real worktree isolation is a prerequisite.

Part of #59.
Supports #39, #71, #72.

Problem

Current behavior indicates a gap between contract and implementation:

  • wiggum run --worktree forwards the flag, but loop execution stays in the project root working tree.
  • feature-loop.sh parses --worktree and logs it, but does not git worktree add or switch APP_DIR to a per-feature worktree.
  • TUI run path does not pass --worktree today, so interactive runs cannot use isolation.
  • Review prompt text still references worktree cleanup despite no guaranteed worktree creation in the flow.

This weakens reliability for parallelism and can cause branch/working-tree contention.

Scope

  • Implement true per-feature worktree provisioning in loop runtime.
  • Route all execution contexts consistently:
    • CLI wiggum run --worktree
    • Agent runLoop(worktree=true)
    • TUI run path (configurable or default policy)
  • Standardize worktree path strategy and lifecycle:
    • create if missing
    • reuse on --resume
    • deterministic cleanup policy after completion/merge/failure
  • Ensure commands run against worktree app dir (tests, build, diff, PR/review gates).
  • Align prompt instructions with actual harness ownership (no phantom cleanup steps in prompts).
  • Add tests covering flag plumbing + runtime behavior.

Acceptance Criteria

  • Running with --worktree creates/uses a dedicated worktree path for the feature branch
  • Concurrent loops on different features can run without branch switching conflicts
  • --resume reattaches to the same worktree for that feature
  • Cleanup behavior is explicit and deterministic (documented + tested)
  • TUI run path supports worktree mode consistently with CLI/agent behavior
  • Prompt text no longer claims cleanup steps that are not guaranteed by harness

Suggested Labels / Priority

  • Type: bug (contract says isolation exists, runtime does not honor it)
  • Domains: cli, infrastructure
  • Meta: loop, user-facing
  • Priority: P1
  • Size: M/L

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcliCommand line interface, commands, entry pointsinfrastructureDevOps, build, debug toolingloopRalph loop's systemuser-facingDirectly impacts end users

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions