Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .agents/scripts/supervisor-archived/todo-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1964,8 +1964,25 @@ cmd_reconcile_queue_dispatchability() {
in_dispatch_queue=true
fi

# Check if task belongs to an active batch (GH#2836)
# Batch membership is explicit dispatch intent — skip reconciliation
# to avoid cancelling newly-added tasks before Phase 0.9 can tag them.
local in_active_batch=false
local active_batch_id=""
active_batch_id=$(db "$SUPERVISOR_DB" "
SELECT bt.batch_id FROM batch_tasks bt
JOIN batches b ON b.id = bt.batch_id
WHERE bt.task_id = '$(sql_escape "$tid")'
AND b.status IN ('active','paused')
LIMIT 1;
" 2>/dev/null || echo "")
Comment on lines +1972 to +1978

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While the || echo "" correctly prevents the script from exiting on failure (if set -e is active), suppressing stderr with 2>/dev/null can hide important database or SQL syntax errors, making debugging difficult. It's better to allow errors to be visible on stderr for diagnostics. This aligns with the repository's guidelines against blanket suppression of errors, especially when set -e is active, to ensure that syntax or system errors remain visible.

Suggested change
active_batch_id=$(db "$SUPERVISOR_DB" "
SELECT bt.batch_id FROM batch_tasks bt
JOIN batches b ON b.id = bt.batch_id
WHERE bt.task_id = '$(sql_escape "$tid")'
AND b.status IN ('active','paused')
LIMIT 1;
" 2>/dev/null || echo "")
active_batch_id=$(db "$SUPERVISOR_DB" "
SELECT bt.batch_id FROM batch_tasks bt
JOIN batches b ON b.id = bt.batch_id
WHERE bt.task_id = '$(sql_escape "$tid")'
AND b.status IN ('active','paused')
LIMIT 1;
" || echo "")
References
  1. Avoid blanket suppression of errors with '2>/dev/null'. For commands that might fail but shouldn't exit the script, use '|| true' or a similar construct, but allow stderr to be printed for debugging purposes.
  2. In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup. Do not suppress stderr with '2>/dev/null' so that actual syntax or system errors remain visible for debugging.
  3. Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.

if [[ -n "$active_batch_id" ]]; then
in_active_batch=true
fi

# If neither condition is met, this is a phantom queue entry
if [[ "$has_auto_dispatch" == "false" && "$in_dispatch_queue" == "false" ]]; then
# But skip tasks in active batches — they are intentionally queued
if [[ "$has_auto_dispatch" == "false" && "$in_dispatch_queue" == "false" && "$in_active_batch" == "false" ]]; then
phantom_count=$((phantom_count + 1))
if [[ "$dry_run" == "true" ]]; then
log_warn "[dry-run] Phase 0.6: $tid queued in DB but not dispatchable in TODO.md (no #auto-dispatch, not in Dispatch Queue)"
Expand All @@ -1980,7 +1997,7 @@ cmd_reconcile_queue_dispatchability() {
cancelled_count=$((cancelled_count + 1))
fi
else
log_verbose "Phase 0.6: $tid is dispatchable (has_auto_dispatch=$has_auto_dispatch, in_dispatch_queue=$in_dispatch_queue)"
log_verbose "Phase 0.6: $tid is dispatchable (has_auto_dispatch=$has_auto_dispatch, in_dispatch_queue=$in_dispatch_queue, in_active_batch=$in_active_batch)"
fi
done <<<"$queued_tasks"

Expand Down
Loading