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-harness/blob/main/coder/eval/run.sh # omega-harness Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-harness / coder / eval / run.sh` 179 lines ยท 10971 bytes Raw Blame History 1 #!/bin/sh 2 # Held-out eval for `aien --omega` (harness tooling, not product code). 3 # usage: sh run.sh ARM OUTDIR TASKDIR [TASK_ID...] 4 # ARM omega - Omega context pack as the system prompt, pack readable 5 # control - same model, tools, guard and check loop; rules-only prompt, no readable pack 6 # TASKDIR holds TASK_ID/{spec.md,stdin,expected.out,expected.exit}; reference solutions live elsewhere 7 # Tasks run one after another (the live 35B takes serial requests only). Each task gets a fresh empty 8 # directory; the model must leave main.om there. Scoring is independent of the session: compile with 9 # the pinned omc, then score.sh runs the om2 gate with no expected output in the program's view, then compares 10 # the program's saved stdout with the expected output through the gate. 11 # Verdicts: pass, wrong-output, timeout, crash, compile-fail (coder/README.md says what each means and what 12 # stops the run with exit 3 instead). 13 # Per task: OUTDIR/ID/{work/,sandbox/,transcript.jsonl,stderr,guard.log,score.log}; summary OUTDIR/results.tsv; 14 # inputs (compiler, gate, prompt, guard, tasks, session program) OUTDIR/manifest.tsv. 15 set -u 16 . "$(dirname "$0")/case.sh" 17 arm=${1:?arm: omega or control} 18 out=${2:?outdir} 19 tasks=${3:?taskdir} 20 shift 3 21 home=${OMEGA_HOME:-$HOME/.local/share/aien-omega} 22 home=$(cd "$home" && pwd) || { echo "no OMEGA_HOME directory $home" >&2; exit 2; } 23 omc="$home/omc" 24 # The pin is read from the repository's PIN (the one place it is written); the installed pack must 25 # have been built for the same pin, or the guard and this scorer would disagree. 26 pin="$(cd "$(dirname "$0")/../.." && pwd)/PIN" 27 sha=$(sed -n 's/^omc-sha256 //p' "$pin") 28 [ -n "$sha" ] || { echo "no omc-sha256 line in $pin" >&2; exit 2; } 29 got=$(sha256sum "$omc" | cut -d' ' -f1) 30 [ "$got" = "$sha" ] || { echo "pinned omc mismatch: $omc sha256 $got, $pin says $sha" >&2; exit 2; } 31 cmp -s "$pin" "$home/context/PIN" || { echo "pack built for another pin: rebuild $home/context with build-context.sh" >&2; exit 2; } 32 # The session loads $home/omega-guard.ts (aien -e); it must be this repository's guard, or the session would run 33 # a check loop this runner does not describe. 34 guard="$(cd "$(dirname "$0")/.." && pwd)/omega-guard.ts" 35 cmp -s "$guard" "$home/omega-guard.ts" || { echo "$home/omega-guard.ts is not $guard: cp it there" >&2; exit 2; } 36 here=$(cd "$(dirname "$0")" && pwd) 37 # q: quote one word for sh -c (OMEGA_CHECK is a command line the guard runs) 38 q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; } 39 command -v aien > /dev/null || { echo "aien not on PATH" >&2; exit 2; } 40 command -v bwrap > /dev/null || { echo "bwrap not on PATH (the gate runs model-written programs inside it)" >&2; exit 2; } 41 command -v jq > /dev/null || { echo "jq not on PATH (it quotes each task's standard input into the prompt)" >&2; exit 2; } 42 # score.sh gives the gate absolute paths in its case lines, and the gate runs with cwd "$home". 43 [ -d "$tasks" ] || { echo "no task directory $tasks" >&2; exit 2; } 44 tasks=$(cd "$tasks" && pwd) 45 model=${OMEGA_EVAL_MODEL:-} 46 seed=${OMEGA_EVAL_SEED:-} 47 [ -n "$model" ] || { echo "set OMEGA_EVAL_MODEL to the exact model id the aien profile serves" >&2; exit 2; } 48 [ -n "$seed" ] || { echo "set OMEGA_EVAL_SEED to the sampling seed the aien profile fixes, or none" >&2; exit 2; } 49 case $arm in 50 omega) prompt_file="$home/context/OMEGA.md"; context="$home/context" ;; 51 control) prompt_file="$home/context/CONTROL.md" ;; 52 *) echo "arm must be omega or control" >&2; exit 2 ;; 53 esac 54 ids=${*:-$(ls "$tasks")} 55 for id in $ids; do 56 [ -d "$tasks/$id" ] || { echo "no task $id in $tasks" >&2; exit 2; } 57 done 58 mkdir -p "$out" "$out/empty-context" 59 out=$(cd "$out" && pwd) 60 [ "$arm" = control ] && context="$out/empty-context" 61 # What this run was measured with. A resumed run must match the manifest it started with, and compare.sh 62 # refuses two arms whose manifests differ in anything but arm and prompt. The model and seed cannot be read 63 # from here (aien takes them from its own profile), so the operator states them: OMEGA_EVAL_MODEL (required, 64 # the exact model id the aien profile serves) and OMEGA_EVAL_SEED (the sampling seed the profile fixes, or 65 # "none" when it fixes none). The runner itself is hashed because it holds the prompt template and the limits. 66 # File names with white space would split in hd(); refuse them rather than hash an error. 67 for dd in "$tasks" "$home/seed/qualification/om2/fixtures"; do 68 [ -d "$dd" ] || continue 69 if find "$dd" | grep -q "[ $(printf '\t')]" || [ "$(find "$dd" | wc -l)" != "$(find "$dd" -exec printf '.\n' \; | wc -l)" ]; then 70 echo "a file name under $dd holds white space; rename it" >&2 71 exit 2 72 fi 73 done 74 h() { if [ -f "$1" ]; then sha256sum "$1" | cut -d' ' -f1; else echo absent; fi; } 75 hd() { if [ -d "$1" ]; then (cd "$1" && find . -type f | LC_ALL=C sort | xargs sha256sum) | sha256sum | cut -d' ' -f1; else echo absent; fi; } 76 # Both prompt files are recorded in every manifest (omega_prompt_sha256, control_prompt_sha256), so compare.sh 77 # can require the rules text to be the same in both arms; prompt_sha256 is the one this arm was given. 78 manifest=$(printf 'arm\t%s\nmodel\t%s\nseed\t%s\nomc_sha256\t%s\ngate_sha256\t%s\nfixtures_sha256\t%s\nprompt_sha256\t%s\nomega_prompt_sha256\t%s\ncontrol_prompt_sha256\t%s\nguard_sha256\t%s\nerrors_sha256\t%s\nrunner_sha256\t%s\ntasks_sha256\t%s\ntasks_count\t%s\ntask_ids\t%s\naien\t%s\naien_version\t%s\n' \ 79 "$arm" "$model" "$seed" "$sha" "$(h "$home/gate")" "$(hd "$home/seed/qualification/om2/fixtures")" "$(h "$prompt_file")" \ 80 "$(h "$home/context/OMEGA.md")" "$(h "$home/context/CONTROL.md")" \ 81 "$(h "$home/omega-guard.ts")" "$(h "$home/context/errors.tsv")" "$(cat "$0" "$here/case.sh" "$here/score.sh" "$here/cat.om" | sha256sum | cut -d' ' -f1)" "$(hd "$tasks")" "$(ls "$tasks" | wc -l | tr -d ' ')" "$(ls "$tasks" | LC_ALL=C sort | tr '\n' ' ' | sed 's/ $//')" \ 82 "$(h "$(command -v aien)")" "$(aien --version 2>&1 | head -n 1)") 83 # Rows with no manifest were scored with unknown inputs (an older runner wrote results.tsv alone): never adopt them. 84 if [ ! -f "$out/manifest.tsv" ] && [ -f "$out/results.tsv" ] && [ "$(wc -l < "$out/results.tsv")" -gt 1 ]; then 85 echo "$out/results.tsv has rows but no manifest.tsv: scored with unknown inputs; use a new OUTDIR" >&2 86 exit 2 87 fi 88 if [ -f "$out/manifest.tsv" ]; then 89 [ "$manifest" = "$(cat "$out/manifest.tsv")" ] || 90 { echo "resume with different inputs; diff $out/manifest.tsv against:" >&2; echo "$manifest" >&2; exit 2; } 91 else 92 echo "$manifest" > "$out/manifest.tsv" 93 fi 94 # Resumable: a task already scored in results.tsv is skipped; an interrupted task left no row and is re-run. 95 [ -s "$out/results.tsv" ] || 96 printf 'id\tverdict\tomc_rc\tgate_rc\tsession_rc\twall_s\tstop_refusals\tnon_om_files\n' > "$out/results.tsv" 97 for id in $ids; do 98 if cut -f1 "$out/results.tsv" | grep -qxF "$id"; then continue; fi 99 t="$tasks/$id" 100 d="$out/$id" 101 rm -rf "$d" 102 mkdir -p "$d/work" 103 # The finish check: the same scorer, on its own scratch directory under the session's output directory 104 # (outside the session directory, which is all the session's programs can read). 105 check="sh $(q "$here/score.sh") $(q "$home") $(q "$d/work/main.om") $(q "$t") $(q "$id") $(q "$d/check")" 106 if [ -s "$t/stdin" ]; then 107 input="Standard input for the check (JSON string): $(jq -Rs . < "$t/stdin")" 108 else 109 input="Standard input for the check is empty." 110 fi 111 prompt="Task: $(cat "$t/spec.md") 112 $input 113 Write the program to main.om in the working directory, check it with omega_run, and finish only when it is correct." 114 start=$(date +%s) 115 (cd "$d/work" && OMEGA_HOME="$home" OMEGA_PROMPT="$prompt_file" OMEGA_CONTEXT="$context" \ 116 OMEGA_CHECK="$check" OMEGA_STOP_LIMIT="$SESSION_STOP_LIMIT" OMEGA_LOG="$d/guard.log" \ 117 timeout "$SESSION_TIMEOUT" aien --omega -p --mode json --no-session "$prompt" \ 118 > "$d/transcript.jsonl" 2> "$d/stderr") 119 src=$? 120 # A session ends with 0, or 124 when timeout stops it. Anything else (126/127: it never started; another 121 # code: aien failed, for example the model server was unreachable) is not the model's answer: stop without 122 # a row, so the operator sees it at once and a rerun retries the task. 123 if [ "$src" -ne 0 ] && [ "$src" -ne 124 ]; then 124 echo "$id: session ended with rc $src (not 0 or 124), see $d/stderr; no row written" >&2 125 exit 3 126 fi 127 # The guard logs a "stop ..." line at every finish. A session that ended normally (rc 0) with none means the 128 # guard was not loaded or never saw the finish, and "no OMEGA_CHECK" means the task check did not reach it: 129 # either way the session ran without the harness, so stop without a row. 130 if [ "$src" -eq 0 ] && ! grep -q 'stop allowed\|stop refused' "$d/guard.log" 2> /dev/null; then 131 echo "$id: guard.log shows no finish (the guard was not loaded?), see $d/guard.log; no row written" >&2 132 exit 3 133 fi 134 if grep -q 'no OMEGA_CHECK' "$d/guard.log" 2> /dev/null; then 135 echo "$id: the guard ran without the task check (OMEGA_CHECK), see $d/guard.log; no row written" >&2 136 exit 3 137 fi 138 # A session in which the model never produced one output token measured the server, not the model 139 # (2026-11-15: a busy 35B answered nothing within the timeout). Stop without a row; a rerun retries it. 140 if ! grep -q '"output":[1-9]' "$d/transcript.jsonl"; then 141 echo "$id: the model produced no output tokens (session rc $src), see $d/transcript.jsonl; no row written" >&2 142 exit 3 143 fi 144 wall=$(($(date +%s) - start)) 145 orc=NA 146 grc=NA 147 if [ ! -f "$d/work/main.om" ]; then 148 verdict=compile-fail 149 echo "no main.om" > "$d/score.log" 150 else 151 "$omc" < "$d/work/main.om" > "$d/main.elf" 2> "$d/score.log" 152 orc=$? 153 # 126/127: omc could not be executed. That is the machine, not the model: stop without a row. 154 if [ "$orc" -eq 126 ] || [ "$orc" -eq 127 ]; then 155 echo "$id: omc could not run (rc $orc), see $d/score.log; no row written" >&2 156 exit 3 157 fi 158 if [ "$orc" -ne 0 ]; then 159 verdict=compile-fail 160 else 161 # score.sh: exit 0 pass, 1 another verdict on the program, 3 (or anything else) the machine's: stop 162 # without a row. 163 sh "$here/score.sh" "$home" "$d/work/main.om" "$t" "$id" "$d/sandbox" >> "$d/score.log" 2>&1 164 scrc=$? 165 s=$(grep "^SCORE $id " "$d/score.log" | tail -n 1) 166 verdict=$(echo "$s" | cut -d' ' -f3) 167 grc=$(echo "$s" | cut -d' ' -f4) 168 if { [ "$scrc" -ne 0 ] && [ "$scrc" -ne 1 ]; } || [ -z "$verdict" ] || ! echo " $VERDICTS " | grep -qF " $verdict " || 169 { [ "$verdict" = pass ] && [ "$scrc" -ne 0 ]; } || { [ "$verdict" != pass ] && [ "$scrc" -ne 1 ]; }; then 170 echo "$id: the scorer gave no verdict on the program (rc $scrc), see $d/score.log; no row written" >&2 171 exit 3 172 fi 173 fi 174 fi 175 refusals=$(grep -c 'stop refused' "$d/guard.log" 2>/dev/null || true) 176 nonom=$(find "$d/work" -type f ! -name '*.om' ! -name NOTES.md | wc -l) 177 printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$id" "$verdict" "$orc" "$grc" "$src" "$wall" "${refusals:-0}" "$nonom" >> "$out/results.tsv" 178 done 179 cat "$out/results.tsv"