Skip to content

P1: Isolate Best of N implementation candidates in separate worktrees #1223

Closed

Description

@currentbits

User outcome: run two providers on the same coding task and compare independent changes, without both editing the main checkout.

Competitor evidence: Orca's first three-agent session, checked 2026-09-10, creates one worktree per implementation before sending the same prompt. This is official-documentation comparison, not a live Orca test.

Solenta source evidence at 9fc8645: runBestOfN calls onFork with provider/model only, then starts each resulting thread. App.handleForkOpen and useCoder.forkThread forward those options. services.forkThread marks pendingWorktree only for explicit worktree:true. The ordinary user-facing race therefore requests fresh threads without isolated worktrees. The source's code branch is not inherited by that service either. This is a traced call chain, not a live overwrite experiment; no claim is made that agents have already damaged files.

Smallest useful scope: give the Best of N implementation path an explicit isolated-workspace contract, carried through the existing fork service and lazy materialization. Each candidate needs a distinct branch/path and the same declared committed starting point. Separate that starting point from its later merge/PR destination. Reuse the snapshot contract in #948 and base-selection primitives in #187/#775; do not build another worktree manager. The isolation choice must be made before any candidate starts, not patched onto a thread afterward.

Acceptance:

  • A two-provider race creates two distinct candidate worktrees. An edit in either candidate cannot appear in the other or the main checkout.
  • All candidates use the same captured committed start revision even if the source advances while the race is being launched.
  • Show the starting branch/short SHA. Uncommitted source edits are not silently copied, committed or claimed as included.
  • Failure to create a worktree cannot fall back to running that candidate in the shared checkout. Existing successful candidates remain inspectable after a partial launch failure.
  • Unsupported projects get a clear preflight result, rather than launching an unsafe parallel implementation.
  • Preserve explicit worktree:false research/orchestration forks and existing Ask behavior. Do not change every ordinary Fork or provider handoff implicitly.
  • Trace sibling user-fork callers during implementation so they retain their deliberate semantics; share only the relevant isolation/start-point plumbing.
  • Verify the actual Best of N-to-service flow plus a disposable real-Git fixture with two candidate paths and independent edits. No live agents are needed for the regression.

Dedup: #30 delivered orchestration-worker isolation, but runBestOfN calls ordinary forkThread. #281 is candidate grading, #241/#344 planning/sketch races, #237 same-thread provider handoff and #240 stacked-PR navigation. #948 is CLOSED plan:done with a merge comment and covers orchestration source snapshots; coordinate its contract rather than treating source provenance as a new research finding. This ticket owns the Best of N launch integration and candidate isolation only.

Activity

  1. added
    plan:todo
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Sep 10, 2026
  2. currentbits commented on Sep 10, 2026

    @currentbits
    OwnerAuthor

    Best of N implementation races now fork with isolate:true before any candidate starts.

    • Each candidate gets pendingWorktree + a recorded start snapshot (leadSnapshotSha/Branch/Dirty) in the same fork patch. The first capture is reused so every candidate starts at the same committed revision even if the source advances mid-launch. baseBranch stays the merge/PR destination.
    • Unsupported projects (Ask, remote, non-git, unsupported scm) throw before createThread. Worktree materialize failures stay Worktree creation failure must never silently run the agent in the main checkout #511 fail-closed; already-forked candidates remain inspectable.
    • Ordinary Fork, hand-off, worktree:true chips, worktree:false research workers, and Ask are unchanged.

    Verified with electron/test/best-of-n-isolate.test.js (two real git worktrees, independent edits) plus Best of N-to-service renderer/App tests. No live agents.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions