omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / ty7_drive.sh
| 1 | #!/bin/sh |
| 2 | # TY-7 session driver (docs/turing/TURING_YIELD_TY7_PROTOCOL.md section 7). |
| 3 | # usage: tools/ty7_drive.sh OUTDIR PROMPTS |
| 4 | # Order: IDLE0 WORK1 IDLE1 WORK2 IDLE2 WORK3 IDLE3. IDLE = 60 s, no requests. |
| 5 | # WORK r = the prompts of round r in order, each WORK window inside its own |
| 6 | # spark-receipt. Health is polled every 1 s for the whole session. |
| 7 | # Writes OUTDIR/session.log, health.log, intervals.log, r<R>-p<I>.json. |
| 8 | # Never stops or restarts the server; server_busy is retried after 0.05 s |
| 9 | # (outside the request interval). |
| 10 | set -u |
| 11 | OUT=$1; PROMPTS=$2 |
| 12 | URL=${TY7_URL:-http://127.0.0.1:18091} |
| 13 | IDLE_S=${TY7_IDLE_S:-60} |
| 14 | ROUNDS=${TY7_ROUNDS:-3} |
| 15 | mkdir -p "$OUT" |
| 16 | ns() { date +%s%N; } |
| 17 | |
| 18 | poll_health() { |
| 19 | while :; do |
| 20 | t=$(ns) |
| 21 | b=$(curl -s -m 1 "$URL/health" | grep -o '"busy":[a-z]*' | cut -d: -f2) |
| 22 | case $b in true) b=1 ;; false) b=0 ;; *) b=E ;; esac |
| 23 | echo "$t $b" >> "$OUT/health.log" |
| 24 | sleep 1 |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | idle() { |
| 29 | echo "IDLE $1 start $(ns)" >> "$OUT/session.log" |
| 30 | sleep "$IDLE_S" |
| 31 | echo "IDLE $1 end $(ns)" >> "$OUT/session.log" |
| 32 | } |
| 33 | |
| 34 | poll_health & |
| 35 | POLL=$! |
| 36 | trap 'kill $POLL 2>/dev/null' EXIT INT TERM |
| 37 | |
| 38 | echo "SESSION start $(ns) url=$URL prompts=$PROMPTS sha256=$(sha256sum "$PROMPTS" | cut -d' ' -f1)" >> "$OUT/session.log" |
| 39 | idle 0 |
| 40 | r=1 |
| 41 | while [ "$r" -le "$ROUNDS" ]; do |
| 42 | echo "WORK $r start $(ns)" >> "$OUT/session.log" |
| 43 | spark-receipt "ty7-w$r" --idle 30 -- "$(dirname "$0")/ty7_round.sh" "$OUT" "$PROMPTS" "$r" "$URL" |
| 44 | echo "WORK $r end $(ns) rc=$? receipt=$HOME/yardsticks/receipts/$(date +%F)-ty7-w$r.json" >> "$OUT/session.log" |
| 45 | idle "$r" |
| 46 | r=$((r + 1)) |
| 47 | done |
| 48 | echo "SESSION end $(ns)" >> "$OUT/session.log" |