fix: prevent stale duplicate planning tasks from blocking phase completion
Three fixes for phases getting stuck when a detail task crashes and is retried: 1. detailPhase mutation (architect.ts): clean up orphaned pending/in_progress detail tasks before creating new ones, preventing duplicates at the source 2. orchestrator recovery: detect and complete stale duplicate planning tasks (same category+phase, one completed, one pending) 3. ensureBranch: catch "already exists" TOCTOU race instead of blocking phase
This commit is contained in:
@@ -337,6 +337,14 @@ export function architectProcedures(publicProcedure: ProcedureBuilder) {
|
||||
});
|
||||
}
|
||||
|
||||
// Clean up orphaned pending/in_progress detail tasks from previous failed attempts
|
||||
const phaseTasks = await taskRepo.findByPhaseId(input.phaseId);
|
||||
for (const t of phaseTasks) {
|
||||
if (t.category === 'detail' && (t.status === 'pending' || t.status === 'in_progress')) {
|
||||
await taskRepo.update(t.id, { status: 'completed', summary: 'Superseded by retry' });
|
||||
}
|
||||
}
|
||||
|
||||
const detailTaskName = input.taskName ?? `Detail: ${phase.name}`;
|
||||
const task = await taskRepo.create({
|
||||
phaseId: phase.id,
|
||||
|
||||
Reference in New Issue
Block a user