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/patches/a088ac2932ee06f9 # 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 ## GitHub aien-dev/omega-mv#235 (code only) closed derived `a088ac2932ee06f9` #235 Imported from GitHub aien-dev/omega-mv#235 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `4225ee1aeca79bc537637f4cd0ea5af41ebcddc8` · Head `eb31554057bcecfade586a56ee269cee4f3c613a` ### Apply it ``` git checkout -b patch-a088ac2932ee06f9 4225ee1aeca79bc537637f4cd0ea5af41ebcddc8 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/a088ac2932ee06f9.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/omega-mv 235 eb31554057bcecfade586a56ee269cee4f3c613a ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":235,"url":"https://github.com/aien-dev/omega-mv/pull/235","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:54Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.gitignore b/.gitignore index 8f2b6ccbe..fd0ce970e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/ build/qual-runs/ +/qual-runs/ *.o .claude/ /omega diff --git a/tools/m19r_campaign.sh b/tools/m19r_campaign.sh new file mode 100755 index 000000000..fbf1c9e1d --- /dev/null +++ b/tools/m19r_campaign.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# m19r_campaign.sh -- mechanical verdict for a multi-run M19R qualification +# campaign. +# +# tools/m19r_campaign.sh --campaign-dir D --runs N +# +# D holds one run directory per qualification run (each written by +# tools/m19r_qualify.sh --evidence-root D). Writes D/campaign.json at first +# use (sha, rule, created_at) and prints + writes D/final-verdict.json. +# +# Rule, evaluated in this order: +# INVALID any run directory lacks run.json or verdict.json, lacks +# hashes.sha256, or fails `sha256sum -c hashes.sha256` +# (also: extra files not covered by hashes are NOT detected, +# only altered or missing hashed files). +# FAIL any run whose status is not PASS (a failed mandatory gate or +# step; QUICK_PASS is not a full PASS). +# INCOMPLETE fewer than N usable (verified) run directories. +# PASS at least N usable runs, all with status PASS. +# Exit 0 only on PASS; 1 on any other verdict; 2 on bad arguments. +# Shell + coreutils + git + jq. No Python. + +campaign_rule='PASS = N completed runs all status PASS; FAIL = any completed run not PASS; INCOMPLETE = fewer than N usable run dirs; INVALID = any run dir missing run.json/verdict.json/hashes.sha256 or failing sha256sum -c (checked first)' + +campaign_main() { + local dir= n= d id status invalid=() failed=() usable=0 verdict here sha + while [ $# -gt 0 ]; do + case $1 in + --campaign-dir) dir=${2:-}; shift;; + --campaign-dir=*) dir=${1#*=};; + --runs) n=${2:-}; shift;; + --runs=*) n=${1#*=};; + *) echo "usage: m19r_campaign.sh --campaign-dir D --runs N" >&2; return 2;; + esac + shift + done + if [ -z "$dir" ] || [ ! -d "$dir" ] || ! [[ ${n:-} =~ ^[1-9][0-9]*$ ]]; then + echo "usage: m19r_campaign.sh --campaign-dir D --runs N (D must exist, N >= 1)" >&2 + return 2 + fi + here=$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) + if [ ! -e "$dir/campaign.json" ]; then + sha=$(git -C "$here" rev-parse HEAD 2> /dev/null || echo unknown) + jq -n --arg sha "$sha" --arg rule "$campaign_rule" --argjson runs "$n" \ + --arg at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ + '{sha: $sha, rule: $rule, runs_required: $runs, created_at: $at}' > "$dir/campaign.json" + fi + for d in "$dir"/*/; do + [ -d "$d" ] || continue + id=$(basename "$d") + if [ ! -f "$d/run.json" ] || [ ! -f "$d/verdict.json" ] || [ ! -f "$d/hashes.sha256" ]; then + invalid+=("$id: missing run.json, verdict.json or hashes.sha256"); continue + fi + if ! (cd "$d" && sha256sum --quiet -c hashes.sha256 > /dev/null 2>&1); then + invalid+=("$id: hashes.sha256 does not verify"); continue + fi + status=$(jq -r '.status' "$d/verdict.json" 2> /dev/null) + if [ -z "$status" ] || [ "$status" = null ]; then + invalid+=("$id: verdict.json unreadable"); continue + fi + usable=$((usable + 1)) + [ "$status" = PASS ] || failed+=("$id: $status") + done + if [ ${#invalid[@]} -gt 0 ]; then verdict=INVALID + elif [ ${#failed[@]} -gt 0 ]; then verdict=FAIL + elif [ "$usable" -lt "$n" ]; then verdict=INCOMPLETE + else verdict=PASS; fi + jq -n --arg v "$verdict" --argjson n "$n" --argjson usable "$usable" \ + --argjson invalid "$(printf '%s\n' "${invalid[@]}" | jq -Rn '[inputs | select(length > 0)]')" \ + --argjson failed "$(printf '%s\n' "${failed[@]}" | jq -Rn '[inputs | select(length > 0)]')" \ + '{verdict: $v, runs_required: $n, usable_runs: $usable, invalid: $invalid, failed: $failed}' > "$dir/final-verdict.json" + cat "$dir/final-verdict.json" + [ "$verdict" = PASS ] +} + +campaign_main "$@" diff --git a/tools/m19r_qualify.sh b/tools/m19r_qualify.sh index 3300e778f..b047fc37e 100755 --- a/tools/m19r_qualify.sh +++ b/tools/m19r_qualify.sh @@ -18,7 +18,11 @@ # (passed, >= 100000 cycles, bytes churned > 2x physical memory, snapshots # start/end/post_destroy); candidates re-checked at the end. # -# Output: build/qual-runs//run.json always (plus per-command logs); +# Output: //run.json always (plus per-command logs, +# command.txt, environment.json, stdout.log, stderr.log, verdict.json and a +# final hashes.sha256); evidence root defaults to $OMEGA/qual-runs, outside +# build/ which `make clean` removes (--evidence-root DIR to change); the run +# directory must not exist yet (exit 2) and is never deleted by this script; # receipt-preview.json on a full run; with --record the permanent receipt # evidence/M19R/.json (created exclusively, mode 0444). # Exit 0 on PASS or QUICK_PASS, 1 on failure, 2 on bad arguments. @@ -383,7 +387,7 @@ m19r_locked_section() { } m19r_usage() { - echo "usage: $M19R_PROG [-h] --omega-candidate OMEGA_CANDIDATE --physics-candidate PHYSICS_CANDIDATE [--physics-dir PHYSICS_DIR] [--record] [--quick]" + echo "usage: $M19R_PROG [-h] --omega-candidate OMEGA_CANDIDATE --physics-candidate PHYSICS_CANDIDATE [--physics-dir PHYSICS_DIR] [--evidence-root DIR] [--run-id ID] [--record] [--quick]" } m19r_argerror() { @@ -392,8 +396,49 @@ m19r_argerror() { exit 2 } +# m19r_write_environment FILE -- who/where/what ran (environment.json). +m19r_write_environment() { + local pshal + pshal=$(git -C "$M19R_PHYSICS" rev-parse HEAD 2> /dev/null) || pshal=unknown + jq -n --arg host "$(hostname)" --arg date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ + --arg omega "$(git -C "$M19R_OMEGA" rev-parse HEAD 2> /dev/null || echo unknown)" \ + --arg physics "$pshal" --arg kernel "$(uname -r)" --arg user "$(id -un)" \ + '{hostname: $host, date_utc: $date, omega_sha: $omega, physics_sha: $physics, uname_r: $kernel, user: $user}' > "$1" +} + +# m19r_write_verdict RUN_DIR EXIT_CODE -- verdict.json from run.json and the +# suite logs. failing_step is run.json's error text; failing_gate_or_exit is +# the first observed FAIL gate (suite:id) in the logs, else "exit:" for +# a failed run, else null. +m19r_write_verdict() { + local dir=$1 code=$2 status step= gate= log name + status=$(jq -r '.status' "$dir/run.json" 2> /dev/null) || status= + [ -n "$status" ] || status=UNKNOWN + step=$(jq -r '.error // empty' "$dir/run.json" 2> /dev/null) + for log in "$dir"/*.log; do + name=$(basename "$log" .log) + case $name in stdout|stderr|build) continue;; esac + gate=$(m19r_events "$log" "$name" | awk -F'\t' '$3 == "FAIL" { print $1 ":" $2; exit }') + [ -z "$gate" ] || break + done + [ -n "$gate" ] || { [ "$code" -eq 0 ] || gate="exit:$code"; } + jq -n --arg id "$(basename "$dir")" --arg status "$status" --arg step "$step" \ + --arg gate "$gate" --argjson code "$code" \ + '{run_id: $id, status: $status, failing_step: (if $step == "" then null else $step end), + failing_gate_or_exit: (if $gate == "" then null else $gate end), exit_code: $code}' > "$dir/verdict.json" +} + +# m19r_seal RUN_DIR -- hashes.sha256 over every file except itself; files made +# read-only. +m19r_seal() { + (cd "$1" && find . -type f ! -name hashes.sha256 -print0 | LC_ALL=C sort -z | + xargs -0 sha256sum -- > hashes.sha256) || return 1 + find "$1" -type f -exec chmod a-w {} + +} + m19r_main() { - local physics_dir= missing=() run_json + local physics_dir= missing=() run_json evidence_root= run_id= argv + printf -v argv '%q ' "$M19R_PROG" "$@" M19R_OMEGA_CAND= M19R_PHYSICS_CAND= M19R_RECORD=0 M19R_QUICK=0 local have_o=0 have_p=0 while [ $# -gt 0 ]; do @@ -402,12 +447,16 @@ m19r_main() { --omega-candidate=*) M19R_OMEGA_CAND=${1#*=}; have_o=1;; --physics-candidate=*) M19R_PHYSICS_CAND=${1#*=}; have_p=1;; --physics-dir=*) physics_dir=${1#*=};; - --omega-candidate|--physics-candidate|--physics-dir) + --evidence-root=*) evidence_root=${1#*=};; + --run-id=*) run_id=${1#*=};; + --omega-candidate|--physics-candidate|--physics-dir|--evidence-root|--run-id) [ $# -ge 2 ] || m19r_argerror "argument $1: expected one argument" case $1 in --omega-candidate) M19R_OMEGA_CAND=$2; have_o=1;; --physics-candidate) M19R_PHYSICS_CAND=$2; have_p=1;; --physics-dir) physics_dir=$2;; + --evidence-root) evidence_root=$2;; + --run-id) run_id=$2;; esac shift;; --record) M19R_RECORD=1;; @@ -427,12 +476,38 @@ m19r_main() { fi M19R_PHYSICS=$(realpath -m "${physics_dir:-$(dirname "$M19R_OMEGA")/physics}") + # Evidence lives outside what `make clean` removes ($OUT_DIR, default build/). + evidence_root=$(realpath -m "${evidence_root:-$M19R_OMEGA/qual-runs}") + local out_dir + out_dir=$(realpath -m "$M19R_OMEGA/${OUT_DIR:-build}") + case $evidence_root/ in + "$out_dir"/*|"$M19R_OMEGA"/build/*) m19r_argerror "evidence root $evidence_root is inside the cleaned build directory";; + esac + case $out_dir/ in + "$evidence_root"/*) m19r_argerror "evidence root $evidence_root would be removed by make clean";; + esac + case $run_id in */*|.|..) m19r_argerror "invalid --run-id";; esac + m19r_build_canon || { echo "M19R qualification failed: cannot build tools/json_canon.c" >&2; exit 1; } trap 'rm -rf "$M19R_TMP"' EXIT - M19R_RUN_ID=$(date -u +%Y%m%dT%H%M%SZ)-$(od -An -N6 -tx1 /dev/urandom | tr -d ' \n') - M19R_RUN_DIR=$M19R_OMEGA/build/qual-runs/$M19R_RUN_ID - mkdir -p "$(dirname "$M19R_RUN_DIR")" && mkdir "$M19R_RUN_DIR" || exit 1 + M19R_RUN_ID=${run_id:-$(date -u +%Y%m%dT%H%M%SZ)-$(od -An -N6 -tx1 /dev/urandom | tr -d ' \n')} + M19R_RUN_DIR=$evidence_root/$M19R_RUN_ID + mkdir -p "$evidence_root" || exit 1 + if ! mkdir "$M19R_RUN_DIR" 2> /dev/null; then + echo "$M19R_PROG: error: run directory $M19R_RUN_DIR already exists or cannot be created; run directories are never reused" >&2 + exit 2 + fi + printf '%s\n' "$argv" > "$M19R_RUN_DIR/command.txt" + m19r_write_environment "$M19R_RUN_DIR/environment.json" || exit 1 + + # Whole-run stdout/stderr go to the console and to the run directory. + local p1 p2 + exec 3>&1 4>&2 + exec > >(tee "$M19R_RUN_DIR/stdout.log" >&3) + p1=$! + exec 2> >(tee "$M19R_RUN_DIR/stderr.log" >&4) + p2=$! R_STATUS=FAILED R_ERROR= R_PERMANENT= R_DIGEST= R_EVENTS= R_M19= R_SOAK= R_SAMPLES= local rc=0 @@ -444,7 +519,6 @@ m19r_main() { R_ERROR=$M19R_ERR echo "M19R qualification failed: $M19R_ERR" >&2 fi - mkdir -p "$M19R_RUN_DIR" run_json="{\"run_id\":$(m19r_jstr "$M19R_RUN_ID"),\"commands\":[],\"status\":\"$R_STATUS\"" [ "$rc" = 0 ] || run_json+=",\"error\":$(m19r_jstr "$R_ERROR")" [ -z "$R_PERMANENT" ] || run_json+=",\"permanent_receipt\":$(m19r_jstr "$R_PERMANENT")" @@ -456,6 +530,10 @@ m19r_main() { run_json+="}" printf '%s' "$run_json" | "$JSON_CANON" --pretty > "$M19R_RUN_DIR/run.json" || rc=1 echo "M19R run evidence: $M19R_RUN_DIR/run.json" + exec 1>&3 2>&4 3>&- 4>&- + wait "$p1" "$p2" 2> /dev/null + m19r_write_verdict "$M19R_RUN_DIR" "$rc" || rc=1 + m19r_seal "$M19R_RUN_DIR" || rc=1 exit "$rc" } diff --git a/tools/test_m19r_qualify.sh b/tools/test_m19r_qualify.sh index a421bd24c..eb3ed0426 100755 --- a/tools/test_m19r_qualify.sh +++ b/tools/test_m19r_qualify.sh @@ -105,6 +105,82 @@ name=$(basename "$rec" .json) check "recorded M19R receipt digest reproduced" '[ "$(jq "del(.receipt_digest)" "$rec" | "$JSON_CANON" --sha256)" = "$name" ]' check "recorded M19R receipt pretty form reproduced" '"$JSON_CANON" --pretty < "$rec" | cmp -s - "$rec"' +echo "evidence retention across runs (stubbed qualification, no hardware)" +check "make clean removes only the build directory" '[ "$(make --no-print-directory -C "$HERE" -n clean | tr -d "\n")" = "rm -rf build" ]' +fake=$TMP/fakeomega +mkdir -p "$fake/tools" "$fake/build" +ln -s "$HERE/src" "$fake/src"; cp "$HERE/tools/json_canon.c" "$fake/tools/" +printf "/qual-runs/\nsrc\n" > "$fake/.gitignore" +printf 'clean:\n\trm -rf build\n' > "$fake/Makefile" +git init -q "$fake" +fake_run() { # fake_run EXTRA_ARGS... ; runs m19r_main with a stubbed qualify + ( + M19R_OMEGA=$fake + m19r_qualify() { # like the real flow: make clean, then write evidence into the run dir + m19r_cmd "$M19R_OMEGA" - make clean || return 1 + mkdir -p "$M19R_OMEGA/build"; echo product > "$M19R_OMEGA/build/omegatool" + printf ' [PASS] GATE_A\n' > "$M19R_RUN_DIR/m19.log" + echo "stub stdout line"; echo "stub stderr line" >&2 + R_STATUS=$STUB_STATUS R_EVENTS='[]' R_M19='{}' + [ "$STUB_STATUS" = PASS ] || { m19r_fail "stub failure"; return 1; } + } + m19r_main --omega-candidate "$(printf 'a%.0s' {1..40})" --physics-candidate "$(printf 'b%.0s' {1..40})" \ + --physics-dir "$TMP/nophysics" "$@" + ) > "$TMP/fake.out" 2> "$TMP/fake.err" +} +STUB_STATUS=PASS fake_run --run-id run1; rc1=$? +r1=$fake/qual-runs/run1 +check "run 1 exits 0 and writes under /qual-runs (default root)" '[ "$rc1" = 0 ] && [ -f "$r1/run.json" ]' +check "run 1 has command, environment, logs, verdict, hashes" 'for f in command.txt environment.json stdout.log stderr.log verdict.json hashes.sha256 m19.log; do [ -f "$r1/$f" ] || exit 1; done' +check "stdout.log/stderr.log captured the run" 'grep -q "stub stdout line" "$r1/stdout.log" && grep -q "stub stderr line" "$r1/stderr.log"' +check "environment.json has the six fields" '[ "$(jq -r "[.hostname,.date_utc,.omega_sha,.physics_sha,.uname_r,.user] | map(length > 0) | all" "$r1/environment.json")" = true ]' +check "verdict.json says PASS, exit 0" '[ "$(jq -r "[.status,.exit_code,.run_id] | @tsv" "$r1/verdict.json")" = "$(printf "PASS\t0\trun1")" ]' +check "hashes.sha256 verifies and omits itself" '(cd "$r1" && sha256sum -c --quiet hashes.sha256) && ! grep -q hashes.sha256 "$r1/hashes.sha256"' +count1=$(find "$r1" -type f | wc -l) +sums1=$(cd "$r1" && find . -type f -print0 | sort -z | xargs -0 sha256sum) +STUB_STATUS=PASS fake_run --run-id run2; rc2=$? +check "run 2 (which runs make clean) exits 0" '[ "$rc2" = 0 ] && [ -f "$fake/qual-runs/run2/run.json" ]' +check "run 2 cleanup removed build products but not run 1" '[ -d "$r1" ] && [ -f "$fake/build/omegatool" ]' +check "run 1 hashes still verify after run 2" '(cd "$r1" && sha256sum -c --quiet hashes.sha256)' +check "run 1 file count unchanged" '[ "$(find "$r1" -type f | wc -l)" = "$count1" ]' +check "run 1 bytes identical (every file)" '[ "$(cd "$r1" && find . -type f -print0 | sort -z | xargs -0 sha256sum)" = "$sums1" ]' +STUB_STATUS=PASS fake_run --run-id run1; rcx=$? +check "reusing an existing run id exits 2" '[ "$rcx" = 2 ] && grep -q "never reused" "$TMP/fake.err"' +check " and leaves run 1 untouched" '(cd "$r1" && sha256sum -c --quiet hashes.sha256) && [ "$(find "$r1" -type f | wc -l)" = "$count1" ]' +STUB_STATUS=PASS fake_run --run-id inbuild --evidence-root "$fake/build/qual"; rcb=$? +check "evidence root inside build/ refused (exit 2)" '[ "$rcb" = 2 ]' +STUB_STATUS=FAILED fake_run --run-id run3; rc3=$? +check "failed run exits 1 with FAILED verdict and exit code" '[ "$rc3" = 1 ] && [ "$(jq -r "[.status,.exit_code,.failing_step,.failing_gate_or_exit] | @tsv" "$fake/qual-runs/run3/verdict.json")" = "$(printf "FAILED\t1\tstub failure\texit:1")" ]' +check "command.txt records the exact argv" 'grep -q -- "--run-id run3" "$fake/qual-runs/run3/command.txt"' + +echo "campaign verdicts (tools/m19r_campaign.sh)" +CAMP=$HERE/tools/m19r_campaign.sh +mkrun() { # mkrun DIR ID STATUS -- a sealed run directory + local d=$1/$2 + mkdir -p "$d" + printf '{"status":"%s"}' "$3" > "$d/run.json" + printf '{"run_id":"%s","status":"%s","exit_code":0}' "$2" "$3" > "$d/verdict.json" + echo "log $2" > "$d/m19.log" + m19r_seal "$d" +} +verdict() { "$CAMP" --campaign-dir "$1" --runs "$2" > /dev/null 2>&1; jq -r .verdict "$1/final-verdict.json"; } +c=$TMP/c_pass; mkdir "$c"; mkrun "$c" r1 PASS; mkrun "$c" r2 PASS +check "PASS: 2 of 2 runs PASS" '[ "$(verdict "$c" 2)" = PASS ]' +check " campaign.json written with sha, rule, created_at" '[ "$(jq -r "[.sha,.rule,.created_at] | map(length > 0) | all" "$c/campaign.json")" = true ]' +check " exits 0" '"$CAMP" --campaign-dir "$c" --runs 2 > /dev/null' +check "INCOMPLETE: 2 usable runs but 3 required" '[ "$(verdict "$c" 3)" = INCOMPLETE ]' +check " exits 1" '! "$CAMP" --campaign-dir "$c" --runs 3 > /dev/null' +c=$TMP/c_fail; mkdir "$c"; mkrun "$c" r1 PASS; mkrun "$c" r2 FAILED +check "FAIL: one run FAILED" '[ "$(verdict "$c" 2)" = FAIL ]' +c=$TMP/c_inv; mkdir "$c"; mkrun "$c" r1 PASS; mkrun "$c" r2 PASS +chmod u+w "$c/r2/m19.log"; printf 'log r3' > "$c/r2/m19.log" +check "INVALID: one altered byte in a run file" '[ "$(verdict "$c" 2)" = INVALID ]' +c=$TMP/c_inv2; mkdir "$c"; mkrun "$c" r1 PASS; mkrun "$c" r2 PASS; rm "$c/r2/verdict.json" +check "INVALID: run lacks verdict.json" '[ "$(verdict "$c" 2)" = INVALID ]' +c=$TMP/c_inv3; mkdir "$c"; mkrun "$c" r1 PASS; mkrun "$c" r2 FAILED; chmod u+w "$c/r1/m19.log"; echo x >> "$c/r1/m19.log" +check "INVALID takes precedence over FAIL" '[ "$(verdict "$c" 2)" = INVALID ]' +check "bad arguments exit 2" '"$CAMP" --campaign-dir "$TMP/nonexistent" --runs 2 > /dev/null 2>&1; [ $? = 2 ]' + if [ "$fails" -ne 0 ]; then echo "M19R qualifier tests: $fails FAILED" exit 1 ```