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
aien-sovereign-core-mv / om / golden / record.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # om/golden/record.sh: record greedy golden token ids from an aien-serve-http endpoint. |
| 4 | # Sequencing only: golden (om/golden/golden.om) validates prompts, writes every request body, judges |
| 5 | # every reply and writes the record; curl only moves bytes. |
| 6 | # Usage: OMC=... bash om/golden/record.sh --url http://HOST:PORT --prompts P.json --model-repo ORG/NAME |
| 7 | # --model-rev SHA40 --max-tokens N --engine-sha256 SHA64 --host-id ID --label REAL|FAKE --out FILE |
| 8 | # [--header-file F] [--timeout SECONDS] |
| 9 | # GOLDEN=path skips the build and uses that golden binary. |
| 10 | # Exit: 0 written, 2 usage or existing --out, 3 compiler not pinned, 4/5 refused by golden, 6 transport. |
| 11 | set -u |
| 12 | here=$(cd "$(dirname "$0")" && pwd) |
| 13 | url= prompts= repo= rev= maxt= eng= host= label= out= hdr= tmo=600 |
| 14 | while [ $# -gt 1 ]; do |
| 15 | case $1 in |
| 16 | --url) url=$2 ;; --prompts) prompts=$2 ;; --model-repo) repo=$2 ;; --model-rev) rev=$2 ;; |
| 17 | --max-tokens) maxt=$2 ;; --engine-sha256) eng=$2 ;; --host-id) host=$2 ;; --label) label=$2 ;; |
| 18 | --out) out=$2 ;; --header-file) hdr=$2 ;; --timeout) tmo=$2 ;; |
| 19 | *) echo "record: refused 2 unknown option $1" >&2; exit 2 ;; |
| 20 | esac |
| 21 | shift 2 |
| 22 | done |
| 23 | [ $# -eq 0 ] || { echo "record: refused 2 option without value" >&2; exit 2; } |
| 24 | for v in url prompts repo rev maxt eng host label out; do |
| 25 | [ -n "${!v}" ] || { echo "record: refused 2 missing $v" >&2; exit 2; } |
| 26 | done |
| 27 | if [ -e "$out" ] || [ -L "$out" ]; then echo "record: refused 2 $out exists" >&2; exit 2; fi |
| 28 | work=$(mktemp -d "$(dirname "$out")/.golden-record.XXXXXX") || exit 2 |
| 29 | trap 'rm -rf "$work"' EXIT |
| 30 | if [ -z "${GOLDEN:-}" ]; then |
| 31 | bash "$here/build.sh" "$work/golden" || exit $? |
| 32 | GOLDEN=$work/golden |
| 33 | fi |
| 34 | mkdir "$work/req" "$work/resp" |
| 35 | n=$("$GOLDEN" req "$prompts" "$repo" "$maxt" "$work/req") || exit $? |
| 36 | hargs=() |
| 37 | [ -z "$hdr" ] || hargs=(-H "@$hdr") |
| 38 | for ((i = 0; i < n; i++)); do |
| 39 | curl --silent --show-error --fail --max-time "$tmo" --noproxy '*' --proto '=http,https' \ |
| 40 | -H 'Content-Type: application/json' -H 'Expect:' "${hargs[@]}" \ |
| 41 | --data-binary "@$work/req/$i.json" -o "$work/resp/$i.json" "$url/v1/chat/completions" \ |
| 42 | || { echo "record: refused 6 transport prompt $i" >&2; exit 6; } |
| 43 | done |
| 44 | "$GOLDEN" rec "$prompts" "$repo" "$rev" "$maxt" "$eng" "$host" "$label" "$work/resp" > "$work/record.json" || exit $? |
| 45 | ln "$work/record.json" "$out" || { echo "record: refused 2 $out exists" >&2; exit 2; } |