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/omega-mv/blob/main/tests/train/train_receipt.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / train / train_receipt.sh` 130 lines ยท 7094 bytes Raw Blame History 1 #!/bin/bash 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # train_receipt.sh -- receipt for the M22 optimizer substrate + E5 provenance 18 # tests (mk/train.mk, pure seeded OM-2). 19 # 20 # tests/train/train_receipt.sh [out-dir] (default: evidence/M22/receipts) 21 # 22 # Refuses a dirty tree. Runs `make test-train` twice from a clean build dir; 23 # both runs must compile bit-identical pure-OM binaries, pass train-purity, 24 # pass all test_train sub-runs, and print identical replay digests and 25 # replay dispatch heads. Writes a NEW file named by the SHA-256 of its own 26 # bytes; never rewrites one. 27 # Verdict vocabulary: the SUBSTRATE tests PASS or FAIL; M22 itself is always 28 # NOT QUALIFIED here (no tensor/autodiff integration; waits M20/M21). 29 # Host-only, single core. Shell + coreutils only. 30 set -u 31 HERE=$(cd "$(dirname "$0")/../.." && pwd) 32 cd "$HERE" || exit 2 33 OUTDIR=${1:-evidence/M22/receipts} 34 BUILD_OUT=${OUT_DIR:-build} 35 TRAIN_OMC=${TRAIN_OMC:-seed/out/omc} 36 37 if [ -n "$(git status --porcelain)" ]; then 38 echo "train_receipt: refusing: working tree is dirty (commit first)" >&2 39 exit 3 40 fi 41 head0=$(git rev-parse HEAD) 42 tree0=$(git rev-parse 'HEAD^{tree}') 43 run_id=$(date -u +%Y%m%dT%H%M%SZ) 44 W=$(mktemp -d) 45 trap 'rm -rf "$W"' EXIT 46 47 run() { # $1 = label 48 rm -rf "$BUILD_OUT/train" 49 make --no-print-directory OUT_DIR="$BUILD_OUT" TRAIN_OMC="$TRAIN_OMC" \ 50 PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-train > "$W/$1.log" 2>&1 51 local rc=$? 52 if [ -f "$BUILD_OUT/train/test_train" ]; then 53 sha256sum "$BUILD_OUT/train/test_train" | awk '{print $1}' > "$W/$1.bin.sha256" 54 fi 55 echo $rc 56 } 57 rc1=$(run run1) 58 rc2=$(run run2) 59 dig_first() { awk -v k="$2" '$1 == k {print $2; exit}' "$W/$1"; } 60 dig_last() { awk -v k="$2" '$1 == k {print $2}' "$W/$1" | tail -n 1; } 61 is_hex64() { case "$1" in [0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) return 0 ;; *) return 1 ;; esac; } 62 63 d1a=$(dig_first run1.log replay_digest); d1b=$(dig_last run1.log replay_digest) 64 d2a=$(dig_first run2.log replay_digest); d2b=$(dig_last run2.log replay_digest) 65 h1a=$(dig_first run1.log replay_dispatch_head); h1b=$(dig_last run1.log replay_dispatch_head) 66 h2a=$(dig_first run2.log replay_dispatch_head); h2b=$(dig_last run2.log replay_dispatch_head) 67 pass1=$(grep -c '^M22_SUBSTRATE_TESTS_PASS$' "$W/run1.log") 68 pass2=$(grep -c '^M22_SUBSTRATE_TESTS_PASS$' "$W/run2.log") 69 fail_lines=$(grep -c '^M22_SUBSTRATE_TESTS_FAIL$' "$W/run1.log" "$W/run2.log" | awk -F: '{s+=$2} END{print s+0}') 70 both1=$(grep -c '^test-train: pure OM-2 PASS, replay digest equal across runs (' "$W/run1.log") 71 both2=$(grep -c '^test-train: pure OM-2 PASS, replay digest equal across runs (' "$W/run2.log") 72 purity1=$(grep -c '^train-purity: src/train is 100% pure seeded OM-2 (0 C/H files)$' "$W/run1.log") 73 purity2=$(grep -c '^train-purity: src/train is 100% pure seeded OM-2 (0 C/H files)$' "$W/run2.log") 74 bin1=$(cat "$W/run1.bin.sha256" 2>/dev/null || true) 75 bin2=$(cat "$W/run2.bin.sha256" 2>/dev/null || true) 76 head1=$(git rev-parse HEAD) 77 dirty1=$(git status --porcelain | grep -v "^?? ${BUILD_OUT}/" || true) 78 79 reasons="" 80 [ "$rc1" = 0 ] && [ "$rc2" = 0 ] || reasons="$reasons make-failed($rc1,$rc2)" 81 [ "$pass1" = 2 ] && [ "$pass2" = 2 ] && [ "$fail_lines" = 0 ] || reasons="$reasons verdict-line-missing($pass1,$pass2,fail=$fail_lines)" 82 [ "$both1" = 1 ] && [ "$both2" = 1 ] || reasons="$reasons cross-run-replay-missing($both1,$both2)" 83 [ "$purity1" = 1 ] && [ "$purity2" = 1 ] || reasons="$reasons purity-missing($purity1,$purity2)" 84 is_hex64 "$d1a" && [ "$d1a" = "$d1b" ] && [ "$d1a" = "$d2a" ] && [ "$d2a" = "$d2b" ] || reasons="$reasons replay-digest-differs" 85 is_hex64 "$h1a" && [ "$h1a" = "$h1b" ] && [ "$h1a" = "$h2a" ] && [ "$h2a" = "$h2b" ] || reasons="$reasons replay-dispatch-head-differs" 86 is_hex64 "$bin1" && [ "$bin1" = "$bin2" ] || reasons="$reasons binary-digest-differs" 87 [ "$head0" = "$head1" ] || reasons="$reasons head-moved" 88 [ -z "$dirty1" ] || reasons="$reasons tree-dirty-after" 89 verdict=PASS; [ -z "$reasons" ] || verdict=FAIL 90 91 log_sha=$(cat "$W/run1.log" "$W/run2.log" | sha256sum | awk '{print $1}') 92 src_sha=$(cat src/train/generation.om src/train/sgd_update.om src/train/tg_sha256.om src/train/tg_store.om src/train/tg_sgd.om tests/train/test_train.om mk/train.mk | sha256sum | awk '{print $1}') 93 omc_sha=$(sha256sum "$TRAIN_OMC" 2>/dev/null | awk '{print $1}') 94 mkdir -p "$OUTDIR" 95 cat > "$W/receipt.json" <&2 126 exit 0 127 fi 128 cp "$W/receipt.json" "$OUTDIR/$name.json" 129 echo "train_receipt: $verdict -> $OUTDIR/$name.json" 130 [ "$verdict" = PASS ]