ops(scripts): dispatch, queue gating, heartbeat, quota probe

dispatch-turn.sh (headless turn launcher with TURN_MODEL routing),
queue-after.sh (serial gate chain + quota-wall guard), pmo-heartbeat.sh
(PMO wake loop), quota-probe-then-chain.sh (post-wall relaunch).
This commit is contained in:
2026-08-29 05:22:43 -05:00
parent 458d92831e
commit 79d93b6c49
18 changed files with 825 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# queue-after.sh <gate-screen> <slug> <task-file>
# Wait until <gate-screen> no longer exists, then dispatch the task turn.
# Keeps repo-touching turns serialized when two queue screens would overlap.
set -uo pipefail
GATE="$1"; SLUG="$2"; TASK="$3"
LOGDIR="$HOME/.coordinate/logs"
while screen -ls 2>/dev/null | grep -q "\.${GATE}[[:space:]]"; do
sleep 60
done
# QUOTA WALL GUARD: if any recent turn log shows the z.ai usage wall,
# halt the chain instead of burning the next turn into the same wall.
WALLLOG=$(ls -t "$LOGDIR"/q-*.log 2>/dev/null | head -1)
if [ -n "$WALLLOG" ] && grep -q "Usage limit reached" "$WALLLOG" 2>/dev/null; then
echo "$(date -Is) QUOTA WALL detected in $WALLLOG — chain halted before $SLUG" >> "$LOGDIR/queue.status"
screen -S RCEO-PMO -X stuff "QUOTA WALL - chain halted before $SLUG. Do not dispatch until quota verified.$(printf '\r')" || true
exit 0
fi
echo "$(date -Is) GATE $GATE cleared — RUN $SLUG" >> "$LOGDIR/queue.status"
bash "$HOME/.coordinate/scripts/dispatch-turn.sh" "q-$SLUG" "$TASK" \
>> "$LOGDIR/queue-$SLUG.log" 2>&1
rc=$?
echo "$(date -Is) $([ $rc -eq 0 ] && echo OK || echo "FAIL(rc=$rc)") $SLUG" >> "$LOGDIR/queue.status"