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/gen/abstract/verify # 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 / gen / abstract / verify` 103 lines ยท 6770 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # tools/gen/abstract/verify [--root ] [--receipts ] ... 3 # 4 # GEN-3 (aien-spark/omega#478): re-derives each record from the pinned corpus and prints `VERIFIED ` or 5 # `BLOCKED ` per record (exit 0 when all are verified, 1 otherwise; 2 on a usage or tool error). 6 # Receipts are read from --receipts, else from receipts/ next to the record's raw/ or abstraction/ directory. 7 # The first failing check is the reason: 8 # 1 recheck --root --receipts: the schema, every source digest, the receipt file exists and hashes to its id 9 # 2 the record says `validity verified` 10 # raw: the task exists, split and family agree with PROBES and META, params/ret/desc/body are the task's own, 11 # then the reader chain, x445 check, the harness runner on the task's public tests, and the harness runner 12 # against the C oracle (corpus/oracle.c) on generated inputs 13 # abstraction: the body passes the reader chain (invalid IR), its canonical fingerprint is the stated one, 14 # every ancestry task is an extraction task with that solution digest and contains this helper, the 15 # helper occurs in >= 2 of them (single source), it equals no whole corpus solution, the differs lines 16 # and families are the recomputed ones, desc/pre/post/example/limits/counters are the spec file's, and the 17 # property, example and counterexample checks pass 18 # last the receipt is rebuilt from the checks just run and must equal the receipt file byte for byte (a 19 # receipt that hashes to its name but was not produced by these checks is a fake) 20 set -euo pipefail 21 HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 22 . "$HERE/genabs.sh" 23 ROOT="$(cd "$HERE/../../.." && pwd)" 24 RDOPT="" 25 while [ $# -gt 0 ]; do 26 case "$1" in 27 --root) ROOT="$(cd "$2" && pwd)"; shift 2 ;; 28 --receipts) RDOPT="$(cd "$2" && pwd)"; shift 2 ;; 29 *) break ;; 30 esac 31 done 32 [ $# -ge 2 ] || { echo "usage: verify [--root ] [--receipts ] ..." >&2; exit 2; } 33 B="$(cd "$1" && pwd)"; shift 34 W="$(mktemp -d "${TMPDIR:-/tmp}/gen-verify.XXXXXXXX")" 35 trap 'rm -rf "$W"' EXIT 36 ga_init "$B" "$ROOT" "$W" || exit 2 37 CR="$ROOT/$GA_CORPUS" 38 ga_scan || { echo "verify: corpus scan failed" >&2; exit 2; } 39 declare -A SPLIT SOLSHA SOLFP 40 while read -r _ t split ssha sfp; do SPLIT[$t]="$split" SOLSHA[$t]="$ssha" SOLFP[$t]="$sfp"; done < <(grep '^S ' "$W/scan") 41 42 # verify_one : runs in a subshell; `blocked` ends only that record 43 verify_one() { 44 REC="$1" 45 [ -f "$REC" ] || { echo "BLOCKED ? no record file $REC"; exit 1; } 46 RD="${RDOPT:-$(cd "$(dirname "$REC")/.." && pwd)/receipts}" 47 ID="$(sed -n '2s/^id //p' "$REC")"; [ -n "$ID" ] || ID="?" 48 blocked() { echo "BLOCKED $ID $*"; exit 1; } 49 50 # 1. format, sources, receipt file 51 out="$("$B/gen_abstract/recheck" --root "$ROOT" --receipts "$RD" "$REC" 2>&1)" || blocked "recheck: ${out#REFUSED }" 52 53 hdr() { sed '/^body$/q' "$REC" | sed -n "s/^$1 //p"; } 54 sed '1,/^body$/d' "$REC" > "$W/body.omegese" 55 KIND="$(hdr kind)" RCPT_ID="$(hdr receipt)" 56 [ "$(hdr validity)" = verified ] || blocked "validity is not 'verified' (genret indexes only verified records)" 57 58 if [ "$KIND" = raw ]; then 59 t="${ID#raw-}" d="$CR/tasks/${ID#raw-}" 60 [ -n "${SPLIT[$t]:-}" ] || blocked "no corpus task $t" 61 [ "$(hdr split)" = "${SPLIT[$t]}" ] || blocked "split is not the task's (PROBES says ${SPLIT[$t]})" 62 [ "$(hdr family)" = "$(ga_meta_token "$t")" ] || blocked "family is not the token of the task's META shape" 63 [ "$(sed -n '/^body$/q; /^params/p' "$REC")" = "$(sed -n '/^params/p' "$d/requirement")" ] || blocked "params differ from the task requirement" 64 [ "$(hdr ret)" = "$(sed -n 's/^ret //p' "$d/requirement")" ] || blocked "ret differs from the task requirement" 65 [ "$(hdr desc)" = "$(cat "$d/desc")" ] || blocked "desc differs from the task's desc file" 66 cmp -s "$W/body.omegese" "$d/solution.omegese" || blocked "body is not the task's solution" 67 ga_raw_checks "$ID" "$d" "$W/raw" || blocked "check failed: $GA_ERR" 68 else 69 ga_chain "$W/body.omegese" "$W/b" || blocked "invalid IR: $GA_ERR" 70 fp="$(ga_fp "$W/body.omegese" "$W/bfp")" || blocked "invalid IR: $GA_ERR" 71 [ "$fp" = "$(hdr fingerprint)" ] || blocked "fingerprint does not match the body (types or code changed)" 72 occ="$(grep '^H ' "$W/scan" | awk -v f="$fp" '$6 == f { print $2 }' | while read -r t; do if [ "${SPLIT[$t]}" = corpus ]; then echo "$t"; fi; done | sort -u)" 73 while read -r t s; do 74 [ "${SPLIT[$t]:-}" = corpus ] || blocked "ancestry task $t is not an extraction task (unknown or a probe)" 75 [ "$s" = "${SOLSHA[$t]}" ] || blocked "ancestry digest of $t is stale" 76 printf '%s\n' "$occ" | grep -qx "$t" || blocked "ancestry task $t does not contain this helper (single-source or forged ancestry)" 77 done < <(hdr ancestry) 78 [ "$(printf '%s\n' "$occ" | grep -c .)" -ge 2 ] || blocked "single-source helper: it occurs in fewer than 2 extraction tasks" 79 [ "$(hdr ancestry | cut -d' ' -f1)" = "$occ" ] || blocked "ancestry is not the set of extraction tasks that contain this helper" 80 same="$(grep '^S ' "$W/scan" | awk -v f="$fp" '$5 == f { print $2; exit }')" 81 [ -z "$same" ] || blocked "helper is identical to the whole corpus solution of $same" 82 [ "$(hdr differs)" = "$(grep '^S ' "$W/scan" | awk '{ print $2 " " $5 }')" ] || blocked "differs lines are not the recomputed corpus solution fingerprints" 83 [ "$(hdr family)" = "$(for t in $occ; do ga_meta_token "$t"; done | sort -u | paste -sd' ' -)" ] || blocked "family is not the set of ancestry META tokens" 84 name="$(hdr entry)" spec="$CR/specs/$(hdr entry).spec" 85 [ -f "$spec" ] || blocked "no spec file for $name" 86 for k in desc example limit counter; do 87 [ "$(hdr "$k")" = "$(sed -n "s/^$k //p" "$spec")" ] || blocked "$k lines differ from the spec file" 88 done 89 for k in pre post; do 90 [ "$(hdr "$k")" = "STATED+TESTED $(sed -n "s/^$k //p" "$spec")" ] || blocked "$k differs from the spec file" 91 done 92 # the checks run on the record's own stated lines 93 { hdr desc | sed 's/^/desc /'; hdr pre | sed 's/^STATED+TESTED /pre /'; hdr post | sed 's/^STATED+TESTED /post /' 94 hdr example | sed 's/^/example /'; hdr limit | sed 's/^/limit /'; hdr counter | sed 's/^/counter /'; } > "$W/stated" 95 ga_abs_checks "$ID" "$W/body.omegese" "$W/stated" "$W/abs" || blocked "functional check failed: $GA_ERR" 96 GA_RCPT+="$(grep '^H ' "$W/scan" | awk -v f="$fp" '$6 == f { print $2 " " $4 }' | while read -r t n; do if [ "${SPLIT[$t]}" = corpus ]; then echo "occurs $t $n"; fi; done | sort)"$'\n' 97 fi 98 printf '%s' "$GA_RCPT" | cmp -s - "$RD/$RCPT_ID" || blocked "receipt does not match the re-run checks (fake or stale receipt)" 99 echo "VERIFIED $ID" 100 } 101 rc=0 102 for r in "$@"; do ( verify_one "$r" ) || rc=1; done 103 exit "$rc"