From b91636be171bc8e43a3dba1b54f78e2048356ab1 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 15 Mar 2026 23:32:14 +0000 Subject: fix: promote stale BLOCKED parent tasks to READY on server startup When the server restarts after all subtasks complete, the parent task was left stuck in BLOCKED state because maybeUnblockParent only fires during a live executor run. RecoverStaleBlocked() scans all BLOCKED tasks on startup and re-evaluates them using the existing logic. Co-Authored-By: Claude Sonnet 4.6 --- internal/executor/executor.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/executor/executor.go') diff --git a/internal/executor/executor.go b/internal/executor/executor.go index f85f1ff..c07171b 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -634,6 +634,21 @@ func (p *Pool) RecoverStaleQueued(ctx context.Context) { } } +// RecoverStaleBlocked promotes any BLOCKED parent task to READY when all of its +// subtasks are already COMPLETED. This handles the case where the server was +// restarted after subtasks finished but before maybeUnblockParent could fire. +// Call this once on server startup, after RecoverStaleRunning and RecoverStaleQueued. +func (p *Pool) RecoverStaleBlocked() { + tasks, err := p.store.ListTasks(storage.TaskFilter{State: task.StateBlocked}) + if err != nil { + p.logger.Error("RecoverStaleBlocked: list tasks", "error", err) + return + } + for _, t := range tasks { + p.maybeUnblockParent(t.ID) + } +} + // terminalFailureStates are dependency states that cause the waiting task to fail immediately. var terminalFailureStates = map[task.State]bool{ task.StateFailed: true, -- cgit v1.2.3