diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-06 03:26:59 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-06 03:26:59 +0000 |
| commit | e26c2a1246d21a9d2d6f6d8be2b9481e07931f9d (patch) | |
| tree | 3ed798fdab62d82be7db9b662555570cb60e97f7 /scripts | |
| parent | 79c1cdad0b51d301b9c78db0dec1d1fec7e3def4 (diff) | |
fix: next-task correctly handles READY parent and COMPLETED sibling cases
READY state means a parent task whose subtasks should now run — select
its first PENDING child, not a global fallback. COMPLETED state means
continue the series via the next PENDING sibling. Only fall back to the
priority+age queue when neither yields a task.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/next-task | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/next-task b/scripts/next-task index eeeca2e..e74ca26 100755 --- a/scripts/next-task +++ b/scripts/next-task @@ -3,9 +3,10 @@ # # Selection logic: # 1. Find the most recently updated COMPLETED or READY task. -# 2. If COMPLETED, prefer its next PENDING sibling (same parent) to continue a series. -# 3. If no sibling exists (series done, or READY state), fall back to the -# highest-priority oldest PENDING task across the whole queue. +# 2. If READY, run its first PENDING child (subtask) to begin the series. +# 3. If COMPLETED, run its next PENDING sibling to continue the series. +# 4. If neither yields a task, fall back to highest-priority oldest PENDING +# task across the whole queue. # # Usage: next_id=$(scripts/next-task) # Example: scripts/start-next-task @@ -21,13 +22,16 @@ fi IFS='|' read -r id state parent_id <<< "$target" -if [ "$state" == "COMPLETED" ]; then - # 2. Find next sibling task that is currently PENDING - next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE parent_task_id = '$parent_id' AND state = 'PENDING' LIMIT 1;") +if [ "$state" == "READY" ]; then + # 2. READY = parent task; run its first PENDING child to begin the series + next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE parent_task_id = '$id' AND state = 'PENDING' ORDER BY created_at ASC LIMIT 1;") +elif [ "$state" == "COMPLETED" ]; then + # 3. Find next PENDING sibling to continue the series + next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE parent_task_id = '$parent_id' AND state = 'PENDING' ORDER BY created_at ASC LIMIT 1;") fi if [ -z "$next_task" ]; then - # 3. No sibling found (or READY state): find next task by priority then oldest + # 4. No child/sibling found: fall back to highest-priority oldest PENDING task next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE state = 'PENDING' AND id != '$id' ORDER BY CASE priority |
