Skip to content

Stop /ship picking a version another git worktree already holds - #4196

Closed
vilano93 wants to merge 2 commits into
garrytan:mainfrom
vilano93:fix/next-version-sees-git-worktrees
Closed

vilano93 wants to merge 2 commits into
garrytan:mainfrom
vilano93:fix/next-version-sees-git-worktrees

Conversation

@vilano93

@vilano93 vilano93 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

When /ship picks a version, it now notices every parallel git worktree of the repo, so two branches in progress stop taking the same number.

Why (in your own words)

Today gstack-next-version only looks in <workspace_root>/<repo>/<workspace>/, the layout Conductor creates. I work in worktrees that Claude Code puts under .claude/worktrees, and pointing workspace_root there does nothing, because the scan then looks for .claude/worktrees/<repo>/. The config comment says any directory holding parallel worktrees will do, but it silently finds none. This change asks git worktree list, which knows every linked worktree wherever it lives, and still reads the workspace root because that is how separate clones are found.

Live evidence

A temp repo with main at 0.1.66.0 and one worktree outside the Conductor layout holding 0.1.67.0, run from the main checkout with --base main --bump micro --current-version 0.1.66.0:

installed 1.98.0.0:
{"version": "0.1.66.1", "reason": "no collision; clean bump from base"} siblings: 0 active: 0
this branch:
{"version": "0.1.67.1", "reason": "bumped past active sibling 0.1.67.0"} siblings: 1 active: 1
this branch, --workspace-root null:
{"version": "0.1.66.1", "reason": "no collision; clean bump from base"} siblings: 0 active: 0

The same comparison on my real project, which has 17 worktrees (the main checkout plus 16 linked ones), run from the main checkout:

installed 1.98.0.0: siblings 0  active 0
this branch:        siblings 14 active 2, and the pick moved past the highest active sibling

The two tests for the new behaviour were red before the fix:

(fail) sibling scan finds git worktrees wherever they live > a worktree outside any workspace root still holds its version
(fail) sibling scan finds git worktrees wherever they live > run from a linked worktree, it lists the others and never itself
 3 pass
 2 fail

The other three tests guard behaviour that must not change, so they pass before the fix too. I broke the code on purpose in four ways to confirm the tests can fail:

Sabotage Test that went red
null no longer disables the scan workspace root null still turns the whole scan off
current worktree not excluded run from a linked worktree, it lists the others and never itself
no de-duplication a worktree inside the Conductor layout is counted once
workspace root scan removed a separate clone in the Conductor layout is still found

After the fix:

bun test <every test file mentioning gstack-next-version or workspace_root>
 222 pass
 0 fail
Ran 222 tests across 10 files.

gstack-checks run
CHECK typecheck PASS
CHECK build PASS
CHECK tests TOO_BROAD (1720 test files selected, left to CI)

Scope

  • Changed:
    • bin/gstack-next-version: the sibling scan takes the union of git worktree list and the workspace root layout, compares real paths, and excludes the current checkout by its top level.
    • bin/gstack-config: the workspace_root comment now says what the setting does, and drops the claim that any directory of worktrees works.
    • test/gstack-next-version.test.ts: five tests against real temp repos and worktrees.
    • changelog.d/fix-next-version-sees-git-worktrees.md: the changelog fragment.
  • Verified live by: the runs above on macOS 26 (Apple Silicon, Bun 1.4.3).
  • Did NOT test:
    • Linux or Windows.
    • Real Conductor workspaces. The Conductor layout is covered by the tests with a directory of the same shape.
    • The full free suite locally (see TOO_BROAD above). CI runs it on this PR.
    • The paid evals. This change adds no prompt text.
  • Behaviour change to weigh: repos with parallel worktrees outside Conductor now get the "bumped past active sibling" path for the first time, so a version can skip a number while another worktree has a fresh unshipped bump with no open PR. That is what the check is for, and it applied only to Conductor users until now.
  • Not changed: the /landing-report template still labels this list "Sibling Conductor worktrees". It is cosmetic, and changing it means regenerating skill files.

Liveness proof (required for external contributors)

SCR-20261109-huxf

Checklist

  • Liveness screenshot attached (GSTACK PR typed live into a real surface) or PR author is @garrytan (owner exemption)
  • This is not a generated-file-only diff (I edited the source/template and regenerated)
  • No ETHOS.md edits, and no changes to voice / founder perspective / YC references
  • New public command / external service / host adapter has an accepted issue linked (or N/A)
  • Linked issue or reproduction: reproduction above

🤖 Generated with Claude Code

The sibling scan only read <workspace_root>/<repo>/<workspace>/, the
layout Conductor creates, so worktrees anywhere else were invisible.
Ask git worktree list as well, keep the workspace root for separate
clones, and count a checkout found both ways once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Nov 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

A blocking git call with no timeout can hang a whole CI shard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vilano93
vilano93 marked this pull request as ready for review November 9, 2026 07:20
@capy-ai

capy-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @vilano93. Confirmed on main: gstack-next-version only scans <workspace_root>/<repo>/<workspace>/, so worktrees that live elsewhere (like .claude/worktrees) are invisible, even though the config comment says any directory works. We're picking this up for a crew rewrite on current main, crediting you as co-author. /ship tooling is in a short freeze until Nov 21, so it will start after that.

@capy-ai

capy-ai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Following up: we're taking this. The config comment says any folder of parallel worktrees works, and with worktrees under .claude/worktrees none is found, so two branches can take the same version. Asking git worktree list is the right source. It will be rebuilt on current main with you credited as co-author, and this PR will be closed with a link when it lands, after November 21.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for this. We're picking up the idea. A maintainer agent working through a batch of fixes (our tracking thread GSTA-802) will first reproduce the problem on current main. If it reproduces, the agent rebuilds the fix on main with you credited as co-author, because we don't merge outside branches directly, and we'll close this PR with a link when it lands. If it no longer reproduces, we'll close this and say what changed.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you, @vilano93. This was rebuilt on current main and landed in #4681 (merged as b3323f4), with credit in the changelog. /ship's version picker now adds git worktree list --porcelain to its scan, so worktrees outside the Conductor layout can't take the same version, and workspace_root: null still turns the scan off. We rebuild outside changes rather than merging the branch directly, so I'm closing this one.

@capy-ai capy-ai Bot closed this Nov 22, 2026
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