#!/usr/bin/env bash # plans/ra-kernel-spike.sh — does a PERSISTENT next/ kernel hold flow_store across HTTP requests? # Boots a background sx_server running ra_kernel:start (flow_store + a blocking http:listen), then # drives it with TWO separate curls: /start (suspend instance 1) then /resume (resume instance 1). # If /resume returns done, the gen_server persisted across requests → RA-live + TA-live are unblocked. set -uo pipefail cd "$(git rev-parse --show-toplevel)" SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}" [ -x "$SX_SERVER" ] || SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe" PORT=51877 EPOCH_FILE=$(mktemp); LOG_FILE=$(mktemp) cleanup() { [ -n "${SXPID:-}" ] && { kill -KILL "$SXPID" 2>/dev/null || true; wait "$SXPID" 2>/dev/null || true; } [ -n "${HOLDPID:-}" ] && { kill -KILL "$HOLDPID" 2>/dev/null || true; wait "$HOLDPID" 2>/dev/null || true; } rm -f "$EPOCH_FILE" "$LOG_FILE" } trap cleanup EXIT cat > "$EPOCH_FILE" < "$FIFO" & HOLDPID=$! "$SX_SERVER" < "$FIFO" > "$LOG_FILE" 2>&1 & SXPID=$! rm -f "$FIFO" echo "── waiting for the kernel to bind :$PORT ──" BOUND="" for i in $(seq 1 240); do if (exec 3<>/dev/tcp/127.0.0.1/$PORT) 2>/dev/null; then BOUND=1; exec 3>&- 3<&-; echo "bound (iter $i)"; break; fi sleep 1 done if [ -z "$BOUND" ]; then echo "FAIL: never bound"; echo "--- log ---"; tail -20 "$LOG_FILE"; exit 1; fi echo "── request 1: GET /start (creates instance 1, suspends) ──" R1=$(curl -s -m 8 "http://127.0.0.1:$PORT/start") echo " /start → $R1" echo "── request 2 (SEPARATE): GET /resume (must hit the SAME live instance 1) ──" R2=$(curl -s -m 8 "http://127.0.0.1:$PORT/resume") echo " /resume → $R2" echo "─────────────────────────────────────────────────────" if echo "$R1" | grep -q "start:suspended" && echo "$R2" | grep -q "resume:done"; then echo "PASS — flow_store PERSISTED across requests. Persistent kernel is VIABLE." else echo "FAIL — R1='$R1' R2='$R2'"; echo "--- log tail ---"; tail -20 "$LOG_FILE" fi