fix(core): fetch origin/<defaultBranch> before creating task worktrees (ARC-108)#1
Merged
loop2zero merged 1 commit intoJun 11, 2026
Hidden character warning
The head ref may contain hidden characters: "task/176c7be3-dispatcher-\u5f00-worktree-\u524d\u5148-fetch"
Conversation
Chained subtasks merge remotely while the local default branch never advances, so each new worktree was cut from a stale base and every PR in the chain conflicted (ARC-104 PR moose-lab#10, ARC-105 PR moose-lab#11). createWorktree now fetches origin/<baseBranch> and bases the new branch on the remote tip via resolveWorktreeBase; when the fetch fails (offline or no remote) it logs a warning and degrades to the local branch so dispatch is never blocked. createWorktreeAt is the repo-root-level core, extracted so tests can run against a temp repo with a local bare remote. ARC-108 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
devlog watch的 dispatcher 为新任务开 worktree 时基于本地 defaultBranch 切分支,从不git fetch。链式子任务每合并一环,远端就前进一次,下一环必然基于陈旧基底 → PR 必冲突(实测 ARC-104 PR moose-lab#10、ARC-105 PR moose-lab#11)。修复
全部收在
src/core/worktree-manager.ts,createWorktree公共签名不变,task-execution.ts零改动:resolveWorktreeBase(repoRoot, baseBranch):git fetch origin <baseBranch>+rev-parse --verify origin/<baseBranch>,成功返回origin/<baseBranch>;失败(离线/无 remote)打 warn 降级返回本地分支,不阻塞派发。createWorktreeAt(repoRoot, …):repo-root 级创建核心,抽出以便单测注入临时 repo(getRepoRoot依赖 cwd 配置,无法在测试中注入)。createWorktree委托给上述两者。测试(TDD,先红后绿)
src/core/__tests__/worktree-manager.test.ts(node:test + tsx),夹具为 bare remote + 双 clone(writer 推进远端、local 保持陈旧):origin/<defaultBranch>远端 tip(前置断言本地确实陈旧)resolveWorktreeBase两条路径各自单测验证
bun run typecheck✅TZ=Asia/Shanghai bun run test→ 350 pass / 0 fail ✅关联:ARC-108(发现于 ARC-102 链;relay 主体 ARC-107)
🤖 Generated with Claude Code