interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / ty7_drive.sh

48 lines · 1604 bytes Raw Blame History
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).
10set -u
11OUT=$1; PROMPTS=$2
12URL=${TY7_URL:-http://127.0.0.1:18091}
13IDLE_S=${TY7_IDLE_S:-60}
14ROUNDS=${TY7_ROUNDS:-3}
15mkdir -p "$OUT"
16ns() { date +%s%N; }
17
18poll_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
28idle() {
29 echo "IDLE $1 start $(ns)" >> "$OUT/session.log"
30 sleep "$IDLE_S"
31 echo "IDLE $1 end $(ns)" >> "$OUT/session.log"
32}
33
34poll_health &
35POLL=$!
36trap 'kill $POLL 2>/dev/null' EXIT INT TERM
37
38echo "SESSION start $(ns) url=$URL prompts=$PROMPTS sha256=$(sha256sum "$PROMPTS" | cut -d' ' -f1)" >> "$OUT/session.log"
39idle 0
40r=1
41while [ "$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))
47done
48echo "SESSION end $(ns)" >> "$OUT/session.log"