fix(issue-50): the loop path reads this attempt's token before it waits (review reviewer-grok-01)

The `--status pending` reset is a redispatch and issues a new dispatch
token, but the loop read `_disp_tok` only after the registry and idle waits.
A busy or idle_wait close from phase two on therefore carried the previous
phase's token and the engine refused it, leaving the record pending while
the caller saw session_busy. The read now follows the reset directly; s1
pins reset < token read < registry wait.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Fable 5.1 committed 2026-10-10 18:14:48 +00:00
1 parent 3705bc72a8
commit 9e78ff3ba3
2 files changed
+10 -3

No files matched your search

@@ -528,6 +528,12 @@ EOF
--role "$display_role" \
--status "pending"
# The reset above is a redispatch: it issued this attempt's token. Read it
# now, so a close from the waits below (busy, idle_wait) names this
# attempt, not the previous phase's (review reviewer-grok-01)
local _disp_tok=""
_disp_tok="$("$PY" -c "import json, os; p=os.path.join('$REGISTRY_DIR', '$JOB_ID.json'); print(json.load(open(p)).get('dispatch_token','') or '') if os.path.exists(p) else print('')" 2>/dev/null || true)"
# Registry wait (Issue #50), then idle wait - on the record just reset to
# pending for this phase, so the waiter's signal is written and other
# waiters see this job in the FIFO (review F1)
@@ -546,9 +552,6 @@ EOF
fi
fi
local _disp_tok=""
_disp_tok="$("$PY" -c "import json, os; p=os.path.join('$REGISTRY_DIR', '$JOB_ID.json'); print(json.load(open(p)).get('dispatch_token','') or '') if os.path.exists(p) else print('')" 2>/dev/null || true)"
# Start subscriber
local logf="$REGISTRY_DIR/${JOB_ID}.iter_${iteration}_${display_role}.subscriber.out"
local loop_sub_args=(--attempt-id "$attempt" --ack-timeout "$TIMEOUT")