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
omega-mv / bench / inference_cost / README.md
| 1 | # Inference-Cost Benchmark: Tokens per Verified Program |
| 2 | |
| 3 | This benchmark measures the metric from Drake Stapleton's Omega/encoder essay, |
| 4 | **verified programs produced per unit of inference cost**. It compares Omega, C, Python and Rust on the |
| 5 | same 20 held-out tasks. |
| 6 | |
| 7 | A model writes one function per task. The harness compiles it, runs it on hidden inputs and compares |
| 8 | the output. Token counts come only from the `usage` object the endpoint reports; nothing is estimated. |
| 9 | |
| 10 | Two arms run for every language: |
| 11 | - **plain**: the same two messages (system, user) are sent for up to K attempts. |
| 12 | - **feedback**: after a failed attempt, the conversation grows by the model's code (assistant) and a |
| 13 | user message holding the compiler's diagnostic, or "wrong results (exit status N)". Omega candidates |
| 14 | are compiled as `om2 diag` units, so the feedback carries both `omc: line N: error K` and the |
| 15 | `omc-diag 1 code=... line=... col=...` record. |
| 16 | |
| 17 | Each task stops at its first verified attempt. |
| 18 | |
| 19 | ## Run against a real model |
| 20 | |
| 21 | The model server must be up first. This harness never starts one. |
| 22 | |
| 23 | ```sh |
| 24 | sh bench/inference_cost/driver.sh --run-model --endpoint http://127.0.0.1:18091 --model <model-id> \ |
| 25 | --langs om,c,py,rs --arms plain,feedback --attempts 3 |
| 26 | ``` |
| 27 | |
| 28 | - `--endpoint` is required and has no default; requests go to `<endpoint>/v1/chat/completions` with |
| 29 | `"stream":false`. |
| 30 | - The other options and their defaults are `--temperature 0.2`, `--max-tokens 4096` and |
| 31 | `--out build/inference_cost/run-<utc>-<pid>`. |
| 32 | - A missing endpoint, a curl failure, a non-200 status other than 503, or a body without `usage` (or |
| 33 | with an `error` member) prints `NOT_RUN: ...` and exits 3. Logs written up to that point are kept. |
| 34 | - HTTP 503 means the endpoint is busy (the live server generates one reply at a time and answers a |
| 35 | concurrent request with 503). The same request is sent again every `BENCH_BUSY_SLEEP_S` seconds |
| 36 | (default 2) until another status comes back; once `BENCH_BUSY_WAIT_S` seconds (default 1800) have |
| 37 | passed since its first send, the run is NOT_RUN exit 3 (`BENCH_BUSY_WAIT_S=0`: no retry). A 503 |
| 38 | carries no usage and adds no tokens; the attempt's wall time starts at the request that was answered. |
| 39 | - `--out` must be absent or an empty real directory, including hidden files. Symbolic links |
| 40 | (including names with trailing slashes) and nonempty directories are refused with exit 2 before |
| 41 | any run files change. An atomic, persistent `.inference-cost-owner/` marker allows exactly one |
| 42 | invocation to claim the output; a post-claim emptiness check closes concurrent creation races. |
| 43 | Completed, interrupted and already-claimed runs are never reused. |
| 44 | - `--langs` and `--arms` require nonempty comma-separated lists without empty elements. |
| 45 | - Bubblewrap is mandatory and fails closed: missing `bwrap` or unavailable namespaces give NOT_RUN |
| 46 | exit 3, never unsandboxed compilation or execution. GNU `timeout`, system Python, C and Rust |
| 47 | toolchains are required for the corresponding self-test paths. |
| 48 | - Every sandboxed compile and run has a kernel-enforced memory ceiling (see "Memory ceiling"). If it |
| 49 | cannot be applied the driver gives NOT_RUN exit 3, never an unbounded run. `BENCH_MEM_MAX_BYTES` |
| 50 | sets it (67108864 to 4294967296; anything else exits 2); the default is 536870912. |
| 51 | |
| 52 | The run directory holds: |
| 53 | |
| 54 | | file | content | |
| 55 | |---|---| |
| 56 | | `run.txt` | endpoint, requested model, `models_reported` (the ids the endpoint returned), options, omc sha256, `task_set_sha256`, `memory_max_bytes`, times | |
| 57 | | `calls.txt` | one line per HTTP call: task lang arm attempt http_code model prompt completion total http_ms | |
| 58 | | `busy.txt` | one line per attempt: task lang arm attempt, the 503 answers before it was answered, and the ms spent waiting | |
| 59 | | `memory.txt` | one line per attempt: task lang arm attempt, the peak bytes of the compile and of the run (`-` when not run), and `none`, `compile` or `run` for a kill by the memory ceiling | |
| 60 | | `attempts.txt` | the attempt wire, version 2, read by `scorer.om` | |
| 61 | | `summary.txt` | the scorer report | |
| 62 | | `<lang>/<arm>/<task>/conv/` | the messages sent | |
| 63 | | `<lang>/<arm>/<task>/a<N>/` | request.json, response.json, candidate, compiler and run output | |
| 64 | |
| 65 | The driver prints one line per (lang, arm): verified/attempted tasks, attempts, first-attempt |
| 66 | verified, total tokens, tokens per verified program, verified per 1k tokens and verified per minute. |
| 67 | |
| 68 | `task_set_sha256` names the exact tasks and prompts of a run: `(cd bench/inference_cost && find tasks |
| 69 | prompts -type f | LC_ALL=C sort | xargs sha256sum) | sha256sum`, first field. Runs with different |
| 70 | digests were given different tasks or prompts and are not comparable. |
| 71 | |
| 72 | ## Not run yet |
| 73 | |
| 74 | - **No complete real-model run exists.** The first real run (2026-11-11, `qwen3.6-35b-a3b-fp8` on the |
| 75 | local endpoint, this driver at `3ab566f8`) ended NOT_RUN when the endpoint stopped answering. Seven |
| 76 | of its eight (language, arm) groups had finished and are filed as a partial result in benchmarks-mv |
| 77 | (`rad:z2nYCN9XZAPjNohqT8bz46rcs9zvZ`, commit `1031e01a`, `evidence/inference-cost-qwen36-20261111/`). |
| 78 | The three-run result and the frontier line are NOT_RUN (no authorized frontier endpoint). |
| 79 | - Wall time in the self-test is the fake model's latency plus local compile and run time. It says |
| 80 | nothing about inference speed. |
| 81 | |
| 82 | ## Self-test and task check |
| 83 | |
| 84 | ```sh |
| 85 | sh bench/inference_cost/driver.sh --check-tasks # every reference verifies, every mutant is rejected |
| 86 | sh bench/inference_cost/driver.sh --self-test # also run by `make test-inference-cost` |
| 87 | ``` |
| 88 | |
| 89 | `--self-test` performs these checks, in order: |
| 90 | |
| 91 | 1. **Build.** Checks the compiler pin: the sha256 of `seed/out/omc` must equal `seed/out/omc.sha256`, |
| 92 | otherwise NOT_RUN exit 3. Then builds `scorer`, `chat` and `fake_model` into |
| 93 | `build/inference_cost/bin`. |
| 94 | 2. **Scorer rejections.** Both wire versions reject trailing rows, contradictory compile/verified |
| 95 | flags, nonboolean flags, skipped/repeated attempts, and attempts after a task has verified. |
| 96 | Interleaved task identities count once, separately in each language/arm group. |
| 97 | 3. **Chat edge.** An error object, a body without usage, and a non-JSON body each give exit 4. |
| 98 | 4. **`--check-tasks`.** |
| 99 | 5. **Fake-model runs.** `fake_model` listens on an ephemeral 127.0.0.1 port, and every reply reports |
| 100 | usage 111/37/148. Five runs, all over om, c, py and rs: |
| 101 | |
| 102 | | mode | arms, attempts | expected | |
| 103 | |---|---|---| |
| 104 | | `good` | plain, 1 | 20/20 per language, with exact token sums, no 503, and run.txt naming the task set | |
| 105 | | `bad` | plain, 1 | every mutant compiles and none verifies | |
| 106 | | `bad-then-good` | plain + feedback, 2 | feedback verifies all 20 on attempt 2 with both attempts' tokens summed; plain verifies 0 | |
| 107 | | `refuse` | plain, 1 | compiles 0 and verifies 0, and no binary is ever run | |
| 108 | | `busy` | plain, 1 | every request answers 503 once, then 200: 20/20 per language with the token sums of `good` | |
| 109 | |
| 110 | The task-set digest of a copy of `tasks/` and `prompts/` equals the driver's, and one added byte in |
| 111 | `tasks/task01/expected.txt` or `prompts/system-om.txt` changes it. |
| 112 | |
| 113 | 6. **NOT_RUN paths.** An unreachable endpoint (the fake is killed first), an HTTP 404, a missing |
| 114 | `--endpoint`, `busy` with `BENCH_BUSY_WAIT_S=0`, and the `down` fake (503 on every request) past |
| 115 | `BENCH_BUSY_WAIT_S=1` each give exit 3; a nonnumeric `BENCH_BUSY_WAIT_S` gives exit 2. |
| 116 | 7. **Adversarial boundaries.** Oracle-reading Python, host writes, C/Rust compile-time oracle reads, |
| 117 | a TERM-ignoring process with a descendant, an unavailable sandbox, empty workloads, reused or |
| 118 | symlinked output directories, and competing output claimants are permanent shell-driven controls |
| 119 | in `audit.sh`; a namespace init that never exits is refused NOT_RUN by the teardown wait below. |
| 120 | Good, bad, mixed-arm and |
| 121 | compiler-refusal runs assert both the group and global PASS/FAIL strings, not only counters. |
| 122 | 8. **Memory ceiling** (`audit.sh`, `memory_checks`). Per language, a correct task01 candidate that |
| 123 | first writes every page of the ceiling plus 256 MiB is killed and scored wrong (`MEM_KILL=run`), |
| 124 | and the same candidate at half the ceiling verifies. A mutant driver with the ceiling line |
| 125 | removed lets the over-ceiling C candidate verify, so it fails that check. A `systemd-run` that |
| 126 | runs the command outside a new scope, and one that cannot reach the user manager, each stop |
| 127 | `--run-model` at the preflight (NOT_RUN exit 3, no run directory) and a compile at the sandbox |
| 128 | (NOT_RUN exit 3); a `systemd-run` that fails once before any scope exists is retried and the |
| 129 | reference verifies with the failure kept out of its stderr; `BENCH_MEM_MAX_BYTES` of 0, 67108863, |
| 130 | 4294967297 and `1G` exit 2. The `good` |
| 131 | run's `memory.txt` shows compile and run peaks below the ceiling and no kill for every attempt. |
| 132 | |
| 133 | ## Handover rule |
| 134 | |
| 135 | `handover.om` decides, from scoreboard results only and with no person in the loop, whether a |
| 136 | candidate model takes over one job (a language and an arm) from the incumbent model. **No real |
| 137 | handover has been decided yet**: every verdict so far comes from the TEST DATA in |
| 138 | `tests/handover/data/`, hand-edited copies of a fake-model self-test run. |
| 139 | |
| 140 | ```sh |
| 141 | { printf 'om2\n'; cat om/tls/sha2.om; sed '/^fn main to int$/,$d' bench/inference_cost/scorer.om |
| 142 | cat bench/inference_cost/handover.om; } | seed/out/omc > handover && chmod +x handover |
| 143 | ./handover LANG ARM PERMFILE INCUMBENT_RUN CANDIDATE_RUN... |
| 144 | sh bench/inference_cost/tests/handover/run.sh # also run by `make test-inference-cost` and `make test-handover` |
| 145 | ``` |
| 146 | |
| 147 | The inputs are one incumbent run directory and the candidate run directories (each written by |
| 148 | `driver.sh --run-model`, holding `run.txt` and `attempts.txt`), the job, and a permanent-case list: |
| 149 | a file of task ids, separated by whitespace, that must never fail again (it may be empty). |
| 150 | |
| 151 | The rule, in integer counts only: |
| 152 | |
| 153 | 1. **Comparable.** Every run names the incumbent's `task_set_sha256` and `omc_sha256` and has |
| 154 | records for the job; every candidate run reports exactly one model and has the same |
| 155 | `model_requested` and `models_reported` as the first candidate run. Otherwise the answer is |
| 156 | REFUSED, never NO and never YES. |
| 157 | 2. **Enough evidence.** At least 3 candidate runs, in distinct directories (compared by device and |
| 158 | inode, so `a` and `./a/` are one directory) with distinct `started` times. Otherwise REFUSED. |
| 159 | 3. **Not worse.** In every candidate run, the number of verified tasks for the job is at least the |
| 160 | incumbent run's number. Equal counts pass. |
| 161 | 4. **Permanent cases.** In every candidate run, every permanent case is verified for the job. |
| 162 | 5. **Complete runs.** A run with a line starting `NOT_RUN` or `interrupted` in `run.txt`, a |
| 163 | `NOT_RUN` file, no `finished` line, a leftover `rows.txt` (the driver stopped before writing |
| 164 | `attempts.txt`), no `run.txt` or `attempts.txt`, or an `attempts.txt` that the scorer refuses |
| 165 | (truncated or malformed, or version 1, which has no language or arm) makes the answer REFUSED. |
| 166 | |
| 167 | REFUSED (rule 1, 2 or 5) wins over NO; the answer is NO when rule 3 or 4 fails, and YES otherwise. |
| 168 | The first output line is exactly `HANDOVER YES`, `HANDOVER NO` or `HANDOVER REFUSED`. One line per |
| 169 | rule follows with the counts that decided it (rules 3 and 4 say `NOT_EVALUATED` when the answer |
| 170 | is REFUSED), then `sha256 <hex> <path>` for the permanent-case list and for each run's `run.txt` and |
| 171 | `attempts.txt` in argument order, so the decision can be rechecked from the same files. Exit |
| 172 | status: 0 YES, 1 NO, 2 REFUSED, 3 usage (fewer than one candidate, an unknown language or arm, an |
| 173 | unreadable permanent-case list; nothing is printed on stdout). |
| 174 | |
| 175 | The wire is read by `scorer.om`'s own functions and tables, unchanged: the build leaves out only |
| 176 | scorer.om's `fn main` (a unit has one main), and `handover.om` repeats that main's version-2 header |
| 177 | loop. The scorer stops the process with exit 2 on a malformed wire, so each `attempts.txt` is |
| 178 | first read in a forked child; the parent reads it again only after the child exited 0. Digests |
| 179 | come from `om/tls/sha2.om`. The files must not change while the program runs. |
| 180 | |
| 181 | `tests/handover/run.sh` runs the known-verdict cases in `tests/handover/cases.txt` (every outcome |
| 182 | and rule; equal counts is YES; one run one task short is NO; a permanent case failed in one of |
| 183 | three runs is NO; two runs, duplicate start times, the same directory twice, mixed task-set |
| 184 | digests, another omc, another candidate model, a NOT_RUN marker, an interrupted run and a |
| 185 | truncated wire are REFUSED; usage errors exit 3), checks the printed digests against `sha256sum`, |
| 186 | and builds each mutant in `tests/handover/mutants.txt` from a temporary copy of `handover.om` |
| 187 | (`at least` made `more than`, every made any for rules 3 and 4, the comparability check removed, |
| 188 | the run-count check removed). It exits 1 if any case fails or any mutant passes every case. |
| 189 | |
| 190 | ## Files |
| 191 | |
| 192 | | file | role | |
| 193 | |---|---| |
| 194 | | `driver.sh` | POSIX sh glue: assembles candidates, runs compilers and curl, writes records | |
| 195 | | `chat.om` | the only JSON code (composed with `seed/json/json.om` and `jsonw.om`). `chat req` turns the request wire into the OpenAI request body. `chat resp` reads a response: usage, model id, and the code block (after the last `</think>`, the first fenced block) on fd 3 | |
| 196 | | `fake_model.om` | an OpenAI-compatible fake on `seed/net/http.om`. Modes `good`, `bad`, `bad-then-good` (reference only when the conversation has 3 or more messages), `refuse`, `busy` (503 on every other request) and `down` (503 always). Uses headers `X-Bench-Task` and `X-Bench-Lang` | |
| 197 | | `scorer.om` | reads the attempt wire (v1 or v2) and writes the summary | |
| 198 | | `io.om` | stdin/stdout helpers appended after an Omega candidate | |
| 199 | | `audit.sh` | permanent F1-F8 adversarial self-test controls, sourced by the driver | |
| 200 | | `prompts/system-<lang>.txt` | system prompts; the Omega one is a compact language primer | |
| 201 | | `tasks/taskNN/` | `statement.txt`, `spec.txt`, `inputs.txt`, `expected.txt`, and `reference.<lang>` plus `mutant.<lang>` for om, c, py and rs | |
| 202 | |
| 203 | ## Candidate assembly and verification |
| 204 | |
| 205 | The model writes only the function. The harness appends a stdin driver generated from `spec.txt`: it |
| 206 | reads `inputs.txt` and prints one decimal per case. A candidate is verified when: |
| 207 | - it compiles with exit 0; |
| 208 | - the run exits 0 within 10 s (TERM at 10 s, hard KILL after a further 1 s); |
| 209 | - its output equals the cases of `expected.txt` byte for byte. |
| 210 | |
| 211 | A compiler refusal is never verified and its output is never run. |
| 212 | |
| 213 | Both compilation and execution happen in separate bubblewrap sandboxes with all namespaces |
| 214 | unshared, no network, a cleared environment, no home/credentials or checkout mount, a fresh `/tmp`, |
| 215 | and read-only candidate and system runtime mounts. Compiler sandboxes additionally expose system |
| 216 | headers/tools; Rust exposes only the selected toolchain's compiler and libraries, not its home. |
| 217 | Inputs enter on stdin and compiler/runtime output leaves on stdout/stderr. The verifier and all |
| 218 | oracle files remain outside. Compilation has the same bounded deadline as execution. Setup failure |
| 219 | aborts the run. A trusted shell inside the fully configured sandbox closes all inherited caller |
| 220 | descriptors except stdin/stdout/stderr and its dedicated readiness descriptor. It emits a readiness |
| 221 | handshake, closes that descriptor, then executes candidate-controlled code. The host requires that |
| 222 | handshake for compilation and execution; bubblewrap namespace JSON alone is not readiness evidence |
| 223 | because it is emitted before mount setup. Permanent tests exercise late compiler/runtime mount |
| 224 | failures with real bubblewrap and assert NOT_RUN, descriptor closure, and denial of inherited host |
| 225 | file reads at both compile time and runtime. After each compile and each run the driver waits up to |
| 226 | 5 s for the sandbox's namespace init (bubblewrap's `child-pid`) to be gone and gives NOT_RUN if it |
| 227 | is not: after a deadline kill the teardown finishes asynchronously (seen once in 15 tries with the |
| 228 | memory ceiling in place, gone 1 s later), and nothing may outlive its attempt. |
| 229 | |
| 230 | **Memory ceiling.** Each compile and each run executes inside a transient cgroup scope, `systemd-run --user --scope -p |
| 231 | MemoryMax=<ceiling> -p MemorySwapMax=0 -p OOMPolicy=continue`, around bubblewrap. The kernel counts |
| 232 | every process of the scope (launcher, bubblewrap, compiler or candidate and all their children) and |
| 233 | OOM-kills inside the scope when the ceiling is reached, so a candidate cannot take memory from the |
| 234 | host or from the model server. The scope's first process reads back its own cgroup's `memory.max` |
| 235 | and `memory.swap.max` and runs nothing unless they are exactly the ceiling and 0; after the command |
| 236 | it writes `memory_peak_bytes` and `memory_oom_kills` beside bubblewrap's JSON on descriptor 4. A |
| 237 | compile with an OOM kill never counts as compiled, and a run with an OOM kill is a failed attempt |
| 238 | whatever it printed; both are recorded in `memory.txt`, and the feedback arm tells the model its |
| 239 | code (or the compiler) was killed for exceeding the ceiling. When `XDG_RUNTIME_DIR` is unset the |
| 240 | driver uses `/run/user/<uid>` to reach the user manager. A `systemd-run` that fails before its scope |
| 241 | started (seen once under load: "Failed to start transient scope unit: Transport endpoint is not |
| 242 | connected") has run nothing, so it is tried again, 5 times in all, 1 s apart, and only then reported |
| 243 | (NOT_RUN). Exercised with systemd 255 on Linux 7.0 |
| 244 | (cgroup v2, memory controller delegated to the user manager). |
| 245 | |
| 246 | The ceiling was set from measurement: `--check-tasks` was run four times with a 4 GiB ceiling (three |
| 247 | times with omc `1e628c80`, once with omc `2495bc25`) and the scope peak of every compile and run read |
| 248 | from `memory.peak`. The heaviest was the Rust compile of `task01/reference.rs`, 100696064 bytes |
| 249 | (about 96 MiB); the heaviest runs were 5775360 bytes (Python) and 2150400 bytes (Rust), and Omega |
| 250 | compiles stayed under 2.2 MB. The default ceiling, 536870912 bytes (512 MiB), is 5.33 times the |
| 251 | heaviest peak (416 MiB above it). |
| 252 | |
| 253 | The host dependencies exercised here are bubblewrap 0.9.0 (Linux namespaces/mounts), GNU coreutils |
| 254 | `timeout` 9.4 (host deadline), Bash 5.2.21 (sandbox-only trusted launcher, mounted as `/usr/bin/sh`) |
| 255 | and systemd 255 `systemd-run --user --scope` (memory ceiling). |
| 256 | The driver itself remains POSIX sh. The launcher needs arbitrary numeric descriptor redirections, |
| 257 | which dash cannot perform above fd 9; it validates the kernel-provided numeric descriptors before |
| 258 | closing them. These are isolation/verification infrastructure, not Omega implementations. Their |
| 259 | Omega replacement would require a qualified namespace/mount, process-tree and descriptor supervisor; |
| 260 | no such replacement is claimed here. |
| 261 | |
| 262 | | lang | assembled as | compile | |
| 263 | |---|---|---| |
| 264 | | om | `om2 diag`, candidate, `io.om`, generated `fn main` | pinned `seed/out/omc` | |
| 265 | | c | candidate, generated `main` | `cc -O2 -include stdint.h -include stdio.h -include stdlib.h ... -lm` | |
| 266 | | py | candidate, generated `_bench_main()` (the result must be an `int`) | `python3 -m py_compile`, run with `python3 -I` | |
| 267 | | rs | candidate, generated `fn main` | `rustc -O --edition 2021 -A warnings` | |
| 268 | |
| 269 | For an Omega candidate, line 1 of the compiled unit is the added `om2 diag` line. A leading `om2...` line |
| 270 | written by the model is dropped. |
| 271 | |
| 272 | ## Wire formats (plain text, no JSON) |
| 273 | |
| 274 | ### Task specification (`spec.txt`) |
| 275 | ```text |
| 276 | version 2 |
| 277 | name <function_name> |
| 278 | param <name> <u32|i32|u64> (one line per parameter, in order) |
| 279 | ret <u32|i32|u64> |
| 280 | ``` |
| 281 | |
| 282 | ### Hidden inputs and expected outputs |
| 283 | ```text |
| 284 | version 1 |
| 285 | cases <N> |
| 286 | <arguments for case 1, or its expected value> |
| 287 | ... |
| 288 | ``` |
| 289 | |
| 290 | ### Chat request wire (`chat req`) |
| 291 | ```text |
| 292 | version 1 |
| 293 | model <id> |
| 294 | max_tokens <N> |
| 295 | temperature <JSON number> |
| 296 | messages <K> |
| 297 | msg <system|user|assistant> <NB> |
| 298 | <NB bytes> |
| 299 | ... |
| 300 | ``` |
| 301 | A malformed wire exits 2; a writer refusal exits 3. |
| 302 | |
| 303 | `chat resp` writes `version 1`, `model`, `prompt_tokens`, `completion_tokens`, `total_tokens` and |
| 304 | `code_bytes` lines. It exits 4 on a missing usage object, an error object, no choices, or a body that |
| 305 | is not JSON. |
| 306 | |
| 307 | ### Attempt records (`attempts.txt`) |
| 308 | Version 2: |
| 309 | ```text |
| 310 | version 2 |
| 311 | attempts <N> |
| 312 | <task_id> <lang> <arm> <attempt_num> <first_attempt> <compiled_rc> <verified_flag> <wall_ms> <prompt_tokens> <completion_tokens> <total_tokens> |
| 313 | ``` |
| 314 | - `lang` is one of `om c py rs`; `arm` is one of `plain feedback`. |
| 315 | - `wall_ms` runs from the request until verification ends (model latency plus compile and run). |
| 316 | |
| 317 | Version 1 (still accepted) has no `lang` or `arm` column: |
| 318 | `<task_id> <attempt_num> <first_attempt> <compiled_rc> <verified_flag> <wall_ms> <prompt_tokens> <completion_tokens> <total_tokens>`. |
| 319 | |
| 320 | Rejection rules: |
| 321 | - An unknown version exits 3. |
| 322 | - A line count different from `attempts <N>`, a non-numeric field, or an unknown lang or arm exits 2. |
| 323 | - Input of 983040 bytes or more exits 2. |
| 324 | - `first_attempt` and `verified_flag` must be 0 or 1; a nonzero `compiled_rc` cannot verify. |
| 325 | - Task identity is exact within each language/arm group. Attempts start at 1, advance by one, |
| 326 | mark only attempt 1 as first, and stop on verification. Repeated task successes are invalid, |
| 327 | not additional verified programs. The same rules apply to version 1. |
| 328 | |
| 329 | ### Summary (`summary.txt`) |
| 330 | A version-1 input gives the version-1 summary (`version 1`, `tasks_total` ... `status`). |
| 331 | |
| 332 | A version-2 input gives one block per (lang, arm) present, in the order om, c, py, rs × plain, |
| 333 | feedback: |
| 334 | ```text |
| 335 | version 2 |
| 336 | groups <G> |
| 337 | group <lang> <arm> |
| 338 | tasks_total <N> |
| 339 | attempts_total <N> |
| 340 | compiled_count <N> |
| 341 | verified_count <N> |
| 342 | first_attempt_verified <N> |
| 343 | total_prompt_tokens <N> |
| 344 | total_completion_tokens <N> |
| 345 | total_tokens <N> |
| 346 | total_wall_ms <N> |
| 347 | total_wall_seconds <N> |
| 348 | tokens_per_verified <fixed3>|none |
| 349 | verified_per_1k_tokens <fixed3> |
| 350 | verified_per_minute <fixed3> |
| 351 | status PASS|FAIL |
| 352 | end |
| 353 | ... |
| 354 | status PASS|FAIL |
| 355 | ``` |
| 356 | - A group's `status` is PASS when every task in it verified. |
| 357 | - Exit status: 0 when every group passes, 1 when any fails (a valid result for a model run), 2 for |
| 358 | malformed input, 3 for an unknown version. |
| 359 | |
| 360 | The rates: |
| 361 | - `tokens_per_verified` $= T_{\text{total\_tokens}} / V$ |
| 362 | - `verified_per_1k_tokens` $= (V \times 1000) / T_{\text{total\_tokens}}$ |
| 363 | - `verified_per_minute` $= (V \times 60) / T_{\text{total\_seconds}}$ |
| 364 | |
| 365 | ## Tasks |
| 366 | |
| 367 | | task | function | computes | |
| 368 | |---|---|---| |
| 369 | | `task01` | `clamp_add_u16` | saturated 16-bit addition | |
| 370 | | `task02` | `absdiff_i32` | exact $\lvert a - b\rvert$ as u64 | |
| 371 | | `task03` | `popcount_u32` | set bits | |
| 372 | | `task04` | `gcd_u32` | greatest common divisor | |
| 373 | | `task05` | `isqrt_u32` | $\lfloor\sqrt{x}\rfloor$ | |
| 374 | | `task06` | `collatz_steps_u32` | steps to 1 under $3n + 1$ | |
| 375 | | `task07` | `bitrev_u16` | 16-bit reversal | |
| 376 | | `task08` | `fibonacci_u32` | $F_n \bmod 2^{32}$ | |
| 377 | | `task09` | `factorial_u32` | $n! \bmod 2^{32}$ | |
| 378 | | `task10` | `is_prime_u32` | primality | |
| 379 | | `task11` | `parity_u32` | bit parity | |
| 380 | | `task12` | `clz_u32` | leading zero bits | |
| 381 | | `task13` | `ctz_u32` | trailing zero bits | |
| 382 | | `task14` | `power_mod_u32` | $a^b \bmod 2^{32}$ | |
| 383 | | `task15` | `min3_i32` | minimum of three | |
| 384 | | `task16` | `max3_i32` | maximum of three | |
| 385 | | `task17` | `sum_digits_u32` | sum of decimal digits | |
| 386 | | `task18` | `reverse_digits_u32` | reversed decimal digits | |
| 387 | | `task19` | `hamming_dist_u32` | Hamming distance | |
| 388 | | `task20` | `rot_left_u32` | 32-bit left rotation | |
| 389 | |
| 390 | Each `statement.txt` is language-neutral; the per-language signature is added to the user prompt. |
| 391 | |
| 392 | ## Reusing the referee (DRA-122) |
| 393 | |
| 394 | Training-data admission reuses the same assembly, hidden inputs, exact-output comparison and mandatory |
| 395 | bubblewrap compiler/runtime sandboxes as benchmark attempts. It does not trust an old attempt verdict. |
| 396 | |
| 397 | ```sh |
| 398 | sh bench/inference_cost/driver.sh --verify-candidate om task01 \ |
| 399 | "$PWD/bench/inference_cost/tasks/task01/reference.om" "$PWD/build/referee-new" |
| 400 | sh bench/inference_cost/driver.sh --task-set-sha256 |
| 401 | seed/out/omc < bench/inference_cost/verify-test.om > build/verify-test |
| 402 | chmod +x build/verify-test |
| 403 | build/verify-test "$PWD" "$PWD/build/verify-test-new" |
| 404 | ``` |
| 405 | |
| 406 | The referee interface takes exactly LANG TASK_ID CANDIDATE ABS_WORK. LANG is om/c/py/rs; TASK_ID |
| 407 | must be an existing taskNN identity, not a path. Both paths must be absolute and traversal-free, |
| 408 | with no symlink component; CANDIDATE must be a regular file and ABS_WORK absent or an empty real |
| 409 | directory. ABS_WORK is claimed atomically and never reused. Its eval/ child retains the assembled |
| 410 | source, compiler diagnostics, stdout and sandbox readiness receipts. No model is called. |
| 411 | |
| 412 | Statuses are 0 verified now, 1 compiled/run result did not verify (including compiler refusal), |
| 413 | 2 refused arguments/paths, and 3 NOT_RUN (pin, dependency or sandbox unavailable). The printed |
| 414 | COMP_RC/RUN_RC/VERIFIED line is evidence about this execution, not an old verdict. The digest mode |
| 415 | uses exactly task_set_sha256(), the same definition written into run.txt; it takes no arguments. |
| 416 | |
| 417 | verify-test.om exercises all four languages, wrong results, compiler refusal, unknown language/task, |
| 418 | traversal, candidate symlink, relative candidate, reused work, wrong compiler and unavailable sandbox. |
| 419 | Its three source-removal mutants must be caught: accepting wrong results, accepting task traversal, |
| 420 | and skipping the preflight sandbox check. The existing --check-tasks and --self-test modes retain |
| 421 | their prior contracts and checks. |
| 422 | |
| 423 | These modes are part of the existing shell driver, still awaiting migration. The seeded-Omega |
| 424 | namespace/mount, process-tree and descriptor supervisor successor is **not yet written**. The |
| 425 | first-party dataset admission/serialization tool lives in aien-train/tools/verified_examples; |
| 426 | it does not duplicate this sandbox or claim the shell dependency is Omega. |