diff --git a/deploy/demo-kill-resume.sh b/deploy/demo-kill-resume.sh index fd643c0..6bc01f8 100755 --- a/deploy/demo-kill-resume.sh +++ b/deploy/demo-kill-resume.sh @@ -54,21 +54,35 @@ curl -sf --max-time 2 localhost:9100/healthz >/dev/null || { echo "agent never c echo "agent back — startup sweep resumes in-flight threads" step "5/6 — wait for the approval card (sweeper resume → node re-run → outbox)" +# Mode-agnostic: the card is "delivered" when its outbox row is done (works for +# both SLACK_DRY_RUN=true — jsonl log — and live Slack). The jsonl tail below +# is the dry-run rendering; live mode points at the Slack channel instead. found="" -for _ in $(seq 1 180); do - if [ -f "$LOG" ] && grep -q "$THREAD" "$LOG" 2>/dev/null; then found=1; break; fi +for _ in $(seq 1 300); do + delivered="$(docker exec agent99-postgres-1 \ + psql -U agent99 -d agent99 -tA -c \ + "SELECT count(*) FROM outbox WHERE idempotency_key LIKE '$THREAD:approval_card:%' AND status = 'done';" 2>/dev/null || echo 0)" + [ "${delivered:-0}" -ge 1 ] && { found=1; break; } sleep 1 done if [ -z "$found" ]; then - echo "no card for $THREAD within 180s — check: $COMPOSE logs agent" + echo "no card for $THREAD within 300s — check: $COMPOSE logs agent" exit 1 fi -grep "$THREAD" "$LOG" | tail -1 | python3 -c ' +if [ -f "$LOG" ] && grep -q "$THREAD" "$LOG" 2>/dev/null; then + grep "$THREAD" "$LOG" | tail -1 | python3 -c ' import json, sys entry = json.loads(sys.stdin.read()) print("[%s] channel=%s ts=%s" % (entry["op"], entry.get("channel"), entry.get("ts"))) print(entry.get("text", "")) ' +else + ts="$(docker exec agent99-postgres-1 \ + psql -U agent99 -d agent99 -tA -c \ + "SELECT extra->'slack_ts'->>'approval' FROM incidents WHERE thread_id = '$THREAD';")" + echo "[chat.postMessage] live Slack (SLACK_DRY_RUN=false) — approval card ts=$ts" + echo "open the #agent99signoz channel to see it" +fi step "6/6 — prove resume + exactly-once (audit trail + outbox dedupe)" docker exec agent99-postgres-1 \