fix(kanban): prevent child task dispatch when parent is not done

Add parent dependency guard to _set_status_direct so dragging
a task to the ready column is rejected (409) when its parents
are not all done. Previously the guard only existed in
recompute_ready, allowing direct status writes via the
dashboard API to bypass the dependency engine.

Root cause: after reclaiming stale workers, both T3 and T4
were set to ready via dashboard status writes in quick
succession, causing the writer to be spawned while the analyst
was blocked — upstream work wasn't done yet.
This commit is contained in:
daixin1204 2026-05-04 20:18:40 +08:00 committed by Teknium
parent 8a1a42d098
commit d2c6eceed9
2 changed files with 42 additions and 8 deletions

View file

@ -662,6 +662,22 @@ def _set_status_direct(
).fetchone()
if prev is None:
return False
# Guard: don't allow promoting to 'ready' unless all parents are done.
# Prevents the dispatcher from spawning a child whose upstream work
# hasn't completed (e.g. T4 dispatched while T3 is still blocked).
if new_status == "ready":
parent_statuses = conn.execute(
"SELECT t.status FROM tasks t "
"JOIN task_links l ON l.parent_id = t.id "
"WHERE l.child_id = ?",
(task_id,),
).fetchall()
if parent_statuses and not all(
p["status"] == "done" for p in parent_statuses
):
return False
was_running = prev["status"] == "running"
cur = conn.execute(