diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-06 03:09:05 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-06 03:09:05 +0000 |
| commit | 79c1cdad0b51d301b9c78db0dec1d1fec7e3def4 (patch) | |
| tree | 832cfef52370537c6d67cfb1ba17d8dc0610437d /scripts/next-task | |
| parent | 3672981c4d225bb5b7d965a8945bc7bc6e8b4e9d (diff) | |
fix: next-task falls back to priority queue when no pending siblings remain
When the most recently completed task had no remaining PENDING siblings
(series fully done), the script returned empty and start-next-task
reported "No task to start." Fix by falling through to the
priority+age fallback whenever the sibling search yields nothing.
Also add header comment documenting the selection logic, and suppress
browser favicon 404s with <link rel="icon" href="data:,">.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts/next-task')
| -rwxr-xr-x | scripts/next-task | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/next-task b/scripts/next-task index 8bd958c..eeeca2e 100755 --- a/scripts/next-task +++ b/scripts/next-task @@ -1,8 +1,18 @@ #!/bin/bash +# next-task — print the ID of the next PENDING task to run, or nothing if none. +# +# 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. +# +# Usage: next_id=$(scripts/next-task) +# Example: scripts/start-next-task DB_PATH="/site/doot.terst.org/data/claudomator.db" -# 1. Fetch the most recently updated task +# 1. Fetch the most recently updated COMPLETED or READY task target=$(sqlite3 "$DB_PATH" "SELECT id, state, parent_task_id FROM tasks WHERE state IN ('COMPLETED', 'READY') ORDER BY updated_at DESC LIMIT 1;") if [ -z "$target" ]; then @@ -14,9 +24,10 @@ 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;") +fi -elif [ "$state" == "READY" ]; then - # 3. Find next task ordered by priority then oldest +if [ -z "$next_task" ]; then + # 3. No sibling found (or READY state): find next task by priority then oldest next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE state = 'PENDING' AND id != '$id' ORDER BY CASE priority |
