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/benchmarks-mv/blob/main/native/queueflow/gate.sh # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. 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 `benchmarks-mv / native / queueflow / gate.sh` 147 lines ยท 10291 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # gate.sh OMC [SCRATCH]: the DRA-190 queue-flow gate. Compiles flow.om and kflow.om with the pinned 6 # seeded omc, replays the committed fixtures and traces, and compares the output byte for byte with 7 # the Wolfram oracle results (flow) and the committed outputs plus the independent awk recount 8 # (kflow). Then it compiles one-line source mutants and planted bad inputs that must be refused or 9 # detected. Prints PASS/FAIL per check and "QFGATE PASS checks=N" (exit 0) or "QFGATE FAIL ..." 10 # (exit 1). Any other compiler: "QFGATE NOT_RUN" (exit 3). 11 set -u 12 here=$(cd "$(dirname "$0")" && pwd) 13 omc=${1:-} 14 read -r pin pinrev < "$here/omc.pin" 15 if [ -z "$omc" ] || [ ! -f "$omc" ] || [ "$(sha256sum "$omc" | cut -c1-64)" != "$pin" ]; then 16 echo "QFGATE NOT_RUN: need the omc with sha256 $pin ($pinrev, from omc.pin)"; exit 3 17 fi 18 w=${2:-${TMPDIR:-/tmp}/qfgate.$$} 19 mkdir -p "$w" 20 n=0; f=0 21 ok() { n=$((n+1)); echo "PASS $1"; } 22 bad() { n=$((n+1)); f=$((f+1)); echo "FAIL $1"; } 23 build() { "$omc" < "$1" > "$2.new" 2> "$2.err" && mv "$2.new" "$2" && chmod +x "$2"; } 24 E=$here/evidence; X=$here/fixtures 25 build "$here/flow.om" "$w/flow" && ok compile-flow || bad compile-flow 26 build "$here/kflow.om" "$w/kflow" && ok compile-kflow || bad compile-kflow 27 same() { # name expect-file command... 28 nm=$1; ex=$2; shift 2 29 "$@" > "$w/out" 2>&1 30 if cmp -s "$w/out" "$ex"; then ok "$nm"; else bad "$nm"; fi 31 } 32 same f1-vs-wolfram "$X/f1.expect" "$w/flow" "$X/f1.tsv" 0 33 same f2-vs-wolfram "$X/f2.expect" "$w/flow" "$X/f2.tsv" 0 34 # f3/f4/f5 pin the H3 boundary (HARM = 60 s, strict >): f3 has a wait difference of exactly 61 s, 35 # f4 (from f1) and f5 (from f2) differences of exactly 60 s in the two directions (wy - wx, wx - wy). 36 # Expected outputs are the Wolfram oracle's (evidence/wolfram/f3, f4, f5). 37 same f3-vs-wolfram "$X/f3.expect" "$w/flow" "$X/f3.tsv" 0 38 same f4-vs-wolfram "$X/f4.expect" "$w/flow" "$X/f4.tsv" 0 39 same f5-vs-wolfram "$X/f5.expect" "$w/flow" "$X/f5.tsv" 0 40 same dev-vs-wolfram "$E/heldout/flow-dev.expect" "$w/flow" "$E/trace/windows-dev.tsv" 0 41 d0=$(cat "$E/trace/windows-heldout.tsv.d0") 42 same heldout-vs-wolfram "$E/wolfram/heldout.result.txt" "$w/flow" "$E/trace/windows-heldout.tsv" "$d0" 43 # planted bad inputs 44 "$w/flow" "$X/bad-overlap.tsv" 0 > "$w/out" 2>&1 45 if grep -q 'anomalies=1 ' "$w/out" && grep -q 'arm=A .*replayerr=1$' "$w/out"; then ok planted-overlap-detected; else bad planted-overlap-detected; fi 46 "$w/flow" "$X/bad-malformed.tsv" 0 > "$w/out" 2>&1; rc=$? 47 if [ $rc -eq 3 ] && grep -q '^QF error malformed line 1$' "$w/out"; then ok planted-malformed-refused; else bad planted-malformed-refused; fi 48 "$w/flow" "$X/f1.tsv" > "$w/out" 2>&1; rc=$? 49 [ $rc -eq 2 ] && ok usage-refused || bad usage-refused 50 # kflow: committed outputs and the independent recount 51 tx=$(sed -n 's/^export_utc_epoch //p' "$E/trace/kanban-export.txt") 52 ctx=$(cut -f2 "$E/trace/control/kanban-events.tsv" | sort -n | tail -n 1) 53 "$w/kflow" "$E/trace/kanban-tasks.tsv" "$E/trace/kanban-runs.tsv" "$E/trace/kanban-events.tsv" "$tx" 12 > "$w/kh" 2>&1; echo "rc $?" >> "$w/kh" 54 cmp -s "$w/kh" "$E/heldout/kflow-heldout.out" && ok kflow-heldout-reproduced || bad kflow-heldout-reproduced 55 "$w/kflow" "$E/trace/control/kanban-tasks.tsv" "$E/trace/control/kanban-runs.tsv" "$E/trace/control/kanban-events.tsv" "$ctx" 12 > "$w/kc" 2>&1; echo "rc $?" >> "$w/kc" 56 cmp -s "$w/kc" "$E/heldout/kflow-control.out" && ok kflow-control-reproduced || bad kflow-control-reproduced 57 recount() { # kflow-output kcheck-output: the shared fields must agree 58 k=$1; c=$2 59 a=$(sed -n 's/^KQ sys created=\([0-9]*\) closed=\([0-9]*\) .*open_table=\([0-9]*\) mismatch=\(-*[0-9]*\)$/\1 \2 \3 \4/p' "$k") 60 b=$(sed -n 's/^KC sys created=\([0-9]*\) closed=\([0-9]*\) open_table=\([0-9]*\) mismatch=\(-*[0-9]*\)$/\1 \2 \3 \4/p' "$c") 61 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 62 a=$(sed -n 's/^KQ run starts=\([0-9]*\) ends=\([0-9]*\) .*running_table=\([0-9]*\) mismatch=\(-*[0-9]*\)$/\1 \2 \3 \4/p' "$k") 63 b=$(sed -n 's/^KC run starts=\([0-9]*\) ends=\([0-9]*\) running_table=\([0-9]*\) mismatch=\(-*[0-9]*\)$/\1 \2 \3 \4/p' "$c") 64 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 65 a=$(sed -n 's/^KQ retry extra=\([0-9]*\) tasks_multi=\([0-9]*\) bad=\([0-9]*\)$/\1 \2 \3/p' "$k") 66 b=$(sed -n 's/^KC retry extra=\([0-9]*\) tasks_multi=\([0-9]*\) bad=\([0-9]*\) busy=.*$/\1 \2 \3/p' "$c") 67 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 68 a=$(sed -n 's/^KQ util busy=\([0-9]*\) .*/\1/p' "$k"); b=$(sed -n 's/^KC retry .* busy=\([0-9]*\)$/\1/p' "$c") 69 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 70 a=$(sed -n 's/^KQ lat n=\([0-9]*\) sum=\([0-9]*\) .*/\1 \2/p' "$k"); b=$(sed -n 's/^KC lat n=\([0-9]*\) sum=\([0-9]*\)$/\1 \2/p' "$c") 71 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 72 a=$(sed -n 's/^KQ pool p=\([0-9]*\) runs=\([0-9]*\) busy=\([0-9]*\) union=\([0-9]*\) .*/\1 \2 \3 \4/p' "$k") 73 b=$(sed -n 's/^KC pool p=\([0-9]*\) runs=\([0-9]*\) busy=\([0-9]*\) union=\([0-9]*\)$/\1 \2 \3 \4/p' "$c") 74 [ -n "$a" ] && [ "$a" = "$b" ] || return 1 75 return 0 76 } 77 sh "$here/kcheck.sh" "$E/trace" "$tx" > "$w/kch" 78 recount "$w/kh" "$w/kch" && ok kflow-heldout-vs-awk-recount || bad kflow-heldout-vs-awk-recount 79 sh "$here/kcheck.sh" "$E/trace/control" "$ctx" > "$w/kcc" 80 recount "$w/kc" "$w/kcc" && ok kflow-control-vs-awk-recount || bad kflow-control-vs-awk-recount 81 grep -q '^KQ retry extra=7 tasks_multi=7 bad=6$' "$w/kc" && ok control-retries-seen || bad control-retries-seen 82 # kanban fixtures, hand-computed (cap 2, tx 200): k1 has a task with 3 runs (the R = 1 arm drops its 83 # completed third run) and 3 concurrent runs for 10 s; k2 is k1 with task 3 planted as running while 84 # its runs and events say closed, so both mismatch checks must fire. 85 kfix() { "$w/kflow" "$X/$1/kanban-tasks.tsv" "$X/$1/kanban-runs.tsv" "$X/$1/kanban-events.tsv" 200 2 > "$2" 2>&1; echo "rc $?" >> "$2"; } 86 kfix k1 "$w/k1"; kfix k2 "$w/k2"; kfix k3 "$w/k3" 87 cmp -s "$w/k1" "$X/k1.expect" && ok k1-reproduced || bad k1-reproduced 88 cmp -s "$w/k2" "$X/k2.expect" && ok k2-reproduced || bad k2-reproduced 89 grep -q '^KQ conc max=3 overcap_s=10$' "$w/k1" && grep -q '^KQ arm=Cr dropped=1 dropped_completed=1$' "$w/k1" \ 90 && ok k1-hand-values || bad k1-hand-values 91 grep -q '^KQ sys .* mismatch=-1$' "$w/k2" && grep -q '^KQ run .* mismatch=-1$' "$w/k2" \ 92 && ok k2-planted-mismatch-detected || bad k2-planted-mismatch-detected 93 sh "$here/kcheck.sh" "$X/k1" 200 > "$w/kc1"; recount "$w/k1" "$w/kc1" && ok k1-vs-awk-recount || bad k1-vs-awk-recount 94 sh "$here/kcheck.sh" "$X/k2" 200 > "$w/kc2"; recount "$w/k2" "$w/kc2" && ok k2-vs-awk-recount || bad k2-vs-awk-recount 95 # k3 is k1 with task 1's third run not completed (the R = 1 arm drops it: dropped_completed = 0, the 96 # H5 NOT EXCLUDED side) and task 2's run crashed (outcome 3, counted as bad). 97 cmp -s "$w/k3" "$X/k3.expect" && ok k3-reproduced || bad k3-reproduced 98 grep -q '^KQ arm=Cr dropped=1 dropped_completed=0$' "$w/k3" && grep -q '^KQ retry extra=2 tasks_multi=1 bad=1$' "$w/k3" \ 99 && grep -q '^KQ acc done=3 done_completed_run=1$' "$w/k3" && ok k3-hand-values || bad k3-hand-values 100 sh "$here/kcheck.sh" "$X/k3" 200 > "$w/kc3"; recount "$w/k3" "$w/kc3" && ok k3-vs-awk-recount || bad k3-vs-awk-recount 101 # mutants: each one-line change must compile and change at least one replay (killed) 102 mut() { # name source sed-expression check... 103 nm=$1; src=$2; ex=$3 104 sed "$ex" "$src" > "$w/m.om" 105 if cmp -s "$w/m.om" "$src"; then bad "mutant-$nm (sed did not apply)"; return; fi 106 if ! build "$w/m.om" "$w/m"; then bad "mutant-$nm (does not compile)"; return; fi 107 if [ "$src" = "$here/flow.om" ]; then 108 k=0 109 "$w/m" "$X/f1.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$X/f1.expect" || k=1 110 "$w/m" "$X/f2.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$X/f2.expect" || k=1 111 "$w/m" "$E/trace/windows-dev.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$E/heldout/flow-dev.expect" || k=1 112 "$w/m" "$X/f3.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$X/f3.expect" || k=1 113 "$w/m" "$X/f4.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$X/f4.expect" || k=1 114 "$w/m" "$X/f5.tsv" 0 > "$w/o" 2>&1; cmp -s "$w/o" "$X/f5.expect" || k=1 115 "$w/m" "$E/trace/windows-heldout.tsv" "$d0" > "$w/o" 2>&1; cmp -s "$w/o" "$E/wolfram/heldout.result.txt" || k=1 116 else 117 k=0 118 "$w/m" "$E/trace/control/kanban-tasks.tsv" "$E/trace/control/kanban-runs.tsv" "$E/trace/control/kanban-events.tsv" "$ctx" 12 > "$w/o" 2>&1; echo "rc $?" >> "$w/o" 119 cmp -s "$w/o" "$E/heldout/kflow-control.out" || k=1 120 "$w/m" "$E/trace/kanban-tasks.tsv" "$E/trace/kanban-runs.tsv" "$E/trace/kanban-events.tsv" "$tx" 12 > "$w/o" 2>&1; echo "rc $?" >> "$w/o" 121 cmp -s "$w/o" "$E/heldout/kflow-heldout.out" || k=1 122 for kf in k1 k2 k3; do 123 "$w/m" "$X/$kf/kanban-tasks.tsv" "$X/$kf/kanban-runs.tsv" "$X/$kf/kanban-events.tsv" 200 2 > "$w/o" 2>&1; echo "rc $?" >> "$w/o" 124 cmp -s "$w/o" "$X/$kf.expect" || k=1 125 done 126 fi 127 [ $k = 1 ] && ok "mutant-$nm-killed" || bad "mutant-$nm-survived" 128 } 129 F=$here/flow.om; K=$here/kflow.om 130 mut no-lease-cap "$F" 's/^if eq cap 1$/if eq cap 7/' 131 mut no-inline-arrival "$F" 's/^put ar i get ar sub i 1$/put ar i a/' 132 mut no-retry-bound "$F" 's/^ret gt get rc i RMAX$/ret false/' 133 mut elig-ignores-el "$F" 's/^c = lmax t lmax get ar j get el j$/c = lmax t get ar j/' 134 mut no-leg-causality "$F" 's/^if eq get sq j 1$/if eq get sq j 9/' 135 mut accept-any-close "$F" 's/^if ne get cc i 0$/if ne get cc i 9/' 136 mut kflow-ends-count-null "$K" 's/^if gt get re i 0$/if ge get re i 0/' 137 mut kflow-archived-not-closed "$K" 's/^if gt k 1$/if gt k 2/' 138 mut flow-harm-61 "$F" 's/^const HARM long 60$/const HARM long 61/' 139 mut flow-harm-ge-x "$F" 's/^if gt sub wx wy HARM$/if ge sub wx wy HARM/' 140 mut flow-harm-ge-y "$F" 's/^if gt sub wy wx HARM$/if ge sub wy wx HARM/' 141 mut kflow-r1-arm-never-drops "$K" 's/^if gt get cnt x 2$/if gt get cnt x 9/' 142 mut kflow-overcap-zero "$K" 's/^if gt concat a nr tx cap$/if gt concat a nr tx 999/' 143 mut kflow-concat-le "$K" '0,/^if lt t rend j tx$/s//if le t rend j tx/' 144 mut kflow-r1-dropped-all-completed "$K" '/^if gt get cnt x 2$/,/^if eq get ro j 1$/s/^if eq get ro j 1$/if ge get ro j 0/' 145 mut kflow-crash-not-bad "$K" 's/^if ge o 3$/if ge o 4/' 146 if [ $f -eq 0 ]; then echo "QFGATE PASS checks=$n"; exit 0; fi 147 echo "QFGATE FAIL checks=$n failed=$f"; exit 1