diff options
Diffstat (limited to 'Omni/Agent')
| -rwxr-xr-x | Omni/Agent/start-worker.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Omni/Agent/start-worker.sh b/Omni/Agent/start-worker.sh index eb096b7..d576870 100755 --- a/Omni/Agent/start-worker.sh +++ b/Omni/Agent/start-worker.sh @@ -82,6 +82,22 @@ while true; do TASK_TITLE=$(echo "$TASK_JSON" | jq -r '.taskTitle') TASK_NS=$(echo "$TASK_JSON" | jq -r '.taskNamespace // "root"') + # Verify against live state to prevent re-claiming completed work + # (This handles cases where local 'InProgress' timestamp > live 'Review' timestamp due to retries) + git show live:.tasks/tasks.jsonl > .tasks/temp-live-tasks.jsonl 2>/dev/null + LIVE_TASK=$(grep "\"taskId\":\"$TASK_ID\"" .tasks/temp-live-tasks.jsonl || true) + LIVE_STATUS=$(echo "$LIVE_TASK" | jq -r '.taskStatus // empty') + rm -f .tasks/temp-live-tasks.jsonl + + if [[ "$LIVE_STATUS" == "Review" ]] || [[ "$LIVE_STATUS" == "Done" ]]; then + echo "Task $TASK_ID is already $LIVE_STATUS in live. Skipping and updating local state." + # Force update local DB to match live for this task + # We can't easily use 'task update' because it updates timestamp. + # Instead, we just rely on the loop continuing and hopefully 'task import' eventually winning + # if we stop touching it. Or we could force import again. + continue + fi + echo "$(date): Claiming task $TASK_ID: $TASK_TITLE" # D. Claim Task |
