interplane.Get Omega
Read in your language

omega-harness

Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories

Brought by drakestapleton

branch main Branches Tags History

omega-harness / coder / eval / selftest / aien

53 lines · 3233 bytes Raw Blame History
1#!/bin/sh
2# Stub session program for selftest.sh only: stands in for `aien --omega` so the runner and scorer can be
3# checked without a model. It records what the session was given in ../session.txt (outside the scored work
4# directory): sha256 of OMEGA_PROMPT, OMEGA_CONTEXT and its entry count, whether OMEGA_CHECK is set and
5# OMEGA_STOP_LIMIT; the task prompt (its last argument) goes to ../session-prompt.txt and the other arguments
6# to ../session-args.txt.
7# Then it writes a program to ./main.om (ID = the task directory): src-control/ID.om when the prompt is
8# CONTROL.md and that file exists, else src/ID.om, else nothing, with @TASKS@ replaced by SELFTEST_TASKS (the
9# absolute task directory; st7-cheat names its expected output with it). Last it runs OMEGA_CHECK as the guard
10# does at a finish and records the verdict of its SCORE line (or none) and its exit status in ../session.txt.
11[ "${1:-}" = --version ] && { echo "selftest-stub 1"; exit 0; }
12here=$(cd "$(dirname "$0")" && pwd)
13id=$(basename "$(dirname "$(pwd)")")
14{
15 echo "prompt $(sha256sum < "${OMEGA_PROMPT:-/dev/null}" | cut -d' ' -f1)"
16 echo "context ${OMEGA_CONTEXT:-unset}"
17 echo "context_entries $(ls -A "${OMEGA_CONTEXT:-/nonexistent}" 2> /dev/null | wc -l | tr -d ' ')"
18 if [ -n "${OMEGA_CHECK:-}" ]; then echo "check yes"; else echo "check no"; fi
19 echo "stop_limit ${OMEGA_STOP_LIMIT:-unset}"
20} > ../session.txt
21args=
22for a in "$@"; do [ -n "${last+x}" ] && args="$args${args:+ }$last"; last=$a; done
23printf '%s\n' "$last" > ../session-prompt.txt
24printf '%s\n' "$args" > ../session-args.txt
25# Guard log lines as the guard writes them at a finish (a mode file in this directory changes that: "nolog"
26# writes no log, as when the guard is not loaded; "nostop" logs a tool call but no finish; "nocheck" writes the
27# finish line of a guard without OMEGA_CHECK; "noreply" reports zero output tokens, as a model that never answered).
28# Known values for the raw columns: st3 has two refused finishes, st6 leaves junk.txt (and NOTES.md, which is
29# not counted), st2 takes at least one second.
30mode=$(cat "$here/mode" 2> /dev/null)
31if [ -n "${OMEGA_LOG:-}" ] && [ "$mode" = nostop ]; then
32 echo "x tool write allowed" >> "$OMEGA_LOG"
33elif [ -n "${OMEGA_LOG:-}" ] && [ "$mode" != nolog ]; then
34 [ "$id" = st3-exit ] && printf 'x stop refused #1: x\nx stop refused #2: x\n' >> "$OMEGA_LOG"
35 if [ "$mode" = nocheck ]; then
36 echo "x stop allowed: every touched .om compiles; no OMEGA_CHECK" >> "$OMEGA_LOG"
37 else
38 echo "x stop allowed: SCORE pass" >> "$OMEGA_LOG"
39 fi
40fi
41[ "$id" = st6-stdin ] && echo junk > junk.txt && echo notes > NOTES.md
42[ "$id" = st2-wrong ] && sleep 1
43src="$here/src/$id.om"
44[ "$(basename "${OMEGA_PROMPT:-}")" = CONTROL.md ] && [ -f "$here/src-control/$id.om" ] && src="$here/src-control/$id.om"
45[ -f "$src" ] && sed "s|@TASKS@|${SELFTEST_TASKS:-}|" "$src" > main.om
46if [ -n "${OMEGA_CHECK:-}" ]; then
47 c=$(sh -c "$OMEGA_CHECK" 2> /dev/null)
48 crc=$?
49 echo "check_score $(echo "$c" | sed -n 's/^SCORE [^ ]* \([^ ]*\) .*/\1/p' | tail -n 1)" >> ../session.txt
50 echo "check_rc $crc" >> ../session.txt
51fi
52if [ "$mode" = noreply ]; then echo '{"type":"stub","usage":{"output":0}}'; else echo '{"type":"stub","usage":{"output":1}}'; fi
53exit 0