← back to Gmc Titlefix
wait-and-verify.sh
49 lines
#!/bin/bash
# STEP 2 wrapper — wait for the running step-d scale-out (PID arg) to exit,
# allow Google reprocessing time, then run the full-feed verifier.
set -u
cd "$HOME/Projects/gmc-titlefix" || exit 1
PID="${1:-2358}"
BUFFER="${BUFFER:-900}" # seconds to wait after step-d exits for Google to reprocess
LOG=/tmp/gmc-verify.log
exec >>"$LOG" 2>&1
echo "[$(date)] wait-and-verify: watching step-d PID $PID, reprocessing buffer ${BUFFER}s"
while kill -0 "$PID" 2>/dev/null; do sleep 60; done
echo "[$(date)] step-d PID $PID has exited. last scale log:"; tail -3 /tmp/gmc-stepd-full.log
echo "[$(date)] sleeping ${BUFFER}s for Google to reprocess supplemental overrides..."
sleep "$BUFFER"
echo "[$(date)] running step-e-verify-all.js ..."
node step-e-verify-all.js
echo "[$(date)] verify done. verdict: $(cat /tmp/gmc-verify-verdict.txt 2>/dev/null) — result: /tmp/gmc-verify-result.json"
# STEP-F retry (DTD-unanimous A) — Steve gave explicit "go" 2026-06-18, so the real retry
# auto-executes after the FINAL post-completion verify (NOT before — that would re-push not-yet-reached offers).
NF=$(node -e 'try{console.log(JSON.parse(require("fs").readFileSync("/tmp/gmc-notflipped.json","utf8")).length)}catch(e){console.log(0)}')
if [ "${NF:-0}" -gt 0 ]; then
if [ "${NF}" -gt 3000 ]; then
echo "[$(date)] SAFETY ABORT: $NF not-flipped is implausibly high for a completed push — verify likely ran early. NOT retrying. Re-run step-e then step-f manually."
else
echo "[$(date)] $NF offers not flipped after completion — executing authorized retry (CONFIRM_RETRY=1):"
CONFIRM_RETRY=1 node step-f-retry-fails.js
echo "[$(date)] retry pushed; sleeping ${BUFFER}s then re-verifying..."
sleep "$BUFFER"
node step-e-verify-all.js
echo "[$(date)] POST-RETRY verdict: $(cat /tmp/gmc-verify-verdict.txt 2>/dev/null)"
NF2=$(node -e 'try{console.log(JSON.parse(require("fs").readFileSync("/tmp/gmc-notflipped.json","utf8")).length)}catch(e){console.log(0)}')
if [ "${NF2:-0}" -gt 0 ]; then
DRAFT="$HOME/.claude/yolo-queue/pending-approval/31-gmc-titlefix-retry-residual.md"
{ echo "# GMC title-fix — $NF2 offers STILL not flipped after auto-retry (DTD-A, Steve go 2026-06-18)";
echo; echo "Started with $NF not-flipped; after a CONFIRM_RETRY pass + ${BUFFER}s reprocess, $NF2 remain.";
echo "These resisted ≤3 idempotent re-inserts → likely a deterministic cause (deleted variant, feed-label";
echo "mismatch, or genuinely removed), NOT a transient 500. Worth a manual look — ids: /tmp/gmc-notflipped.json";
echo "Persistent insert-failures (if any): /tmp/gmc-retry-persisted-fails.json. Full log: /tmp/gmc-verify.log";
} > "$DRAFT"
echo "[$(date)] residual draft written → $DRAFT"
else
echo "[$(date)] ✅ ALL offers flipped after retry — 100%. Done."
fi
fi
else
echo "[$(date)] 0 offers not flipped — nothing to retry. ✅"
fi