Skip to content

fix: isolate V2 workers at the lead checkout's commit - #62

Open
victorblaga wants to merge 3 commits into
hueyexe:mainfrom
victorblaga:bugfix/v2-worker-checkout
Open

victorblaga wants to merge 3 commits into
hueyexe:mainfrom
victorblaga:bugfix/v2-worker-checkout

Conversation

@victorblaga

@victorblaga victorblaga commented Nov 24, 2026 •

Copy link
Copy Markdown

On OpenCode 2.4.1, requesting a worktree and passing its directory when creating a linked child does not guarantee the child runs there. With a Git-created lead checkout one commit ahead of the main checkout, the worker's first relative write and commit landed on the lead's branch. team_merge had nothing to merge.

There was a separate limitation for leads in OpenCode-created worktrees: Ensemble skipped worker worktree creation there. This change enables isolated workers for those leads on V2 as well.

V2 starts the worker checkout at the lead's committed HEAD. If the linked child inherits its parent's directory, Ensemble moves it, waits, and verifies its location before dispatch. A project without a commit still gets the existing shared-directory warning. Explicit shared-directory and read-only spawns keep their existing behavior.

If child creation is rejected, the unused worker checkout is cleaned up so the lead can retry the same name. If a known child cannot be removed after a failed setup or first dispatch, Ensemble keeps its checkout and reports the child ID and path.

Verification

  • Native OpenCode 2.4.1 on Linux: exercised Git-created and OpenCode-created lead worktrees. A worker committed a relative-path edit in its own checkout, based on the lead commit. The lead stayed clean until team_merge, and the main checkout stayed unchanged.
  • Checked the warning and shared location for a default spawn outside Git. Regression tests cover a repository without a first commit, retry after rejected child creation, and preservation of a surviving child's worktree.

@victorblaga
victorblaga requested a review from hueyexe as a code owner November 24, 2026 12:51
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.

1 participant