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/build-context.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 / build-context.sh` 69 lines ยท 3779 bytes Raw Blame History 1 #!/bin/sh 2 # Build the Omega-only context pack read by `aien --omega` (harness config, not product code). 3 # usage: OMEGA_MV=/path/to/omega-mv OMC=/path/to/omc sh coder/build-context.sh OUTDIR 4 # OMC must be the build named in the repository's PIN file (the one place the pin is written). 5 # Writes OUTDIR/OMEGA.md (system prompt: rules + language reference + compiled examples), 6 # OUTDIR/CONTROL.md (rules only, for the no-context eval arm), OUTDIR/errors.tsv (compiler error 7 # meanings and fixes from data/reference.tsv, read by the guard) and OUTDIR/PIN (read by the guard 8 # and the eval runner). Every example must compile with OMC and every observed fact must still hold. 9 set -eu 10 here=$(cd "$(dirname "$0")" && pwd) 11 skill="$here/../skills/omega-encoding" 12 mv=${OMEGA_MV:?set OMEGA_MV to an omega-mv checkout} 13 omc=${OMC:?set OMC to the omc named in PIN} 14 out=${1:?usage: build-context.sh OUTDIR} 15 pin_rev=$(sed -n 's/^omega-mv //p' "$here/../PIN") 16 pin_sha=$(sed -n 's/^omc-sha256 //p' "$here/../PIN") 17 [ -n "$pin_rev" ] && [ -n "$pin_sha" ] || { echo "PIN must hold 'omega-mv ' and 'omc-sha256 '" >&2; exit 1; } 18 got=$(sha256sum "$omc" | cut -d' ' -f1) 19 [ "$got" = "$pin_sha" ] || { echo "omc sha256 $got, PIN says $pin_sha (omega-mv $pin_rev)" >&2; exit 1; } 20 mkdir -p "$out" 21 tmp=$(mktemp) 22 trap 'rm -f "$tmp" "$tmp.elf" "$tmp.err" "$tmp.head"' EXIT 23 24 # Each fact in omega-observed.md has a probe in observed/; a fact the pinned omc no longer shows stops the build. 25 tab=$(printf '\t') 26 grep -v '^#' "$here/observed/expect.tsv" | while IFS="$tab" read -r f crc prc; do 27 set +e 28 "$omc" < "$here/observed/$f" > "$tmp.elf" 2> "$tmp.err" 29 rc=$? 30 got_prc=- 31 if [ "$rc" -eq 0 ]; then chmod +x "$tmp.elf"; "$tmp.elf" < /dev/null > /dev/null; got_prc=$?; fi 32 set -e 33 [ "$rc" = "$crc" ] && [ "$got_prc" = "$prc" ] || 34 { echo "observed fact no longer holds: $f omc rc $rc (want $crc), run rc $got_prc (want $prc)" >&2; exit 1; } 35 done 36 37 sed "s/@OMC_SHA256@/$pin_sha/g; s/@OMEGA_MV@/$(printf %.9s "$pin_rev")/g" "$here/omega-prompt-head.md" > "$tmp.head" 38 { 39 cat "$tmp.head" 40 printf '\n# Omega language reference\n\n' 41 # Sections 2..11 of the omega-encoding skill; citation links are dropped to save tokens. 42 awk '/^## 2\. /{on=1} /^## 11a\. /{on=0} on' "$skill/SKILL.md" | 43 sed -E 's/ ?\((\[[^]]*\]\([^)]*\)(, ?)?)+\)//g; s/\[([^]]*)\]\([^)]*\)/\1/g' 44 printf '\n## Observed with the pinned omc (%.8s)\n' "$pin_sha" 45 cat "$here/omega-observed.md" 46 printf '\n# Examples (each compiles with the pinned omc)\n' 47 for f in "$skill/examples/fnv1a32.om" "$skill/examples/trap_narrow.om" \ 48 "$mv/seed/rung4/tests/echo.om" "$mv/seed/rung4/tests/fib.om" "$mv/seed/omc/tests/text.om" \ 49 "$mv/seed/omc/tests/loop/c1.om" "$mv/seed/omc/tests/loop/w1.om" "$mv/seed/omc/tests/float/structs.om"; do 50 "$omc" < "$f" > "$tmp.elf" || { echo "example does not compile: $f" >&2; exit 1; } 51 printf '\n## %s\n\n```\n' "$(basename "$f")" 52 cat "$f" 53 printf '```\n' 54 done 55 } > "$tmp" 56 mv "$tmp" "$out/OMEGA.md" 57 cp "$tmp.head" "$out/CONTROL.md" 58 cp "$here/../PIN" "$out/PIN" 59 # Error meanings: meaning and fix of each code from data/reference.tsv (the omega-mcp reference data that 60 # tools/check.sh ties to this pin), one "codemeaning. Fix: fix" line per code. Reference data for another 61 # pin, or no error rows, stops the build. 62 ref="$here/../data/reference.tsv" 63 [ "$(awk -F'\t' '$1 == "/pin/omc_sha256" { print $2 }' "$ref")" = "$pin_sha" ] || { echo "$ref is not for omc $pin_sha" >&2; exit 1; } 64 awk -F'\t' ' 65 $1 ~ /^\/errors\/[0-9]+\/(meaning|fix)$/ { 66 split($1, p, "/"); v[p[3], p[4]] = $2; codes[p[3]] = 1 67 } 68 END { for (c in codes) print c "\t" v[c, "meaning"] ". Fix: " v[c, "fix"] }' "$ref" | sort -n > "$out/errors.tsv" 69 [ -s "$out/errors.tsv" ] || { echo "no /errors rows in $ref" >&2; exit 1; }