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/tools/test_chipwait_campaign.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 / tools / test_chipwait_campaign.sh` 155 lines ยท 8786 bytes Raw Blame History 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_chipwait_campaign.sh -- host-only tests of tools/chipwait_campaign.sh 18 # with a STUB qualify script (CHIPWAIT_QUALIFY). No GPU, no real qualifier. 19 # Run: make test-chipwait-campaign (or run this file). 20 set -u 21 HERE=$(cd -P "$(dirname "$0")/.." && pwd) 22 CW=$HERE/tools/chipwait_campaign.sh 23 TMP=$(mktemp -d) 24 trap 'rm -rf "$TMP"' EXIT 25 fails=0 26 ok() { echo " [PASS] $1"; } 27 bad() { echo " [FAIL] $1"; fails=$((fails + 1)); } 28 check() { if eval "$2"; then ok "$1"; else bad "$1"; fi; } 29 30 # Stub qualify. Per-run behaviour from env STUB_STATUS_ (default PASS): 31 # PASS/FAIL write a valid verified run dir; NODIR writes nothing; both exit 32 # nonzero for FAIL/NODIR. STUB_NEED_CAMPAIGN_JSON=1 records whether 33 # campaign.json existed at invocation time. 34 STUB=$TMP/stub_qualify.sh 35 cat > "$STUB" <<'STUBEOF' 36 #!/bin/bash 37 root= id= 38 while [ $# -gt 0 ]; do 39 case $1 in --evidence-root) root=$2;; --run-id) id=$2;; esac 40 shift 41 done 42 n=${id#run-}; n=$((10#$n)) 43 # STUB_CLEAN=1: what m19r_qualify.sh does to build/ (make clean), on CHIPWAIT_BUILD_DIR. 44 [ "${STUB_CLEAN:-0}" = 1 ] && rm -rf "$CHIPWAIT_BUILD_DIR" 45 [ -e "$root/campaign.json" ] && echo "$id saw campaign.json" >> "$root/../stub-order.log" || 46 echo "$id NO campaign.json" >> "$root/../stub-order.log" 47 echo "stub stdout $id"; echo "stub stderr $id" >&2 48 v=STUB_STATUS_$n; s=${!v:-PASS} 49 [ "$s" = NODIR ] && exit 3 50 mkdir "$root/$id" || exit 2 51 echo '{"stub":true}' > "$root/$id/run.json" 52 printf '{"status":"%s"}\n' "$s" > "$root/$id/verdict.json" 53 (cd "$root/$id" && sha256sum run.json verdict.json > hashes.sha256) 54 [ "$s" = PASS ] 55 STUBEOF 56 chmod +x "$STUB" 57 export CHIPWAIT_QUALIFY=$STUB 58 # The build directory the lane receipt guard inspects (never the real build/ here). 59 export CHIPWAIT_BUILD_DIR=$TMP/build; unset WINDOW_LANE_OUT 60 S40=$(printf 'a%.0s' $(seq 40)); P40=$(printf 'b%.0s' $(seq 40)) 61 run() { # run [extra args]; sets rc 62 local d=$1; shift 63 "$CW" --omega-candidate "$S40" --physics-candidate "$P40" --physics-dir "$TMP/phys" --campaign-dir "$d" "$@" \ 64 > "$TMP/out.log" 2> "$TMP/err.log" 65 rc=$? 66 } 67 verdict() { jq -r .verdict "$1/final-verdict.json"; } 68 69 echo "PASS: three PASS runs" 70 c=$TMP/pass; run "$c" 71 check "exit 0" '[ $rc = 0 ]' 72 check "final-verdict PASS" '[ "$(verdict "$c")" = PASS ]' 73 check "three run dirs" '[ "$(ls -d "$c"/run-00?/ | wc -l)" = 3 ]' 74 check "campaign.json written before the first run" '[ "$(head -n1 "$TMP/stub-order.log")" = "run-001 saw campaign.json" ] && ! grep -q NO "$TMP/stub-order.log"' 75 check "campaign.json fields" 'jq -e --arg o "$S40" --arg p "$P40" ".omega_candidate_sha==\$o and .physics_candidate_sha==\$p and .rule==\"3/3 PASS, predeclared\" and .runs_required==3 and (.created_at|test(\"Z\$\")) and (.host|length>0) and (.uname|length>0) and has(\"runner_sha\")" "$c/campaign.json" > /dev/null' 76 check "stdout log captured" 'grep -q "stub stdout run-002" "$c/runner-run-002.stdout.log"' 77 check "stderr log captured" 'grep -q "stub stderr run-002" "$c/runner-run-002.stderr.log"' 78 check "output also shown on terminal" 'grep -q "stub stdout run-003" "$TMP/out.log" && grep -q "stub stderr run-003" "$TMP/err.log"' 79 check "exit codes recorded" '[ "$(cat "$c/runner-run-001.exit")" = 0 ]' 80 81 echo "FAIL: run 2 fails, campaign continues" 82 c=$TMP/fail; STUB_STATUS_2=FAIL run "$c" 83 check "exit 1" '[ $rc = 1 ]' 84 check "final-verdict FAIL" '[ "$(verdict "$c")" = FAIL ]' 85 check "run 3 still ran" '[ -d "$c/run-003" ] && [ "$(cat "$c/runner-run-003.exit")" = 0 ]' 86 check "failing exit code recorded" '[ "$(cat "$c/runner-run-002.exit")" = 1 ]' 87 88 echo "INCOMPLETE: run 3 writes no run dir (m19r_campaign.sh mechanically gives INCOMPLETE)" 89 c=$TMP/inc; STUB_STATUS_3=NODIR run "$c" 90 check "exit nonzero (1)" '[ $rc = 1 ]' 91 check "final-verdict INCOMPLETE" '[ "$(verdict "$c")" = INCOMPLETE ]' 92 check "exit code 3 recorded" '[ "$(cat "$c/runner-run-003.exit")" = 3 ]' 93 94 echo "runs count" 95 c=$TMP/two; run "$c" --runs 2 96 check "--runs 2 passes with 2 runs, rule text derived" '[ $rc = 0 ] && [ "$(jq -r .rule "$c/campaign.json")" = "2/2 PASS, predeclared" ] && [ ! -d "$c/run-003" ]' 97 98 echo "refusal to reuse a campaign dir" 99 find "$TMP/pass" -type f | sort | xargs sha256sum > "$TMP/before.sums" 100 run "$TMP/pass" 101 check "exit 2" '[ $rc = 2 ]' 102 check "existing files byte-identical" 'find "$TMP/pass" -type f | sort | xargs sha256sum | cmp -s - "$TMP/before.sums"' 103 mkdir -p "$TMP/partial/run-001"; echo keep > "$TMP/partial/run-001/x" 104 run "$TMP/partial" 105 check "lone run-001 dir refused (exit 2) and untouched" '[ $rc = 2 ] && [ "$(cat "$TMP/partial/run-001/x")" = keep ] && [ ! -e "$TMP/partial/campaign.json" ]' 106 107 echo "bad arguments" 108 check "no arguments" '"$CW" > /dev/null 2>&1; [ $? = 2 ]' 109 check "runs 0" 'run "$TMP/b1" --runs 0; [ $rc = 2 ]' 110 check "runs abc" 'run "$TMP/b2" --runs abc; [ $rc = 2 ]' 111 check "runs -1" 'run "$TMP/b3" --runs -1; [ $rc = 2 ]' 112 check "missing candidate" '"$CW" --physics-candidate x --physics-dir y --campaign-dir "$TMP/b4" > /dev/null 2>&1; [ $? = 2 ]' 113 check "unknown flag" '"$CW" --bogus > /dev/null 2>&1; [ $? = 2 ]' 114 check "error text on stderr" '"$CW" --runs 0 2>&1 >/dev/null | grep -q usage' 115 check "bad usage created no campaign dir" '[ ! -e "$TMP/b1" ] && [ ! -e "$TMP/b2" ]' 116 117 echo "lane receipt guard (omega #315): R11 evidence is archived before the make-clean lane" 118 B=$CHIPWAIT_BUILD_DIR; WD=$TMP/window 119 mkdir -p "$B/qual-runs/r16/R11" "$B/qual-runs/r11/R11" 120 printf '{"gate":"PASS","from":"R16 ladder rung"}\n' > "$B/qual-runs/r16/R11/rx_aien_faculty_receipt.json" 121 printf '{"gate":"PASS","from":"r11 lane"}\n' > "$B/qual-runs/r11/R11/rx_aien_faculty_receipt.json" 122 s16=$(sha256sum "$B/qual-runs/r16/R11/rx_aien_faculty_receipt.json" | cut -c1-64) 123 s11=$(sha256sum "$B/qual-runs/r11/R11/rx_aien_faculty_receipt.json" | cut -c1-64) 124 c=$TMP/g1; STUB_CLEAN=1 run "$c" 125 check "no WINDOW_LANE_OUT, R11 receipts in build: refused (exit 2)" '[ $rc = 2 ]' 126 check "refusal names the R11 receipt" 'grep -q "REFUSED: lane chipwait would clean .* R11 receipt" "$TMP/err.log"' 127 check "refused before anything ran: no campaign dir, receipts intact" '[ ! -e "$c" ] && [ -s "$B/qual-runs/r16/R11/rx_aien_faculty_receipt.json" ] && [ -s "$B/qual-runs/r11/R11/rx_aien_faculty_receipt.json" ]' 128 ( . "$HERE/tools/window_lane_guard.sh"; wl_begin "$WD" r11; wl_r11_archive "$WD" "$B" ) 129 c=$TMP/g2; WINDOW_LANE_OUT=$WD STUB_CLEAN=1 run "$c" 130 check "only the newest R11 receipt archived: still refused" '[ $rc = 2 ] && [ ! -e "$c" ] && [ -d "$B" ]' 131 ( . "$HERE/tools/window_lane_guard.sh"; wl_begin "$WD" ladder ) 132 ( . "$HERE/tools/window_lane_guard.sh"; wl_r11_archive_all "$WD" "$B" ) 133 c=$TMP/g3; WINDOW_LANE_OUT=$WD STUB_CLEAN=1 run "$c" 134 check "a pending ladder lane is refused by name" '[ $rc = 2 ] && grep -q "lane ladder has an unarchived receipt" "$TMP/err.log"' 135 ( . "$HERE/tools/window_lane_guard.sh"; wl_no_receipt "$WD" ladder ) 136 c=$TMP/g4; WINDOW_LANE_OUT=$WD STUB_CLEAN=1 run "$c" 137 check "everything archived: the campaign runs (exit 0)" '[ $rc = 0 ] && [ "$(verdict "$c")" = PASS ]' 138 check "the campaign's clean removed build/" '[ ! -e "$B" ]' 139 check "both R11 receipts survive under their sha256 names" 'cmp -s "$WD/R11-living/rx_aien_faculty_receipt.$s16.json" <(printf "{\"gate\":\"PASS\",\"from\":\"R16 ladder rung\"}\n") && cmp -s "$WD/R11-living/rx_aien_faculty_receipt.$s11.json" <(printf "{\"gate\":\"PASS\",\"from\":\"r11 lane\"}\n")' 140 mkdir -p "$B/qual-runs/r11/R11"; printf '{"gate":"FAIL","from":"a later r11 run"}\n' > "$B/qual-runs/r11/R11/rx_aien_faculty_receipt.json" 141 c=$TMP/g5; WINDOW_LANE_OUT=$WD STUB_CLEAN=1 run "$c" 142 check "a new, different R11 receipt is not covered by an old archive: refused" '[ $rc = 2 ] && [ ! -e "$c" ] && [ -s "$B/qual-runs/r11/R11/rx_aien_faculty_receipt.json" ]' 143 rm -rf "$B" 144 145 echo "nothing deleted" 146 find "$TMP" -type f | sort > "$TMP/files.before" 147 run "$TMP/after-all" ; run "$TMP/fail" ; run "$TMP/inc" 148 find "$TMP" -type f | sort > "$TMP/files.after" 149 check "file list before is a subset of after" '[ -z "$(comm -23 "$TMP/files.before" "$TMP/files.after")" ]' 150 151 if [ "$fails" -ne 0 ]; then 152 echo "chipwait campaign tests: $fails FAILED" 153 exit 1 154 fi 155 echo "chipwait campaign tests: all passed"