Auto-enable worktrees for code tasks
This commit is contained in:
@@ -728,6 +728,102 @@ func TestOrchStrictWorktreeAllowsExplicitBaseRefOnDirtyRepo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrchDispatchAutoEnablesWorktreeForCodeLikeTask(t *testing.T) {
|
||||
dbPath := filepath.Join(t.TempDir(), "coord.db")
|
||||
repoPath := initGitRepo(t)
|
||||
|
||||
runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"run", "init",
|
||||
"--run", "run_blog_auto_worktree_001",
|
||||
"--goal", "Validate auto worktree detection",
|
||||
)
|
||||
runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"task", "add",
|
||||
"--run", "run_blog_auto_worktree_001",
|
||||
"--task", "T1",
|
||||
"--title", "Implement backend API",
|
||||
"--default-to", "backend-worker",
|
||||
)
|
||||
|
||||
dispatchOut := runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"dispatch",
|
||||
"--run", "run_blog_auto_worktree_001",
|
||||
"--task", "T1",
|
||||
"--repo-path", repoPath,
|
||||
)
|
||||
|
||||
var dispatchResp map[string]any
|
||||
mustDecodeJSON(t, dispatchOut, &dispatchResp)
|
||||
attempt := nestedValue(t, dispatchResp, "data", "attempt").(map[string]any)
|
||||
|
||||
worktreePath, _ := attempt["worktree_path"].(string)
|
||||
if worktreePath == "" {
|
||||
t.Fatalf("expected auto-detected code task to allocate a worktree, got %#v", attempt)
|
||||
}
|
||||
if got, _ := attempt["workspace_status"].(string); got != "created" {
|
||||
t.Fatalf("expected created workspace status, got %#v", attempt["workspace_status"])
|
||||
}
|
||||
if _, err := os.Stat(worktreePath); err != nil {
|
||||
t.Fatalf("stat auto worktree path %s: %v", worktreePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrchDispatchDoesNotAutoEnableWorktreeForNonCodeTask(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dbPath := filepath.Join(t.TempDir(), "coord.db")
|
||||
repoPath := initGitRepo(t)
|
||||
|
||||
runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"run", "init",
|
||||
"--run", "run_blog_auto_worktree_002",
|
||||
"--goal", "Validate non-code dispatch fallback",
|
||||
)
|
||||
runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"task", "add",
|
||||
"--run", "run_blog_auto_worktree_002",
|
||||
"--task", "T1",
|
||||
"--title", "Review QA findings",
|
||||
"--summary", "Summarize test failures and next steps",
|
||||
"--default-to", "qa-worker",
|
||||
)
|
||||
|
||||
dispatchOut := runOrchCommand(
|
||||
t,
|
||||
"--db", dbPath,
|
||||
"--json",
|
||||
"dispatch",
|
||||
"--run", "run_blog_auto_worktree_002",
|
||||
"--task", "T1",
|
||||
"--repo-path", repoPath,
|
||||
)
|
||||
|
||||
var dispatchResp map[string]any
|
||||
mustDecodeJSON(t, dispatchOut, &dispatchResp)
|
||||
attempt := nestedValue(t, dispatchResp, "data", "attempt").(map[string]any)
|
||||
if got, _ := attempt["worktree_path"].(string); got != "" {
|
||||
t.Fatalf("expected non-code task to stay on non-worktree path, got %#v", attempt["worktree_path"])
|
||||
}
|
||||
if got, _ := attempt["workspace_status"].(string); got != "" {
|
||||
t.Fatalf("expected no workspace status for non-code task, got %#v", attempt["workspace_status"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrchWaitWakesOnBlockedEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user