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/program_id_receipt.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 / program_id_receipt.sh` 285 lines ยท 14836 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 # program_id_receipt.sh -- qualification receipt for program identity v2 18 # (spec/program-identity.md): the program id binds the canonical semantic body. 19 # 20 # tools/program_id_receipt.sh [out-dir] (default: evidence/PROGRAM_ID) 21 # 22 # Runs, on the committed tree only: 23 # - make test-program-id (5 gates, physics-free) 24 # - make test-visor-core, test-visor-world, test-visor-authority (pinned Aienux lib) 25 # - the Visor V1 qualification campaign (tests/visor/qualification/run_qualification.sh, 26 # plain shell) against a freshly built physics-free `omega` 27 # - program consumers: omegatool M8 M9 M10 M11 M14 gate suites and test-crumbline 28 # - the non-energy host regression suites CI runs: test-effect-cap64, test (M4 omegatool), 29 # r3 r7 r8 r9 r10 r11 r12 action-graph state-projection capability-query typed-results 30 # - a grep that no runtime (MetaSkill / plan cache / action graph) code consumes program_id 31 # Every make is wrapped in `flock $BENCH_LOCK`. Nothing under evidence/ is rewritten: 32 # the receipt is a NEW file named by the SHA-256 of its own bytes. It says FAIL (and why) 33 # when any suite fails, the tree is dirty or changes during the run, or a pin mismatches. 34 # Shell and coreutils only (git, sha256sum, grep, sed, awk, tar, make). No Python. 35 set -u 36 37 HERE=$(cd "$(dirname "$0")/.." && pwd) 38 cd "$HERE" || exit 2 39 OUTDIR=${1:-evidence/PROGRAM_ID} 40 AIENOS_REPO=${AIENOS_REPO:-$HOME/workspace/aienos-repo} 41 PHYSICS_DIR=${PHYSICS_DIR:-$HOME/workspace/physics-r13} 42 BENCH_LOCK=${BENCH_LOCK:-$HOME/workspace/.argus-bench.lock} 43 Q=build/pidq 44 LOGS=$Q/logs 45 REASONS=() 46 47 head0=$(git rev-parse HEAD) 48 tree0=$(git rev-parse 'HEAD^{tree}') 49 dirty0=$(git status --porcelain) 50 [ -z "$dirty0" ] || REASONS+=("tree dirty at start") 51 run_id=$(date -u +%Y%m%dT%H%M%SZ) 52 53 rm -rf "$Q" && mkdir -p "$LOGS" "$Q/aienos" 54 55 # ---- pins ------------------------------------------------------------------- 56 aienos_pin=$(awk 'NF && $1 !~ /^#/ {print $1; exit}' aienos.lock) 57 physics_pin=$(awk 'NF && $1 !~ /^#/ {print $1; exit}' physics.lock) 58 physics_head=$(git -C "$PHYSICS_DIR" rev-parse HEAD 2>/dev/null || echo missing) 59 [ "$physics_head" = "$physics_pin" ] || REASONS+=("physics checkout $physics_head != physics.lock $physics_pin") 60 61 aienos_src_tree=$(git -C "$AIENOS_REPO" rev-parse "$aienos_pin:native/capability" 2>/dev/null || echo missing) 62 if git -C "$AIENOS_REPO" archive "$aienos_pin" native/capability | tar -x -C "$Q/aienos" && 63 flock "$BENCH_LOCK" make -C "$Q/aienos/native/capability" > "$LOGS/aienos-lib.log" 2>&1; then 64 lib_ok=1 65 else 66 lib_ok=0 67 REASONS+=("AIENOS capability library did not build from $aienos_pin") 68 fi 69 LIB=$Q/aienos/native/capability/out/libaienos_capability.a 70 lib_sha=$( [ -f "$LIB" ] && sha256sum "$LIB" | awk '{print $1}' || echo null) 71 72 # ---- suites ----------------------------------------------------------------- 73 SUITES_JSON="" 74 declare -A RC RUN FAILED 75 76 counts() { # -> "run failed source" 77 local log=$1 r 78 r=$(awk '/^(PASS|FAIL) [0-9]+\/[0-9]+ *$/ { split($2, x, "/"); r += x[2]; f += x[2] - x[1]; n++ } 79 /TOTAL GATES: *[0-9]+ *\| *PASSED: *[0-9]+ *\| *FAILED: *[0-9]+/ { 80 match($0, /TOTAL GATES: *[0-9]+/); t = substr($0, RSTART, RLENGTH); gsub(/[^0-9]/, "", t) 81 match($0, /FAILED: *[0-9]+/); u = substr($0, RSTART, RLENGTH); gsub(/[^0-9]/, "", u) 82 r += t; f += u; n++ } 83 /^CRUMBLINE_CONFORMANCE pass=[0-9]+ fail=[0-9]+/ { 84 split($2, p, "="); split($3, q, "="); r += p[2] + q[2]; f += q[2]; n++ } 85 /^QUAL_SECTION [a-z]+ run=[0-9]+ failed=[0-9]+/ { 86 split($3, p, "="); split($4, q, "="); r += p[2]; f += q[2]; n++ } 87 END { if (n) printf "%d %d\n", r, f }' "$log") 88 if [ -n "$r" ]; then echo "$r output"; return; fi 89 local rcpt 90 rcpt=$(grep -oE 'receipt: [^ ]+\.json' "$log" | tail -n 1 | awk '{print $2}') 91 if [ -n "$rcpt" ] && [ -f "$rcpt" ]; then 92 local line c f 93 line=$(grep -m1 '^ "totals":' "$rcpt") 94 if [ -n "$line" ]; then 95 c=$(printf '%s' "$line" | grep -oE '"checks": [0-9]+' | grep -oE '[0-9]+') 96 f=$(printf '%s' "$line" | grep -oE '"failures": [0-9]+' | grep -oE '[0-9]+') 97 else 98 c=$(grep -m1 -E '^ "checks": [0-9]+' "$rcpt" | grep -oE '[0-9]+') 99 f=$(grep -m1 -E '^ "failures": [0-9]+' "$rcpt" | grep -oE '[0-9]+') 100 fi 101 if [ -n "$c" ] && [ -n "$f" ]; then echo "$c $f receipt:$rcpt"; return; fi 102 fi 103 echo "0 0 exit-status-only" 104 } 105 106 record() { # record 107 local name=$1 rc=$2 log=$3 n f src 108 read -r n f src < <(counts "$log") 109 RC[$name]=$rc 110 RUN[$name]=$n 111 FAILED[$name]=$f 112 local status=FAIL 113 [ "$rc" -eq 0 ] && [ "$f" -eq 0 ] && status=PASS 114 [ "$status" = PASS ] || REASONS+=("$name $status (rc=$rc, $f of $n failed)") 115 SUITES_JSON+="${SUITES_JSON:+,} 116 {\"target\": \"$name\", \"rc\": $rc, \"tests_run\": $n, \"tests_failed\": $f, \"count_source\": \"$src\", \"status\": \"$status\", \"log_sha256\": \"$(sha256sum "$log" | awk '{print $1}')\"}" 117 echo "suite $name: $status (rc=$rc run=$n failed=$f)" >&2 118 } 119 120 suite() { # suite 121 local name=$1 out=$2 122 shift 2 123 local log=$LOGS/$name.log 124 flock "$BENCH_LOCK" env OMEGA_CANDIDATE_COMMIT="$head0" AIENOS_COMMIT="$aienos_pin" \ 125 PHYSICS_COMMIT="$physics_pin" make OUT_DIR="$out" "$@" "$name" > "$log" 2>&1 126 record "$name" $? "$log" 127 } 128 129 PF=(PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 AIENOS_R7_DIR="$Q/aienos") 130 RT=(PHYSICS_DIR="$PHYSICS_DIR" AIENOS_R7_DIR="$Q/aienos" VISOR_AUTH_CAP_LIB="$LIB") 131 132 suite test-program-id "$Q/pf" "${PF[@]}" 133 suite test-visor-core "$Q/pf" "${PF[@]}" 134 suite test-visor-world "$Q/pf" "${RT[@]}" 135 suite test-visor-authority "$Q/pf" "${RT[@]}" 136 137 # Visor V1 qualification campaign (shell), physics-free omega binary. 138 qlog=$LOGS/visor-qualification.log 139 { flock "$BENCH_LOCK" make OUT_DIR="$Q/q8" PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 "$Q/q8/omega" && 140 flock "$BENCH_LOCK" env QUAL_WORK="$Q/q8/qual-work" tests/visor/qualification/run_qualification.sh "$Q/q8/omega"; } \ 141 > "$qlog" 2>&1 142 record visor-qualification $? "$qlog" 143 144 CONSUMERS=(test-m8 test-m9 test-m10 test-m11 test-m14 test-crumbline) 145 for t in "${CONSUMERS[@]}"; do suite "$t" "$Q/reg" "${RT[@]}"; done 146 147 REGRESSION=(test-effect-cap64 test test-r3 test-r7 test-r8 test-r9 test-r10 test-r11 test-r12 test-action-graph 148 test-state-projection test-capability-query test-typed-results) 149 suite test-effect-cap64 "$Q/pf" "${PF[@]}" 150 for t in "${REGRESSION[@]:1}"; do suite "$t" "$Q/reg" "${RT[@]}"; done 151 152 # ---- consumer grep ---------------------------------------------------------- 153 # MetaSkills (rx_fusion), the plan cache (rx_plan*) and action graphs identify by graph 154 # digest. If any runtime file starts consuming program_id, this receipt must be revisited. 155 rt_hits=$(grep -rn 'program_id' src/runtime --include='*.c' --include='*.h' || true) 156 rt_n=$(printf '%s' "$rt_hits" | grep -c . || true) 157 [ "$rt_n" -eq 0 ] || REASONS+=("runtime consumes program_id: $rt_n hit(s); extend the library gate") 158 159 # ---- gates ------------------------------------------------------------------ 160 pid_log=$LOGS/test-program-id.log 161 gate_line() { # -> "STATUS passed total" 162 local line 163 line=$(grep -E "^GATE $1 (PASS|FAIL) [0-9]+/[0-9]+$" "$pid_log" | tail -n 1) 164 [ -n "$line" ] || { echo "NOT_RUN 0 0"; return; } 165 local st=${line#GATE $1 } 166 local status=${st%% *} frac=${st#* } 167 echo "$status ${frac%/*} ${frac#*/}" 168 } 169 GATES_JSON="" 170 all_pass=1 171 add_gate() { # add_gate 172 GATES_JSON+="${GATES_JSON:+,} 173 \"$1\": {\"status\": \"$2\", \"tests_run\": $3, \"tests_failed\": $4, \"sources\": \"$5\"}" 174 [ "$2" = PASS ] || { all_pass=0; REASONS+=("$1 $2"); } 175 } 176 combine() { # combine : test gate + suites; echoes "status run failed" 177 local g=$1; shift 178 local st p t run fail 179 read -r st p t < <(gate_line "$g") 180 [ "${RC[test-program-id]}" -eq 0 ] || st=FAIL 181 run=$t; fail=$((t - p)) 182 for s in "$@"; do 183 run=$((run + RUN[$s])); fail=$((fail + FAILED[$s])) 184 { [ "${RC[$s]}" -eq 0 ] && [ "${FAILED[$s]}" -eq 0 ] && [ "${RUN[$s]}" -gt 0 ]; } || 185 { st=FAIL; [ "${FAILED[$s]}" -eq 0 ] && fail=$((fail + 1)); } 186 done 187 echo "$st $run $fail" 188 } 189 qual_case() { # qual_case -> 1 if that qualification case passed 190 grep -F "QUAL semantic $1" "$qlog" | grep -q ' PASS' && echo 1 || echo 0 191 } 192 193 read -r st r f < <(combine OMEGA_PROGRAM_ID_BODY_BOUND_PASS) 194 bb=$(qual_case 'program-id[body-bound: x+1 != x+2 after clear]') 195 r=$((r + 1)); [ "$bb" -eq 1 ] || { st=FAIL; f=$((f + 1)); } 196 add_gate OMEGA_PROGRAM_ID_BODY_BOUND_PASS "$st" "$r" "$f" \ 197 "make test-program-id (gate BODY_BOUND) + Visor qualification case program-id[body-bound: x+1 != x+2 after clear]" 198 199 read -r st r f < <(combine OMEGA_PROGRAM_ID_REPRESENTATION_INVARIANT_PASS) 200 pn=$(qual_case 'program-id[param name + commutative side]') 201 r=$((r + 1)); [ "$pn" -eq 1 ] || { st=FAIL; f=$((f + 1)); } 202 add_gate OMEGA_PROGRAM_ID_REPRESENTATION_INVARIANT_PASS "$st" "$r" "$f" \ 203 "make test-program-id (gate REPRESENTATION_INVARIANT, incl. seeded associativity: 400 chains x 4 bracketings == left fold, 400 a;b != b;a) + Visor qualification case program-id[param name + commutative side]" 204 205 read -r st r f < <(combine OMEGA_PROGRAM_ID_MUTATION_SEPARATION_PASS) 206 add_gate OMEGA_PROGRAM_ID_MUTATION_SEPARATION_PASS "$st" "$r" "$f" \ 207 "make test-program-id (gate MUTATION_SEPARATION: 3000-program seeded differential, all pairs, hash-free oracle; 2000 x 8 single mutations)" 208 209 read -r st r f < <(combine OMEGA_PROGRAM_ID_LIBRARY_REGRESSION_PASS "${CONSUMERS[@]}") 210 r=$((r + 1)); [ "$rt_n" -eq 0 ] || { st=FAIL; f=$((f + 1)); } 211 add_gate OMEGA_PROGRAM_ID_LIBRARY_REGRESSION_PASS "$st" "$r" "$f" \ 212 "make test-program-id (gate LIBRARY_REGRESSION) + make ${CONSUMERS[*]} + runtime program_id consumer grep" 213 214 read -r st r f < <(combine OMEGA_PROGRAM_ID_VISOR_REGRESSION_PASS test-visor-core test-visor-world test-visor-authority visor-qualification) 215 add_gate OMEGA_PROGRAM_ID_VISOR_REGRESSION_PASS "$st" "$r" "$f" \ 216 "make test-program-id (gate VISOR_REGRESSION) + make test-visor-core test-visor-world test-visor-authority + run_qualification.sh (all sections)" 217 218 # Host regression (not a named gate; required for the verdict). 219 r_run=0; r_fail=0; r_st=PASS 220 for t in "${REGRESSION[@]}"; do 221 r_run=$((r_run + RUN[$t])); r_fail=$((r_fail + FAILED[$t])) 222 { [ "${RC[$t]}" -eq 0 ] && [ "${FAILED[$t]}" -eq 0 ]; } || { r_st=FAIL; [ "${FAILED[$t]}" -eq 0 ] && r_fail=$((r_fail + 1)); } 223 done 224 [ "$r_st" = PASS ] || { all_pass=0; REASONS+=("host regression FAIL"); } 225 226 # ---- tree stability --------------------------------------------------------- 227 head1=$(git rev-parse HEAD) 228 dirty1=$(git status --porcelain) 229 stable=true 230 { [ "$head1" = "$head0" ] && [ "$dirty1" = "$dirty0" ]; } || { stable=false; REASONS+=("tree changed during the run"); } 231 tree_dirty=false; [ -z "$dirty0" ] || tree_dirty=true 232 verdict=OMEGA_PROGRAM_ID_PASS 233 { [ "$all_pass" -eq 1 ] && [ "$stable" = true ] && [ "$tree_dirty" = false ] && [ "$lib_ok" -eq 1 ] && 234 [ "$physics_head" = "$physics_pin" ]; } || verdict=OMEGA_PROGRAM_ID_FAIL 235 236 json_str() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' | awk 'BEGIN{ORS=""} {if (NR>1) print "\\n"; print}'; } 237 reasons_json="" 238 for r in "${REASONS[@]}"; do reasons_json+="${reasons_json:+, }\"$(json_str "$r")\""; done 239 240 body=$(cat </dev/null)")"}, 251 "hardware_scope": "host-only (CPU); no GPU, no silicon, no energy measurement", 252 "aienos": {"lock": "$aienos_pin", "source": "git archive $aienos_pin native/capability (tree $aienos_src_tree)", "lib_sha256": "$lib_sha", "lib_built": $([ "$lib_ok" -eq 1 ] && echo true || echo false)}, 253 "physics": {"lock": "$physics_pin", "checkout_head": "$physics_head"}, 254 "gates": {$GATES_JSON 255 }, 256 "host_regression": {"status": "$r_st", "tests_run": $r_run, "tests_failed": $r_fail, "targets": "${REGRESSION[*]}"}, 257 "suites": [$SUITES_JSON 258 ], 259 "runtime_program_id_consumers": {"hits": $rt_n, "detail": "$(json_str "$rt_hits")"}, 260 "not_run": [ 261 "GPU / silicon targets (test-m12, test-m15, test-m17, test-m18, test-m19, r12 silicon seat, r13/r14 living runs, R15)", 262 "suites CI runs that read the package energy counter (test-semantic-comm, test-cognitive-routing, test-sem-incremental, test-workflow-fusion, test-plan-reuse): not run here (no energy measurements); MetaSkill and plan-cache code does not consume program_id (grep above); CI runs them" 263 ], 264 "non_claims": [ 265 "Identity is intensional (canonical body), not extensional: x+1+1 and x+2 compute the same function and have different ids.", 266 "Composition postconditions are the flattened ordered leaf list (spec 2.4): associative by construction; leaf clauses are still identified by canonical text, not logical meaning.", 267 "Historical receipts under evidence/ carry v1 program ids and are not rewritten.", 268 "The body model is the V0 unary step chain (five ops, one constant each, <= 64 steps)." 269 ], 270 "verdict": "$verdict", 271 "verdict_reasons": [$reasons_json] 272 } 273 EOF 274 ) 275 mkdir -p "$OUTDIR" 276 tmp=$(mktemp "$OUTDIR/.tmp-XXXXXX") 277 printf '%s\n' "$body" > "$tmp" 278 digest=$(sha256sum "$tmp" | awk '{print $1}') 279 final=$OUTDIR/$digest.json 280 if [ -e "$final" ]; then rm -f "$tmp"; else mv "$tmp" "$final"; fi 281 chmod 0644 "$final" 282 grep -E '"OMEGA_PROGRAM_ID_[A-Z_]+_PASS"' "$final" | sed 's/^ *//' 283 echo "RECEIPT $final" 284 echo "VERDICT $verdict" 285 [ "$verdict" = OMEGA_PROGRAM_ID_PASS ]