Skip to content

feat(#485): add worktree isolation for /exec parallel agent groups - #500

Merged
admarble merged 3 commits into
mainfrom
feature/485-evaluate-built-in-worktree-isolation-for-exec-para
Apr 7, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/485-evaluate-built-in-worktree-isolation-for-exec-para

Conversation

@admarble

@admarble admarble commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add worktree isolation for /exec parallel agent groups — each agent gets its own sub-worktree, eliminating file conflicts structurally instead of relying on task partitioning
  • New agents.isolateParallel setting (default: false) and --isolate-parallel CLI flag
  • Investigation validated: nested worktrees work, creation ~400ms, git merge --no-ff handles conflict detection

Changes

Core Module (src/lib/worktree-isolation.ts)

  • createSubWorktree() — creates sub-worktree at .exec-agents/agent-<N>/, symlinks node_modules, copies env files
  • mergeAllSubWorktrees() — sequential merge-back with git merge --no-ff, conflict detection and partial merge support
  • cleanupAllSubWorktrees() / cleanupOrphanedSubWorktrees() — post-merge and orphan cleanup

Settings & CLI

  • isolateParallel: boolean added to AgentSettings interface
  • --isolate-parallel flag registered in bin/cli.ts, wired through RunOptions → run.ts

Skill Integration

  • /exec SKILL.md parallel group section updated with isolation steps (0, 1b, 5b)
  • All three skill directories synced (.claude/skills/, templates/skills/, skills/)

Cleanup & Docs

  • cleanup-worktree.sh updated to handle .exec-agents/ sub-worktrees
  • docs/reference/worktree-isolation.md — investigation results, architecture, API reference
  • CHANGELOG updated

AC Coverage

23/23 items met (20 original + 3 derived)

Test plan

  • 19 unit tests for worktree-isolation module (branch naming, create, merge, conflict, cleanup, formatting)
  • 156 total tests pass (no regressions)
  • Build passes, lint passes (0 errors)
  • CLI --help shows --isolate-parallel flag
  • All three skill directories verified identical

Closes #485

Each parallel agent can now get its own sub-worktree via the
agents.isolateParallel setting or --isolate-parallel CLI flag,
eliminating file conflicts structurally instead of relying on
careful task partitioning.

- New src/lib/worktree-isolation.ts module with create, merge-back,
  and cleanup functions
- git merge --no-ff strategy with conflict detection and reporting
- Sub-worktrees nested at .exec-agents/agent-<N>/ inside issue worktree
- node_modules symlinked (~13ms) instead of npm install (~30s)
- Orphaned sub-worktree cleanup in cleanup-worktree.sh
- 19 unit tests covering branch naming, merge, conflict, and cleanup
- Investigation docs at docs/reference/worktree-isolation.md

Closes #485
admarble added 2 commits April 7, 2026 12:13
…ktreeinclude

Three gaps fixed:

1. CLI flag propagation: --isolate-parallel now flows through
   ExecutionConfig → phase-executor → SEQUANT_ISOLATE_PARALLEL env var.
   SKILL.md checks env var first, settings.json second.

2. Dead code bridge: new scripts/worktree-isolation.ts CLI wrapper exposes
   the tested TypeScript API as shell commands. SKILL.md steps 1b/5b now
   call the script instead of raw git, making tested code the single
   source of truth.

3. .worktreeinclude: new file at repo root lists files to copy into
   sub-worktrees. createSubWorktree() reads from it, falling back to
   hardcoded defaults. 4 new tests for getIncludeFiles().
@admarble
admarble merged commit 72a1217 into main Apr 7, 2026
8 checks passed
@admarble
admarble deleted the feature/485-evaluate-built-in-worktree-isolation-for-exec-para branch April 7, 2026 21:42
admarble added a commit that referenced this pull request May 3, 2026
Mirrors the --testgen pattern from #557 to remove the only --phases
emission /assess was still forced to produce for non-resume cases.

- bin/cli.ts: register --security-review next to --testgen
- types.ts: add RunOptions.securityReview
- phase-mapper.ts: extend PhaseMapperOptions and insert security-review
  after spec when flag set; idempotent vs label-based auto-detection
- batch-executor.ts: SEQUANT_SECURITY_REVIEW env override and runtime
  injection block (handles --resume after spec already ran)
- assess/SKILL.md (×3 mirrors): rewrite Rule 8 — drop "asymmetry"
  clause, list both --testgen and --security-review as additive flags;
  example commands at #412 and #500 switch from --phases to
  --security-review (Flags annotations updated to match)
- docs/features/assess-minimal-flags.md: update for new flag
- assess-skill.test.ts: extend rejection regex to also catch
  --phases ...,security-review patterns
- phase-mapper.test.ts: 5 new tests covering insertion, idempotency,
  composition with --testgen, and absence of spec
- CHANGELOG: [Unreleased] / Added entry

Closes #559
admarble added a commit that referenced this pull request Sep 9, 2026
Mirrors the --testgen pattern from #557 to remove the only --phases
emission /assess was still forced to produce for non-resume cases.

- bin/cli.ts: register --security-review next to --testgen
- types.ts: add RunOptions.securityReview
- phase-mapper.ts: extend PhaseMapperOptions and insert security-review
  after spec when flag set; idempotent vs label-based auto-detection
- batch-executor.ts: SEQUANT_SECURITY_REVIEW env override and runtime
  injection block (handles --resume after spec already ran)
- assess/SKILL.md (×3 mirrors): rewrite Rule 8 — drop "asymmetry"
  clause, list both --testgen and --security-review as additive flags;
  example commands at #412 and #500 switch from --phases to
  --security-review (Flags annotations updated to match)
- docs/features/assess-minimal-flags.md: update for new flag
- assess-skill.test.ts: extend rejection regex to also catch
  --phases ...,security-review patterns
- phase-mapper.test.ts: 5 new tests covering insertion, idempotency,
  composition with --testgen, and absence of spec
- CHANGELOG: [Unreleased] / Added entry

Closes #559
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluate built-in worktree isolation for /exec parallel agent groups

1 participant