diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-20 22:36:49 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-20 22:36:49 -0500 |
| commit | 2be878900bdec1b1273c90b07d7352914d8911c5 (patch) | |
| tree | 4e91088722f4b42a3b27e2f41affd8b22708f238 /Omni | |
| parent | 257dda3db5da6e497558cacde15488b618e443b0 (diff) | |
fix(worker): verify task status against live before claiming
Diffstat (limited to 'Omni')
| -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 |
