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/seed/omc/gate5.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 / seed / omc / gate5.sh` 245 lines ยท 20035 bytes Raw Blame History 1 #!/bin/sh 2 # gate5.sh -- the checks of rung 5, omc (seed/README.md). Run from the repo root: sh seed/omc/gate5.sh 3 # Needs seed/rung4/om4.bin (rung 4) and what gate4 needs: build/omegese/omegese and build/omega_emit/omega_emit 4 # (the C path), cc for the reference runner, gcc for the C twins. Oracles only, named where used: none of them 5 # writes a byte of seed/; omc is built by om4 and then by itself. Results: build/seed/r5/evidence/. 6 set -eu 7 R=seed/omc; R4=seed/rung4; B=build/seed/r5; E=build/seed/r5/evidence 8 TAB="seed/rung2/table.s2 seed/rung3/table3.s2 $R4/table4.s2" 9 mkdir -p "$B" "$E" 10 fail=0; cases=0 11 say() { printf '%s\n' "$*" | tee -a "$E/gate5.log"; } 12 bad() { say "FAIL: $*"; fail=1; } 13 : > "$E/gate5.log" 14 say "gate5 $(date -u +%FT%TZ) at $(git rev-parse HEAD)" 15 sha() { sha256sum "$1" | cut -d' ' -f1; } 16 17 # fix: stage1 = om4(src); stage2 = stage1(src); stage3 = stage2(src), in directory $1 (any stage may fail) 18 fix() { # dir src compiler 19 rm -f $1/stage1 $1/stage2 $1/stage3 20 $3 < $2 > $1/stage1 2> $1/err1 && chmod +x $1/stage1 && 21 ./$1/stage1 < $2 > $1/stage2 2> $1/err2 && chmod +x $1/stage2 && 22 ./$1/stage2 < $2 > $1/stage3 2> $1/err3 && chmod +x $1/stage3 23 } 24 25 # 1. (a) fixpoint 26 mkdir -p $B/fix; fix $B/fix $R/omc.om $R4/om4.bin || bad "a stage did not build: $(cat $B/fix/err* )" 27 s1=$(sha $B/fix/stage1); s2=$(sha $B/fix/stage2); s3=$(sha $B/fix/stage3) 28 say "stage1 = om4(omc.om) $s1" 29 say "stage2 = stage1(omc.om) $s2" 30 say "stage3 = stage2(omc.om) $s3" 31 [ "$s2" = "$s3" ] && say "PASS (a) fixpoint: sha256(stage2) = sha256(stage3)" || bad "(a) stage2 != stage3" 32 cases=$((cases + 1)) 33 S=$B/fix/stage2 34 35 # 2. (b) the second route. The C path (omegese + omega_emit, an oracle) cannot express omc.om; its own refusal 36 # and the probes below say what is missing. So the fallback, which is not independent of this author's 37 # design: two different compilers of omc.om, om4 (asm2 language) and stage1 (omc, Omegese), and the stage 38 # each one's output builds from omc.om must be the same bytes. 39 build/omegese/omegese emit $R/omc.om $B/omc.json > $B/cpath.out 2>&1 || true 40 say "C path on omc.om: $(head -1 $B/cpath.out)" 41 probe() { # what must-name text: refused, and the refusal names what is missing 42 printf '%b' "$3" > $B/probe.om 43 m=$(build/omegese/omegese emit $B/probe.om $B/probe.json 2>&1 | head -1) 44 case "$m" in REFUSED*"$2"*) say " C path lacks $1: $m";; *) bad "C path probe for $1 changed: $m (rethink (b))";; esac 45 } 46 probe "global pools" "'global'" 'global g uchar 4\nfn f a ulong to ulong\nret a\nend\n' 47 probe "a self-call" "cannot call itself" 'fn f a ulong to ulong\nif eq a 0\nret 0\nend\nret f sub a 1\nend\n' 48 probe "arrays over 64 cells" "must be 1..64" 'fn f a ulong to ulong\nx = new uchar 100 0\nret a\nend\n' 49 probe "text literals" "character '\"'" 'text t "ab"\nfn f a ulong to ulong\nret a\nend\n' 50 probe "read" "'read' is not a name" 'fn f a ulong to ulong\nx = new uchar 4 0\nn = read int 0 x ulong 0 ulong 4\nret a\nend\n' 51 probe "write" "'write' is not a name" 'fn f a ulong to ulong\nx = new uchar 4 0\nn = write int 1 x ulong 0 ulong 4\nret a\nend\n' 52 probe "exit (it reads exit as a new name)" "'exit' is written but never read" 'fn f a ulong to ulong\nexit int 3\nret a\nend\n' 53 probe "a colon in a note" "character ':'" 'note a: b\nfn f a ulong to ulong\nret a\nend\n' 54 say " (and it writes .oscir for a runner, not a program that reads stdin and writes stdout)" 55 cmp -s $B/fix/stage1 $B/fix/stage2 && say "PASS (b) om4 and omc build the same omc from omc.om (stage1 = stage2)" || bad "(b) stage1 != stage2" 56 cmp -s $B/fix/stage2 $B/fix/stage3 && say "PASS (b) the stage from each parent is bit-identical (om4-built -> stage2, omc-built -> stage3)" || bad "(b) stage2 != stage3" 57 cases=$((cases + 2)) 58 59 # 3. every input gate4 gives om4, plus every .om / .omegese file in the repo and omc.om: om4 and stage2 60 # give the same output bytes, exit status and error number (and line); gate4 is run with om4 wrapped 61 # so each input is kept (gate4's own results go to $B, not to evidence/) 62 CODES=""; C=$B/corpus; for d in "$C" "$B/g4cap" "$B/g4cape"; do if test -d "$d"; then find "$d" -depth -delete; fi; done; mkdir -p "$C" 63 cat > $B/cap.sh << EOF 64 #!/bin/sh 65 n=\$(ls $C | wc -l); f=$C/\$(printf '%04d' \$n).in; cat > \$f; exec $R4/om4.bin < \$f 66 EOF 67 chmod +x $B/cap.sh 68 g4() { # compiler build-dir evidence-dir -> gate4 with the compiler in om4's place 69 # gate4's error-13 case names a 9-byte variable, over om4's 8 bytes; omc accepts names up to 63 bytes, so here 70 # (the capturing run and the omc run alike) the case names a 64-byte one, error 13 from both. 71 l13="s/^t 13 'fn f a uint to uint\\\\nabcdefghi = a\\\\nret a\\\\nend\\\\n'/t 13 'fn f a uint to uint\\\\nabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl = a\\\\nret a\\\\nend\\\\n'/" 72 sed -e "s|^R=seed/rung4; B=build/seed/r4; E=[\$]B/evidence; REC=evidence/SEED-0/rung4;|R=seed/rung4; B=$2; E=$3; REC=;|" \ 73 -e "s#\\\$R/om4\\.bin < #$1 < #g" -e "s#| \\\$R/om4\\.bin #| $1 #g" -e "$l13" $R4/gate4.sh > $2.sh 74 [ "$(grep -c "$1" $2.sh)" = 7 ] || { bad "gate4 changed shape: the compiler is not in its 7 places"; return 1; } 75 grep -q "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl = a" $2.sh || { bad "gate4 changed shape: its error-13 case was not renamed"; return 1; } 76 grep -q "^R=seed/rung4; B=$2; E=$3; REC=;" $2.sh || { bad "gate4 changed shape: its result and receipt directories are not set"; return 1; } 77 # om4's own table capacities (OMEGESE 9.6): its value nesting of 1024 and its 4096 functions (section 7b) 78 # are om4's fixed tables; omc has none of its own since 2026-11-11, so with any compiler but om4 itself 79 # those two checks are left out here (gate12, gate-nocaps and gate-usage check omc's boundaries instead) 80 if [ "$1" != "$B/cap.sh" ]; then 81 grep -c "values nested over 1024 deep (a capacity, refused not overrun)" $2.sh | grep -qx 1 && 82 grep -c "^# 7b\. function table capacity" $2.sh | grep -qx 1 && 83 grep -c "^# 8\. negative control" $2.sh | grep -qx 1 || { bad "gate4 changed shape: its capacity checks were not found"; return 1; } 84 awk '/values nested over 1024 deep \(a capacity, refused not overrun\)/ { next } 85 /^# 7b\. function table capacity/ { skip = 1 } /^# 8\. negative control/ { skip = 0 } !skip { print }' $2.sh > $2.sh.t && mv $2.sh.t $2.sh 86 fi 87 NF_N=0 sh $2.sh > $2.out 2>&1 && tail -1 $2.out | grep -q "^GATE4 PASS$" # section 10 (next fuzz of om4 alone) is run by gate4 itself 88 } 89 g4 $B/cap.sh $B/g4cap $B/g4cape || bad "gate4 (capturing) did not pass: $(grep FAIL $B/g4cap.out | head -3)" 90 for f in $(find $R4/tests tests/one_layer/omegese tools/exp445/arms/examples -name '*.om' -o -name '*.omegese' | sort) $R/omc.om; do 91 cp $f $C/$(printf '%04d' $(ls $C | wc -l)).in 92 done 93 # om4 = stage2 on every input, or the input is a row of $R/tests/om4-superset.tsv: a program using words omc 94 # added beyond om4 (OMEGESE.md section 9), listed by the sha256 of its text with om4's refusal and omc's exit; 95 # the C path (the language oracle) must accept it. An unlisted difference, a listed row that no longer differs, 96 # a listed row the corpus does not reach, or a listed program the C path refuses is a FAIL. 97 # The rows of $R/tests/om4-capacity.tsv are inputs om4 refuses with error 14 at one of its own table capacities 98 # (OMEGESE 9.6), which omc no longer has: om4 must give exactly the row's refusal and omc exactly the row's 99 # status and stderr line (`-` for none); a stale or unreached row is a FAIL as above. 100 X=$R/tests/om4-superset.tsv; K=$R/tests/om4-capacity.tsv; same=0; ext=0; capd=0; n=0; seen="" 101 for f in $C/*.in; do n=$((n + 1)) 102 set +e; $R4/om4.bin < $f > $B/c.a 2> $B/c.ae; ra=$?; $S < $f > $B/c.b 2> $B/c.be; rb=$?; set -e 103 CODES="$CODES $ra" 104 sed -i 's/^om4:/X:/' $B/c.ae; sed -i 's/^omc:/X:/' $B/c.be 105 h=$(sha $f); row=$(grep "^$h[[:space:]]" $X || true); krow=$(grep "^$h[[:space:]]" $K || true) 106 if [ $ra = $rb ] && cmp -s $B/c.a $B/c.b && cmp -s $B/c.ae $B/c.be; then same=$((same + 1)) 107 [ -z "$row$krow" ] || bad "om4-superset/om4-capacity row $(echo "$row$krow" | cut -f2) no longer differs from om4: drop the row" 108 elif [ -n "$krow" ]; then seen="$seen $h"; src=$(echo "$krow" | cut -f2); ke=$(echo "$krow" | cut -f3); kb=$(echo "$krow" | cut -f4); kx=$(echo "$krow" | cut -f5) 109 [ "$kx" = - ] && kx="" 110 if [ $ra = 14 ] && [ "$(cat $B/c.ae)" = "X: $ke" ] && [ $rb = $kb ] && [ "$(cat $B/c.be)" = "${kx:+X: $kx}" ] 111 then capd=$((capd + 1)); say " om4 capacity: $src: om4 $ke; omc exit $rb${kx:+ ($kx)}" 112 else bad "om4-capacity $src: om4 exit $ra $(cat $B/c.ae) (row: 14 $ke), stage2 exit $rb $(cat $B/c.be) (row: $kb $kx)"; fi 113 elif [ -z "$row" ]; then bad "corpus $(basename $f): om4 exit $ra $(cat $B/c.ae), stage2 exit $rb $(cat $B/c.be)" 114 else seen="$seen $h"; src=$(echo "$row" | cut -f2); xa=$(echo "$row" | cut -f4); xe=$(echo "$row" | cut -f5); xb=$(echo "$row" | cut -f6) 115 if [ $ra = $xa ] && [ "$(cat $B/c.ae)" = "X: $xe" ] && [ $rb = $xb ] && [ -s $B/c.b ] && [ ! -s $B/c.be ] && build/omegese/omegese emit $f $B/c.json > /dev/null 2>&1 116 then ext=$((ext + 1)); say " beyond om4: $src ($(echo "$row" | cut -f3)): om4 $xe, omc exit $xb, the C path accepts it" 117 else bad "om4-superset $src: om4 exit $ra $(cat $B/c.ae) (row: $xa $xe), stage2 exit $rb $(cat $B/c.be) (row: $xb), C path: $(build/omegese/omegese emit $f $B/c.json 2>&1 | head -1)"; fi 118 fi 119 done 120 for h in $(cat $X $K | grep -v '^#' | grep -v '^sha256 ' | cut -f1); do case "$seen" in *" $h"*) ;; *) bad "om4-superset/om4-capacity row $h is not in the corpus: stale row";; esac; done 121 refused=$(for f in $C/*.in; do $R4/om4.bin < $f > /dev/null 2>&1 || echo x; done | wc -l) 122 [ $((same + ext + capd)) = $n ] && say "PASS corpus: om4 = stage2 on $same inputs ($refused of them refused, same error number and line); $ext inputs beyond om4 are listed in seed/omc/tests/om4-superset.tsv, each accepted by omc and the C path; $capd inputs at om4's own capacities are listed in seed/omc/tests/om4-capacity.tsv" 123 cases=$((cases + n)) 124 125 # 3b. what the corpus does not reach. A program that writes a text with every escape, checked against fixed 126 # bytes and a fixed exit value (97 + 9 + 98, worked by hand), not only against om4. One input for each 127 # error number the corpus and the fuzz do not reach: 1 (stdin is a folder), 2 (stdout is full), 4, 11, 128 # 12, 13; om4 and stage2 must both give it, with the same message. 14: om4's 8 MiB input buffer refuses a 129 # `9000000`-byte unit, which omc, whose input is part of its arena (OMEGESE 9.6), compiles. 130 for c in om4:$R4/om4.bin stage2:$S; do n=${c%%:*}; cc=${c#*:} 131 $cc < $R/tests/text.om > $B/text.$n; chmod +x $B/text.$n 132 set +e; ./$B/text.$n > $B/text.$n.out; rc=$?; set -e 133 [ $rc = $(cat $R/tests/text.want) ] && cmp -s $B/text.$n.out $R/tests/text.out && say "PASS text program built by $n: writes its 9 bytes, exit $rc" || bad "text program built by $n: exit $rc" 134 done 135 cmp -s $B/text.om4 $B/text.stage2 && say "PASS text program: om4 and stage2 make the same bytes" || bad "text program: om4 and stage2 differ" 136 ecase() { # error input stdout 137 set +e; $R4/om4.bin < $2 > $3 2> $B/e.a; ra=$?; $S < $2 > $3 2> $B/e.b; rb=$?; set -e 138 sed -i 's/^om[4c]:/X:/' $B/e.a $B/e.b 139 [ $ra = $1 ] && [ $rb = $1 ] && cmp -s $B/e.a $B/e.b && say "PASS error $1 from both:$(sed 's/^X://' $B/e.a)" || bad "error $1: om4 exit $ra, stage2 exit $rb" 140 CODES="$CODES $ra" 141 } 142 printf 'fn f a uint to uint\nret a\nend\n' > $B/ok.om; ecase 1 / $B/e.out; ecase 2 $B/ok.om /dev/full 143 printf 'fn f to uint\nret add\nend\n' > $B/e4.om; ecase 4 $B/e4.om $B/e.out 144 printf 'fn f to uint\nret add 1 2\nend\n' > $B/e11.om; ecase 11 $B/e11.om $B/e.out 145 { echo 'fn f to uint'; for i in $(seq 1 17); do echo "v$i = uint $i"; done; echo 'ret 0'; echo 'end'; } > $B/e12.om; ecase 12 $B/e12.om $B/e.out 146 # error 13 with a 64-byte name: om4 refuses names over 8 bytes, omc names over 63 (OMEGESE.md section 4) 147 printf 'fn f to uint\nabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl = uint 1\nret 0\nend\n' > $B/e13.om; ecase 13 $B/e13.om $B/e.out 148 { yes 'note filler' | head -c `9000000` | sed '$d'; printf 'fn f a uint to uint\nret a\nend\n'; } > $B/e14.om 149 set +e; $R4/om4.bin < $B/e14.om > $B/e.out 2> $B/e.a; ra=$?; $S < $B/e14.om > $B/e.out 2> $B/e.b; rb=$?; set -e 150 [ $ra = 14 ] && [ "$(cat $B/e.a)" = "om4: line 0: error 14" ] && [ $rb = 0 ] && [ -s $B/e.out ] && [ ! -s $B/e.b ] && 151 say "PASS error 14 from om4 (line 0, its 8 MiB input); omc compiles the same `9000000`-byte unit" || bad "error 14: om4 exit $ra $(cat $B/e.a), stage2 exit $rb $(cat $B/e.b)" 152 CODES="$CODES $ra" 153 cases=$((cases + 10)) 154 155 # 4. (c) gate4 with stage2 in om4's place: the 10 dev tasks and 9 function-mode tests against the C path 156 # on the reference runner (raw x0, traps), the program-mode tests against gcc twins and their exits, 157 # every refusal number 158 g4ok=1; g4 $S $B/g4omc $B/g4omce || g4ok=0 159 if [ $g4ok = 0 ] || grep -q "^FAIL" $B/g4omc.out; then bad "(c) gate4 with stage2: $(grep FAIL $B/g4omc.out | head -3)" 160 else say "PASS (c) gate4 with stage2 in om4's place: $(grep -c '^PASS' $B/g4omc.out) checks, 0 FAIL"; fi 161 cp $B/g4omce/words.tsv $E/corpus-words.tsv 162 sed 's/om4_words/omc_words/' $E/corpus-words.tsv > $B/t && mv $B/t $E/corpus-words.tsv 163 say "(c) table: $E/corpus-words.tsv"; cat $E/corpus-words.tsv >> "$E/gate5.log" 164 cases=$((cases + 1)) 165 166 # 5. (d) negative controls 167 # A: a one-word mutation omc itself uses (or compiled as and): the fixpoint must break, and the corpus 168 mk() { sed "$1" $R/omc.om > $2; cmp -s $2 $R/omc.om && { bad "mutation did nothing: $1"; return 1; }; return 0; } 169 diffs() { # compiler -> how many corpus inputs differ from om4 (by output, exit or error) 170 k=0; for f in $C/*.in; do 171 set +e; $R4/om4.bin < $f > $B/d.a 2>&1; ra=$?; timeout 10 $1 < $f > $B/d.b 2>&1; rb=$?; set -e 172 sed -i 's/^om[4c]:/X:/' $B/d.a $B/d.b 173 { [ $ra = $rb ] && cmp -s $B/d.a $B/d.b; } || k=$((k + 1)); done; echo $k; } 174 mkdir -p $B/ma; mk 's/^if eq op 39$/if eq op 40/' $B/ma/omc.om 175 if fix $B/ma $B/ma/omc.om $R4/om4.bin && cmp -s $B/ma/stage2 $B/ma/stage3; then bad "(d) A: fixpoint kept" 176 else say "PASS (d) A caught by the fixpoint: or -> and in omc.om (a stage failed, or stage2 != stage3)"; fi 177 k=$(diffs $B/ma/stage1); [ $k -gt 0 ] && say "PASS (d) A caught by the corpus: $k inputs differ from om4" || bad "(d) A: corpus blind" 178 # B: a one-word mutation omc does not use (signed div compiled as unsigned): the fixpoint stays, the 179 # corpus catches it 180 mkdir -p $B/mb; mk 's/^bo_w3 `2596277248` rd ra rb 0$/bo_w3 `2596276224` rd ra rb 0/' $B/mb/omc.om 181 fix $B/mb $B/mb/omc.om $R4/om4.bin && cmp -s $B/mb/stage2 $B/mb/stage3 && say "PASS (d) B keeps the fixpoint (a fixpoint proves determinism, not correctness)" || bad "(d) B: fixpoint broke" 182 k=$(diffs $B/mb/stage2); [ $k -gt 0 ] && say "PASS (d) B caught by the corpus: $k inputs differ from om4" || bad "(d) B: corpus blind" 183 # C: the same wrong word in om4.s and omc.om (signed div as unsigned): fixpoint and om4 = omc both stay; 184 # only the C path oracle catches it (fm2: -7 / 2) 185 mkdir -p $B/mc; mk 's/^bo_w3 `2596277248` rd ra rb 0$/bo_w3 `2596276224` rd ra rb 0/; s/^e3 `2596277248` t ra rb$/e3 `2596276224` t ra rb/' $B/mc/omc.om 186 sed 's/^ movz.x x0 0x0c00 0$/ movz.x x0 0x0800 0/' $R4/om4.s > $B/mc/om4.s 187 cat $TAB $B/mc/om4.s | seed/rung2/asm2.bin > $B/mc/om4.bin; chmod +x $B/mc/om4.bin 188 fix $B/mc $B/mc/omc.om $B/mc/om4.bin && cmp -s $B/mc/stage2 $B/mc/stage3 && say "PASS (d) C keeps the fixpoint" || bad "(d) C: fixpoint broke" 189 sed '/^free /d' $R4/tests/fm2.omegese > $B/mc/fm2.om 190 $B/mc/om4.bin < $B/mc/fm2.om > $B/mc/fm2.a; ./$B/mc/stage2 < $B/mc/fm2.om > $B/mc/fm2.b 191 cmp -s $B/mc/fm2.a $B/mc/fm2.b && say "PASS (d) C keeps om4 = omc on fm2" || bad "(d) C: om4' != omc' on fm2" 192 g4 $B/mc/stage2 $B/g4mc $B/g4mce || true 193 if ! grep -q "^FAIL: fm2 differs from the C path$" $B/g4mc.out; then bad "(d) C: the C path comparison of fm2 did not catch it" 194 else say "PASS (d) C caught only by the C path: $(grep '^FAIL' $B/g4mc.out | head -2 | tr '\n' ' ')"; fi 195 # D: a malformed program is refused with an error number 196 printf 'fn f a uint to uint\nret add a q\nend\n' > $B/bad.om 197 set +e; $S < $B/bad.om > /dev/null 2> $B/bad.err; rc=$?; set -e 198 [ $rc = 3 ] && grep -q '^omc: line 2: error 3$' $B/bad.err && say "PASS (d) refusal: $(cat $B/bad.err), exit 3" || bad "(d) refusal: exit $rc $(cat $B/bad.err)" 199 cases=$((cases + 7)) 200 201 # 6. output does not depend on addresses or time: stage2 run twice, with a different environment size (so 202 # a different stack address) and a second later, gives the same bytes 203 env -i X=$(printf '%0999d' 0) $S < $R/omc.om > $B/det1; sleep 1; $S < $R/omc.om > $B/det2 204 cmp -s $B/det1 $B/det2 && cmp -s $B/det1 $S && say "PASS deterministic: same bytes under another environment and a second later" || bad "output depends on the run" 205 cases=$((cases + 1)) 206 207 # 6b. decision 22 for omc: the next-word fuzz (seed/check/nextfuzz.sh) with om4 as the reference and 208 # stage2 as the other: every generated program, every cut and every changed word gives the same bytes, 209 # exit status and error number from both, and neither crashes 210 if NFW=$B/nextfuzz sh seed/check/nextfuzz.sh 20 $R4/om4.bin $S > $B/nextfuzz.out 2>&1; then say "PASS om4 = stage2 in the $(tail -1 $B/nextfuzz.out)" 211 else bad "next fuzz: $(grep -v '^nextfuzz:' $B/nextfuzz.out | head -3) $(tail -1 $B/nextfuzz.out)"; fi 212 cases=$((cases + 1)) 213 # every error number 1..23 is reached somewhere above (corpus, the cases of 3b, the fuzz), with om4 = stage2 214 miss=""; all=" $CODES $(sed 's/:[0-9]*//g' $B/nextfuzz/codes 2>/dev/null) " 215 for e in $(seq 1 23); do case "$all" in *" $e "*) ;; *) miss="$miss $e";; esac; done 216 [ -z "$miss" ] && say "PASS every error number 1..23 is reached, om4 = stage2 on each" || bad "error numbers never reached:$miss" 217 cases=$((cases + 1)) 218 219 # 7. sizes and speed. Whole-compiler size and compile time against the C path on the dev tasks. 220 # Incomplete source prefixes cannot measure function size when signatures reference later functions. 221 lines=$(wc -l < $R/omc.om); nfn=$(grep -c '^fn ' $R/omc.om); bytes=$(stat -c %s $S) 222 printf 'rewrite\tbuilt_by\tsource_lines\tfunctions\tbytes\twords\tsha256\n' > $E/size.tsv 223 for st in 1 2 3; do by=om4; [ $st -gt 1 ] && by=stage$((st - 1)) 224 printf 'stage%s\t%s\t%s\t%s\t%s\t%s\t%s\n' $st $by $lines $nfn $(stat -c %s $B/fix/stage$st) $(( ($(stat -c %s $B/fix/stage$st) - 176) / 4 )) $(sha $B/fix/stage$st) >> $E/size.tsv 225 done 226 say "omc: $lines lines, $nfn functions, $bytes bytes = 176-byte header + $(( (bytes - 176) / 4 )) words ($E/size.tsv)" 227 # The living ledger is maintained before qualification; historical evidence is never rewritten. 228 tail -1 "$R/size-history.tsv" | grep -q " $(sha $S)\$" && say "PASS size history: its last row is this omc ($(tail -1 "$R/size-history.tsv" | cut -f1))" || bad "size-history.tsv has no row for this omc: add one" 229 ns() { date +%s%N; } 230 N=200; printf 'program\tomc_us\tc_path_us\n' > $E/compile-time.tsv 231 for d in $(ls tests/one_layer/omegese/dev/dev*.omegese $R4/tests/fm*.omegese); do p=$(basename $d .omegese) 232 sed '/^free /d' $d > $B/t.om 233 t0=$(ns); i=0; while [ $i -lt $N ]; do $S < $B/t.om > /dev/null; i=$((i + 1)); done; t1=$(ns) 234 i=0; while [ $i -lt $N ]; do build/omegese/omegese emit $d $B/t.json > /dev/null 235 build/omega_emit/omega_emit emit $B/t.json $B/t.oscir > /dev/null; i=$((i + 1)); done; t2=$(ns) 236 printf '%s\t%s\t%s\n' $p $(( (t1 - t0) / N / 1000 )) $(( (t2 - t1) / N / 1000 )) >> $E/compile-time.tsv 237 done 238 N=20; t0=$(ns); i=0; while [ $i -lt $N ]; do $S < $R/omc.om > /dev/null; i=$((i + 1)); done; t1=$(ns) 239 say "compile time per program (10 dev tasks, 9 fm), microseconds, 200 runs each, process start included ($E/compile-time.tsv); omc compiling itself: $(( (t1 - t0) / N / 1000 )) us" 240 cat $E/compile-time.tsv $E/size.tsv >> "$E/gate5.log" 241 242 cp $S $E/omc.elf; sha $S > $E/omc.sha256 243 say "cases run: $cases" 244 [ $fail = 0 ] && say "GATE5 PASS" || say "GATE5 FAIL" 245 exit $fail