fix(runtime): use main project root for MCP preflight on task retry (#515) - #527
Conversation
Test-DotbotMcpReadiness set DOTBOT_PROJECT_ROOT to the worktree path when spawning the standalone preflight MCP process. On task retry the worktree's .control junction can be stale (teardown/re-create is not atomic), so the MCP server fails to resolve runtime.json and exits before the handshake begins — the 2-attempt retry loop from andresharpe#479 cannot help because the process dies pre-handshake. This also bypassed andresharpe#356: Resolve-ProjectRoot returns DOTBOT_PROJECT_ROOT verbatim when set, skipping git-common-dir detection entirely. Add an optional -ProjectRoot parameter to Test-DotbotMcpReadiness and pass the main project root at the call site. The main root always has a stable .control/ directory, so runtime.json resolution keeps working on retry. Backward compatible: callers that omit -ProjectRoot fall back to the worktree path. Closes andresharpe#515
|
@kabaogluemre this highlights a bigger concern with the root model around MCP. Right now, I think we should make that split explicit instead of patching one caller. The agent cwd should stay as the worktree, but MCP state/runtime resolution should use a dedicated |
@carlospedreira , thanks for your review, a dedicated |
PR andresharpe#527 (fix andresharpe#515) landed the Issue A fix upstream using DOTBOT_STATE_ROOT rather than overwriting DOTBOT_PROJECT_ROOT. Resolved conflict in Invoke-WorkflowProcess.ps1 by taking upstream s approach: DOTBOT_PROJECT_ROOT stays the worktree, DOTBOT_STATE_ROOT carries the stable main root. Issue A is now fully covered by upstream -- our v4-runtime unique changes remaining are B (interview-answers.json), D (output delta), E (Products page). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Fixes #515 —
Test-DotbotMcpReadinesscrashing with "MCP server exited or returned an empty response" when a task is retried after a failed squash-merge.Root cause
The standalone preflight MCP process had
DOTBOT_PROJECT_ROOTset to the worktree path. On task retry the worktree's.controljunction can be stale — teardown/re-creation is not atomic — so the MCP server cannot resolveruntime.json(via<worktree>/.bot/.control/) and exits before the handshake even begins.Two existing fixes don't cover this case:
Resolve-DotbotProjectRootviagit rev-parse --git-common-dir— but that detection is bypassed wheneverDOTBOT_PROJECT_ROOTis set, becauseResolve-ProjectRoot.ps1returns the env var value verbatim and skips git-based detection (seeResolve-ProjectRoot.ps1:30-49).Fix
Add an optional
-ProjectRootparameter toTest-DotbotMcpReadiness. When supplied, it is used forDOTBOT_PROJECT_ROOTinstead of the worktree path:The call site now passes the main project root, which always has a stable
.control/directory:WorkingDirectorystays the worktree (work happens there); only task-state resolution is redirected to the main root — consistent with #356's intent. Backward compatible: callers that omit-ProjectRootfall back to the previous worktree behaviour.Closes #515