Skip to content

[P2-worktree] Re-enable worktree isolation with real merge-back (+auto-commit, workspace_path, verify) #787

Description

@frankbria

Context

#714 [P0.3] shipped the sanctioned interim: --isolation worktree is hard-rejected so it can no longer silently discard agent work. This issue tracks re-implementing worktree isolation correctly and re-enabling it.

Why it wasn't done in #714

Real merge-back is entangled and unsafe to ship alone:

  1. Uncommitted work — adapters run in the worktree but never git commit, so git merge cf/<task_id> merges nothing. Merge-back needs an auto-commit step in the worktree first.
  2. #715 [P0.4] — the default react/builtin engine ignores workspace_path and writes to the main repo, so isolation is a no-op there until that's fixed.
  3. #716 [P0.5]VerificationWrapper runs gates against the main repo, not the worktree, so a worktree run would falsely pass.

Acceptance criteria

  • After a successful worktree run: uncommitted changes are auto-committed on cf/<task_id>, then merge_back() merges to the base branch before cleanup.
  • Merge conflict → surfaced as a blocker; the branch/worktree are preserved (not force-deleted) for recovery.
  • Run failure/blocked → branch preserved (no git branch -D).
  • validate_isolation() no longer rejects WORKTREE; the CLI re-accepts --isolation worktree.
  • Integration test: a file created by the adapter under --isolation worktree exists on the base branch after a successful run.
  • Regression test: a conflicting change produces a blocker and preserves the branch.

Dependencies

Evidence / anchors

  • codeframe/core/sandbox/context.pyvalidate_isolation() / create_execution_context() (WORKTREE branch to restore)
  • codeframe/core/worktrees.pyTaskWorktree.merge_back() (implemented, currently unwired)
  • codeframe/core/runtime.py:~931finally: exec_ctx.cleanup() (must merge before cleanup)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-medium-betaMedium priority - nice to have for betapriority:mediumtype:bugSomething is broken and needs fixing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions