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:
- 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.
#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.
#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.py — validate_isolation() / create_execution_context() (WORKTREE branch to restore)
codeframe/core/worktrees.py — TaskWorktree.merge_back() (implemented, currently unwired)
codeframe/core/runtime.py:~931 — finally: exec_ctx.cleanup() (must merge before cleanup)
Context
#714 [P0.3]shipped the sanctioned interim:--isolation worktreeis 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:
git commit, sogit merge cf/<task_id>merges nothing. Merge-back needs an auto-commit step in the worktree first.#715 [P0.4]— the defaultreact/builtin engine ignoresworkspace_pathand writes to the main repo, so isolation is a no-op there until that's fixed.#716 [P0.5]—VerificationWrapperruns gates against the main repo, not the worktree, so a worktree run would falsely pass.Acceptance criteria
cf/<task_id>, thenmerge_back()merges to the base branch before cleanup.git branch -D).validate_isolation()no longer rejectsWORKTREE; the CLI re-accepts--isolation worktree.--isolation worktreeexists on the base branch after a successful run.Dependencies
workspace_path— isolation is a silent no-op #715 (P0.4 — builtin engines must use the worktree path)VerificationWrapperruns gates/quick-fixes against the main repo, not the worktree the agent modified #716 (P0.5 — verification must run against the worktree)merge_backis dead code) #714Evidence / anchors
codeframe/core/sandbox/context.py—validate_isolation()/create_execution_context()(WORKTREE branch to restore)codeframe/core/worktrees.py—TaskWorktree.merge_back()(implemented, currently unwired)codeframe/core/runtime.py:~931—finally: exec_ctx.cleanup()(must merge before cleanup)