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/patches/1ede962bb5bf28b8 # 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 ## GitHub aien-dev/omega-harness#94 (code only) closed derived `1ede962bb5bf28b8` #94 Imported from GitHub aien-dev/omega-harness#94 (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 `ec1bb54e2ef6c5cc2cf58ff05d6de531850a4969` · Head `a1b3f7563ff2c4bc8668cca8e6112b6ef9921734` ### Apply it ``` git checkout -b patch-1ede962bb5bf28b8 ec1bb54e2ef6c5cc2cf58ff05d6de531850a4969 curl -fsSL https://interplane.io/drakestapleton/omega-harness/patches/1ede962bb5bf28b8.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-harness 94 a1b3f7563ff2c4bc8668cca8e6112b6ef9921734 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-harness","number":94,"url":"https://github.com/aien-dev/omega-harness/pull/94","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:52Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/AGENTS.md b/AGENTS.md index 2c1c61c..3ee7f89 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,6 +27,11 @@ pinned compiler hash and reruns every program in `examples/` and `skills/*/examp any change to an example or a language rule. `skills/omega-encoding/examples/` holds two more runnable programs. `LICENSE` is Apache 2.0. +`coder/` is harness configuration for an Omega-only `omp` session: a TypeScript `omp` extension that +allows `.om` writes only and runs the pinned `omc` after each one, the builder of its context pack +(sections 2-11 of `omega-encoding` plus compiled examples), and a held-out eval. See `coder/README.md`. +When `omega-encoding` sections 2-11 change, rebuild the pack with `coder/build-context.sh`. + ## Before you edit a skill 1. Read the skill you intend to change, and `skills/omega-harness/SKILL.md` section 6, which maps a diff --git a/coder/README.md b/coder/README.md new file mode 100644 index 0000000..3226738 --- /dev/null +++ b/coder/README.md @@ -0,0 +1,57 @@ +# coder: an Omega-only coding session for omp + +Harness configuration that makes an `omp` session write Omega and nothing else, with the pinned +seeded compiler in the loop. It is not product code and not part of the trusted Omega stack: the +extension is TypeScript because `omp` extensions are TypeScript, and the builders are small shell +scripts. "Only Omega" is enforced by the harness and the compiler, not by model weights. + +| File | What it does | +|---|---| +| `omega-guard.ts` | `omp` extension (load with `-e`). Refuses every write or edit except `.om` files and `NOTES.md` inside the session directory; refuses reads outside the session directory and the context pack; compiles each written `.om` with the pinned `omc` (sha256 checked before every compile) and appends the result, with the error meaning and offending line, to the tool result; adds the `omega_run` tool (compile, then run in a `bwrap` sandbox with no network); refuses to let the session finish while a touched `.om` fails to compile, or, with `OMEGA_CASES` set, until the om2 gate passes those cases. | +| `omega-prompt-head.md` | Rules part of the system prompt (tools, check loop, `DONE `). | +| `omega-observed.md` | Compiler facts observed with the pinned `omc` that the skill does not state. | +| `build-context.sh` | Builds the context pack: `OMEGA.md` = rules + `skills/omega-encoding` sections 2-11 (citation links stripped) + observed facts + eight examples that must each compile with the pinned `omc`; `CONTROL.md` = rules only. | +| `eval/` | Held-out eval: 27 tasks (`tasks/ID/{spec.md,stdin,expected.out,expected.exit}`), manifest `tasks.json`, runner `run.sh`. | + +## Environment read by the guard + +| Variable | Default | Meaning | +|---|---|---| +| `OMEGA_HOME` | `~/.local/share/aien-omega` | holds `omc`, the built `gate` and `seed/qualification/om2/fixtures` | +| `OMEGA_CONTEXT` | `$OMEGA_HOME/context` | the one directory outside the session the model may read | +| `OMEGA_CASES` | unset | om2 gate case file that must pass before the session may finish | +| `OMEGA_STOP_LIMIT` | `0` (no limit) | after this many refused finishes the finish is allowed and logged | +| `OMEGA_LOG` | unset | append-only log of every allowed/refused tool call, compile and finish | + +The required `omc` sha256 (`2c824805...029f`, aien-dev/omega-mv `f1b9ecb5d` `seed/out/omc`) is fixed in +`omega-guard.ts`; a mismatch refuses every compile. `omega_run` and the finish check run the program +with a read-only root, no network and a 10 s timeout (the finish check gives the gate 120 s). + +## Running it + +Build the pack, install the guard, then start `omp` in the project directory with no shell tool: + +```sh +OMEGA_MV=/path/to/omega-mv OMC=$HOME/.local/share/aien-omega/omc sh coder/build-context.sh ~/.local/share/aien-omega/context +cp coder/omega-guard.ts ~/.local/share/aien-omega/ +omp --model PROVIDER/MODEL --tools read,edit,write,grep,glob,omega_run --no-skills --no-rules \ + --no-extensions --no-lsp --no-context-files -e ~/.local/share/aien-omega/omega-guard.ts \ + --system-prompt ~/.local/share/aien-omega/context/OMEGA.md +``` + +`--no-extensions` does not stop an extension named with `-e`. Use an isolated `omp` profile with +advisors off and no other providers so the session cannot fall back to another model. + +## Eval + +`sh coder/eval/run.sh omega|control OUTDIR coder/eval/tasks` runs every task in a fresh empty +directory, one after another. The `control` arm keeps the model, tools, guard and check loop and swaps +the system prompt for `CONTROL.md` with an empty readable context, so the only variable is the Omega +context. Scoring does not trust the session: the runner compiles `main.om` with the pinned `omc` +(non-zero exit or no file = compile-fail) and runs the om2 gate on the task's case line in a fresh +scratch directory (FAIL = wrong-output). + +The reference solutions are held out: they are not in this repository, the context pack or any +session directory; `tasks.json` records only their sha256. They were checked with the pinned gate +(27/27 PASS, with a negative control that failed as it should). Keep `coder/eval/` out of any +training corpus built from this repository, or the eval stops measuring anything. diff --git a/coder/build-context.sh b/coder/build-context.sh new file mode 100755 index 0000000..3249169 --- /dev/null +++ b/coder/build-context.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Build the Omega-only context pack read by `aien --omega` (harness config, not product code). +# usage: OMEGA_MV=/path/to/omega-mv OMC=/path/to/pinned/omc sh coder/build-context.sh OUTDIR +# Writes OUTDIR/OMEGA.md (system prompt: rules + language reference + compiled examples) and +# OUTDIR/CONTROL.md (rules only, for the no-context eval arm). Every example must compile with OMC. +set -eu +here=$(cd "$(dirname "$0")" && pwd) +skill="$here/../skills/omega-encoding" +mv=${OMEGA_MV:?set OMEGA_MV to an omega-mv checkout} +omc=${OMC:?set OMC to the pinned omc} +out=${1:?usage: build-context.sh OUTDIR} +mkdir -p "$out" +tmp=$(mktemp) +trap 'rm -f "$tmp" "$tmp.elf"' EXIT + +{ + cat "$here/omega-prompt-head.md" + printf '\n# Omega language reference\n\n' + # Sections 2..11 of the omega-encoding skill; citation links are dropped to save tokens. + awk '/^## 2\. /{on=1} /^## 11a\. /{on=0} on' "$skill/SKILL.md" | + sed -E 's/ ?\((\[[^]]*\]\([^)]*\)(, ?)?)+\)//g; s/\[([^]]*)\]\([^)]*\)/\1/g' + cat "$here/omega-observed.md" + printf '\n# Examples (each compiles with the pinned omc)\n' + for f in "$skill/examples/fnv1a32.om" "$skill/examples/trap_narrow.om" \ + "$mv/seed/rung4/tests/echo.om" "$mv/seed/rung4/tests/fib.om" "$mv/seed/omc/tests/text.om" \ + "$mv/seed/omc/tests/loop/c1.om" "$mv/seed/omc/tests/loop/w1.om" "$mv/seed/omc/tests/float/structs.om"; do + "$omc" < "$f" > "$tmp.elf" || { echo "example does not compile: $f" >&2; exit 1; } + printf '\n## %s\n\n```\n' "$(basename "$f")" + cat "$f" + printf '```\n' + done +} > "$tmp" +mv "$tmp" "$out/OMEGA.md" +cp "$here/omega-prompt-head.md" "$out/CONTROL.md" diff --git a/coder/eval/run.sh b/coder/eval/run.sh new file mode 100755 index 0000000..11c69cd --- /dev/null +++ b/coder/eval/run.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Held-out eval for `aien --omega` (harness tooling, not product code). +# usage: sh run.sh ARM OUTDIR TASKDIR [TASK_ID...] +# ARM omega - Omega context pack as the system prompt, pack readable +# control - same model, tools, guard and check loop; rules-only prompt, no readable pack +# TASKDIR holds TASK_ID/{spec.md,stdin,expected.out,expected.exit}; reference solutions live elsewhere +# Tasks run one after another (the live 35B takes serial requests only). Each task gets a fresh empty +# directory; the model must leave main.om there. Scoring is independent of the session: compile with +# the pinned omc, then run the om2 gate on the task's case line in a fresh scratch directory. +# Per task: OUTDIR/ID/{work/,cases.txt,transcript.jsonl,stderr,guard.log,score.log}; summary OUTDIR/results.tsv. +set -u +arm=${1:?arm: omega or control} +out=${2:?outdir} +tasks=${3:?taskdir} +shift 3 +home=${OMEGA_HOME:-$HOME/.local/share/aien-omega} +omc="$home/omc" +sha=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +[ "$(sha256sum "$omc" | cut -d' ' -f1)" = "$sha" ] || { echo "pinned omc mismatch" >&2; exit 2; } +command -v aien > /dev/null || { echo "aien not on PATH" >&2; exit 2; } +case $arm in +omega) prompt_file="$home/context/OMEGA.md"; context="$home/context" ;; +control) prompt_file="$home/context/CONTROL.md" ;; +*) echo "arm must be omega or control" >&2; exit 2 ;; +esac +mkdir -p "$out" "$out/empty-context" +out=$(cd "$out" && pwd) +[ "$arm" = control ] && context="$out/empty-context" +ids=${*:-$(ls "$tasks")} +# Resumable: a task already scored in results.tsv is skipped; an interrupted task left no row and is re-run. +[ -s "$out/results.tsv" ] || + printf 'id\tverdict\tomc_rc\tgate_rc\tsession_rc\twall_s\tstop_refusals\tnon_om_files\n' > "$out/results.tsv" +for id in $ids; do + if cut -f1 "$out/results.tsv" | grep -qx "$id"; then continue; fi + t="$tasks/$id" + d="$out/$id" + rm -rf "$d" + mkdir -p "$d/work" + printf 'deadline 10\n%s run %s/work/main.om file:%s/stdin file:%s/expected.out - %s\n' \ + "$id" "$d" "$t" "$t" "$(cat "$t/expected.exit")" > "$d/cases.txt" + if [ -s "$t/stdin" ]; then + input="Standard input for the check (JSON string): $(jq -Rs . < "$t/stdin")" + else + input="Standard input for the check is empty." + fi + prompt="Task: $(cat "$t/spec.md") +$input +Write the program to main.om in the working directory, check it with omega_run, and finish only when it is correct." + start=$(date +%s) + (cd "$d/work" && OMEGA_HOME="$home" OMEGA_PROMPT="$prompt_file" OMEGA_CONTEXT="$context" \ + OMEGA_CASES="$d/cases.txt" OMEGA_STOP_LIMIT=5 OMEGA_LOG="$d/guard.log" \ + timeout 900 aien --omega -p --mode json --max-time 600 --no-session "$prompt" \ + > "$d/transcript.jsonl" 2> "$d/stderr") + src=$? + # 126/127: the session never started (not executable / not found). Scoring that as compile-fail would + # count an infrastructure failure against the model; stop without writing a row so a rerun retries it. + if [ "$src" -eq 126 ] || [ "$src" -eq 127 ]; then + echo "$id: session did not start (rc $src), see $d/stderr; no row written" >&2 + exit 3 + fi + wall=$(($(date +%s) - start)) + orc=NA + grc=NA + if [ ! -f "$d/work/main.om" ]; then + verdict=compile-fail + echo "no main.om" > "$d/score.log" + else + "$omc" < "$d/work/main.om" > "$d/main.elf" 2> "$d/score.log" + orc=$? + if [ "$orc" -ne 0 ]; then + verdict=compile-fail + else + rm -rf "$d/scratch" + (cd "$home" && ./gate "$omc" "$sha" "$d/cases.txt" "$d/scratch") >> "$d/score.log" 2>&1 + grc=$? + if [ "$grc" -eq 0 ] && grep -q '^OM2GATE PASS ' "$d/score.log"; then verdict=pass; else verdict=wrong-output; fi + fi + fi + refusals=$(grep -c 'stop refused' "$d/guard.log" 2>/dev/null || true) + nonom=$(find "$d/work" -type f ! -name '*.om' ! -name NOTES.md | wc -l) + 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" +done +cat "$out/results.tsv" diff --git a/coder/eval/tasks.json b/coder/eval/tasks.json new file mode 100644 index 0000000..a956dc6 --- /dev/null +++ b/coder/eval/tasks.json @@ -0,0 +1,218 @@ +[ + { + "id": "01-hello", + "spec": "Print exactly the line `hello, omega` followed by a newline to standard output. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "e6b51fc65d4c7e81a4db2c096921fb29dd91a30dac677f4d05e1db8f0464523a", + "exit": 0, + "ref_sha256": "53500fbfed13c4d9e85f7a719442bd1cb8d80d49fb154031b699dd8296f08a5e" + }, + { + "id": "02-sum100", + "spec": "Print the sum of the integers 1 through 100 in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "cae8934a441243980ca44aadcdf5e70da43aff4b901e7d53b6f17b479ec4986e", + "exit": 0, + "ref_sha256": "bccb9b30fdfdcf1a36fae8ff79dd999fcf467afe983563321125c663e538d189" + }, + { + "id": "03-fact20", + "spec": "Print 20 factorial (20!) in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "3cec9f38c592acdcecaf2ff2a76fcc2c6864ea86fd3d2a43bb1e6f99df440867", + "exit": 0, + "ref_sha256": "2561332e1b4183fa35a21db7b05efe8be86e43fe45aaafef325238cd80d525a2" + }, + { + "id": "04-squares", + "spec": "Print the squares of 1 through 10 in decimal, one per line (1, 4, 9, ... 100), each followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "e0d6ffbca61566fccf5f4347b44c909a563516bf306aed095e5f62dbc3e6d207", + "exit": 0, + "ref_sha256": "69bde26a0b146893f1f7121d72295b74a355793f67adf4be75ccec3d72e23cd6" + }, + { + "id": "05-primes50", + "spec": "Print every prime number less than 50 in increasing order, one per line in decimal. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "3c6d9976691ffdf36dcd13abefd9a89acdf40e1aa7953d50733bafea4f9eb273", + "exit": 0, + "ref_sha256": "d9d606e181593f680cacad0f78d147abc6308cd9ad1dc0e7429ed17c51e13eba" + }, + { + "id": "06-collatz27", + "spec": "Start with n = 27. Repeat: if n is even, n becomes n/2, otherwise n becomes 3n+1, until n is 1. Print the number of steps taken in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "1fc917c7ad66487470e466c0ad40ddd45b9f7730a4b43e1b2542627f0596bbdc", + "exit": 0, + "ref_sha256": "85bb7a1ba5bbb0cfd187b94ab1bd7fff7d7255da9f9677d3a5b43e591d2f7971" + }, + { + "id": "07-gcdlcm", + "spec": "Print the greatest common divisor and the least common multiple of 1071 and 462 in decimal on one line, separated by one space, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "a2a29ec044ffdd593c97a256391bce04c4aa8c5444e12709d231ec7b547cf4d1", + "exit": 0, + "ref_sha256": "a344fad0b2b68459e825ddbe6bbf255bc99b7c8b78ba17f423e2e1a91b7661f0" + }, + { + "id": "08-upper", + "spec": "Read all of standard input (at most 65535 bytes). Write it to standard output with every ASCII lowercase letter a-z changed to its uppercase letter; all other bytes unchanged. Exit status 0.", + "stdin_bytes": 17, + "expected_sha256": "c7d50cb406c0cb6054709ec488911839c1a3dc577d59fa231561bbbe3a6a7894", + "exit": 0, + "ref_sha256": "715f9e32846f3c21123fa425ba2da6af4bbbcc4ee02ca79153efc7c5d29d4cb5" + }, + { + "id": "09-wc", + "spec": "Read all of standard input (at most 65535 bytes). Print the number of newline bytes and the total number of bytes, in decimal, on one line separated by one space, followed by a newline. Exit status 0.", + "stdin_bytes": 24, + "expected_sha256": "30f377392009e176b1c861bd19983ea0a2e1e6a70e33caef6c6508a2ba52b255", + "exit": 0, + "ref_sha256": "f17e0ea84de3b86c04decf95097675415f4a5b6252fddc9bf48c28636de8ffcf" + }, + { + "id": "10-fizzbuzz", + "spec": "For each integer k from 1 to 15 print one line: `FizzBuzz` if k is divisible by 15, else `Fizz` if divisible by 3, else `Buzz` if divisible by 5, else k in decimal. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "97a001055c31d662bd99aaa118eea34eed0ebdffeae98312effd306161ba2f26", + "exit": 0, + "ref_sha256": "6e66893401249b8ae479c1222f0b1d8318b855a38376654b81b47a62f8f49f30" + }, + { + "id": "11-exit42", + "spec": "Write nothing to standard output and exit with status 42.", + "stdin_bytes": 0, + "expected_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "exit": 42, + "ref_sha256": "5bbca7c11490cfb39c47132a20884d5b71e4438c06a05a748f765a7f4975c149" + }, + { + "id": "12-div0", + "spec": "Read standard input (it will be empty) into a 16-byte buffer with one read call. Let d be the returned byte count converted to ulong. Compute 7 divided by d with the div word and print the quotient in decimal followed by a newline. Do not guard against zero: the run check expects the exit status this produces under Omega semantics.", + "stdin_bytes": 0, + "expected_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "exit": 102, + "ref_sha256": "5969c7ca0c43d1b664b85db3e1ba489cd55ec3fbda0d383f61bb2dca609a59ed" + }, + { + "id": "13-digitsum", + "spec": "Read all of standard input (at most 65535 bytes). Print the sum of the values of all ASCII decimal digit bytes 0-9 in it, in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 10, + "expected_sha256": "420002158111bff8adb3347d84029e480f45e60e1869b454b6adac3345f9f7d4", + "exit": 0, + "ref_sha256": "cac7ec1029b3855dcd68e41f8e72639b3f2b2be512b3647731661baebafe9b1a" + }, + { + "id": "14-double", + "spec": "Standard input holds one non-negative decimal integer (less than 10^18) followed by a newline. Print twice its value in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 6, + "expected_sha256": "f1288c3cc2a1ca2760f5d2fd88b372d5a21662b7e0037a6266337a91a28f4353", + "exit": 0, + "ref_sha256": "f9619d60618a2a44ca527c213811ad7d79b07319e588d4eeda1e13cad0d7440b" + }, + { + "id": "15-sort10", + "spec": "Sort the ten numbers 31 4 15 9 26 5 35 8 97 93 into increasing order and print them in decimal on one line separated by single spaces, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "b3896dca8267afc228b3a0a9f9b6c7a7b99aedbdc3511976f726cf9dc016596f", + "exit": 0, + "ref_sha256": "09b8dcbbe8499fee5ceb9d1fc59fcdfb81f72e49212f97d84d1a8c476c8a5be0" + }, + { + "id": "16-bytesum", + "spec": "Read all of standard input (at most 65535 bytes). Print the sum of all its byte values modulo 65536, in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 6, + "expected_sha256": "87fcb8e2232cd8ea18e93e6d4761f9843db167599efe621edf5329561faf24a7", + "exit": 0, + "ref_sha256": "7edb4b5078b32c387a305d638363c40dad22027c40da5c2ae03516bddbf09a0e" + }, + { + "id": "17-struct", + "spec": "Define a struct with two long fields x and y. Make two values of it, (3, -4) and (-5, 7). Print the Manhattan distance between them (|x1-x2| + |y1-y2|) in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "a9742eb8ee320e006666aef25ae9aeed948247f3125c9cafa7cf97b7e7467dd5", + "exit": 0, + "ref_sha256": "a5ffb2688b8aad1e0c2fd185760ca7170484cdcea6a46e8d7a71bcb5c4741568" + }, + { + "id": "18-binary", + "spec": "Print 37 in binary (base 2) digits with no leading zeros, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "ef430007dcb51252d3ba29192f078bca5bdd15eb428516ccd51789372e748d39", + "exit": 0, + "ref_sha256": "21be1a76de8104eb2758c36e7516ade2523451a1e23610bf5d5d94194918dc46" + }, + { + "id": "19-hex", + "spec": "Print 48879 in lowercase hexadecimal digits with no prefix and no leading zeros, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "9133a08119601ab3c6a4a352e869094e283458d95cfce45d33b924a047b0e94f", + "exit": 0, + "ref_sha256": "51c1b0a26676e69e081154745c5a06d3b9593bac709d0ff9adb41f4e67c5d50d" + }, + { + "id": "20-revwords", + "spec": "Standard input is one line of words separated by single spaces, ending in a newline. Print the words in reverse order, separated by single spaces, followed by a newline. Exit status 0.", + "stdin_bytes": 19, + "expected_sha256": "1e870ec15528c4602ab5a01bd7f697a3720746fa52ea563cbbc6d3722a1ffd25", + "exit": 0, + "ref_sha256": "e0b8cab0f97e11ed6645c03514d195c6ea585730981444241f53eaef3da7058e" + }, + { + "id": "21-pow2", + "spec": "Print the powers of two 2^0 through 2^10 in decimal, one per line. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "aa8e76f20698eb3d574963d24dd484c296089762b6e88bb070921d361078fcc4", + "exit": 0, + "ref_sha256": "a3a45244ec811716310deb45b247bee4d460b6338dcdc8f12f1c5a3ca406fdf2" + }, + { + "id": "22-triangle", + "spec": "Print the largest integer n such that n(n+1)/2 is less than 1000, in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "b1ce0aa6fdf3cf349d773243dab9fbbe09d30619f38b0c1e8977e28c4f0bc495", + "exit": 0, + "ref_sha256": "f3d8798e310eb12e8b71b5ec8546391507d6f0f5cb13b3d0333694bf18cc8b7d" + }, + { + "id": "23-palindrome", + "spec": "Standard input is one line ending in a newline. Ignoring that final newline, print `yes` and a newline if the line reads the same backwards as forwards, otherwise print `no` and a newline. Exit status 0.", + "stdin_bytes": 8, + "expected_sha256": "5040625b1fb6fa4af07226683f6e6003b29e5e70b16f8cfb24be7a752393f0ee", + "exit": 0, + "ref_sha256": "738fa60a3d781b9620141837ecbee7c723c29bbf39d27e6b95f80e173fc2cfbc" + }, + { + "id": "24-maxline", + "spec": "Standard input holds non-negative decimal integers, one per line, each line ending in a newline. Print the largest of them in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 12, + "expected_sha256": "94ea0504da906138495e412400707ebec1f315c58330820504f132152150f828", + "exit": 0, + "ref_sha256": "9aa9994e6835e728fb9bdeca8ff671af7dbc6aee0d42520a292a964d1ca57c77" + }, + { + "id": "25-vowels", + "spec": "Read all of standard input (at most 65535 bytes). Print how many of its bytes are one of the vowels a e i o u A E I O U, in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 44, + "expected_sha256": "25d4f2a86deb5e2574bb3210b67bb24fcc4afb19f93a7b65a057daa874a9d18e", + "exit": 0, + "ref_sha256": "1559032c02dc62a4c6ee4bb4753efece1b3a19556b1db44f1fe0e110f6c674f4" + }, + { + "id": "26-isqrt", + "spec": "Print the integer square root of 1000000007 (the largest integer r with r*r <= 1000000007) in decimal, followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "54abcef7dd5931b10f1c26b08c1b1f868724c509dbbb6eb3108140cb506567e4", + "exit": 0, + "ref_sha256": "a86e47a74c1323b6b06e2ef79c59a95e999d62e5aeeff8fb93adc18e1607c754" + }, + { + "id": "27-negative", + "spec": "Compute -17 multiplied by 3 as a signed 64-bit integer and print it in decimal (with a leading minus sign when negative), followed by a newline. Exit status 0.", + "stdin_bytes": 0, + "expected_sha256": "c0c646181a7cf70f4837cc4e435f7fb0b022f761a31b9ed3c177e4a707f63a45", + "exit": 0, + "ref_sha256": "4f908b5e119dc6e28aa4ff826d7bc987d1a24691979ab219d070e042c742ab69" + } +] \ No newline at end of file diff --git a/coder/eval/tasks/01-hello/expected.exit b/coder/eval/tasks/01-hello/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/01-hello/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/01-hello/expected.out b/coder/eval/tasks/01-hello/expected.out new file mode 100644 index 0000000..02952da --- /dev/null +++ b/coder/eval/tasks/01-hello/expected.out @@ -0,0 +1 @@ +hello, omega diff --git a/coder/eval/tasks/01-hello/spec.md b/coder/eval/tasks/01-hello/spec.md new file mode 100644 index 0000000..33fd0f2 --- /dev/null +++ b/coder/eval/tasks/01-hello/spec.md @@ -0,0 +1 @@ +Print exactly the line `hello, omega` followed by a newline to standard output. Exit status 0. diff --git a/coder/eval/tasks/01-hello/stdin b/coder/eval/tasks/01-hello/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/02-sum100/expected.exit b/coder/eval/tasks/02-sum100/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/02-sum100/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/02-sum100/expected.out b/coder/eval/tasks/02-sum100/expected.out new file mode 100644 index 0000000..c3ac783 --- /dev/null +++ b/coder/eval/tasks/02-sum100/expected.out @@ -0,0 +1 @@ +5050 diff --git a/coder/eval/tasks/02-sum100/spec.md b/coder/eval/tasks/02-sum100/spec.md new file mode 100644 index 0000000..9aabe5d --- /dev/null +++ b/coder/eval/tasks/02-sum100/spec.md @@ -0,0 +1 @@ +Print the sum of the integers 1 through 100 in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/02-sum100/stdin b/coder/eval/tasks/02-sum100/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/03-fact20/expected.exit b/coder/eval/tasks/03-fact20/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/03-fact20/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/03-fact20/expected.out b/coder/eval/tasks/03-fact20/expected.out new file mode 100644 index 0000000..c2f08cb --- /dev/null +++ b/coder/eval/tasks/03-fact20/expected.out @@ -0,0 +1 @@ +2432902008176640000 diff --git a/coder/eval/tasks/03-fact20/spec.md b/coder/eval/tasks/03-fact20/spec.md new file mode 100644 index 0000000..3b83e1e --- /dev/null +++ b/coder/eval/tasks/03-fact20/spec.md @@ -0,0 +1 @@ +Print 20 factorial (20!) in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/03-fact20/stdin b/coder/eval/tasks/03-fact20/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/04-squares/expected.exit b/coder/eval/tasks/04-squares/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/04-squares/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/04-squares/expected.out b/coder/eval/tasks/04-squares/expected.out new file mode 100644 index 0000000..bc7257c --- /dev/null +++ b/coder/eval/tasks/04-squares/expected.out @@ -0,0 +1,10 @@ +1 +4 +9 +16 +25 +36 +49 +64 +81 +100 diff --git a/coder/eval/tasks/04-squares/spec.md b/coder/eval/tasks/04-squares/spec.md new file mode 100644 index 0000000..180c583 --- /dev/null +++ b/coder/eval/tasks/04-squares/spec.md @@ -0,0 +1 @@ +Print the squares of 1 through 10 in decimal, one per line (1, 4, 9, ... 100), each followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/04-squares/stdin b/coder/eval/tasks/04-squares/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/05-primes50/expected.exit b/coder/eval/tasks/05-primes50/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/05-primes50/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/05-primes50/expected.out b/coder/eval/tasks/05-primes50/expected.out new file mode 100644 index 0000000..6beaeaa --- /dev/null +++ b/coder/eval/tasks/05-primes50/expected.out @@ -0,0 +1,15 @@ +2 +3 +5 +7 +11 +13 +17 +19 +23 +29 +31 +37 +41 +43 +47 diff --git a/coder/eval/tasks/05-primes50/spec.md b/coder/eval/tasks/05-primes50/spec.md new file mode 100644 index 0000000..3ec6634 --- /dev/null +++ b/coder/eval/tasks/05-primes50/spec.md @@ -0,0 +1 @@ +Print every prime number less than 50 in increasing order, one per line in decimal. Exit status 0. diff --git a/coder/eval/tasks/05-primes50/stdin b/coder/eval/tasks/05-primes50/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/06-collatz27/expected.exit b/coder/eval/tasks/06-collatz27/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/06-collatz27/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/06-collatz27/expected.out b/coder/eval/tasks/06-collatz27/expected.out new file mode 100644 index 0000000..58c9bdf --- /dev/null +++ b/coder/eval/tasks/06-collatz27/expected.out @@ -0,0 +1 @@ +111 diff --git a/coder/eval/tasks/06-collatz27/spec.md b/coder/eval/tasks/06-collatz27/spec.md new file mode 100644 index 0000000..3b4fd1c --- /dev/null +++ b/coder/eval/tasks/06-collatz27/spec.md @@ -0,0 +1 @@ +Start with n = 27. Repeat: if n is even, n becomes n/2, otherwise n becomes 3n+1, until n is 1. Print the number of steps taken in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/06-collatz27/stdin b/coder/eval/tasks/06-collatz27/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/07-gcdlcm/expected.exit b/coder/eval/tasks/07-gcdlcm/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/07-gcdlcm/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/07-gcdlcm/expected.out b/coder/eval/tasks/07-gcdlcm/expected.out new file mode 100644 index 0000000..d3a02ff --- /dev/null +++ b/coder/eval/tasks/07-gcdlcm/expected.out @@ -0,0 +1 @@ +21 23562 diff --git a/coder/eval/tasks/07-gcdlcm/spec.md b/coder/eval/tasks/07-gcdlcm/spec.md new file mode 100644 index 0000000..9b8ed4a --- /dev/null +++ b/coder/eval/tasks/07-gcdlcm/spec.md @@ -0,0 +1 @@ +Print the greatest common divisor and the least common multiple of 1071 and 462 in decimal on one line, separated by one space, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/07-gcdlcm/stdin b/coder/eval/tasks/07-gcdlcm/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/08-upper/expected.exit b/coder/eval/tasks/08-upper/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/08-upper/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/08-upper/expected.out b/coder/eval/tasks/08-upper/expected.out new file mode 100644 index 0000000..6061c29 --- /dev/null +++ b/coder/eval/tasks/08-upper/expected.out @@ -0,0 +1 @@ +HELLO, WORLD 42! diff --git a/coder/eval/tasks/08-upper/spec.md b/coder/eval/tasks/08-upper/spec.md new file mode 100644 index 0000000..a9feb95 --- /dev/null +++ b/coder/eval/tasks/08-upper/spec.md @@ -0,0 +1 @@ +Read all of standard input (at most 65535 bytes). Write it to standard output with every ASCII lowercase letter a-z changed to its uppercase letter; all other bytes unchanged. Exit status 0. diff --git a/coder/eval/tasks/08-upper/stdin b/coder/eval/tasks/08-upper/stdin new file mode 100644 index 0000000..755f2e0 --- /dev/null +++ b/coder/eval/tasks/08-upper/stdin @@ -0,0 +1 @@ +Hello, World 42! diff --git a/coder/eval/tasks/09-wc/expected.exit b/coder/eval/tasks/09-wc/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/09-wc/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/09-wc/expected.out b/coder/eval/tasks/09-wc/expected.out new file mode 100644 index 0000000..7f0887a --- /dev/null +++ b/coder/eval/tasks/09-wc/expected.out @@ -0,0 +1 @@ +4 24 diff --git a/coder/eval/tasks/09-wc/spec.md b/coder/eval/tasks/09-wc/spec.md new file mode 100644 index 0000000..dca81b5 --- /dev/null +++ b/coder/eval/tasks/09-wc/spec.md @@ -0,0 +1 @@ +Read all of standard input (at most 65535 bytes). Print the number of newline bytes and the total number of bytes, in decimal, on one line separated by one space, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/09-wc/stdin b/coder/eval/tasks/09-wc/stdin new file mode 100644 index 0000000..93b8bc9 --- /dev/null +++ b/coder/eval/tasks/09-wc/stdin @@ -0,0 +1,4 @@ +alpha beta +gamma + +delta diff --git a/coder/eval/tasks/10-fizzbuzz/expected.exit b/coder/eval/tasks/10-fizzbuzz/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/10-fizzbuzz/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/10-fizzbuzz/expected.out b/coder/eval/tasks/10-fizzbuzz/expected.out new file mode 100644 index 0000000..0a934f2 --- /dev/null +++ b/coder/eval/tasks/10-fizzbuzz/expected.out @@ -0,0 +1,15 @@ +1 +2 +Fizz +4 +Buzz +Fizz +7 +8 +Fizz +Buzz +11 +Fizz +13 +14 +FizzBuzz diff --git a/coder/eval/tasks/10-fizzbuzz/spec.md b/coder/eval/tasks/10-fizzbuzz/spec.md new file mode 100644 index 0000000..4c90ad7 --- /dev/null +++ b/coder/eval/tasks/10-fizzbuzz/spec.md @@ -0,0 +1 @@ +For each integer k from 1 to 15 print one line: `FizzBuzz` if k is divisible by 15, else `Fizz` if divisible by 3, else `Buzz` if divisible by 5, else k in decimal. Exit status 0. diff --git a/coder/eval/tasks/10-fizzbuzz/stdin b/coder/eval/tasks/10-fizzbuzz/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/11-exit42/expected.exit b/coder/eval/tasks/11-exit42/expected.exit new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/coder/eval/tasks/11-exit42/expected.exit @@ -0,0 +1 @@ +42 diff --git a/coder/eval/tasks/11-exit42/expected.out b/coder/eval/tasks/11-exit42/expected.out new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/11-exit42/spec.md b/coder/eval/tasks/11-exit42/spec.md new file mode 100644 index 0000000..d80924d --- /dev/null +++ b/coder/eval/tasks/11-exit42/spec.md @@ -0,0 +1 @@ +Write nothing to standard output and exit with status 42. diff --git a/coder/eval/tasks/11-exit42/stdin b/coder/eval/tasks/11-exit42/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/12-div0/expected.exit b/coder/eval/tasks/12-div0/expected.exit new file mode 100644 index 0000000..257e563 --- /dev/null +++ b/coder/eval/tasks/12-div0/expected.exit @@ -0,0 +1 @@ +102 diff --git a/coder/eval/tasks/12-div0/expected.out b/coder/eval/tasks/12-div0/expected.out new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/12-div0/spec.md b/coder/eval/tasks/12-div0/spec.md new file mode 100644 index 0000000..27672c6 --- /dev/null +++ b/coder/eval/tasks/12-div0/spec.md @@ -0,0 +1 @@ +Read standard input (it will be empty) into a 16-byte buffer with one read call. Let d be the returned byte count converted to ulong. Compute 7 divided by d with the div word and print the quotient in decimal followed by a newline. Do not guard against zero: the run check expects the exit status this produces under Omega semantics. diff --git a/coder/eval/tasks/12-div0/stdin b/coder/eval/tasks/12-div0/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/13-digitsum/expected.exit b/coder/eval/tasks/13-digitsum/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/13-digitsum/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/13-digitsum/expected.out b/coder/eval/tasks/13-digitsum/expected.out new file mode 100644 index 0000000..ea90ee3 --- /dev/null +++ b/coder/eval/tasks/13-digitsum/expected.out @@ -0,0 +1 @@ +45 diff --git a/coder/eval/tasks/13-digitsum/spec.md b/coder/eval/tasks/13-digitsum/spec.md new file mode 100644 index 0000000..ef6de5e --- /dev/null +++ b/coder/eval/tasks/13-digitsum/spec.md @@ -0,0 +1 @@ +Read all of standard input (at most 65535 bytes). Print the sum of the values of all ASCII decimal digit bytes 0-9 in it, in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/13-digitsum/stdin b/coder/eval/tasks/13-digitsum/stdin new file mode 100644 index 0000000..478042f --- /dev/null +++ b/coder/eval/tasks/13-digitsum/stdin @@ -0,0 +1 @@ +987654321 diff --git a/coder/eval/tasks/14-double/expected.exit b/coder/eval/tasks/14-double/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/14-double/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/14-double/expected.out b/coder/eval/tasks/14-double/expected.out new file mode 100644 index 0000000..b3f0221 --- /dev/null +++ b/coder/eval/tasks/14-double/expected.out @@ -0,0 +1 @@ +24690 diff --git a/coder/eval/tasks/14-double/spec.md b/coder/eval/tasks/14-double/spec.md new file mode 100644 index 0000000..840ff4d --- /dev/null +++ b/coder/eval/tasks/14-double/spec.md @@ -0,0 +1 @@ +Standard input holds one non-negative decimal integer (less than 10^18) followed by a newline. Print twice its value in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/14-double/stdin b/coder/eval/tasks/14-double/stdin new file mode 100644 index 0000000..e56e15b --- /dev/null +++ b/coder/eval/tasks/14-double/stdin @@ -0,0 +1 @@ +12345 diff --git a/coder/eval/tasks/15-sort10/expected.exit b/coder/eval/tasks/15-sort10/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/15-sort10/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/15-sort10/expected.out b/coder/eval/tasks/15-sort10/expected.out new file mode 100644 index 0000000..0ee265f --- /dev/null +++ b/coder/eval/tasks/15-sort10/expected.out @@ -0,0 +1 @@ +4 5 8 9 15 26 31 35 93 97 diff --git a/coder/eval/tasks/15-sort10/spec.md b/coder/eval/tasks/15-sort10/spec.md new file mode 100644 index 0000000..db8082d --- /dev/null +++ b/coder/eval/tasks/15-sort10/spec.md @@ -0,0 +1 @@ +Sort the ten numbers 31 4 15 9 26 5 35 8 97 93 into increasing order and print them in decimal on one line separated by single spaces, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/15-sort10/stdin b/coder/eval/tasks/15-sort10/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/16-bytesum/expected.exit b/coder/eval/tasks/16-bytesum/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/16-bytesum/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/16-bytesum/expected.out b/coder/eval/tasks/16-bytesum/expected.out new file mode 100644 index 0000000..78b122b --- /dev/null +++ b/coder/eval/tasks/16-bytesum/expected.out @@ -0,0 +1 @@ +531 diff --git a/coder/eval/tasks/16-bytesum/spec.md b/coder/eval/tasks/16-bytesum/spec.md new file mode 100644 index 0000000..824e2dc --- /dev/null +++ b/coder/eval/tasks/16-bytesum/spec.md @@ -0,0 +1 @@ +Read all of standard input (at most 65535 bytes). Print the sum of all its byte values modulo 65536, in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/16-bytesum/stdin b/coder/eval/tasks/16-bytesum/stdin new file mode 100644 index 0000000..2c27abe --- /dev/null +++ b/coder/eval/tasks/16-bytesum/stdin @@ -0,0 +1 @@ +omega diff --git a/coder/eval/tasks/17-struct/expected.exit b/coder/eval/tasks/17-struct/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/17-struct/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/17-struct/expected.out b/coder/eval/tasks/17-struct/expected.out new file mode 100644 index 0000000..d6b2404 --- /dev/null +++ b/coder/eval/tasks/17-struct/expected.out @@ -0,0 +1 @@ +19 diff --git a/coder/eval/tasks/17-struct/spec.md b/coder/eval/tasks/17-struct/spec.md new file mode 100644 index 0000000..23866f5 --- /dev/null +++ b/coder/eval/tasks/17-struct/spec.md @@ -0,0 +1 @@ +Define a struct with two long fields x and y. Make two values of it, (3, -4) and (-5, 7). Print the Manhattan distance between them (|x1-x2| + |y1-y2|) in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/17-struct/stdin b/coder/eval/tasks/17-struct/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/18-binary/expected.exit b/coder/eval/tasks/18-binary/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/18-binary/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/18-binary/expected.out b/coder/eval/tasks/18-binary/expected.out new file mode 100644 index 0000000..7ccdec5 --- /dev/null +++ b/coder/eval/tasks/18-binary/expected.out @@ -0,0 +1 @@ +100101 diff --git a/coder/eval/tasks/18-binary/spec.md b/coder/eval/tasks/18-binary/spec.md new file mode 100644 index 0000000..54f53cd --- /dev/null +++ b/coder/eval/tasks/18-binary/spec.md @@ -0,0 +1 @@ +Print 37 in binary (base 2) digits with no leading zeros, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/18-binary/stdin b/coder/eval/tasks/18-binary/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/19-hex/expected.exit b/coder/eval/tasks/19-hex/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/19-hex/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/19-hex/expected.out b/coder/eval/tasks/19-hex/expected.out new file mode 100644 index 0000000..bf8b66a --- /dev/null +++ b/coder/eval/tasks/19-hex/expected.out @@ -0,0 +1 @@ +beef diff --git a/coder/eval/tasks/19-hex/spec.md b/coder/eval/tasks/19-hex/spec.md new file mode 100644 index 0000000..933a90d --- /dev/null +++ b/coder/eval/tasks/19-hex/spec.md @@ -0,0 +1 @@ +Print 48879 in lowercase hexadecimal digits with no prefix and no leading zeros, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/19-hex/stdin b/coder/eval/tasks/19-hex/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/20-revwords/expected.exit b/coder/eval/tasks/20-revwords/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/20-revwords/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/20-revwords/expected.out b/coder/eval/tasks/20-revwords/expected.out new file mode 100644 index 0000000..e84831c --- /dev/null +++ b/coder/eval/tasks/20-revwords/expected.out @@ -0,0 +1 @@ +four three two one diff --git a/coder/eval/tasks/20-revwords/spec.md b/coder/eval/tasks/20-revwords/spec.md new file mode 100644 index 0000000..5ed3401 --- /dev/null +++ b/coder/eval/tasks/20-revwords/spec.md @@ -0,0 +1 @@ +Standard input is one line of words separated by single spaces, ending in a newline. Print the words in reverse order, separated by single spaces, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/20-revwords/stdin b/coder/eval/tasks/20-revwords/stdin new file mode 100644 index 0000000..4d0e08d --- /dev/null +++ b/coder/eval/tasks/20-revwords/stdin @@ -0,0 +1 @@ +one two three four diff --git a/coder/eval/tasks/21-pow2/expected.exit b/coder/eval/tasks/21-pow2/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/21-pow2/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/21-pow2/expected.out b/coder/eval/tasks/21-pow2/expected.out new file mode 100644 index 0000000..b4d2a4c --- /dev/null +++ b/coder/eval/tasks/21-pow2/expected.out @@ -0,0 +1,11 @@ +1 +2 +4 +8 +16 +32 +64 +128 +256 +512 +1024 diff --git a/coder/eval/tasks/21-pow2/spec.md b/coder/eval/tasks/21-pow2/spec.md new file mode 100644 index 0000000..57d8db7 --- /dev/null +++ b/coder/eval/tasks/21-pow2/spec.md @@ -0,0 +1 @@ +Print the powers of two 2^0 through 2^10 in decimal, one per line. Exit status 0. diff --git a/coder/eval/tasks/21-pow2/stdin b/coder/eval/tasks/21-pow2/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/22-triangle/expected.exit b/coder/eval/tasks/22-triangle/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/22-triangle/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/22-triangle/expected.out b/coder/eval/tasks/22-triangle/expected.out new file mode 100644 index 0000000..c739b42 --- /dev/null +++ b/coder/eval/tasks/22-triangle/expected.out @@ -0,0 +1 @@ +44 diff --git a/coder/eval/tasks/22-triangle/spec.md b/coder/eval/tasks/22-triangle/spec.md new file mode 100644 index 0000000..d8c5fc4 --- /dev/null +++ b/coder/eval/tasks/22-triangle/spec.md @@ -0,0 +1 @@ +Print the largest integer n such that n(n+1)/2 is less than 1000, in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/22-triangle/stdin b/coder/eval/tasks/22-triangle/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/23-palindrome/expected.exit b/coder/eval/tasks/23-palindrome/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/23-palindrome/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/23-palindrome/expected.out b/coder/eval/tasks/23-palindrome/expected.out new file mode 100644 index 0000000..7cfab5b --- /dev/null +++ b/coder/eval/tasks/23-palindrome/expected.out @@ -0,0 +1 @@ +yes diff --git a/coder/eval/tasks/23-palindrome/spec.md b/coder/eval/tasks/23-palindrome/spec.md new file mode 100644 index 0000000..576f0a6 --- /dev/null +++ b/coder/eval/tasks/23-palindrome/spec.md @@ -0,0 +1 @@ +Standard input is one line ending in a newline. Ignoring that final newline, print `yes` and a newline if the line reads the same backwards as forwards, otherwise print `no` and a newline. Exit status 0. diff --git a/coder/eval/tasks/23-palindrome/stdin b/coder/eval/tasks/23-palindrome/stdin new file mode 100644 index 0000000..c8d20d3 --- /dev/null +++ b/coder/eval/tasks/23-palindrome/stdin @@ -0,0 +1 @@ +racecar diff --git a/coder/eval/tasks/24-maxline/expected.exit b/coder/eval/tasks/24-maxline/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/24-maxline/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/24-maxline/expected.out b/coder/eval/tasks/24-maxline/expected.out new file mode 100644 index 0000000..dcb6b5b --- /dev/null +++ b/coder/eval/tasks/24-maxline/expected.out @@ -0,0 +1 @@ +230 diff --git a/coder/eval/tasks/24-maxline/spec.md b/coder/eval/tasks/24-maxline/spec.md new file mode 100644 index 0000000..52f45e7 --- /dev/null +++ b/coder/eval/tasks/24-maxline/spec.md @@ -0,0 +1 @@ +Standard input holds non-negative decimal integers, one per line, each line ending in a newline. Print the largest of them in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/24-maxline/stdin b/coder/eval/tasks/24-maxline/stdin new file mode 100644 index 0000000..429bcbf --- /dev/null +++ b/coder/eval/tasks/24-maxline/stdin @@ -0,0 +1,4 @@ +17 +4 +230 +99 diff --git a/coder/eval/tasks/25-vowels/expected.exit b/coder/eval/tasks/25-vowels/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/25-vowels/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/25-vowels/expected.out b/coder/eval/tasks/25-vowels/expected.out new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/coder/eval/tasks/25-vowels/expected.out @@ -0,0 +1 @@ +11 diff --git a/coder/eval/tasks/25-vowels/spec.md b/coder/eval/tasks/25-vowels/spec.md new file mode 100644 index 0000000..0984b86 --- /dev/null +++ b/coder/eval/tasks/25-vowels/spec.md @@ -0,0 +1 @@ +Read all of standard input (at most 65535 bytes). Print how many of its bytes are one of the vowels a e i o u A E I O U, in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/25-vowels/stdin b/coder/eval/tasks/25-vowels/stdin new file mode 100644 index 0000000..84102df --- /dev/null +++ b/coder/eval/tasks/25-vowels/stdin @@ -0,0 +1 @@ +The quick brown fox jumps over the lazy dog diff --git a/coder/eval/tasks/26-isqrt/expected.exit b/coder/eval/tasks/26-isqrt/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/26-isqrt/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/26-isqrt/expected.out b/coder/eval/tasks/26-isqrt/expected.out new file mode 100644 index 0000000..6c2d709 --- /dev/null +++ b/coder/eval/tasks/26-isqrt/expected.out @@ -0,0 +1 @@ +31622 diff --git a/coder/eval/tasks/26-isqrt/spec.md b/coder/eval/tasks/26-isqrt/spec.md new file mode 100644 index 0000000..ec92ab3 --- /dev/null +++ b/coder/eval/tasks/26-isqrt/spec.md @@ -0,0 +1 @@ +Print the integer square root of 1000000007 (the largest integer r with r*r <= 1000000007) in decimal, followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/26-isqrt/stdin b/coder/eval/tasks/26-isqrt/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/eval/tasks/27-negative/expected.exit b/coder/eval/tasks/27-negative/expected.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/coder/eval/tasks/27-negative/expected.exit @@ -0,0 +1 @@ +0 diff --git a/coder/eval/tasks/27-negative/expected.out b/coder/eval/tasks/27-negative/expected.out new file mode 100644 index 0000000..279ebfb --- /dev/null +++ b/coder/eval/tasks/27-negative/expected.out @@ -0,0 +1 @@ +-51 diff --git a/coder/eval/tasks/27-negative/spec.md b/coder/eval/tasks/27-negative/spec.md new file mode 100644 index 0000000..a92cbea --- /dev/null +++ b/coder/eval/tasks/27-negative/spec.md @@ -0,0 +1 @@ +Compute -17 multiplied by 3 as a signed 64-bit integer and print it in decimal (with a leading minus sign when negative), followed by a newline. Exit status 0. diff --git a/coder/eval/tasks/27-negative/stdin b/coder/eval/tasks/27-negative/stdin new file mode 100644 index 0000000..e69de29 diff --git a/coder/omega-guard.ts b/coder/omega-guard.ts new file mode 100644 index 0000000..17af6c6 --- /dev/null +++ b/coder/omega-guard.ts @@ -0,0 +1,319 @@ +// omega-guard: omp extension for `aien --omega`. Harness configuration, not product code: omp +// extensions are TypeScript, so this file is the smallest shim between the omp tool loop and the +// pinned seeded Omega compiler. All checking of programs is done by Omega itself: `omc` compiles, +// and the OM-2 qualification conductor `seed/qualification/om2/gate.om` (built by the pinned omc) +// runs and compares task cases. This file only routes paths, starts those two binaries and sandboxes +// model-written programs with bubblewrap. +// +// Policy +// - write/edit may touch only `*.om` files (plus NOTES.md) inside the session directory; every other +// path, an `MV` to a non-.om name, and archive/URL targets are refused before the tool runs. +// - read/grep/glob are confined to the session directory and the Omega context pack. +// - Every tool other than read, grep, glob, edit, write and omega_run is refused (no shell). +// - After a successful write/edit of a `.om` file the pinned omc compiles it; the result (rc, the +// `omc: line N: error K` line, the offending source line and the error's meaning) is appended to +// the tool result the model sees. +// - omega_run compiles a `.om` file and runs it in a bubblewrap sandbox: read-only root, private +// /tmp, no network, own pid namespace, 10 s wall limit. +// - The session cannot end while any touched `.om` file fails to compile, or, when OMEGA_CASES names a +// gate case list, until the gate prints `OM2GATE PASS`. +// +// Environment: OMEGA_HOME (default ~/.local/share/aien-omega: omc, gate, gate fixtures, context/), +// OMEGA_CASES (optional case list for the stop check; keep it outside the session directory). +import { spawnSync } from 'node:child_process' +import { createHash } from 'node:crypto' +import { appendFileSync, chmodSync, existsSync, mkdtempSync, readFileSync, realpathSync } from 'node:fs' +import { homedir, tmpdir } from 'node:os' +import { basename, isAbsolute, join, resolve, sep } from 'node:path' + +const OMEGA_HOME = process.env.OMEGA_HOME || join(homedir(), '.local/share/aien-omega') +const OMC = join(OMEGA_HOME, 'omc') +const GATE = join(OMEGA_HOME, 'gate') +// Readable Omega reference. The eval control arm points this at an empty directory. +const CONTEXT = process.env.OMEGA_CONTEXT || join(OMEGA_HOME, 'context') +// Stop refusals before the session may end anyway (eval runs set it; unset means no limit). +const STOP_LIMIT = Number(process.env.OMEGA_STOP_LIMIT || 0) +// omega-mv f1b9ecb5d13f3b7303c055a187fff06e802eb952, seed/out/omc (commit 82a399b9f "batch 2 pin 2c824805"). +const OMC_SHA256 = '2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f' +const LOG = process.env.OMEGA_LOG + +function note(line: string): void { + if (LOG) appendFileSync(LOG, `${new Date().toISOString()} ${line}\n`) +} +const ALLOWED_TOOLS = new Set(['read', 'grep', 'glob', 'edit', 'write', 'omega_run']) +const BUILD = mkdtempSync(join(tmpdir(), 'aien-omega-')) + +const ERRORS: Record = { + 1: 'compiler I/O', 2: 'compiler I/O', 3: 'unknown name or field', 4: 'line ends too early (missing value)', + 5: 'extra words on the line', 6: 'malformed number', 7: 'type mismatch (no implicit conversion)', + 8: 'number out of range', 9: 'word in a disallowed place', 10: 'duplicate name', 11: 'ambiguous bare number (give it a type: uint 5)', + 12: 'register pool exhausted (fewer live names or split the function)', 13: 'name too long (non-function names at most 8 characters)', + 14: 'capacity', 15: 'missing end', 16: 'syntax error or unknown word', 17: 'line after ret/break/continue/trap/exit', + 18: 'missing ret (end of a value-returning function is reachable)', 19: 'global passed as argument, or same array twice in one call', + 20: 'write to a view or text', 21: 'constant index out of range', 22: 'bad text literal', 23: 'size capacity', +} + +type Ctx = { cwd?: string } +type Content = { type: string; text?: string } +type Pi = { + on(name: string, handler: (event: any, ctx: Ctx) => unknown): void + registerTool(def: any): void + zod: any +} + +function omcVerified(): string | undefined { + try { + const sha = createHash('sha256').update(readFileSync(OMC)).digest('hex') + return sha === OMC_SHA256 ? undefined : `pinned omc mismatch: ${OMC} sha256 ${sha}, expected ${OMC_SHA256}` + } catch (e) { + return `pinned omc unreadable: ${OMC}: ${e}` + } +} + +function root(ctx: Ctx): string { + return realpathSync(ctx.cwd || process.cwd()) +} + +// Resolve a model-supplied path the way the file tools do (relative to the session directory). +// Symlinks are resolved for the existing prefix so a link cannot carry a write outside the root. +function resolvePath(p: string, base: string): string { + let abs = resolve(base, p) + let probe = abs + const tail: string[] = [] + while (!existsSync(probe) && probe !== sep) { + tail.unshift(basename(probe)) + probe = resolve(probe, '..') + } + try { + abs = join(realpathSync(probe), ...tail) + } catch {} + return abs +} + +function inside(abs: string, dir: string): boolean { + return abs === dir || abs.startsWith(dir.endsWith(sep) ? dir : dir + sep) +} + +function writePaths(tool: string, input: any): string[] { + const out: string[] = [] + // The edit tool takes `path` as `FILE#TAG` (TAG = snapshot hash from the last read); the tag is not part of the + // path. Anything else after a `#` is kept, and checkWrite refuses every path that still contains `#`. + for (const k of ['path', 'file_path', 'file', 'target']) { + const p = input?.[k] + if (typeof p !== 'string') continue + const h = p.lastIndexOf('#') + out.push(h >= 0 && /^[0-9A-Za-z]+$/.test(p.slice(h + 1)) ? p.slice(0, h) : p) + } + if (typeof input?.input === 'string') { + for (const m of input.input.matchAll(/^\[([^\]#\n]+)#/gm)) out.push(m[1]) + for (const m of input.input.matchAll(/^\s*MV\s+("([^"]+)"|(\S+))/gm)) out.push(m[2] ?? m[3]) + } + if (Array.isArray(input?.edits)) for (const e of input.edits) if (typeof e?.path === 'string') out.push(e.path) + if (tool === 'write' && out.length === 0) out.push('') + return out +} + +function readPaths(input: any): string[] { + const out: string[] = [] + for (const k of ['path', 'paths', 'file_path']) { + const v = input?.[k] + if (typeof v === 'string') out.push(...v.split(';').map((s: string) => s.trim()).filter(Boolean)) + if (Array.isArray(v)) out.push(...v.filter((s: unknown) => typeof s === 'string')) + } + return out +} + +function stripSelector(p: string): string { + // read accepts `file.om:10-20`; the selector is not part of the path. + return p.replace(/:(raw|conflicts|img|[-+0-9,]+[-+0-9,:raw]*)$/, '') +} + +function checkWrite(p: string, base: string): string | undefined { + if (!p) return 'write needs a path ending in .om' + if (p.includes('://') || p.includes(':') || p.includes('#')) return `refused: ${p}: only plain paths to .om files may be written` + const abs = resolvePath(p, base) + if (!inside(abs, base)) return `refused: ${p} is outside the session directory ${base}` + if (abs.endsWith('.om') || basename(abs) === 'NOTES.md') return undefined + return `refused: ${p}: this session writes Omega only; edit or create .om files (or NOTES.md for notes)` +} + +function checkRead(p: string, base: string): string | undefined { + if (p.startsWith('artifact://')) return undefined + if (p.includes('://')) return `refused: ${p}: read only files in ${base} or the Omega reference` + const abs = resolvePath(stripSelector(p).replace(/[*?{[].*$/, '') || '.', base) + let pack = CONTEXT + try { + pack = realpathSync(CONTEXT) + } catch {} + if (inside(abs, base) || inside(abs, pack)) return undefined + return `refused: ${p} is outside ${base} and the Omega reference ${pack}` +} + +type Compile = { rc: number; elf: string; report: string } + +function compile(file: string): Compile { + const bad = omcVerified() + if (bad) return { rc: -1, elf: '', report: `OMC REFUSED: ${bad}` } + const src = readFileSync(file) + const elf = join(BUILD, createHash('sha256').update(file).digest('hex').slice(0, 16)) + const r = spawnSync('sh', ['-c', '"$1" < "$2" > "$3" 2> "$3.err"', 'omc', OMC, file, elf]) + const rc = r.status ?? -1 + let err = '' + try { + err = readFileSync(`${elf}.err`, 'utf8').trim() + } catch {} + if (rc === 0) { + chmodSync(elf, 0o755) + return { rc, elf, report: `omc: compile rc=0 (${basename(file)}, pinned omc ${OMC_SHA256.slice(0, 8)})` } + } + const m = err.match(/line (\d+): error (\d+)/) + let detail = err || '(no diagnostic)' + if (m) { + const line = src.toString('utf8').split('\n')[Number(m[1]) - 1] ?? '' + detail = `${err}\n error ${m[2]} = ${ERRORS[Number(m[2])] ?? 'see the error table'}\n line ${m[1]}: ${line}` + } + return { rc, elf: '', report: `omc: compile FAILED rc=${rc} (${basename(file)})\n${detail}\nFix the .om source; never run output from a failed compile.` } +} + +function sandboxRun(elf: string, base: string, args: string[], stdin: string): { rc: number; out: string; err: string } { + const r = spawnSync( + 'bwrap', + ['--ro-bind', '/', '/', '--dev', '/dev', '--proc', '/proc', '--tmpfs', '/tmp', '--ro-bind', base, base, '--ro-bind', elf, '/tmp/prog', + '--unshare-net', '--unshare-pid', '--die-with-parent', '--chdir', base, '--', '/tmp/prog', ...args], + { input: stdin, timeout: 10_000, maxBuffer: 1 << 22 }, + ) + const cut = (b: Buffer | null) => { + const s = (b ?? Buffer.alloc(0)).toString('utf8') + return s.length > 8192 ? `${s.slice(0, 8192)}\n[... ${s.length - 8192} more bytes cut]` : s + } + return { rc: r.error ? -1 : (r.status ?? (r.signal ? 128 : -1)), out: cut(r.stdout), err: r.error ? String(r.error) : cut(r.stderr) } +} + +function trapNote(rc: number): string { + const traps: Record = { + 101: 'trap 1 signed overflow', 102: 'trap 2 divide by zero', 103: 'trap 3 index or slice out of bounds', 104: 'trap 4 loop bound exceeded', + 105: 'trap 5 conversion does not fit', 106: 'trap 6 stack exhausted', 107: 'trap 7 shift amount out of range', + } + if (rc < 0) return ' (did not finish: timeout or sandbox failure)' + if (traps[rc]) return ` (${traps[rc]})` + if (rc > 100 && rc <= 114) return ` (trap ${rc - 100})` + return '' +} + +export default function (pi: Pi) { + const touched = new Map() + const z = pi.zod + + const block = (tool: string, reason: string) => { + note(`tool ${tool} refused: ${reason}`) + return { block: true, reason } + } + + pi.on('tool_call', async (event: any, ctx: Ctx) => { + const base = root(ctx) + const tool = String(event.toolName) + if (!ALLOWED_TOOLS.has(tool)) return block(tool, `refused: ${tool} is not available in Omega mode; use omega_run to run .om programs`) + if (tool === 'edit' || tool === 'write') { + for (const p of writePaths(tool, event.input)) { + const why = checkWrite(p, base) + if (why) return block(tool, why) + } + } + if (tool === 'read' || tool === 'grep' || tool === 'glob') { + for (const p of readPaths(event.input)) { + const why = checkRead(p, base) + if (why) return block(tool, why) + } + } + note(`tool ${tool} allowed`) + return undefined + }) + + pi.on('tool_result', async (event: any, ctx: Ctx) => { + const tool = String(event.toolName) + if ((tool !== 'edit' && tool !== 'write') || event.isError) return undefined + const base = root(ctx) + const reports: string[] = [] + for (const p of writePaths(tool, event.input)) { + const abs = resolvePath(p, base) + if (!abs.endsWith('.om') || !existsSync(abs)) continue + const c = compile(abs) + touched.set(abs, c.rc) + reports.push(c.report) + note(`${tool} ${basename(abs)}: ${c.report.split('\n').slice(0, 2).join(' | ')}`) + } + if (reports.length === 0) return undefined + const content: Content[] = [...(event.content ?? []), { type: 'text', text: `\n${reports.join('\n')}` }] + return { content } + }) + + pi.registerTool({ + name: 'omega_run', + label: 'Omega run', + description: + 'Compile a .om file with the pinned seeded Omega compiler and, if it compiles, run it in a sandbox (read-only files, no network, 10 s). Returns the compiler diagnostic or the exit status, stdout and stderr. Exit status 101..114 is a runtime trap (100 + trap code).', + parameters: z.object({ + path: z.string().describe('the .om file to compile and run'), + stdin: z.string().optional().describe('bytes given to the program on standard input'), + args: z.array(z.string()).optional().describe('command-line arguments after the program name'), + }), + loadMode: 'essential', + async execute(_id: string, params: { path: string; stdin?: string; args?: string[] }, _signal: unknown, _onUpdate: unknown, ctx: Ctx) { + const base = root(ctx) + const abs = resolvePath(params.path, base) + const text = (t: string) => ({ content: [{ type: 'text', text: t }] }) + if (!abs.endsWith('.om') || !inside(abs, base) || !existsSync(abs)) return text(`omega_run: ${params.path} is not a .om file in ${base}`) + const c = compile(abs) + touched.set(abs, c.rc) + if (c.rc !== 0) { + note(`omega_run ${basename(abs)}: compile FAILED rc=${c.rc}`) + return text(c.report) + } + const r = sandboxRun(c.elf, base, params.args ?? [], params.stdin ?? '') + note(`omega_run ${basename(abs)}: run exit=${r.rc} stdout_bytes=${Buffer.byteLength(r.out)}`) + return text(`${c.report}\nrun exit status=${r.rc}${trapNote(r.rc)}\n--- stdout ---\n${r.out}\n--- stderr ---\n${r.err}`) + }, + }) + + let refusals = 0 + const refuse = (reason: string) => { + refusals += 1 + if (STOP_LIMIT > 0 && refusals > STOP_LIMIT) { + note(`stop allowed after ${STOP_LIMIT} refusals (OMEGA_STOP_LIMIT); last: ${reason.split('\n')[0]}`) + return undefined + } + note(`stop refused #${refusals}: ${reason.split('\n')[0]}`) + return { decision: 'block', reason } + } + + pi.on('session_stop', async (_event: unknown, ctx: Ctx) => { + const failing = [...touched].filter(([f, rc]) => rc !== 0 && existsSync(f)).map(([f]) => f) + for (const f of failing) { + const c = compile(f) + touched.set(f, c.rc) + if (c.rc !== 0) return refuse(`Not done: ${basename(f)} does not compile.\n${c.report}`) + } + const cases = process.env.OMEGA_CASES + if (!cases) { + note('stop allowed: every touched .om compiles; no OMEGA_CASES') + return undefined + } + const base = root(ctx) + const scratchParent = mkdtempSync(join(tmpdir(), 'aien-omega-gate-')) + const r = spawnSync( + 'bwrap', + ['--ro-bind', '/', '/', '--dev', '/dev', '--proc', '/proc', '--bind', scratchParent, scratchParent, '--unshare-net', '--unshare-pid', + '--die-with-parent', '--chdir', OMEGA_HOME, '--', GATE, OMC, OMC_SHA256, cases, join(scratchParent, 's')], + { cwd: base, timeout: 120_000, maxBuffer: 1 << 22 }, + ) + const out = (r.stdout ?? Buffer.alloc(0)).toString('utf8') + if (/^OM2GATE PASS /m.test(out)) { + note('stop allowed: OM2GATE PASS') + return undefined + } + const verdicts = out.split('\n').filter(l => l.startsWith('VERDICT') || l.startsWith('OM2GATE')).join('\n') + return refuse(`Not done: the task check did not pass.\n${verdicts || `gate exit ${r.status}`}\nRead the task again, fix the program, check it with omega_run, then finish.`) + }) +} + +export { checkRead, checkWrite, writePaths } diff --git a/coder/omega-observed.md b/coder/omega-observed.md new file mode 100644 index 0000000..715f7f5 --- /dev/null +++ b/coder/omega-observed.md @@ -0,0 +1,7 @@ + +## Observed with the pinned omc (2c824805) + +- `struct` definitions come before the first `fn`; a `struct` after a function is error 9. +- `global`, `const` and `text` may appear between functions. +- An `if` with an `else` arm: `if COND` ... `else` ... `end`. There is no `elif`; nest a second `if` + inside the `else` arm. diff --git a/coder/omega-prompt-head.md b/coder/omega-prompt-head.md new file mode 100644 index 0000000..4fc09f7 --- /dev/null +++ b/coder/omega-prompt-head.md @@ -0,0 +1,21 @@ +# Omega coder + +You write programs in Omega (`.om` source), compiled by the pinned seeded Omega compiler `omc` +(sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`, aien-dev/omega-mv +`f1b9ecb5d`). Programs run on a Linux AArch64 host. + +Rules: +- Write only `.om` files (and `NOTES.md` for notes) inside the working directory. The harness refuses + every other write. Never write C, Python, shell or any other language, and never present a + program in another language as Omega. +- After each write or edit of a `.om` file the harness compiles it and appends either + `omc: compile rc=0` or `omc: compile FAILED rc=N` with the error meaning and the offending line. + Fix every failure before going on. +- Call the `omega_run` tool with the file path and the task's standard input to compile and run the + program. Compare its exit status and stdout with what the task asks for, and fix the program until + they match. Exit status 101..114 is a runtime trap (100 + trap code). +- You are not done until the program compiles and its run matches the task. When a task has a run + check, the harness runs it when you stop and sends you back if it fails. +- If Omega cannot express something, say which word or capacity is missing. Do not work around it in + another language. +- Keep replies short. When the program works, reply with one line: `DONE `. ```