fix(worktree): reused worktrees track current origin tip #13

Merged
janpeter merged 5 commits from claude/naughty-brown-2be56e into main 2026-05-26 15:32:41 +02:00
Owner

Summary

  • Fix reused-worktree staleness: createWorktreeForJob's reuse path now checks origin/<branch> first and uses git worktree add -B <branch> ... origin/<branch> (create-or-reset to the origin tip) instead of a possibly-stale local ref. Prevents multi-worker non-fast-forward pushes (reason: 'conflict') when a clone's local ref lags origin after another worker pushed.
  • Local-only (unpushed) + nowhere paths unchanged; safe under the sequential-sibling protocol (a reused branch was already pushed, so the local ref is at-or-behind origin).
  • Adds a real-git test: origin ahead of a stale local ref must yield a worktree on the origin tip (red on old code, green on new).
  • Also includes the design spec + implementation plan and a worker-context-overview reference doc.

Test plan

  • npm test (518 pass)
  • npm run typecheck (clean)
  • New test fails on old code, passes on the fix
## Summary - Fix reused-worktree staleness: `createWorktreeForJob`'s reuse path now checks `origin/<branch>` first and uses `git worktree add -B <branch> ... origin/<branch>` (create-or-reset to the origin tip) instead of a possibly-stale local ref. Prevents multi-worker non-fast-forward pushes (reason: 'conflict') when a clone's local ref lags origin after another worker pushed. - Local-only (unpushed) + nowhere paths unchanged; safe under the sequential-sibling protocol (a reused branch was already pushed, so the local ref is at-or-behind origin). - Adds a real-git test: origin ahead of a stale local ref must yield a worktree on the origin tip (red on old code, green on new). - Also includes the design spec + implementation plan and a worker-context-overview reference doc. ## Test plan - [x] npm test (518 pass) - [x] npm run typecheck (clean) - [x] New test fails on old code, passes on the fix
Reused worktrees check out a possibly-stale local branch ref; with multiple
workers on one story/sprint branch this yields stale code + base_sha and a
non-ff push conflict. Fix: base the reuse path on current origin/<branch>
via `git worktree add -B`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The -B reset in the reuse path discards no unpushed local commits because,
under the sequential-sibling protocol, a reused branch was already pushed by
an earlier sibling — so the local ref is at-or-behind origin. Documents the
invariant the code-quality review flagged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documents the context (kind-prompt + payload) each job-kind receives via
wait_for_job, the config cascade, and per-kind default model/tools — captured
while investigating the claim/worktree flow. Reflects the merged agent-guide
sub-agent passing for SPRINT_IMPLEMENTATION.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-mcp!13
No description provided.