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/aienos.com/blob/main/om/omega-reference/check.sh # aienos.com Source of www.aienos.com, served from my own hardware 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 `aienos.com / om / omega-reference / check.sh` 78 lines ยท 4028 bytes Raw Blame History 1 #!/bin/sh 2 # Host orchestration only. page.om (seeded Omega) writes main.html from the 3 # vendored omega-harness guide and examples; this script checks the inputs, 4 # gates every example with the pinned omc and publishes the page. 5 # check.sh full check; needs OMEGA_OMC, the omc pinned in vendor.pin 6 # check.sh --hashes inputs and output against their recorded hashes only 7 # Optional OMEGA_HARNESS= also compares vendor/ with 8 # git archive of the pinned commit. 9 set -eu 10 cd "$(dirname "$0")" 11 vendor_ok() { 12 (cd vendor && sha256sum --quiet -c ../vendor.sha256) || { echo 'vendor/ differs from vendor.sha256' >&2; exit 3; } 13 [ "$(find vendor -type f | wc -l)" -eq "$(wc -l < vendor.sha256)" ] || { echo 'vendor/ holds a file vendor.sha256 does not list' >&2; exit 3; } 14 } 15 vendor_ok 16 if [ "${1:-}" = --hashes ]; then 17 sha256sum --quiet -c main.html.sha256 18 printf 'OMEGA-REFERENCE HASHES PASS files=%s main=%s\n' "$(wc -l < vendor.sha256)" "$(cut -d' ' -f1 main.html.sha256)" 19 exit 0 20 fi 21 [ $# -eq 0 ] || { echo 'usage: check.sh [--hashes]' >&2; exit 2; } 22 omc=${OMEGA_OMC:?set OMEGA_OMC to the omc pinned in vendor.pin} 23 pin=$(awk '$1 == "omc-sha256" { print $2 }' vendor.pin) 24 commit=$(awk '$1 == "omega-harness" { print $2 }' vendor.pin) 25 [ "$(sha256sum "$omc" | cut -d' ' -f1)" = "$pin" ] || { echo 'Compiler pin mismatch' >&2; exit 3; } 26 work=$(mktemp -d) 27 trap 'rm -rf "$work"' EXIT HUP INT TERM 28 if [ -n "${OMEGA_HARNESS:-}" ]; then 29 mkdir "$work/h" 30 git -C "$OMEGA_HARNESS" archive "$commit" examples skills/writing-omega/SKILL.md skills/omega-encoding/examples | tar -x -C "$work/h" 31 rm -f "$work/h/examples/WOLFRAM.md" 32 diff -r "$work/h" vendor > /dev/null || { echo "vendor/ differs from omega-harness $commit" >&2; exit 3; } 33 echo "vendor/ equals omega-harness $commit" 34 fi 35 # Every worked example on the page: compiled and run by the harness gate. 36 bash vendor/examples/gate.sh "$omc" > "$work/gate.log" 2>&1 || { cat "$work/gate.log" >&2; exit 5; } 37 gate=$(grep '^GATE PASS' "$work/gate.log") 38 echo "$gate" 39 # Negative control: one changed expected exit code must fail the gate. 40 cp -R vendor "$work/mut" 41 printf 'compile 0\nexit 9\n' > "$work/mut/examples/hello.expect" 42 if bash "$work/mut/examples/gate.sh" "$omc" > "$work/mut.log" 2>&1; then 43 echo 'Mutated example wrongly passed the gate' >&2; exit 5 44 fi 45 echo "negative control: $(grep '^GATE FAIL' "$work/mut.log")" 46 # Error 24 has no example file: the recipe in the guide, run at both sizes. 47 e24() { 48 { printf 'fn main to int\nx = ulong 0\nc = true\nwhile c bound 1\n' 49 yes 'x = add x 1' | head -n "$1" 50 printf 'c = false\nend\nret int and x 1\nend\n'; } > "$work/e24.om" 51 rc=0; "$omc" < "$work/e24.om" > "$work/e24" 2> "$work/e24.err" || rc=$? 52 } 53 e24 270000 54 [ "$rc" = 24 ] && [ "$(cat "$work/e24.err")" = 'omc: line 270006: error 24' ] || { echo "error 24 recipe: rc $rc" >&2; exit 5; } 55 e24 140000 56 [ "$rc" = 0 ] || { echo "error 24 recipe, short loop: rc $rc" >&2; exit 5; } 57 echo 'error 24 recipe: 270000 lines refused with error 24 at line 270006, 140000 lines compiled' 58 "$omc" < page.om > "$work/page" 59 chmod +x "$work/page" 60 "$work/page" > "$work/first.html" 61 "$work/page" > "$work/second.html" 62 cmp "$work/first.html" "$work/second.html" 63 [ -s "$work/first.html" ] 64 # Negative control: a missing pin must refuse, not publish links to no commit. 65 mkdir "$work/nopin" 66 cp vendor.sha256 "$work/nopin/" 67 ln -s "$PWD/vendor" "$work/nopin/vendor" 68 if (cd "$work/nopin" && "$work/page" > refused.html 2>/dev/null); then 69 echo 'Missing vendor.pin wrongly accepted' >&2; exit 5 70 fi 71 stale=0 72 if [ ! -f main.html ] || ! cmp -s "$work/first.html" main.html; then stale=1; fi 73 cp "$work/first.html" main.html 74 sha256sum main.html > main.html.sha256 75 if [ "$stale" = 1 ] && [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then 76 echo 'main.html changed; commit it with its Omega source and vendor/' >&2; exit 4 77 fi 78 printf 'OMEGA-REFERENCE PASS compiler=%s harness=%s main=%s\n' "$pin" "$commit" "$(cut -d' ' -f1 main.html.sha256)"