Skip to content

Preserve completed detached worktrees on provisioning retry - #5361

Closed
skevy wants to merge 1 commit into
get-bb:mainfrom
skevy:fix/preserve-detached-worktree-retries
Closed

skevy wants to merge 1 commit into
get-bb:mainfrom
skevy:fix/preserve-detached-worktree-retries

Conversation

@skevy

@skevy skevy commented Oct 11, 2026

Copy link
Copy Markdown

Human comments

What was wrong

A retry of completed Worktree provisioning required Git's symbolic HEAD to match the requested branch. JJ colocation detaches HEAD after creation, so a valid completed workspace fell through to forced removal and branch reset. Retrying could erase tracked edits, new files, deletions, staged changes, and JJ workspace state.

What changed

Reuse completed detached worktrees when the existing completion marker matches the request. Validate the canonical Git common directory and the exact registered, non-main worktree before reuse; leave foreign or unverifiable completed targets alone. Creation scans all worktree records for this identity check while adoption retains its existing 500-entry listing limit. Incomplete detached attempts and attached targets on the wrong branch keep their existing recovery behavior. No wire, CLI, or public SDK changes.

How you verified

  • pnpm exec turbo run test typecheck --filter=bb-plugin-environment-git-worktree: 106 tests across five files passed; typechecking passed.
  • New regressions fail before their corresponding fixes and pass afterward. Coverage includes dirty detached retries across restart, exact Git index preservation, staged changes, JJ state, source aliases, foreign repositories, main/nested directory aliases, corrupt Git metadata, and targets beyond the default listing limit.
  • Built the installed BB 0.44.0 source with its matching SDK. The unmodified build was byte-identical to the installed Worktree host artifact. The repaired build passed real OverlayFS creation, dirty retry, JJ snapshot, and cleanup with installed GNU JJ 0.46.0 and jj-worktree-overlay; source state and workspace registration stayed unchanged.
  • Applied the matching 0.44.0 host module locally and verified the reloaded server-to-daemon worker fetched the exact tested artifact.
  • Formatting checks on all four changed files and git diff --check passed.

AGENT GENERATED

@github-actions

Copy link
Copy Markdown
Contributor

Thanks @skevy for the PR. This repo needs approval before a PR. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ) and explain what you want to open a PR for and why. A maintainer then adds you to the allow list. This PR now closes on its own. Reopen it or open a new one after approval.

@github-actions github-actions Bot closed this Oct 11, 2026
@skevy
skevy deleted the fix/preserve-detached-worktree-retries branch October 11, 2026 17:29
@skevy

skevy commented Oct 11, 2026

Copy link
Copy Markdown
Author

Sorry about this...wasn't an intentional PR. My apologies!

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