interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / atlas / gate5.sh

57 lines · 3503 bytes Raw Blame History
1#!/bin/sh
2# gate5.sh -- the checks of rung 5, "Atlas reborn" (seed/README.md). Run from the repo root:
3# sh seed/atlas/gate5.sh [<atlas folder>] (default ~/workspace/atlas, only read)
4# 1. asm2 builds the Atlas image from seed/atlas/atlas.s2; a second build gives the same bytes;
5# 2. it is byte-identical to the audited atlas.bin (sha256 f7802501...a5);
6# 3. objdump (reference) reads every instruction back to its name, registers, numbers and labels;
7# planted mistakes are caught;
8# 4. the existing Atlas M1 gates (run_m1_gates.sh, not edited) run in QEMU on a scratch copy of the
9# Atlas folder whose atlas.bin is the one asm2 made. The Atlas folder itself is never written.
10# Results: build/seed/r5/evidence/. The recorded receipt evidence/SEED-0/rung5/ (and seed/atlas/atlas.audit) is
11# only read: the results are compared with it at the end (seed/check/receipt.sh), never written over it.
12set -eu
13A=${1:-$HOME/workspace/atlas}
14R=seed/atlas; B=build/seed/r5; E=$B/evidence; REC=evidence/SEED-0/rung5
15PIN=f7802501b410a0c19eff7b8fca8865c9ba9c96bfa4f8065ca8f508b67748b9a5
16mkdir -p "$B" "$E"
17fail=0
18: > "$E/gate5.log"
19say() { printf '%s\n' "$*" | tee -a "$E/gate5.log"; }
20bad() { say "FAIL: $*"; fail=1; }
21say "gate5 $(date -u +%FT%TZ) at $(git rev-parse HEAD)"
22TAB="seed/rung2/table.s2 seed/rung3/table3.s2 $R/table5.s2"
23cat $TAB $R/atlas.s2 | seed/rung2/asm2.bin > $R/atlas.bin
24cat $TAB $R/atlas.s2 | seed/rung2/asm2.bin > $B/atlas.again
25cmp -s $R/atlas.bin $B/atlas.again && say "PASS built by asm2 twice, same bytes" || bad "two builds differ"
26sha=$(sha256sum $R/atlas.bin | cut -d' ' -f1)
27say "atlas.bin $(stat -c %s $R/atlas.bin) bytes sha256 $sha"
28[ "$sha" = "$PIN" ] && say "PASS sha256 = audited atlas.bin" || bad "sha256 differs from the audited $PIN"
29if [ -f "$A/atlas.bin" ]; then
30 cmp $R/atlas.bin "$A/atlas.bin" > "$E/cmp.txt" 2>&1 && say "PASS byte-identical to $A/atlas.bin" || bad "bytes differ: $(head -1 $E/cmp.txt)"
31fi
32echo "$sha seed/atlas/atlas.bin" > "$E/atlas.sha256"
33if sh seed/check/audit2.sh $R/atlas.s2 $R/atlas.bin > $E/atlas.audit; then :; fi
34tail -1 $E/atlas.audit | tee -a "$E/gate5.log" | grep -q 'mismatch=0$' && say "PASS audit (objdump reference run)" || bad "audit"
35for c in 's/^ and.x.bm x20 x20 1 58 57 / and.x.bm x20 x20 1 58 56 /' 's/^ ldp.w w13 w11 sp 25$/ ldp.w w13 w11 sp 26/' \
36 's/^ adrp x13 0 0 / adrp x13 1 0 /' 's/^ ldr.x.lit x19 L_40200000$/ ldr.x.lit x19 L_401fe100/' \
37 's/^ extr.w w2 w3 w3 19$/ extr.w w2 w3 w2 19/'; do
38 sed "$c" $R/atlas.s2 > $B/bad.s2
39 if cmp -s $B/bad.s2 $R/atlas.s2; then bad "control edit did nothing: $c"
40 elif sh seed/check/audit2.sh $B/bad.s2 $R/atlas.bin > $B/bad.audit; then bad "control not caught: $c"
41 else say "PASS control caught ($c)"; fi
42done
43# the M1 gates, on a scratch copy (the gate script and its tools are the Atlas folder's own, unedited)
44S=$(mktemp -d /tmp/seed-atlas-gate5.XXXXXX)
45cp -a "$A/." "$S/"
46cp $R/atlas.bin "$S/atlas.bin"
47sha256sum "$S/run_m1_gates.sh" "$A/run_m1_gates.sh" | tee -a "$E/gate5.log"
48set +e
49(cd "$S" && sh ./run_m1_gates.sh) > "$E/m1-gates.log" 2>&1; rc=$?
50set -e
51say "run_m1_gates.sh exit $rc on the asm2-made atlas.bin (log: $E/m1-gates.log)"
52[ $rc = 0 ] || bad "Atlas M1 gates"
53say "scratch copy left at $S"
54# the recorded receipt is compared, never rewritten; the verdict below is the checks' alone
55say "$(sh seed/check/receipt.sh "$E" "$REC" $R/atlas.audit || true)"
56[ $fail = 0 ] && say "GATE5 PASS" || say "GATE5 FAIL"
57exit $fail