Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/evidence/l387-motor-ship/swap.sh # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / evidence / l387-motor-ship / swap.sh` 51 lines ยท 5629 bytes Raw Blame History 1 #!/bin/bash 2 # L387 swap of 18091 to the ship build, timing receipts on the live door before (old build), 3 # stop old (clean SIGTERM), start new (same flags + switches), live gate2 (gate-batch.sh 18091 18091) + tool call, 4 # timing after. Back-out on any failure: the old bin with its switches. q36-extra admits no load during the restart. 5 # swap.sh 6 set -u 7 T=$HOME/workspace/targets/l387; S=$HOME/.local/state/aien-q36; E=$HOME/workspace/sc-motor-ship/evidence/l387-motor-ship 8 G=$HOME/workspace/sc-motor-ship/evidence/q36-batch-`20261021` 9 NEW=${1:?new bin}; OLD=bin-`16b0e6f8`; OLD_ENV="AIEN_Q36_STROKE=1"; NEW_ENV="AIEN_Q36_STROKE=1" 10 log() { echo "$(date -u +%FT%TZ) $*" | tee -a $T/swap.log; } 11 board() { echo "$(date -u +%FT%H:%MZ | sed 's/T.*T/T/') L387 to all|coordinator|renda|L040: $*" >> $HOME/handoffs/BOARD.md; } 12 # L405 (2026-10-22): exclusive windows are at most 20 min, so each timing part gets its own window; the swap and the 13 # live gate2 are value checks and need none. The old build reads 20k tokens too slowly for a 20-min window: that read 14 # runs on the shared machine and its receipt line says so. 15 win() { # : one 20-min window around one timing part 16 local n=$1; shift; log "waiting for a window ($n)" 17 spark-window open $n --ledger L387 --lease 20 --wait >> $T/swap.log 2>&1 || { log "no window for $n (chip reserved or refused): running it on the shared machine, receipts say so"; env -u SPARK_WINDOW "$@" >> $T/swap.log 2>&1; return $?; } 18 spark-window run "$@" >> $T/swap.log 2>&1; local rc=$?; spark-window close >> $T/swap.log 2>&1; log "window $n closed (rc $rc)"; return $rc; } 19 up() { for i in $(seq 1 ${2:-120}); do curl -s -m 5 127.0.0.1:18091/v1/models | grep -q qwen3.6 && return 0; sleep 2; done; return 1; } 20 idle() { for i in $(seq 1 ${1:-150}); do [ "$(curl -s -m 5 127.0.0.1:18091/health | jq -r '.in_flight // 0')" = 0 ] && return 0; sleep 2; done; return 1; } 21 stop_live() { local p; p=$(cat $S/serve.pid); ps -o args= -p $p | grep -q 'port 18091' || { log "serve.pid $p is not the 18091 server"; return 1; } 22 kill -TERM $p; for i in $(seq 1 60); do kill -0 $p 2>/dev/null || { log "stopped $p (SIGTERM, ${i}s)"; return 0; }; sleep 1; done; log "pid $p still alive after 60 s"; return 1; } 23 start_live() { # 24 local b=$1; shift; env "$@" Q36_BATCH_BIN=$b $S/start-35b-batch.sh >> $T/swap.log 2>&1; } 25 backout() { log "BACK OUT: $*"; touch /tmp/aien-q36-live-restart; stop_live; start_live $OLD $OLD_ENV; up 120 && log "old $OLD back on 18091" || log "OLD DID NOT COME UP"; rm -f /tmp/aien-q36-live-restart; board "18091 BACKED OUT to $OLD ($OLD_ENV): $*"; ledger note L387 "BACK OUT $(date -u +%H:%MZ): $*; 18091 = $OLD $OLD_ENV" >/dev/null; exit 1; } 26 log "before timing on $OLD: 20k read on the shared machine, then 2k/8k reads + decode in a window" 27 idle 60 || log "18091 not idle before timing (in_flight $(curl -s -m 5 127.0.0.1:18091/health | jq -r .in_flight))" 28 [ -n "${SKIP_BEFORE_20K:-}" ] || READ_FILES=long-20k.txt DEC_REPS=0 $E/time-motor.sh 18091 $E/before-${OLD#bin-} >> $T/swap.log 2>&1 29 win l387-before env APPEND=1 READ_FILES="long-2048.txt long-8192.txt" DEC_REPS=3 $E/time-motor.sh 18091 $E/before-${OLD#bin-} 30 board "SWAP NOW: 18091 restarts on the ship build $NEW ($NEW_ENV), back in under 3 min; requests get connection refused meanwhile, retry. Back-out line: $OLD $OLD_ENV." 31 idle 900 || { log "18091 still busy after 30 min: NO SWAP (never cut a live request; in_flight $(curl -s -m 5 127.0.0.1:18091/health | jq -r .in_flight))"; board "SWAP CANCELLED: 18091 stayed busy 30 min, still $OLD; will retry later."; exit 1; } 32 touch /tmp/aien-q36-live-restart; t0=$(date +%s) 33 stop_live || { rm -f /tmp/aien-q36-live-restart; log "could not stop old: no swap"; exit 1; } 34 start_live $NEW $NEW_ENV 35 if ! up 120; then t1=$(date +%s); log "new build not serving after $((t1-t0)) s: $(tail -3 $S/serve.log | tr '\n' ' ' | cut -c1-300)"; backout "new build $NEW did not come up"; fi 36 t1=$(date +%s); rm -f /tmp/aien-q36-live-restart; log "SWAPPED: 18091 = $NEW ($NEW_ENV), downtime $((t1-t0)) s" 37 ledger note L387 "$(date -u +%H:%MZ) SWAPPED 18091 to $NEW ($NEW_ENV), downtime $((t1-t0)) s; back-out line: Q36_BATCH_BIN=$OLD $OLD_ENV start-35b-batch.sh" >/dev/null 38 (cd $G && ./gate-batch.sh 18091 18091 live-${NEW#bin-}-$(date -u +%m%dT%H%MZ)) >> $T/swap.log 2>&1; grc=$? 39 log "live gate2 rc $grc" 40 [ $grc = 0 ] || backout "live gate2 FAIL rc $grc on $NEW" 41 M=$(curl -s -m 10 127.0.0.1:18091/v1/models | jq -r '.data[0].id') 42 jq -cn --arg m "$M" '{model:$m, messages:[{role:"user",content:"What is the weather in Paris right now? Use the tool."}], temperature:0, max_tokens:200, chat_template_kwargs:{enable_thinking:false}, tools:[{type:"function",function:{name:"get_weather",description:"Current weather for a city",parameters:{type:"object",properties:{city:{type:"string"}},required:["city"]}}}]}' \ 43 | curl -s -m 300 127.0.0.1:18091/v1/chat/completions -H 'Content-Type: application/json' -d @- > $E/live-tool-call.json 44 tn=$(jq -r '.choices[0].message.tool_calls[0].function.name // empty' $E/live-tool-call.json) 45 log "live tool call: ${tn:-NONE} $(jq -c '.choices[0].message.tool_calls[0].function.arguments // .choices[0].message.content' $E/live-tool-call.json | cut -c1-100)" 46 [ "$tn" = get_weather ] || backout "live tool call did not parse on $NEW" 47 board "18091 serves the ship build $NEW ($NEW_ENV): live gate2 PASS + tool call parsed. Back-out line: Q36_BATCH_BIN=$OLD $OLD_ENV start-35b-batch.sh." 48 log "after timing on $NEW" 49 idle 60 || true 50 win l387-after env DEC_REPS=3 $E/time-motor.sh 18091 $E/after-${NEW#bin-} 51 log "SWAP DONE"