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-protocols-mv/blob/main/specs/aienet/jobpath/parity.sh # aien-protocols-mv Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem 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-protocols-mv / specs / aienet / jobpath / parity.sh` 51 lines ยท 2080 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # Parity: the Omega recompute (Spark verifier) against the Rust worker kernel 3 # (aien-microjob aienet0::matmul_u32_digest, i-k-j order) on fixed shapes, 4 # then the .om refusal exits. Usage: parity.sh RECOMPUTE_BIN 5 # Exit 0 only for parity, 1 for a behavioral mismatch, 2 for invalid setup/output. 6 set -e -u -o pipefail 7 bin=${1:?usage: parity.sh RECOMPUTE_BIN} 8 root=$(cd "$(dirname "$0")/../../.." && pwd) 9 cd "$root" 10 invalid() { echo "PARITY INVALID: $*" >&2; exit 2; } 11 for tool in cargo xxd; do 12 command -v "$tool" >/dev/null || invalid "missing $tool" 13 done 14 [ -x "$bin" ] || invalid "recompute is not executable" 15 target=${CARGO_TARGET_DIR:-$root/target} 16 cargo build -q -p aien-microjob --example an0_digest --target-dir "$target" || invalid 'Rust oracle build failed' 17 ex=$target/debug/examples/an0_digest 18 [ -x "$ex" ] || invalid 'Rust oracle is not executable' 19 fail=0 20 while read -r m k n seed; do 21 oracle=$("$ex" "$m" "$k" "$n" "$seed") || invalid 'Rust oracle failed' 22 [[ $oracle =~ ^[0-9a-f]{30}\ [0-9a-f]{64}$ ]] || invalid 'malformed Rust oracle output' 23 read -r payload want <<< "$oracle" 24 got=$(printf '%s' "$payload" | xxd -r -p | "$bin") || invalid 'recompute failed' 25 [[ $got =~ ^[0-9a-f]{64}$ ]] || invalid 'malformed recompute output' 26 if [ "$got" = "$want" ]; then 27 echo "MATCH $m $k $n $seed $got" 28 else 29 echo "MISMATCH $m $k $n $seed rust=$want om=$got"; fail=1 30 fi 31 done <<'EOF' 32 1 1 1 0 33 7 5 3 `2716205057` 34 3 8 1 `18446744073709551615` 35 16 9 31 42 36 64 64 64 `1311768467463790320` 37 1 256 1 7 38 256 1 256 7 39 256 256 256 `2716205057` 40 EOF 41 # Refusals: payload kind 2 -> 3, a zero dimension -> 4, m=257 -> 4, short -> 2. 42 check() { 43 local hex=$1 want=$2 rc 44 if printf '%s' "$hex" | xxd -r -p | "$bin" >/dev/null 2>&1; then rc=0; else rc=$?; fi 45 if [ "$rc" = "$want" ]; then echo "REFUSE_OK exit=$rc payload=$hex"; else echo "REFUSE_BAD want=$want got=$rc payload=$hex"; fail=1; fi 46 } 47 check `020001000100010000000000000001` 3 48 check `010000000100010000000000000001` 4 49 check `010101000100010000000000000001` 4 50 check `0100010001000100000000000000` 2 51 exit "$fail"