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
omega-mv / tools / test_e1_combine.sh
| 1 | #!/bin/bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # test_e1_combine.sh -- host-only tests (no GPU) for tools/e1_combine.sh. |
| 18 | # Builds a scratch git repository with a "candidate" and a "main" commit, a |
| 19 | # full synthetic constituent set (Gate 5 receipt, reduce and transc receipts, |
| 20 | # MEAN-mutant log, campaign log, LDST chip log, host rerun, equivalence |
| 21 | # manifest), then expects accept for the good set and refuse for each hostile |
| 22 | # mutant: child digest, candidate SHA, Physics SHA, PASS->FAIL, input count, |
| 23 | # mismatch count, equivalence digest, chip file differing, missing child, |
| 24 | # duplicate child, uncertain completion, mutant not killed, host line failing, |
| 25 | # rebuilt binary not the chip binary, prior transc kernel digest changed. Run: |
| 26 | # make test-e1-combine. |
| 27 | set -u |
| 28 | HERE=$(cd -P "$(dirname "$0")/.." && pwd) |
| 29 | COMBINE=$HERE/tools/e1_combine.sh |
| 30 | # shellcheck source=tools/e1_combine.sh |
| 31 | . "$COMBINE" |
| 32 | e1_build_canon || { echo "FAIL: cannot build tools/json_canon.c"; exit 1; } |
| 33 | TMP=$(mktemp -d) |
| 34 | trap 'rm -rf "$TMP" "$E1_TMP"' EXIT |
| 35 | fails=0 passes=0 |
| 36 | ok() { echo " [PASS] $1"; passes=$((passes + 1)); } |
| 37 | bad() { echo " [FAIL] $1"; fails=$((fails + 1)); } |
| 38 | check() { if eval "$2"; then ok "$1"; else bad "$1"; fi; } |
| 39 | |
| 40 | # ---- scratch repository: candidate -> main, one host file (Makefile) differs ---- |
| 41 | R=$TMP/repo; mkdir -p "$R/src/numeric" "$R/tests" |
| 42 | git -C "$R" init -q; git -C "$R" config user.email t@t; git -C "$R" config user.name t |
| 43 | echo 'kernel' > "$R/src/numeric/k.c"; echo 'gate' > "$R/tests/run_numeric_gates.sh"; echo 'all:' > "$R/Makefile" |
| 44 | git -C "$R" add -A; git -C "$R" commit -qm cand; CAND=$(git -C "$R" rev-parse HEAD) |
| 45 | echo 'all: more' > "$R/Makefile"; git -C "$R" commit -qam main; MAIN=$(git -C "$R" rev-parse HEAD) |
| 46 | export E1_GIT_DIR=$R |
| 47 | PHYS=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf |
| 48 | OTHER=1111111111111111111111111111111111111111 |
| 49 | sha() { sha256sum -- "$1" | cut -c1-64; } |
| 50 | gsha() { git -C "$R" show "$1:$2" | sha256sum | cut -c1-64; } |
| 51 | H() { printf '%064d' "$1"; } # fake 64-hex digests |
| 52 | G5BIN=$(H 5) REDBIN=$(H 6) TRBIN=$(H 7) LDBIN=$(H 8) DESC=$(H 9) LOGH=$(H 10) |
| 53 | |
| 54 | # content-named file: write BODY to TMP/DIR/<sha>.EXT, print path |
| 55 | named() { local d=$TMP/$1 f; mkdir -p "$d"; f=$(mktemp "$d/x.XXXX"); printf '%s' "$3" > "$f"; mv "$f" "$d/$(sha "$f").$2"; echo "$d/$(sha "$d/$(sha "$f").$2" 2>/dev/null || true)" > /dev/null; ls "$d"/*."$2" | tail -n1; } |
| 56 | named() { local d=$TMP/$1 f s; mkdir -p "$d"; f=$(mktemp "$d/x.XXXX"); printf '%s' "$3" > "$f"; s=$(sha "$f"); mv "$f" "$d/$s.$2"; echo "$d/$s.$2"; } |
| 57 | # json receipts: pretty and content-named |
| 58 | njson() { named "$1" json "$(printf '%s' "$2" | jq -c "${3:-.}" | "$JSON_CANON" --pretty)"; } |
| 59 | |
| 60 | # Gate 5: receipt_digest over the body without it; named by that digest |
| 61 | G5_BODY="{\"schema\":\"AIEN_OMEGA_NUMERIC_0_V1\",\"status\":\"PASS\",\"candidate_git_commit\":\"$CAND\",\"run_git_commit\":\"$CAND\",\"physics_candidate_git_commit\":\"$PHYS\",\"physics_lock\":\"$PHYS\",\"candidate_trees_clean\":{\"omega\":true,\"physics\":true},\"gate_binary_exit_status\":0,\"observed_fail_count\":0,\"observed_test_count\":2,\"observed_pass_count\":2,\"test_results\":[{\"suite\":\"s\",\"id\":\"A_PASS\",\"status\":\"PASS\"},{\"suite\":\"s\",\"id\":\"B_PASS\",\"status\":\"PASS\"}],\"hardware_descriptor_digest\":\"$DESC\",\"candidate_binary_sha256\":\"$G5BIN\"}" |
| 62 | mkg5() { # [JQ_FILTER] [RENAME_DIGEST] |
| 63 | local b d dir; b=$(printf '%s' "$G5_BODY" | jq -c "${1:-.}") && d=$(printf '%s' "$b" | "$JSON_CANON" --sha256) || return 1 |
| 64 | dir=$(mktemp -d "$TMP/g5.XXXX"); printf '{"receipt_digest":"%s",%s' "${2:-$d}" "${b#\{}" | "$JSON_CANON" --pretty > "$dir/${2:-$d}.json"; echo "$dir/${2:-$d}.json" |
| 65 | } |
| 66 | G5=$(mkg5); G5D=$(basename "$G5" .json) |
| 67 | |
| 68 | RED_BODY="{\"suite\":\"E1_REDUCE_GB10_PARITY\",\"status\":\"PASS\",\"exit_status\":\"0\",\"omega_commit\":\"$CAND\",\"physics_commit\":\"$PHYS\",\"omega_clean_before\":true,\"omega_clean_after\":true,\"ops\":[\"SUM\",\"MAX\",\"MIN\",\"MEAN\"],\"parity_line\":\"RED_GB10_PARITY: PASS ops=SUM,MAX,MIN,MEAN cases=380 mismatches=0\",\"parity_by_op\":{\"SUM\":\"RED_GB10_PARITY_SUM: PASS op=SUM cases=95 mismatches=0\",\"MAX\":\"RED_GB10_PARITY_MAX: PASS op=MAX cases=95 mismatches=0\",\"MIN\":\"RED_GB10_PARITY_MIN: PASS op=MIN cases=95 mismatches=0\",\"MEAN\":\"RED_GB10_PARITY_MEAN: PASS op=MEAN cases=95 mismatches=0\"},\"binary_sha256\":\"$REDBIN\",\"log_sha256\":\"$LOGH\"}" |
| 69 | RED=$(njson red "$RED_BODY"); REDD=$(basename "$RED" .json) |
| 70 | |
| 71 | ops_json() { local o j=; for o in SIN COS ERF GELU RSQRT; do j+="{\"op\":\"$o\",\"checked\":${1:-4294967296},\"exhaustive\":true,\"mismatches\":${2:-0},\"unwritten\":0,\"verdict\":\"PASS\"},"; done; echo "[${j%,}]"; } |
| 72 | KERN4() { local o j= i=1; for o in EXP2 LOG2 SIGMOID TANH; do j+="{\"op\":\"$o\",\"instructions\":$((i*8)),\"sha256\":\"${1:-$(H $((20+i)))}\"},"; i=$((i+1)); done; echo "${j%,}"; } |
| 73 | TR_BODY="{\"gate\":\"E1-TRANSC-GB10\",\"verdict\":\"PASS\",\"chip_exit_status\":0,\"omega_commit\":\"$CAND\",\"physics_commit\":\"$PHYS\",\"physics_lock_pin\":\"$PHYS\",\"omega_tree_clean_before\":true,\"omega_tree_clean_after\":true,\"omega_commit_unchanged_after\":true,\"physics_tree_clean_before\":true,\"physics_tree_clean_after\":true,\"physics_commit_unchanged_after\":true,\"ops_requested\":[\"SIN\",\"COS\",\"ERF\",\"GELU\",\"RSQRT\"],\"ops\":$(ops_json),\"kernels\":[$(KERN4),{\"op\":\"SIN\",\"instructions\":120,\"sha256\":\"$(H 31)\"}],\"binary_sha256\":\"$TRBIN\",\"chip_log_sha256\":\"$LOGH\"}" |
| 74 | TR=$(njson tr "$TR_BODY"); TRD=$(basename "$TR" .json) |
| 75 | ops4_json() { local o j=; for o in EXP2 LOG2 SIGMOID TANH; do j+="{\"op\":\"$o\",\"checked\":4294967296,\"exhaustive\":true,\"mismatches\":${1:-0},\"unwritten\":0,\"verdict\":\"PASS\"},"; done; echo "[${j%,}]"; } |
| 76 | TRP_BODY="{\"gate\":\"E1-TRANSC-GB10\",\"verdict\":\"PASS\",\"chip_exit_status\":0,\"omega_commit\":\"$(H 1 | cut -c1-40)\",\"physics_commit\":\"$PHYS\",\"physics_lock_pin\":\"$PHYS\",\"omega_tree_clean_before\":true,\"omega_tree_clean_after\":true,\"ops_requested\":[\"EXP2\",\"LOG2\",\"SIGMOID\",\"TANH\"],\"ops\":$(ops4_json),\"kernels\":[$(KERN4)],\"binary_sha256\":\"$(H 32)\"}" |
| 77 | TRP=$(njson trp "$TRP_BODY") |
| 78 | |
| 79 | MUT_TXT=$'RED_GB10_PARITY_SUM: PASS op=SUM cases=95 mismatches=0\nRED_GB10_PARITY_MAX: PASS op=MAX cases=95 mismatches=0\nRED_GB10_PARITY_MIN: PASS op=MIN cases=95 mismatches=0\nRED_GB10_PARITY_MEAN: FAIL op=MEAN cases=95 mismatches=95\nE1 Reduce Verdict: FAIL\n' |
| 80 | MUT=$(named mut log "$MUT_TXT"); MUTD=$(basename "$MUT" .log) |
| 81 | |
| 82 | camp() { # [sed expression] |
| 83 | local f; f=$(mktemp "$TMP/campaign.XXXX.log") |
| 84 | printf 'omega %s physics %s\nGate LDST host: PASSED=148 FAILED=0\n[PASS] ldst: 148 of 148 kernels decode\nspecs passed: 3\nGate 5 PASS: receipt digest %s\nreceipt: /x/%s.json status=PASS\nRECEIPT /x/%s.json\nlog sha256: %s\nE1 MEAN MUTANT: KILLED\nVERDICT PASS\n' \ |
| 85 | "$CAND" "$PHYS" "$G5D" "$REDD" "$TRD" "$MUTD" | sed "${1:-}" > "$f"; echo "$f" |
| 86 | } |
| 87 | CAMP=$(camp) |
| 88 | LDST_TXT=$'RESULT chip spec=1 a count=1000 rc=0 mismatches=0 unwritten=0 verdict=PASS\nRESULT chip spec=2 b count=1000 rc=0 mismatches=0 unwritten=0 verdict=PASS\nRESULT chip spec=3 c count=1000 rc=0 mismatches=0 unwritten=0 verdict=PASS\nVERDICT PASS\n' |
| 89 | printf '%s' "$LDST_TXT" > "$TMP/ldst.log"; LDST=$TMP/ldst.log |
| 90 | |
| 91 | HOST_BODY="{\"schema\":\"AIEN_E1_HOST_RERUN_V1\",\"omega_commit\":\"$MAIN\",\"tracked_tree_clean_before\":true,\"tracked_tree_clean_after\":true,\"lines\":{\"GB10-COMPILE\":\"PASS\",\"NUMERIC-HOST\":\"PASS\",\"PROGRAM\":\"PASS\",\"TRANSC\":\"PASS\",\"MANIFEST\":\"PASS\",\"HOSTALL\":\"PASS\"}}" |
| 92 | HOST=$(njson host "$HOST_BODY") |
| 93 | |
| 94 | mf() { local p=$1 c=$2 a b; a=$(gsha "$CAND" "$p"); b=$(gsha "$MAIN" "$p"); printf '{"path":"%s","class":"%s","sha256_candidate":"%s","sha256_main":"%s","equal":%s}' "$p" "$c" "$a" "$b" "$([ "$a" = "$b" ] && echo true || echo false)"; } |
| 95 | MAN_BODY="{\"schema\":\"AIEN_E1_EQUIVALENCE_MANIFEST_V1\",\"candidate_git_commit\":\"$CAND\",\"main_git_commit\":\"$MAIN\",\"whole_tree_identical\":false,\"files_equal\":2,\"files_differ\":1,\"chip_files_differ\":0,\"files\":[$(mf src/numeric/k.c chip),$(mf tests/run_numeric_gates.sh chip),$(mf Makefile host)],\"rebuilt_chip_binaries\":[{\"gate\":\"GATE5\",\"sha256_main\":\"$G5BIN\"},{\"gate\":\"REDUCE\",\"sha256_main\":\"$REDBIN\"},{\"gate\":\"TRANSC\",\"sha256_main\":\"$TRBIN\"},{\"gate\":\"LDST\",\"sha256_main\":\"$LDBIN\"}]}" |
| 96 | MAN=$(njson man "$MAN_BODY") |
| 97 | |
| 98 | ARGS=(--candidate "$CAND" --main "$MAIN" --physics "$PHYS") |
| 99 | good() { echo --manifest "${MANX:-$MAN}" --gate5 "${G5X:-$G5}" --reduce "${REDX:-$RED}" --transc "${TRX:-$TR}" --mutant-log "${MUTX:-$MUT}" --campaign-log "${CAMPX:-$CAMP}" --ldst-chip-log "${LDSTX:-$LDST}" --host-rerun "${HOSTX:-$HOST}" --transc-prior "${TRPX:-$TRP}"; } |
| 100 | run() { "$COMBINE" "$@" > "$TMP/out" 2> "$TMP/err"; } |
| 101 | refused() { ! run "$@" && grep -q "^REFUSED: .*$REASON" "$TMP/err" || { echo " err: $(head -c 300 "$TMP/err") out: $(head -c 100 "$TMP/out")"; false; }; } |
| 102 | # with VAR=path overridden for one call |
| 103 | with() { local v=$1 p=$2; eval "$v=\$p"; refused "${ARGS[@]}" $(good); local rc=$?; unset "$v"; return $rc; } |
| 104 | |
| 105 | echo "== accept ==" |
| 106 | EV=$TMP/ev; export E1_TIMESTAMP_UTC=2026-10-02T00:00:00.000000Z |
| 107 | check "good constituent set accepted and written" 'run "${ARGS[@]}" $(good) --evidence-dir "$EV" && grep -q "^E1 CLOSURE PASS" "$TMP/out"' |
| 108 | OUT=$(ls "$EV"/*.json 2>/dev/null | head -n1) |
| 109 | check "written receipt is named for its receipt_digest" '[ -n "$OUT" ] && [ "$(jq -r .receipt_digest "$OUT")" = "$(basename "$OUT" .json)" ]' |
| 110 | check "receipt_digest = sha256(canonical body without it)" '[ "$(jq -c "del(.receipt_digest)" "$OUT" | "$JSON_CANON" --sha256)" = "$(basename "$OUT" .json)" ]' |
| 111 | check "receipt is read-only and says the chip ran on the candidate" '[ ! -w "$OUT" ] && [ "$(jq -r .chip_ran_on "$OUT")" = candidate ] && [ "$(jq -r .merged_main_git_commit "$OUT")" = "$MAIN" ]' |
| 112 | check "receipt records one differing host file and host rerun PASS" '[ "$(jq -r .e1_artifact_set.host_class_files_differ "$OUT")" = 1 ] && [ "$(jq -r .constituents.host_rerun.status "$OUT")" = PASS ]' |
| 113 | check "second write of the same receipt is refused (exclusive)" 'REASON="cannot write" refused "${ARGS[@]}" $(good) --evidence-dir "$EV"' |
| 114 | check "deterministic digest apart from timestamp" 'run "${ARGS[@]}" $(good) && [ "$(jq -c "del(.receipt_digest,.timestamp_utc)" "$OUT")" = "$(jq -c "del(.receipt_digest,.timestamp_utc)" "$OUT")" ] && grep -q "receipt digest" "$TMP/out"' |
| 115 | |
| 116 | echo "== refuse: child digest ==" |
| 117 | X=$(mkg5 . "$(H 42)"); check "gate5 receipt_digest not matching content" 'REASON="receipt_digest does not match" with G5X "$X"' |
| 118 | cp "$RED" "$TMP/red-tampered.json"; sed -i 's/cases=380/cases=380 /' "$TMP/red-tampered.json"; mv "$TMP/red-tampered.json" "$TMP/$REDD.tampered"; mkdir -p "$TMP/rt"; cp "$TMP/$REDD.tampered" "$TMP/rt/$REDD.json" |
| 119 | check "reduce receipt whose content no longer matches its name" 'REASON="not named for its SHA-256" with REDX "$TMP/rt/$REDD.json"' |
| 120 | mkdir -p "$TMP/tt"; cp "$TR" "$TMP/tt/$(H 43).json" |
| 121 | check "transc receipt renamed to a different digest" 'REASON="not named for its SHA-256" with TRX "$TMP/tt/$(H 43).json"' |
| 122 | mkdir -p "$TMP/mt"; printf '%s' "$MUT_TXT" > "$TMP/mt/$(H 44).log" |
| 123 | check "mutant log renamed" 'REASON="not named for its SHA-256" with MUTX "$TMP/mt/$(H 44).log"' |
| 124 | X=$(njson man "$MAN_BODY" ".files[0].sha256_main=\"$(H 45)\"") |
| 125 | check "equivalence manifest digest not matching git" 'REASON="do not match git" with MANX "$X"' |
| 126 | |
| 127 | echo "== refuse: SHAs ==" |
| 128 | check "candidate SHA on the command line differs from the receipts" 'REASON="candidate" refused --candidate "$OTHER" --main "$MAIN" --physics "$PHYS" $(good)' |
| 129 | X=$(mkg5 ".candidate_git_commit=\"$OTHER\""); check "gate5 names another candidate" 'REASON="gate5" with G5X "$X"' |
| 130 | X=$(njson red "$RED_BODY" ".physics_commit=\"$OTHER\""); check "reduce names another Physics commit" 'REASON="physics" with REDX "$X"' |
| 131 | X=$(njson tr "$TR_BODY" ".physics_lock_pin=\"$OTHER\""); check "transc pin differs from Physics" 'REASON="transc" with TRX "$X"' |
| 132 | check "Physics SHA on the command line differs" 'REASON="physics" refused --candidate "$CAND" --main "$MAIN" --physics "$OTHER" $(good)' |
| 133 | X=$(njson host "$HOST_BODY" ".omega_commit=\"$CAND\""); check "host rerun on the candidate, not main" 'REASON="host rerun" with HOSTX "$X"' |
| 134 | X=$(njson man "$MAN_BODY" ".main_git_commit=\"$CAND\""); check "manifest for other commits" 'REASON="manifest" with MANX "$X"' |
| 135 | |
| 136 | echo "== refuse: PASS->FAIL ==" |
| 137 | X=$(mkg5 '.status="FAIL"'); check "gate5 FAIL" 'REASON="gate5" with G5X "$X"' |
| 138 | X=$(mkg5 '.test_results[1].status="FAIL"'); check "gate5 one failing test" 'REASON="gate5" with G5X "$X"' |
| 139 | X=$(njson red "$RED_BODY" '.status="FAIL"'); check "reduce FAIL" 'REASON="reduce" with REDX "$X"' |
| 140 | X=$(njson tr "$TR_BODY" '.ops[2].verdict="FAIL"'); check "transc one op FAIL" 'REASON="transc" with TRX "$X"' |
| 141 | X=$(njson host "$HOST_BODY" '.lines.TRANSC="FAIL(rc=2)"'); check "host rerun line FAIL" 'REASON="TRANSC is not PASS" with HOSTX "$X"' |
| 142 | X=$(njson host "$HOST_BODY" 'del(.lines.HOSTALL)'); check "host rerun line missing" 'REASON="HOSTALL is not PASS" with HOSTX "$X"' |
| 143 | X=$(camp 's/^VERDICT PASS/VERDICT FAIL/'); check "campaign VERDICT FAIL" 'REASON="VERDICT PASS" with CAMPX "$X"' |
| 144 | printf '%s' "${LDST_TXT/verdict=PASS/verdict=FAIL}" > "$TMP/ldst-f.log"; check "ldst one spec FAIL" 'REASON="ldst" with LDSTX "$TMP/ldst-f.log"' |
| 145 | |
| 146 | echo "== refuse: counts ==" |
| 147 | X=$(njson tr "$TR_BODY" ".ops=$(ops_json 4294967295)"); check "transc input count short of 2^32" 'REASON="transc" with TRX "$X"' |
| 148 | X=$(njson tr "$TR_BODY" '.ops |= .[0:4]'); check "transc only four ops" 'REASON="transc" with TRX "$X"' |
| 149 | X=$(njson red "$RED_BODY" '.parity_by_op.MIN="RED_GB10_PARITY_MIN: PASS op=MIN cases=94 mismatches=0"'); check "reduce per-op case count sums short" 'REASON="reduce" with REDX "$X"' |
| 150 | X=$(mkg5 '.observed_test_count=3'); check "gate5 test count disagrees with results" 'REASON="gate5" with G5X "$X"' |
| 151 | X=$(camp 's/^specs passed: 3/specs passed: 4/'); check "campaign spec count disagrees with ldst log" 'REASON="PASS results" with CAMPX "$X"' |
| 152 | X=$(njson man "$MAN_BODY" '.files_differ=0'); check "manifest differ count wrong" 'REASON="files_differ" with MANX "$X"' |
| 153 | |
| 154 | echo "== refuse: mismatches ==" |
| 155 | X=$(njson red "$RED_BODY" '.parity_by_op.MEAN="RED_GB10_PARITY_MEAN: PASS op=MEAN cases=95 mismatches=1"'); check "reduce one mismatch in one op" 'REASON="reduce" with REDX "$X"' |
| 156 | X=$(njson tr "$TR_BODY" ".ops=$(ops_json 4294967296 1)"); check "transc one mismatch" 'REASON="transc" with TRX "$X"' |
| 157 | X=$(mkg5 '.observed_fail_count=1'); check "gate5 nonzero fail count" 'REASON="gate5" with G5X "$X"' |
| 158 | printf '%s' "${LDST_TXT/mismatches=0 unwritten=0 verdict=PASS/mismatches=0 unwritten=0 verdict=PASS |
| 159 | OMEGA_DEVERR x}" > "$TMP/ldst-e.log"; check "ldst device error" 'REASON="device error" with LDSTX "$TMP/ldst-e.log"' |
| 160 | |
| 161 | echo "== refuse: equivalence ==" |
| 162 | echo 'changed' > "$R/src/numeric/k.c"; git -C "$R" commit -qam chip; MAIN2=$(git -C "$R" rev-parse HEAD) |
| 163 | mf2() { local p=$1 c=$2 a b; a=$(gsha "$CAND" "$p"); b=$(gsha "$MAIN2" "$p"); printf '{"path":"%s","class":"%s","sha256_candidate":"%s","sha256_main":"%s","equal":%s}' "$p" "$c" "$a" "$b" "$([ "$a" = "$b" ] && echo true || echo false)"; } |
| 164 | MAN2="{\"schema\":\"AIEN_E1_EQUIVALENCE_MANIFEST_V1\",\"candidate_git_commit\":\"$CAND\",\"main_git_commit\":\"$MAIN2\",\"whole_tree_identical\":false,\"files_equal\":1,\"files_differ\":2,\"chip_files_differ\":0,\"files\":[$(mf2 src/numeric/k.c chip),$(mf2 tests/run_numeric_gates.sh chip),$(mf2 Makefile host)],\"rebuilt_chip_binaries\":[{\"gate\":\"GATE5\",\"sha256_main\":\"$G5BIN\"},{\"gate\":\"REDUCE\",\"sha256_main\":\"$REDBIN\"},{\"gate\":\"TRANSC\",\"sha256_main\":\"$TRBIN\"},{\"gate\":\"LDST\",\"sha256_main\":\"$LDBIN\"}]}" |
| 165 | X=$(njson man "$MAN2"); HOST2=$(njson host "$HOST_BODY" ".omega_commit=\"$MAIN2\"") |
| 166 | check "a chip-class file differs between candidate and main (needs requalification)" 'REASON="chip artifact" refused --candidate "$CAND" --main "$MAIN2" --physics "$PHYS" --manifest "$X" --gate5 "$G5" --reduce "$RED" --transc "$TR" --mutant-log "$MUT" --campaign-log "$CAMP" --ldst-chip-log "$LDST" --host-rerun "$HOST2" --transc-prior "$TRP"' |
| 167 | X=$(njson man "$MAN_BODY" ".rebuilt_chip_binaries[1].sha256_main=\"$(H 46)\""); check "rebuilt REDUCE binary is not the chip binary" 'REASON="rebuilt REDUCE" with MANX "$X"' |
| 168 | X=$(njson man "$MAN_BODY" '.rebuilt_chip_binaries |= .[0:3]'); check "no rebuilt LDST binary" 'REASON="LDST" with MANX "$X"' |
| 169 | X=$(njson man "$MAN_BODY" '.files[2].equal=true'); check "manifest equal flag lies" 'REASON="equal flag" with MANX "$X"' |
| 170 | X=$(njson man "$MAN_BODY" '.files[0].class="host" | .files[1].class="host"'); check "chip file relabelled host (digests still match, still accepted only if equal)" 'run "${ARGS[@]}" --manifest "$X" --gate5 "$G5" --reduce "$RED" --transc "$TR" --mutant-log "$MUT" --campaign-log "$CAMP" --ldst-chip-log "$LDST" --host-rerun "$HOST" --transc-prior "$TRP"' |
| 171 | |
| 172 | echo "== refuse: campaign / mutant / children ==" |
| 173 | X=$(camp 's/^E1 MEAN MUTANT: KILLED/E1 MEAN MUTANT: SURVIVED/'); check "campaign mutant not killed" 'REASON="KILLED" with CAMPX "$X"' |
| 174 | X=$(camp '$a GB10_COMPLETION_UNCERTAIN'); check "campaign has an uncertain completion" 'REASON="uncertain" with CAMPX "$X"' |
| 175 | X=$(camp "s/$G5D/$(H 47)/"); check "campaign names a different Gate 5 receipt" 'REASON="Gate 5" with CAMPX "$X"' |
| 176 | X=$(named mut log "${MUT_TXT/MEAN: FAIL op=MEAN cases=95 mismatches=95/MEAN: PASS op=MEAN cases=95 mismatches=0}"); check "mutant log where MEAN passed (mutant survived)" 'REASON="MEAN failing" with MUTX "$X"' |
| 177 | check "missing child (no host rerun)" 'REASON="not given" refused "${ARGS[@]}" --manifest "$MAN" --gate5 "$G5" --reduce "$RED" --transc "$TR" --mutant-log "$MUT" --campaign-log "$CAMP" --ldst-chip-log "$LDST" --transc-prior "$TRP"' |
| 178 | check "missing child (no gate5)" 'REASON="not given" refused "${ARGS[@]}" --manifest "$MAN" --reduce "$RED" --transc "$TR" --mutant-log "$MUT" --campaign-log "$CAMP" --ldst-chip-log "$LDST" --host-rerun "$HOST" --transc-prior "$TRP"' |
| 179 | check "missing child (no prior transc receipt)" 'REASON="not given" refused "${ARGS[@]}" --manifest "$MAN" --gate5 "$G5" --reduce "$RED" --transc "$TR" --mutant-log "$MUT" --campaign-log "$CAMP" --ldst-chip-log "$LDST" --host-rerun "$HOST"' |
| 180 | X=$(njson trp "$TRP_BODY" ".kernels[1].sha256=\"$(H 50)\""); check "prior transc LOG2 kernel digest differs from the candidate kernel" 'REASON="LOG2 kernel digest" with TRPX "$X"' |
| 181 | X=$(njson trp "$TRP_BODY" ".ops=$(ops4_json 1)"); check "prior transc with one mismatch" 'REASON="transc prior" with TRPX "$X"' |
| 182 | X=$(njson trp "$TRP_BODY" ".physics_commit=\"$OTHER\""); check "prior transc on another Physics commit" 'REASON="transc prior" with TRPX "$X"' |
| 183 | X=$(njson tr "$TR_BODY" ".kernels[0].sha256=\"$(H 51)\""); check "candidate transc EXP2 kernel differs from the chip-run prior" 'REASON="EXP2 kernel digest" with TRX "$X"' |
| 184 | check "duplicate child (gate5 twice)" 'REASON="duplicate" refused "${ARGS[@]}" $(good) --gate5 "$G5"' |
| 185 | check "nonexistent child path" 'REASON="cannot read" with TRX "$TMP/nope.json"' |
| 186 | mkdir -p "$TMP/nj"; echo 'not json' > "$TMP/nj/x.json"; X=$TMP/nj/$(sha "$TMP/nj/x.json").json; mv "$TMP/nj/x.json" "$X" |
| 187 | check "child is not JSON" 'REASON="not valid JSON" with REDX "$X"' |
| 188 | check "nothing written on any refusal" '[ "$(ls "$EV" | wc -l)" = 1 ]' |
| 189 | check "short SHA is a usage error" '"$COMBINE" --candidate abc --main "$MAIN" --physics "$PHYS" $(good) > /dev/null 2>&1; [ $? = 2 ]' |
| 190 | |
| 191 | echo "e1_combine tests: $passes passed, $fails failed" |
| 192 | [ "$fails" = 0 ] |