Skip to content

feat: harness-managed worktree isolation for arm subagents #133

@sriumcp

Description

@sriumcp

TL;DR

Use the harness-native Agent(isolation="worktree") primitive for per-arm subagents (#3) instead of the manual lifecycle in worktree.py.

Why this matters

worktree.py predates the harness primitive. It manually creates, tracks, and cleans up worktrees. The race condition observed on 5/18 (two executors writing to one iter dir, ghost worktrees lingering as iter-4-… for hours) wouldn't happen under harness-managed worktrees, which are auto-cleaned and tracked.

What's already shipped

  • worktree.py (initial impl).
  • This issue replaces the lifecycle, keeps the post-run patch extraction.

Proposed approach

  1. When spawning per-arm subagents (Framework buildout: 4-layer approach from methodology docs to autonomous orchestrator #3), pass isolation="worktree" to the harness.
  2. Capture the post-run patch via git diff in the subagent before it exits; the subagent writes the patch to iter-N/patches/<arm>.patch (already the existing convention).
  3. Delete worktree.py's lifecycle code; keep only the patch-extraction helper.
  4. On orphan detection (any worktree under <repo>/.nous-experiments/ older than 1 hour with no live PID), garbage collect on next nous run start.

Acceptance criteria

  • After running a multi-arm campaign, <repo>/.nous-experiments/ contains zero leftover worktrees.
  • Per-arm patches end up in iter-N/patches/<arm>.patch exactly as today.
  • worktree.py is reduced by ≥ 60% LoC.

Part of #120.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions