interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tests / turing / test_tc_eval_dry.sh

104 lines · 6707 bytes Raw Blame History
1#!/usr/bin/env 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# EXP-001 evaluator dry run on DEVELOPMENT data (not evidence): group 1 = dev seed 7, group 2 = dev seed 6,
18# all seven candidates. The run root OUT has the sealed-run layout of calibration/docs/DATA_FORMAT.md section 4
19# (candidate_manifest.json, dataset_manifest.json, bundle/, work/, run with cwd = OUT). Order: run, then the
20# independent scorer (tools/turing_verify_indep, reads only the published docs, the bundle and the CTR1 files),
21# then the gate with the independent scorer's output. Requires verdict PASS with S8 PASS, M_candidate T > 0,
22# both memorizers T < 0. Writes only under OUT (never calibration/experiments/EXP-001).
23# test_tc_eval_dry.sh BIN OUTDIR DEV_RUN_DIR BIG_CANDIDATE_DIR [INDEP_BIN]
24# Experiment: env EXP_ID = EXP-001 (default, Turing-profile-v1.0) or EXP-001R (Turing-profile-v1.1), the same variable
25# the calibration scripts, the evaluator and the independent scorer read. EXP-001R has no committed candidate
26# manifest before its freeze, so the dry run derives one from the EXP-001 manifest (same seven candidates, this
27# experiment id and profile digest) inside OUT only.
28set -euo pipefail
29REPO="$(pwd)"
30BIN="$(realpath "$1")" OUT="$2" DATA="$(realpath "$3")" BIG="$(realpath "$4")"
31IND="$(realpath "${5:-build/turing-verify-indep/indep-scorer}")"
32die() { echo "eval dry run: FAIL: $*" >&2; exit 1; }
33[ ! -e "$HOME/workspace/.spark-quiet" ] || die ".spark-quiet is set"
34. calibration/scripts/tc_exp.sh
35before="$(git status --porcelain -- calibration/experiments/EXP-001 calibration/experiments/EXP-001R)"
36rm -rf "$OUT"
37mkdir -p "$OUT/docs/profiles"
38OUT="$(realpath "$OUT")"
39SRCMAN="$REPO/calibration/experiments/EXP-001/candidate_manifest.json"
40P="$(cut -c1-64 "$REPO/$EXP_SIDECAR")"
41SRC2="$OUT/candidate_manifest_id.json"
42if [ "$EXP_ID" = EXP-001 ]; then cp "$SRCMAN" "$SRC2"; else
43 sed -e "s/\"experiment\": \"EXP-001\"/\"experiment\": \"$EXP_ID\"/" -e "s|Turing-profile-v1.0|$EXP_PROFILE_ID|g" \
44 -e "s/\"profile_sha256\": \"[0-9a-f]*\"/\"profile_sha256\": \"$P\"/" -e "s/\"profile_sidecar_sha256\": \"[0-9a-f]*\"/\"profile_sidecar_sha256\": \"$P\"/" "$SRCMAN" >"$SRC2"
45fi
46# The frozen EXP-001 manifest pins the exact bytes of every shared-background file, including the evaluator source
47# and the protocol docs, so it cannot be used unchanged once any of them is revised. A dry run is not evidence:
48# its manifest is a copy in OUT with the shared-background hashes recomputed from the current tree.
49MAN="$OUT/candidate_manifest_src.json"
50sect=0
51while IFS= read -r line; do
52 case "$line" in
53 *'"shared_background_sha256": {'*) sect=1 ;;
54 *'}'*) sect=0 ;;
55 *) if [ $sect = 1 ]; then
56 key="${line#*\"}"; key="${key%%\"*}"; com=""; case "$line" in *,) com="," ;; esac
57 line="$(printf ' "%s": "%s"%s' "$key" "$(sha256sum "$REPO/$key" | cut -c1-64)" "$com")"
58 fi ;;
59 esac
60 printf '%s\n' "$line"
61done <"$SRC2" >"$MAN"
62SMALL="$REPO/calibration/experiments/EXP-001/candidates"
63cp "$MAN" "$OUT/candidate_manifest.json"
64# The docs directory: what a docs-only reader has (the published profile and candidate manifest).
65cp "$REPO/$EXP_PROFILE" "$OUT/docs/profiles/"
66cp "$MAN" "$OUT/docs/candidate_manifest.json"
67bash calibration/scripts/make_dataset_manifest.sh --dev "$DATA" "7" "6" "$P" "$OUT/dataset_manifest.json"
68cd "$OUT"
69/usr/bin/time -v "$BIN" run --dry-run --repo "$REPO" --manifest "$MAN" --cand-dir "$SMALL" --cand-dir "$BIG" \
70 --dataset dataset_manifest.json --out bundle --work work 2>run.stderr || { cat run.stderr; die "run refused"; }
71grep -E 'Elapsed|Maximum resident' run.stderr
72/usr/bin/time -v "$IND" --docs docs --bundle-root . --cand-dir "$SMALL" --cand-dir "$BIG" \
73 --out scorer_independent.json --details indep_details.json 2>indep.stderr || { tail -20 indep.stderr; die "independent scorer failed"; }
74grep -E 'Elapsed|Maximum resident' indep.stderr
75cp scorer_independent.json bundle/scorer_independent.json
76"$BIN" gate --dry-run --bundle bundle --independent bundle/scorer_independent.json
77grep -q '"S8": "PASS"' bundle/final_receipt.json || die "S8 not PASS: the independent scorer disagrees (see indep_details.json)"
78grep -q '"verdict": "PASS"' bundle/final_receipt.json || die "verdict rule not PASS: $(grep -o '"criteria": {[^}]*}' bundle/final_receipt.json)"
79val() { sed -n "s/.*\"key\": \"$1\", \"value\": \(-\{0,1\}[0-9]*\)}.*/\1/p" bundle/scorer_primary.json; }
80for g in 1 2; do
81 for m in ideal range rans; do
82 v="$(val "g$g.M_candidate.T_${m}_vs_B2.lo_ub")"
83 [ -n "$v" ] && [ "$v" -gt 0 ] || die "g$g M_candidate T_$m lower bound $v not > 0"
84 for mem in M_mem M_mem_seed1; do
85 v="$(val "g$g.$mem.T_${m}_vs_B2.hi_ub")"
86 [ -n "$v" ] && [ "$v" -lt 0 ] || die "g$g $mem T_$m upper bound $v not < 0"
87 done
88 done
89done
90grep -q '"dry_run": true' scorer_independent.json || die "independent scorer did not report dry_run true on development data"
91# The independent scorer takes dry_run from the dataset manifest split: a sealed_test split must give false.
92mkdir -p sealedchk
93sed 's/"split": "development"/"split": "sealed_test"/' dataset_manifest.json >sealedchk/dataset_manifest.json
94cp candidate_manifest.json sealedchk/
95ln -sfn "$OUT/bundle" sealedchk/bundle; ln -sfn "$OUT/work" sealedchk/work; ln -sfn "$OUT/docs" sealedchk/docs
96(cd sealedchk && "$IND" --docs docs --bundle-root . --cand-dir "$SMALL" --cand-dir "$BIG" \
97 --out s.json --details d.json 2>e.txt) || { tail -5 sealedchk/e.txt; die "independent scorer failed on the sealed_test split copy"; }
98grep -q '"dry_run": false' sealedchk/s.json || die "independent scorer did not report dry_run false for split sealed_test"
99rm -rf sealedchk
100cd "$REPO"
101[ "$(git status --porcelain -- calibration/experiments/EXP-001 calibration/experiments/EXP-001R)" = "$before" ] || die "the dry run changed calibration/experiments"
102du -sh "$OUT/work" | sed 's/^/work dir size: /'
103rm -rf "$OUT/work"
104echo "eval dry run ($EXP_ID): PASS (verdict rule PASS, S8 PASS from the independent scorer, M_candidate T > 0, memorizers T < 0)"