#!/usr/bin/env bash
# Bench-only: report whether any Keno / gameplay synth path is armed.
set -uo pipefail
echo "host=$(hostname) ip=$(hostname -I 2>/dev/null | awk '{print $1}')"
echo "ROLE_FILE:"
cat /etc/ethergold/role.env 2>/dev/null || echo "(none)"
echo "--- fixture-bridge.env ---"
for f in \
  /etc/ethergold/fixture-bridge.env \
  "$HOME/EtherGold/dev/fixture-bridge.env" \
  "$HOME/EtherGold/sync/fixture-bridge.env" \
  "$HOME/.config/ethergold/fixture-bridge.env"; do
  if [[ -f "$f" ]]; then
    echo "FILE $f"
    grep -E 'KENO|JPOT|SYNTH|LAB_|EARLY_WIN|GAMEPLAY' "$f" || echo "(no synth keys)"
  fi
done
echo "--- process cmdline ---"
ps -ef | grep -E 'pog422_bridge|hat_bridge|run_bridge|run_ethergold' | grep -v grep || echo "(no bridge)"
echo "--- argv synth flags ---"
ps -ef | grep -E 'lab-keno|lab-touch|lab-bingo|lab-gameplay|early-win|phase2' | grep -v grep || echo "(none in ps)"
echo "--- recent events ---"
python3 - <<'PY'
from pathlib import Path
p = Path.home() / "EtherGold/dev/data/events.jsonl"
if not p.exists():
    print("no events.jsonl")
else:
    keys = ("lab_keno", "keno_jpot", "lab_gameplay_synth", "early_win", "phase2", "9309")
    hits = []
    for line in p.open(errors="replace"):
        low = line.lower()
        if any(k in low for k in keys) and ("synth" in low or "early_win" in low or "lab_keno" in low or "lab_gameplay" in low):
            hits.append(line.rstrip())
    print(f"hits={len(hits)}")
    for h in hits[-20:]:
        print(h[:400])
PY
echo "--- ERRORS synth lines ---"
grep -nE 'LAB Keno|lab_keno|keno jpot|GAMEPLAY_SYNTH|early.win|phase2|9309' "$HOME/EtherGold/dev/ERRORS.txt" 2>/dev/null | tail -40 || true
