interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-sovereign-core-mv / om / effects / run.sh

113 lines · 5872 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Parity of the seeded .om effect world check (om/effects/world.om) with the Rust reference world
4# check (aien-runtime effects::world_state + effects::reconcile_text; not the confined production
5# path confined_world_state): same stdout bytes and exit code
6# on every fixture, refusals on inputs Rust's u64 parse refuses, and two mutants caught.
7# Usage: OMEGA_OMC=<seed omc> bash om/effects/run.sh
8set -u
9ROOT=$(cd "$(dirname "$0")/../.." && pwd)
10PIN=734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61
11OMC=${OMEGA_OMC:?set OMEGA_OMC to the seed compiler (omega-mv seed/out/omc)}
12O=$ROOT/target/om-effects
13got=$(sha256sum < "$OMC" | cut -d' ' -f1)
14[ "$got" = "$PIN" ] || { echo "FAIL omc sha256 $got, pinned $PIN"; exit 1; }
15rm -rf "$O"; mkdir -p "$O/fx"
16fails=0
17pass() { echo "PASS $1"; }
18fail() { echo "FAIL $1"; fails=$((fails + 1)); }
19build() { cat "$ROOT/om/vendor/sha256.om" "$1" | "$OMC" > "$2" && chmod +x "$2"; }
20build "$ROOT/om/effects/world.om" "$O/world" || { echo "FAIL build world.om"; exit 1; }
21(cd "$ROOT" && cargo build --offline -q -p aien-runtime --example om_world_reference) || { echo "FAIL build reference"; exit 1; }
22REF=$ROOT/target/debug/examples/om_world_reference
23OMW=$O/world
24
25# Fixtures (relative to $O/fx, so paths in error messages are short and stable).
26cd "$O/fx"
27printf abc > abc
28printf 'prior bytes' > prior
29: > empty
30head -c 1048579 /dev/urandom > big
31mkdir dir
32ln -s abc link
33ln -s loop loop
34mkfifo fifo
35printf secret > noread; chmod 000 noread
36WEIRD=$'we"ird\\na\nme\001'
37printf w > "$WEIRD"
38mkdir "$WEIRD.d"
39LONG=$(printf 'n%.0s' $(seq 300))
40H() { sha256sum < "$1" | cut -d' ' -f1; }
41A=$(H abc); P=$(H prior); E=$(H empty); B=$(H big); W=$(H "$WEIRD")
42UP=$(printf '%s' "$A" | tr a-f A-F)
43CTL=$(printf 'c%b' '\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\177')
44n=0
45same() {
46 n=$((n + 1)); label=$1; want=$2; shift 2
47 "$REF" "$@" > "$O/r$n.out" 2> /dev/null; rr=$?
48 "$OMW" "$@" > "$O/w$n.out" 2> /dev/null; wr=$?
49 st=$(grep -o '"state":"[A-Z_]*"' "$O/w$n.out" | cut -d'"' -f4)
50 if [ $rr = 0 ] && [ $wr = 0 ] && cmp -s "$O/r$n.out" "$O/w$n.out" && [ "$st" = "$want" ]; then
51 pass "$label: $st, identical bytes"
52 else fail "$label (want $want, got $st; rust exit $rr, om exit $wr; $O/r$n.out vs $O/w$n.out)"; fi
53}
54same "content written" DONE abc "$A" - 3 2 'reconcile@start'
55same "absent, no prior" NOT_DONE absent "$A" - 3 2 'reconcile@start'
56same "prior bytes still there" NOT_DONE prior "$A" "$P" 3 2 x
57same "absent, prior named" UNRESOLVED absent "$A" "$P" 3 2 x
58same "other bytes, no prior" UNRESOLVED prior "$A" - 3 2 x
59same "content equals prior" DONE abc "$A" "$A" 3 2 x
60same "uppercase content digest" UNRESOLVED abc "$UP" - 3 2 x
61same "empty file" DONE empty "$E" - 3 2 x
62same "1 MiB + 3 bytes" DONE big "$B" - 3 2 x
63same "directory" UNRESOLVED dir "$A" - 3 2 x
64same "symlink to a file" UNRESOLVED link "$A" - 3 2 x
65same "fifo" UNRESOLVED fifo "$A" - 3 2 x
66same "unreadable file (or read by root: other bytes)" UNRESOLVED noread "$A" - 3 2 x
67same "path through a file (ENOTDIR)" UNRESOLVED abc/x "$A" - 3 2 x
68same "symlink loop (ELOOP)" UNRESOLVED loop/x "$A" - 3 2 x
69same "300-byte name (ENAMETOOLONG)" UNRESOLVED "$LONG" "$A" - 3 2 x
70same "empty path" NOT_DONE "" "$A" - 3 2 x
71same "quote, backslash, newline, 0x01 in the name" DONE "$WEIRD" "$W" - 3 2 x
72same "that name inside disk_error" UNRESOLVED "$WEIRD.d" "$A" - 3 2 x
73same "every control byte and 0x7f in by" DONE abc "$A" - 3 2 "$CTL"
74same "quote, backslash, slash, UTF-8 in by" DONE abc "$A" - 3 2 'q"b\s/é ✓'
75same "u64 parse: + and leading zeros" DONE abc "$A" - +7 007 x
76same "largest u64 intent, authorization 0" DONE abc "$A" - 18446744073709551615 0 x
77same "empty by" DONE abc "$A" - 3 2 ""
78
79# Refusals: Rust's parse refuses these (the reference panics); world exits 2 with no output.
80refuse() {
81 "$REF" "$@" > /dev/null 2>&1; rr=$?
82 "$OMW" "$@" > "$O/ref.out" 2> /dev/null; wr=$?
83 if [ $rr != 0 ] && [ $wr = 2 ] && [ ! -s "$O/ref.out" ]; then pass "both refuse intent '$4'"
84 else fail "refusal intent '$4' (rust exit $rr, om exit $wr)"; fi
85}
86refuse abc "$A" - 18446744073709551616 2 x
87refuse abc "$A" - -1 2 x
88refuse abc "$A" - + 2 x
89refuse abc "$A" - "" 2 x
90"$OMW" abc "$A" - 3 2 > "$O/ref.out" 2> /dev/null; wr=$?
91if [ $wr = 2 ] && [ ! -s "$O/ref.out" ]; then pass "world refuses five arguments"; else fail "five arguments (exit $wr)"; fi
92
93# Mutants: one byte of the record and one decision; each must run to completion (exit 0 on both
94# fixtures) and make a fixture's output differ. A mutant that refuses or crashes is not a catch.
95mutant() {
96 sed "$2" "$ROOT/om/effects/world.om" > "$O/m.om"
97 cmp -s "$O/m.om" "$ROOT/om/effects/world.om" && { fail "mutant $1 did not change the source"; return; }
98 build "$O/m.om" "$O/m" || { fail "mutant $1 did not build"; return; }
99 "$REF" abc "$A" - 3 2 x > "$O/mr.out"; "$O/m" abc "$A" - 3 2 x > "$O/mw.out"; m1=$?
100 "$REF" absent "$A" - 3 2 x >> "$O/mr.out"; "$O/m" absent "$A" - 3 2 x >> "$O/mw.out"; m2=$?
101 if [ $m1 != 0 ] || [ $m2 != 0 ]; then fail "mutant $1 did not complete (exit $m1, $m2)"
102 elif cmp -s "$O/mr.out" "$O/mw.out"; then fail "mutant $1 not caught"; else pass "mutant $1 caught"; fi
103}
104mutant "key by -> bx" 's/,\\"by\\":/,\\"bx\\":/'
105mutant "absent with no prior -> UNRESOLVED" '/^if eq pnone 1$/{n;s/^ret 1$/ret 2/}'
106
107chmod 600 "$O/fx/noread"
108echo "world.om $(sha256sum < "$ROOT/om/effects/world.om" | cut -d' ' -f1)"
109echo "sha256.om $(sha256sum < "$ROOT/om/vendor/sha256.om" | cut -d' ' -f1)"
110echo "world binary $(sha256sum < "$OMW" | cut -d' ' -f1)"
111echo "omc $got"
112if [ "$fails" -ne 0 ]; then echo "OM-EFFECT-WORLD FAIL $fails"; exit 1; fi
113echo "OM-EFFECT-WORLD PASS ($n fixtures)"