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/tests/physics0/learner/test_pd0b_run.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 / tests / physics0 / learner / test_pd0b_run.sh` 69 lines ยท 4349 bytes Raw Blame History 1 #!/bin/sh 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 of pd0b_run.sh law-record retention and validity, with a fake harness in a throw-away git repo. 18 set -eu 19 SRC=$(pwd); T=$(mktemp -d); trap 'rm -rf "$T"' EXIT 20 fail=0; check() { if ! eval "$1"; then echo "FAIL: $1"; fail=1; fi; } 21 mkdir -p "$T/tests/physics0/learner" "$T/src/physics0/learner" "$T/src/physics0/ladder" "$T/src/physics0/score" "$T/src/physics0/controls" "$T/tests/physics0/verify" 22 cp tests/physics0/learner/pd0b_run.sh tests/physics0/learner/pd0b_freeze.sh "$T/tests/physics0/learner/" 23 for d in learner ladder score controls; do echo x > "$T/src/physics0/$d/f.c"; done; echo x > "$T/tests/physics0/verify/f.c" 24 cat > "$T/harness" <<'EOS' 25 #!/bin/sh 26 # fake harness: world - level seed outdir. FAKE=nolaw: REPLICATED but no law record; FAKE=reject: law file but verifier rejected 27 L=$3; S=$4; O=$5; [ "$L" = null ] || L=L$L; [ "$L" = nullL ] && L=null 28 st=REPLICATED; lrc=0 29 [ "${FAKE:-}" != nolaw ] || lrc=-1 30 [ "${FAKE:-}" != reject ] || lrc=3 31 if [ "$lrc" != -1 ]; then echo "law-bytes-$L-$S" > "$O/pd0l-$L-s$S.law"; fi 32 echo ledger > "$O/pd0l-$L-s$S.ledger" 33 echo "PD0L level=$L seed=$S state=$st code=0 law=$lrc score=PASS score_code=0" 34 echo "PD0F level=$L seed=$S final=00 final_status=0 score_before_final=0 shape_before_final=0 play_after_final=0 dup_final=0 audit_ok=1 mode=SEALED s_star=2 n_vars=2 n_latent=0 n_channels=1 valid=VALID" 35 EOS 36 chmod +x "$T/harness"; printf '#!/bin/sh\nexit 0\n' > "$T/world"; chmod +x "$T/world" 37 for s in 1 2 3 4 5; do echo "0 $s"; done > "$T/seeds.txt" 38 ( cd "$T" && git init -q && git add -A && git -c user.email=t@t -c user.name=t commit -q -m t ) 39 run() { ( cd "$T" && env PD0B_LEDGER_ARCHIVE="$T/archive" "$@" sh tests/physics0/learner/pd0b_run.sh ./harness ./world seeds.txt note ) > "$T/out.txt" 2>&1; } 40 # good run 41 run FAKE=none; rc=$?; R=$(ls "$T"/evidence/physics0/pd0b/PD0B_RUN-*.txt | head -1) 42 check "[ -f '$R' ]"; check "grep -q '^run_validity: VALID' '$R'" 43 check "grep -q '^validity_rule:.*law=1' '$R'" 44 D="${R%.txt}-laws"; check "[ -d '$D' ]" 45 check "[ -f '$D/pd0l-L0-s1.law' ] && [ ! -e '$D/pd0l-L0-s1.ledger' ]" 46 A="$T/archive/$(basename "${R%.txt}")-ledgers"; check "[ -f '$A/pd0l-L0-s1.ledger' ]" 47 nled=$(ls "$A" | wc -l); nman=$(wc -l < "$D/LEDGERS.sha256") 48 check "[ $nled -eq 5 ] && [ $nman -eq 5 ]" 49 check "(cd '$A' && sha256sum -c '$D/LEDGERS.sha256' >/dev/null)" 50 check "grep -q '^ledger_archive: $A\$' '$R'" 51 msha=$(sha256sum "$D/LEDGERS.sha256" | cut -d' ' -f1) 52 check "grep -q '^ledgers_manifest_sha256: $msha' '$R'" 53 sha=$(sha256sum "$D/pd0l-L0-s1.law" | cut -d' ' -f1) 54 check "grep -q '^level=L0 seed=1 state=REPLICATED code=0 score=PASS score_code=0 law=1 law_sha256=$sha\$' '$R'" 55 check "[ \$(grep -c ' law=1 law_sha256=' '$R') -eq 5 ]" 56 # the laws directory is never overwritten, nor the receipt 57 run FAKE=none && { echo "FAIL: second run succeeded"; fail=1; } || true 58 check "grep -q 'refusing to overwrite' '$T/out.txt'" 59 rm -rf "$T/evidence" "$T/archive" 60 # REPLICATED without a law record: INVALID, law=0, law_sha256=- 61 run FAKE=nolaw && { echo "FAIL: nolaw run succeeded"; fail=1; } || true 62 R=$(ls "$T"/evidence/physics0/pd0b/PD0B_RUN-*.txt | head -1) 63 check "grep -q '^run_validity: INVALID' '$R'"; check "grep -q 'seed=1 state=REPLICATED code=0 score=PASS score_code=0 law=0 law_sha256=-\$' '$R'" 64 rm -rf "$T/evidence" "$T/archive" 65 # law bytes present but the verifier rejected them: law=0, INVALID 66 run FAKE=reject && { echo "FAIL: reject run succeeded"; fail=1; } || true 67 R=$(ls "$T"/evidence/physics0/pd0b/PD0B_RUN-*.txt | head -1) 68 check "grep -q '^run_validity: INVALID' '$R'"; check "grep -q 'seed=2 state=REPLICATED.* law=0 law_sha256=-\$' '$R'" 69 [ "$fail" = 0 ] && echo "PD0B_RUN_TEST: PASS" || { echo "PD0B_RUN_TEST: FAIL"; exit 1; }