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 / seed / check / receipt.sh
| 1 | #!/bin/sh |
| 2 | # receipt.sh OUT REC [FILE...] -- compare a gate run's results (OUT, under build/) with the recorded receipt |
| 3 | # (REC, under evidence/). REC is only read: a rerun never writes a recorded receipt (evidence/ is additions |
| 4 | # only, OMEGA-EVIDENCE-IMMUTABLE). Each file in OUT whose name REC also holds is compared byte for byte, |
| 5 | # except *.log (a log carries the run's date and commit). Each FILE, a recorded copy kept outside REC |
| 6 | # (seed/rung4/om4.audit), is compared with OUT/<its name>. Prints one line. Exit 0: all the same; |
| 7 | # 1: some differ; 2: no receipt (REC empty or missing), nothing compared. |
| 8 | set -eu |
| 9 | out=$1; rec=$2; shift 2 |
| 10 | if [ -z "$rec" ] || [ ! -d "$rec" ]; then echo "receipt ${rec:-(none)}: none recorded, nothing compared"; exit 2; fi |
| 11 | n=0; d="" |
| 12 | for f in "$out"/*; do |
| 13 | b=${f##*/} |
| 14 | case $b in *.log) continue ;; esac |
| 15 | [ -f "$f" ] && [ -f "$rec/$b" ] || continue |
| 16 | n=$((n + 1)); cmp -s "$f" "$rec/$b" || d="$d $b" |
| 17 | done |
| 18 | for r in "$@"; do |
| 19 | n=$((n + 1)); cmp -s "$out/${r##*/}" "$r" || d="$d $r" |
| 20 | done |
| 21 | if [ -z "$d" ]; then echo "receipt $rec: $n files compared, all the same (not rewritten)"; exit 0; fi |
| 22 | echo "receipt $rec: $n files compared, differ (not rewritten):$d"; exit 1 |