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/sovereign-intelligence/blob/main/evidence/x86-native/run.sh # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. 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 `sovereign-intelligence / evidence / x86-native / run.sh` 130 lines ยท 8699 bytes Raw Blame History 1 #!/bin/sh 2 # evidence/x86-native/run.sh: omega-mv's FR-9 x86 corpus oracle, run on an x86-64 host. 3 # 4 # sh evidence/x86-native/run.sh OMEGA_MV OMEGA_BRIDGE WORK 5 # 6 # OMEGA_MV is a clone of omega-mv (rad:z6do9WDBhuSnvopDkgFdFr1yWA62) and OMEGA_BRIDGE a clone of 7 # omega-bridge (rad:`z3Hr9ZaiKHwwuNzPK5M8c7uw6pj7y`), each holding the commit pinned below; WORK is a new 8 # directory. Run sh build.sh first: the compilers under test are its out/omc and out/omc-x86. 9 # 10 # The oracle is omega-mv's seed/omc/qualify-x86.py at MV_REV with qualify-x86-native.patch applied. 11 # The patch adds --host x86-native and changes no assertion: x86-64 programs run directly, AArch64 12 # programs run under qemu-aarch64. The corpus's own exec children (conductors, helpers) are AArch64, 13 # so the kernel must hand AArch64 ELF files to qemu-aarch64 through binfmt_misc, with argv[0] kept 14 # (flag P). On Ubuntu 24.04, as root: 15 # apt-get install qemu-user-static gcc-aarch64-linux-gnu libc6-dev-arm64-cross jq xz-utils 16 # mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc # if it is not mounted 17 # cat /usr/lib/binfmt.d/qemu-aarch64.conf > /proc/sys/fs/binfmt_misc/register 18 # The oracle checks that entry, and that no entry takes x86-64 programs away from the kernel. 19 # 20 # WORK receives qualify.jsonl (every row the oracle printed), qualify.err, compilers.tsv and 21 # receipt.json. Exit status: the oracle's (0 only when every row is PASS or EXCLUDED). 22 set -eu 23 [ $# -eq 3 ] || { echo "usage: sh evidence/x86-native/run.sh OMEGA_MV OMEGA_BRIDGE WORK" >&2; exit 2; } 24 R=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) 25 MV=$(cd "$1" && pwd) 26 BR=$(cd "$2" && pwd) 27 mkdir "$3" 28 W=$(cd "$3" && pwd) 29 30 MV_REV=`6fbc6cbe4bfa4092608e2b5f06d2e8f537893992` 31 BRIDGE_REV=`1958a1895279c0d4869bab39eaa20f070b174a6c` 32 BASELINE_REV=`e17039d9ceeb30e0637ef4145e37afc5821c3773` 33 ORACLE_SHA256=`206d6cf26f2df74aa2017715444bd61a0fe3c208cda6f60170c7ca3b819431ce` 34 PATCHED_SHA256=`07746827bf3b6bc349f7b580533d4e2d75914b61970bb933f95b9b897684aef3` 35 DRIVERS_SHA256=`672cbc99c98568866abaf49e3944c98dc893ab3bd7906e806ff5c678dd95624b` 36 BASELINE_SHA256=`734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61` 37 38 fail() { printf 'run.sh: %s\n' "$*" >&2; exit 1; } 39 sha() { sha256sum < "$1" | cut -c1-64; } 40 [ "$(uname -m)" = x86_64 ] || fail "this is the x86-64 host run; on AArch64 run the oracle unpatched" 41 for f in out/omc out/omc-x86; do [ -x "$R/$f" ] || fail "$f missing: run sh build.sh first"; done 42 want() { # want NAME FILE: FILE must have the sha256 seed/PINS.tsv gives NAME 43 pin=$(awk -F'\t' -v n="$1" '$1 == n { print $3 }' "$R/seed/PINS.tsv") 44 [ "$(sha "$2")" = "$pin" ] || fail "$2 is not the pinned $1" 45 } 46 want omc "$R/out/omc" 47 want omc-x86 "$R/out/omc-x86" 48 49 # The oracle tree: omega-mv at MV_REV, the oracle patched and nothing else changed. 50 git -C "$MV" worktree add --detach "$W/omega-mv" "$MV_REV" > /dev/null 2>&1 || fail "omega-mv has no commit $MV_REV" 51 O=$W/omega-mv/seed/omc 52 [ "$(sha "$O/qualify-x86.py")" = "$ORACLE_SHA256" ] || fail "qualify-x86.py at $MV_REV is not the reviewed one" 53 [ "$(sha "$O/x86_corpus_drivers.py")" = "$DRIVERS_SHA256" ] || fail "x86_corpus_drivers.py at $MV_REV is not the reviewed one" 54 git -C "$W/omega-mv" apply "$R/evidence/x86-native/qualify-x86-native.patch" 55 [ "$(sha "$O/qualify-x86.py")" = "$PATCHED_SHA256" ] || fail "patched qualify-x86.py has an unexpected sha256" 56 git -C "$BR" worktree add --detach "$W/omega-bridge" "$BRIDGE_REV" > /dev/null 2>&1 || fail "omega-bridge has no commit $BRIDGE_REV" 57 git -C "$MV" show "$BASELINE_REV:seed/out/omc" > "$W/baseline-omc" 58 chmod +x "$W/baseline-omc" 59 [ "$(sha "$W/baseline-omc")" = "$BASELINE_SHA256" ] || fail "baseline compiler at $BASELINE_REV is not $BASELINE_SHA256" 60 61 # Every compiler the oracle runs that it does not itself print: the four historical candidates it 62 # bootstraps with the baseline (qualify-x86.py HISTORICAL_COMPILERS), rebuilt here the same way when 63 # their commit is in OMEGA_MV. The oracle fails the rows that need an absent one. 64 { 65 printf 'role\tsha256\tmade_by\n' 66 printf 'omc\t%s\tsh build.sh (seed/PINS.tsv)\n' "$(sha "$R/out/omc")" 67 printf 'omc-x86\t%s\tsh build.sh (seed/PINS.tsv); --x86-compiler\n' "$(sha "$R/out/omc-x86")" 68 printf 'baseline\t%s\tgit %s:seed/out/omc\n' "$(sha "$W/baseline-omc")" "$BASELINE_REV" 69 for c in s1:`a5927895c02a5abe6b5c3a455f5d54303962ebe8` s2:`7fb62f3a87104f48bb1317ab05333c5805ce5340` \ 70 s3:`ad220c054b2e018a985384a33bf09b9f0d612787` s4:`f6a6492fd1a3b608f0413a75685ddbb712075a73`; do 71 if git -C "$MV" cat-file -e "${c#*:}:seed/omc/omc.om" 2> /dev/null; then 72 git -C "$MV" show "${c#*:}:seed/omc/omc.om" | "$W/baseline-omc" > "$W/cand-${c%%:*}" 73 printf 'cand-%s\t%s\tbaseline from git %s:seed/omc/omc.om\n' "${c%%:*}" "$(sha "$W/cand-${c%%:*}")" "${c#*:}" 74 else 75 printf 'cand-%s\tABSENT\tcommit %s is not in OMEGA_MV\n' "${c%%:*}" "${c#*:}" 76 fi 77 done 78 } > "$W/compilers.tsv" 79 80 mkdir "$W/tmp" 81 set -- python3 seed/omc/qualify-x86.py --host x86-native \ 82 --compiler "$R/out/omc" --x86-compiler "$R/out/omc-x86" --qemu-aarch64 qemu-aarch64-static \ 83 --bridge "$W/omega-bridge/tools/native" --bridge-baseline-compiler "$W/baseline-omc" \ 84 --objdump x86_64-linux-gnu-objdump 85 start=$(date -u +%Y-%m-%dT%H:%M:%SZ) 86 rc=0 87 (cd "$W/omega-mv" && TMPDIR="$W/tmp" "$@") > "$W/qualify.jsonl" 2> "$W/qualify.err" || rc=$? 88 end=$(date -u +%Y-%m-%dT%H:%M:%SZ) 89 rm -rf "$W/tmp" 90 91 # The receipt: the oracle's own header, metadata and summary lines verbatim, every row that is not 92 # PASS or EXCLUDED, and the pins. Nothing is recounted here. 93 n=$(wc -l < "$W/qualify.jsonl") 94 jq -s --arg start "$start" --arg end "$end" --argjson exit "$rc" --arg command "$*" \ 95 --arg mv "$MV_REV" --arg bridge "$BRIDGE_REV" --arg oracle "$ORACLE_SHA256" --arg patched "$PATCHED_SHA256" \ 96 --arg patch "$(sha "$R/evidence/x86-native/qualify-x86-native.patch")" --arg drivers "$DRIVERS_SHA256" \ 97 --arg bridge_tool "$(sha "$W/omega-bridge/tools/native")" --arg nproc "$(nproc)" \ 98 --arg a64cc "$(aarch64-linux-gnu-gcc --version | sed -n 1p)" --arg x86cc "$(x86_64-linux-gnu-gcc --version | sed -n 1p)" \ 99 --arg objdump "$(x86_64-linux-gnu-objdump --version | sed -n 1p)" --arg python "$(python3 --version)" \ 100 --arg jsonl_sha "$(sha "$W/qualify.jsonl")" --argjson jsonl_bytes "$(wc -c < "$W/qualify.jsonl")" \ 101 --rawfile compilers "$W/compilers.tsv" ' 102 .[0] as $header | .[1] as $meta | .[-1] as $final | 103 [.[] | select(.status? and .status != "PASS" and .status != "EXCLUDED")] as $other | 104 {schema: 1, date: ($start[0:10]), started: $start, finished: $end, 105 execution: "NATIVE_X86_64", aarch64_arm: "EMULATED (qemu-aarch64 via binfmt_misc)", 106 source_commit: $mv, command: $command, exit: $exit, 107 summary: $final.summary, verdict: $final.verdict, 108 host: {cpu_model: $meta.cpu_model, nproc: ($nproc | tonumber), kernel: $meta.kernel, platform: $meta.platform, 109 qemu_aarch64: $meta.qemu_aarch64, qemu_aarch64_sha256: $meta.qemu_aarch64_sha256, 110 qemu_aarch64_version: ($meta.qemu_aarch64_version | split("\n")[0]), binfmt: $meta.binfmt, 111 objdump: $objdump, aarch64_cc: $a64cc, x86_64_cc: $x86cc, python: $python}, 112 compilers: ($compilers | split("\n")[1:] | map(select(length > 0) | split("\t") | {role: .[0], sha256: .[1], made_by: .[2]})), 113 compilers_in_rows: { 114 x86_hosted_frontend: ([.[] | .evidence?.frontend_compiler?.x86_compiler_sha256? // empty] | unique), 115 generation_ceiling_variant: ([.[] | .evidence?.generation_ceiling_whitebox?.variant_compiler_sha256? // empty] | unique), 116 bridge_selected: ([.[] | .bridge_result?.observations?[]?.compiler_sha256? // empty] | unique), 117 bridge_baseline: ([.[] | .bridge_result?.observations?[]?.baseline_compiler_sha256? // empty] | unique)}, 118 oracle: {checker_sha256: $header.checker_sha256, original_checker_sha256: $oracle, patched_checker_sha256: $patched, 119 patch_sha256: $patch, driver_sha256: $header.driver_sha256, reviewed_driver_sha256: $drivers, 120 source_revision_contract: $header.source_revision_contract, compiler_source_sha256: $header.compiler_source_sha256, 121 inventory_files: $header.inventory_files}, 122 bridge: {repo: "omega-bridge rad:`z3Hr9ZaiKHwwuNzPK5M8c7uw6pj7y`", commit: $bridge, tool_sha256: $bridge_tool}, 123 reasons: $final.reasons, 124 not_pass: [$other[] | {status, case, reason, source_sha256}], 125 negative_controls: [.[] | select(.case? and (.case | startswith("negative-")))], 126 coverage_limits: $final.coverage_limits, 127 jsonl_rows: (length), jsonl_bytes: $jsonl_bytes, jsonl_sha256: $jsonl_sha}' \ 128 "$W/qualify.jsonl" > "$W/receipt.json" 129 printf 'run.sh: %s rows, oracle exit %s, receipt %s\n' "$n" "$rc" "$W/receipt.json" 130 exit "$rc"