Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
About Files History Releases Proposed changes Issues For developers
GitHub aien-dev/omega-mv#915 (code only)
closed derived eedf4c06e3b4b07b #915
Imported from GitHub aien-dev/omega-mv#915 (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 62d1d0d668f897386a0e311374f8dbcc5c32dde8 · Head 15efb8948cb66ae935a082dab91be75ecf58927b
drakestapleton reviewed (COMMENTED) on 2026-10-30 11:33 UTC
Bench audit (audit.sh, driver.sh, scorer.om) looks reasonable and checks are green, but the body says "no merge requested" and it overlaps the #912-related fix. Please state its relationship to #912 and whether it should be merged at all before anyone merges it.
— Grokbot
Fetch it
A git bundle of the pull request's head, 18008 bytes.
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/eedf4c06e3b4b07b .bundle -o eedf4c06e3b4b07b .bundle
git fetch eedf4c06e3b4b07b .bundle refs/pull/915/head
Raw bundle · 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-mv
915
15efb8948cb66ae935a082dab91be75ecf58927b
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":915,"url":"https://github.com/aien-dev/omega-mv/pull/915","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452 ","imported_utc":"2026-11-18T16:39:19Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb
index f3e51fe46 ..fb8a4717b 100644
--- a/.crumb
+++ b/.crumb
@@ -72,7 +72,7 @@
},
{
"digest": "f765ad87fdddd9b47f690b07298c951a0f7e7675dc5de4ffe44e33a0c14b1986 ",
- "last_commit": "a8a6a3d3c ",
+ "last_commit": "d94a503f7 ",
"name": "spec",
"purpose": "Directory spec. Purpose not yet described by a human."
},
@@ -84,26 +84,26 @@
},
{
"digest": "5395ff8ff9afceebe8e453788f80a3064b831513cc4cb92fd55869115e06b874 ",
- "last_commit": "a8a6a3d3c ",
+ "last_commit": "dcccc0211 ",
"name": "tests",
"purpose": "Directory tests. Purpose not yet described by a human."
},
{
"digest": "308db0e6cf45c0a48f01f5f5f228450f191389de68006915b9ecf9c65b9a2e29 ",
- "last_commit": "a8a6a3d3c ",
+ "last_commit": "a50c3bd41 ",
"name": "tools",
"purpose": "Directory tools. Purpose not yet described by a human."
}
],
"children_root": "sha256:07bf1706dcffbad66c0353871ff67a6749055da03cee8d8ebdf9a4c91e36bddc ",
- "compiled_at": "2026-10-30T12:31:50Z",
+ "compiled_at": "2026-10-30T16:29:04Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:904fca8c0e0cf3e3a5e5adb73393e01c7018b920bb542d289904240f70e400d6 ",
+ "digest": "sha256:145642bc89d576e2614c2880b07804488e9369307a4d13f55cf04c7396f2e476 ",
"evidence_files": 12622,
"evidence_root": "sha256:b1a08e2ce56e6feada0d8a31f06fbd7adee57adc1c1ad8dec220293ee5d439f9 ",
- "files": 17849,
- "generated_at_commit": "52a82f392fa513ebbc2d9d719a0f14c385289b06 ",
- "source_tree": "sha256:75458da6553a0ee5ea2af95f46afb658e8a3f6e53cca6e3b4b9874035f78c2ed "
+ "files": 17850,
+ "generated_at_commit": "30a54e64589db9b65d24ba595ef0a610ad35d341 ",
+ "source_tree": "sha256:7c95a05d1eae5990bd3f40252a6694204823fb08a90298b49a01c933fac8509e "
},
"owner_lane": "",
"provenance": {
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index dda6d20b5 ..d07ebcf59 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -11,6 +11,7 @@ Every model below did real work. A model is listed only for work it did. The orc
| Codex (GPT-6.1 Sol) | FR-9 x86-64 Linux backend integration from historical 7eca2ac3f , full-language lowering, contract-loop/output-capacity/dead-branch repairs, division/shift proof-aware diagnostics, original-conductor and historical-mutant qualification repair, independent disassembly and cross-architecture qualification; orphaned-lane recovery, current mutation re-anchoring and x86 OM-2 emitted-storage bound |
| Codex (GPT-6.1 Sol) | TileLab decimal-overflow and malformed-register-budget refusal repair, host regression fixtures and semantic negative controls (TL907-01) |
| Codex (GPT-6.1 Sol) | Corrected qty prefix-query types and capacity-only diagnostic repairability, with exact-record regression controls (#911) |
+| Codex (GPT-6.1 Sol) | Inference-cost audit F1-F8: fail-closed compiler/runtime sandboxes, hard process deadlines, strict task-identity scoring and adversarial self-tests |
| Codex | Inference-cost driver compiler-failure status repair, host-only refusal regression probes and independent review; native Omega execution NOT_RUN |
| Codex (GPT-6 Astra) | Bounded native peer credentials, multi-descriptor polling, single-iovec sendmsg, socket-option allowlist and host fixtures (#788) |
| Codex (GPT-6 Astra) | Seeded IR statement/type/scope validation repairs, bootstrap-safe helper splits, and independent C-oracle regression qualification |
diff --git a/bench/inference_cost/.crumb b/bench/inference_cost/.crumb
index e5164a86f ..38fb9d02b 100644
--- a/bench/inference_cost/.crumb
+++ b/bench/inference_cost/.crumb
@@ -3,14 +3,14 @@
"generated": {
"children": [],
"children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "compiled_at": "2026-10-28T03:06:12Z",
+ "compiled_at": "2026-10-28T12:07:07Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:602e7339549a372df88ab65ab0e2d921741aa5297ae4292fba05236a5ea342ea ",
+ "digest": "sha256:b9104063519fa30f206a096529f99c3ad17de79e002a816217d8846b6b085e6d ",
"evidence_files": 0,
"evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 250,
- "generated_at_commit": "79b8c1f9c24195c53ac8dad111d35175a4431506 ",
- "source_tree": "sha256:4928d99bc226e58d67a3b0639ddd959e8676a6662a1f9e5dd90da3d0829e2658 "
+ "files": 251,
+ "generated_at_commit": "1c9a1b03c6b025c6aae6de00b46f922cc68db5bf ",
+ "source_tree": "sha256:d3c99e593cf06a63c2609aafabd5b8a67a3c4ae9e4fc0335045183e56b3073aa "
}
},
"name": "bench/inference_cost",
diff --git a/bench/inference_cost/README.md b/bench/inference_cost/README.md
index 30b9d1fcd ..0db94339f 100644
--- a/bench/inference_cost/README.md
+++ b/bench/inference_cost/README.md
@@ -31,6 +31,15 @@ sh bench/inference_cost/driver.sh --run-model --endpoint http://127.0.0.1:18091
`--out build/inference_cost/run-<utc>-<pid>`.
- A missing endpoint, a curl failure, a non-200 status, or a body without `usage` (or with an `error`
member) prints `NOT_RUN: ...` and exits 3. Logs written up to that point are kept.
+- `--out` must be absent or an empty real directory, including hidden files. Symbolic links
+ (including names with trailing slashes) and nonempty directories are refused with exit 2 before
+ any run files change. An atomic, persistent `.inference-cost-owner/` marker allows exactly one
+ invocation to claim the output; a post-claim emptiness check closes concurrent creation races.
+ Completed, interrupted and already-claimed runs are never reused.
+- `--langs` and `--arms` require nonempty comma-separated lists without empty elements.
+- Bubblewrap is mandatory and fails closed: missing `bwrap` or unavailable namespaces give NOT_RUN
+ exit 3, never unsandboxed compilation or execution. GNU `timeout`, system Python, C and Rust
+ toolchains are required for the corresponding self-test paths.
The run directory holds:
@@ -65,7 +74,9 @@ sh bench/inference_cost/driver.sh --self-test # also run by `make test-infer
1. **Build.** Checks the compiler pin: the sha256 of `seed/out/omc` must equal `seed/out/omc.sha256`,
otherwise NOT_RUN exit 3. Then builds `scorer`, `chat` and `fake_model` into
`build/inference_cost/bin`.
-2. **Scorer rejections.** A wrong version gives 3, a truncated wire 2, and an unknown language 2.
+2. **Scorer rejections.** Both wire versions reject trailing rows, contradictory compile/verified
+ flags, nonboolean flags, skipped/repeated attempts, and attempts after a task has verified.
+ Interleaved task identities count once, separately in each language/arm group.
3. **Chat edge.** An error object, a body without usage, and a non-JSON body each give exit 4.
4. **`--check-tasks`.**
5. **Fake-model runs.** `fake_model` listens on an ephemeral 127.0.0.1 port, and every reply reports
@@ -80,6 +91,11 @@ sh bench/inference_cost/driver.sh --self-test # also run by `make test-infer
6. **NOT_RUN paths.** An unreachable endpoint (the fake is killed first), an HTTP 404, and a missing
`--endpoint` each give exit 3.
+7. **Adversarial boundaries.** Oracle-reading Python, host writes, C/Rust compile-time oracle reads,
+ a TERM-ignoring process with a descendant, an unavailable sandbox, empty workloads, reused or
+ symlinked output directories, and competing output claimants are permanent shell-driven controls
+ in `audit.sh`. Good, bad, mixed-arm and
+ compiler-refusal runs assert both the group and global PASS/FAIL strings, not only counters.
## Files
@@ -90,6 +106,7 @@ sh bench/inference_cost/driver.sh --self-test # also run by `make test-infer
| `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) and `refuse`. Uses headers `X-Bench-Task` and `X-Bench-Lang` |
| `scorer.om` | reads the attempt wire (v1 or v2) and writes the summary |
| `io.om` | stdin/stdout helpers appended after an Omega candidate |
+| `audit.sh` | permanent F1-F8 adversarial self-test controls, sourced by the driver |
| `prompts/system-<lang>.txt` | system prompts; the Omega one is a compact language primer |
| `tasks/taskNN/` | `statement.txt`, `spec.txt`, `inputs.txt`, `expected.txt`, and `reference.<lang>` plus `mutant.<lang>` for om, c, py and rs |
@@ -98,11 +115,33 @@ sh bench/inference_cost/driver.sh --self-test # also run by `make test-infer
The model writes only the function. The harness appends a stdin driver generated from `spec.txt`: it
reads `inputs.txt` and prints one decimal per case. A candidate is verified when:
- it compiles with exit 0;
-- the run exits 0 within 10 s;
+- the run exits 0 within 10 s (TERM at 10 s, hard KILL after a further 1 s);
- its output equals the cases of `expected.txt` byte for byte.
A compiler refusal is never verified and its output is never run.
+Both compilation and execution happen in separate bubblewrap sandboxes with all namespaces
+unshared, no network, a cleared environment, no home/credentials or checkout mount, a fresh `/tmp`,
+and read-only candidate and system runtime mounts. Compiler sandboxes additionally expose system
+headers/tools; Rust exposes only the selected toolchain's compiler and libraries, not its home.
+Inputs enter on stdin and compiler/runtime output leaves on stdout/stderr. The verifier and all
+oracle files remain outside. Compilation has the same bounded deadline as execution. Setup failure
+aborts the run. A trusted shell inside the fully configured sandbox closes all inherited caller
+descriptors except stdin/stdout/stderr and its dedicated readiness descriptor. It emits a readiness
+handshake, closes that descriptor, then executes candidate-controlled code. The host requires that
+handshake for compilation and execution; bubblewrap namespace JSON alone is not readiness evidence
+because it is emitted before mount setup. Permanent tests exercise late compiler/runtime mount
+failures with real bubblewrap and assert NOT_RUN, descriptor closure, and denial of inherited host
+file reads at both compile time and runtime.
+
+The host dependencies exercised here are bubblewrap 0.9.0 (Linux namespaces/mounts), GNU coreutils
+`timeout` 9.4 (host deadline), and Bash 5.2.21 (sandbox-only trusted launcher, mounted as `/usr/bin/sh`).
+The driver itself remains POSIX sh. The launcher needs arbitrary numeric descriptor redirections,
+which dash cannot perform above fd 9; it validates the kernel-provided numeric descriptors before
+closing them. These are isolation/verification infrastructure, not Omega implementations. Their
+Omega replacement would require a qualified namespace/mount, process-tree and descriptor supervisor;
+no such replacement is claimed here.
+
| lang | assembled as | compile |
|---|---|---|
| om | `om2 diag`, candidate, `io.om`, generated `fn main` | pinned `seed/out/omc` |
@@ -165,6 +204,10 @@ Rejection rules:
- An unknown version exits 3.
- A line count different from `attempts <N>`, a non-numeric field, or an unknown lang or arm exits 2.
- Input of 983040 bytes or more exits 2.
+- `first_attempt` and `verified_flag` must be 0 or 1; a nonzero `compiled_rc` cannot verify.
+- Task identity is exact within each language/arm group. Attempts start at 1, advance by one,
+ mark only attempt 1 as first, and stop on verification. Repeated task successes are invalid,
+ not additional verified programs. The same rules apply to version 1.
### Summary (`summary.txt`)
A version-1 input gives the version-1 summary (`version 1`, `tasks_total` ... `status`).
diff --git a/bench/inference_cost/audit.sh b/bench/inference_cost/audit.sh
new file mode 100644
index 000000000 ..8e75272a4
--- /dev/null
+++ b/bench/inference_cost/audit.sh
@@ -0,0 +1,271 @@
+# SPDX-License-Identifier: Apache-2.0
+# Sourced only by driver.sh --self-test; all candidates below are disposable fixtures.
+summary_status() { awk '$1=="status"{v=$2} END{print v}' "$1"; }
+
+scorer_probe() { # label expected_rc version-2 wire; challenge both wire versions
+ sp_label=$1 sp_want=$2 sp_wire=$3
+ for sp_version in 1 2; do
+ sp_rc=0
+ if [ "$sp_version" -eq 1 ]; then
+ printf '%s\n' "$sp_wire" | awk 'NR==1{$2=1} NR>2{$2=""; $3=""} {print}' |
+ "$BIN_DIR/scorer" > "$BUILD_DIR/selftest/probe.txt" 2>/dev/null || sp_rc=$?
+ else
+ printf '%s\n' "$sp_wire" | "$BIN_DIR/scorer" > "$BUILD_DIR/selftest/probe.txt" 2>/dev/null || sp_rc=$?
+ fi
+ st_expect "$sp_label v$sp_version rc" "$sp_want" "$sp_rc"
+ done
+}
+
+audit_checks() {
+ say '== audit regressions'
+ scorer_probe 'trailing row' 2 'version 2
+attempts 1
+task01 om plain 1 1 0 1 10 111 37 148
+task02 om plain 1 1 0 0 10 111 37 148'
+ scorer_probe 'refused compile marked verified' 2 'version 2
+attempts 1
+task01 om plain 1 1 1 1 10 111 37 148'
+ scorer_probe 'duplicate verified task' 2 'version 2
+attempts 3
+task01 om feedback 1 1 0 1 10 111 37 148
+task01 om feedback 2 0 0 1 10 111 37 148
+task02 om feedback 1 1 0 0 10 111 37 148'
+ scorer_probe 'nonboolean verified flag' 2 'version 2
+attempts 1
+task01 om plain 1 1 0 2 10 111 37 148'
+ scorer_probe 'nonboolean first flag' 2 'version 2
+attempts 1
+task01 om plain 1 2 0 0 10 111 37 148'
+ scorer_probe 'skipped attempt' 2 'version 2
+attempts 1
+task01 om plain 2 0 0 0 10 111 37 148'
+ scorer_probe 'distinct interleaved tasks' 1 'version 2
+attempts 3
+task01 om feedback 1 1 0 0 10 111 37 148
+task02 om feedback 1 1 0 0 10 111 37 148
+task01 om feedback 2 0 0 1 10 111 37 148'
+ st_expect 'distinct tasks counted' 2 "$(meta tasks_total "$BUILD_DIR/selftest/probe.txt")"
+ st_expect 'distinct verified counted' 1 "$(meta verified_count "$BUILD_DIR/selftest/probe.txt")"
+
+ ac_dir="$BUILD_DIR/selftest/security"
+ mkdir -p "$ac_dir"
+ cat > "$ac_dir/attack.py" <<EOF
+from pathlib import Path
+import sys
+try:
+ Path("$ac_dir/host-marker").write_text("candidate wrote host file")
+except OSError:
+ print("host write denied", file=sys.stderr)
+sys.stdout.write("".join(Path("$TASKS_DIR/task01/expected.txt").read_text().splitlines(True)[2:]))
+sys.exit(0)
+EOF
+ evaluate py "$TASKS_DIR/task01" "$ac_dir/attack.py" "$ac_dir/attack"
+ st_expect 'oracle attack compiled' 0 "$COMP_RC"
+ st_expect 'oracle attack unverified' 0 "$VERIFIED"
+ if [ ! -e "$ac_dir/host-marker" ] && grep -q 'expected.txt' "$ac_dir/attack/run.err"; then
+ st_ok 'sandbox denies host write and oracle read'
+ else
+ st_bad 'sandbox allowed host write or did not exercise oracle read'
+ fi
+ evaluate py "$TASKS_DIR/task01" "$TASKS_DIR/task01/reference.py" "$ac_dir/reference"
+ st_expect 'sandboxed candidate verified' 1 "$VERIFIED"
+ say 'sandboxed candidate output:'
+ cat "$ac_dir/reference/out.txt"
+ # Compile-time oracle reads must fail too (neither runtime-only isolation nor
+ # Python -I prevents C/Rust's compile-time file reads).
+ {
+ printf '#if __has_include("%s")\n#error ORACLE_VISIBLE\n#endif\n' "$TASKS_DIR/task01/expected.txt"
+ cat "$TASKS_DIR/task01/reference.c"
+ } > "$ac_dir/include.c"
+ evaluate c "$TASKS_DIR/task01" "$ac_dir/include.c" "$ac_dir/c-include"
+ st_expect 'C compiler cannot see oracle' 0 "$COMP_RC"
+ st_expect 'C oracle-invisibility control verified' 1 "$VERIFIED"
+ printf 'const ORACLE: &str = include_str!("%s");\n' "$TASKS_DIR/task01/expected.txt" > "$ac_dir/include.rs"
+ evaluate rs "$TASKS_DIR/task01" "$ac_dir/include.rs" "$ac_dir/rs-include"
+ st_expect 'Rust compile-time oracle unverified' 0 "$VERIFIED"
+ if [ "$COMP_RC" -ne 0 ] && grep -q 'No such file or directory' "$ac_dir/rs-include/err.txt"; then
+ st_ok 'Rust compiler cannot read oracle'
+ else
+ st_bad 'Rust oracle include did not fail at the filesystem boundary'
+ fi
+ # bwrap emits namespace JSON before mount setup; only an in-sandbox handshake
+ # distinguishes setup failure from a genuine compiler/candidate exit status.
+ mkdir -p "$ac_dir/setup-tools" "$ac_dir/empty-sysroot"
+ cat > "$ac_dir/setup-tools/rustc" <<EOF
+#!/bin/sh
+printf '%s\n' "$ac_dir/empty-sysroot"
+EOF
+ chmod +x "$ac_dir/setup-tools/rustc"
+ ac_rc=0
+ ac_out=$(PATH="$ac_dir/setup-tools:$PATH" sh "$SCRIPT_DIR/driver.sh" --evaluate-probe rs \
+ "$TASKS_DIR/task01/reference.rs" "$ac_dir/compile-setup" 2>&1) || ac_rc=$?
+ st_expect 'compiler mount setup failure NOT_RUN' 3 "$ac_rc"
+ if [ -s "$ac_dir/compile-setup/compile.sandbox" ] && [ ! -s "$ac_dir/compile-setup/compile.ready" ]; then
+ st_ok 'namespace JSON is not compiler readiness'
+ else
+ st_bad 'compiler setup negative control did not separate JSON and readiness'
+ fi
+ ac_bwrap=$(command -v bwrap)
+ cat > "$ac_dir/setup-tools/bwrap" <<EOF
+#!/bin/sh
+for arg do :; done
+if [ "\$arg" = /work/candidate ]; then
+ exec "$ac_bwrap" --ro-bind "$ac_dir/nonexistent-mount" /unavailable "\$@"
+fi
+exec "$ac_bwrap" "\$@"
+EOF
+ chmod +x "$ac_dir/setup-tools/bwrap"
+ ac_rc=0
+ ac_out=$(PATH="$ac_dir/setup-tools:$PATH" sh "$SCRIPT_DIR/driver.sh" --evaluate-probe py \
+ "$TASKS_DIR/task01/reference.py" "$ac_dir/run-setup" 2>&1) || ac_rc=$?
+ st_expect 'runtime mount setup failure NOT_RUN' 3 "$ac_rc"
+ if [ -s "$ac_dir/run-setup/run.sandbox" ] && [ ! -s "$ac_dir/run-setup/run.ready" ]; then
+ st_ok 'namespace JSON is not candidate readiness'
+ else
+ st_bad 'runtime setup negative control did not separate JSON and readiness'
+ fi
+ {
+ printf 'import os\ntry:\n os.write(3, b"forged")\nexcept OSError:\n pass\nelse:\n raise RuntimeError("readiness fd leaked")\n'
+ cat "$TASKS_DIR/task01/reference.py"
+ } > "$ac_dir/readiness-fd.py"
+ evaluate py "$TASKS_DIR/task01" "$ac_dir/readiness-fd.py" "$ac_dir/readiness-fd"
+ st_expect 'candidate cannot inherit readiness fd' 1 "$VERIFIED"
+ # A caller may hold host files on arbitrary inheritable descriptors. Both
+ # compiler includes and runtime /proc/self/fd reads must lose that access.
+ {
+ printf 'import os\ntry:\n os.read(99, 1)\nexcept OSError:\n pass\nelse:\n raise RuntimeError("inherited host descriptor leaked")\n'
+ cat "$TASKS_DIR/task01/reference.py"
+ } > "$ac_dir/inherited-fd.py"
+ ac_rc=0
+ ac_out=$(bash -c 'exec 99< "$1"; shift; exec "$@"' _ "$TASKS_DIR/task01/expected.txt" \
+ sh "$SCRIPT_DIR/driver.sh" --evaluate-probe py "$ac_dir/inherited-fd.py" "$ac_dir/inherited-py" 2>&1) || ac_rc=$?
+ st_expect 'inherited descriptor runtime control rc' 0 "$ac_rc"
+ case $ac_out in *'COMP_RC=0 RUN_RC=0 VERIFIED=1'*) st_ok 'runtime cannot read inherited host descriptor' ;;
+ *) st_bad 'runtime inherited descriptor was not closed' ;; esac
+ {
+ printf 'const SECRET: &str = include_str!("/proc/self/fd/99");\n'
+ cat "$TASKS_DIR/task01/reference.rs"
+ } > "$ac_dir/inherited-fd.rs"
+ ac_rc=0
+ ac_out=$(bash -c 'exec 99< "$1"; shift; exec "$@"' _ "$TASKS_DIR/task01/expected.txt" \
+ sh "$SCRIPT_DIR/driver.sh" --evaluate-probe rs "$ac_dir/inherited-fd.rs" "$ac_dir/inherited-rs" 2>&1) || ac_rc=$?
+ st_expect 'inherited descriptor compiler control rc' 0 "$ac_rc"
+ if grep -q 'No such file or directory' "$ac_dir/inherited-rs/err.txt"; then
+ st_ok 'compiler cannot read inherited host descriptor'
+ else
+ st_bad 'compiler inherited descriptor was not closed'
+ fi
+
+ cat > "$ac_dir/ignore-term.py" <<'EOF'
+import os
+import signal
+import time
+signal.signal(signal.SIGTERM, signal.SIG_IGN)
+if os.fork() == 0:
+ while True:
+ time.sleep(1)
+def clamp_add_u16(a, b):
+ while True:
+ time.sleep(1)
+EOF
+ ac_rc=0
+ timeout --kill-after=1s 13s sh "$SCRIPT_DIR/driver.sh" --deadline-probe \
+ "$ac_dir/ignore-term.py" "$ac_dir/deadline" || ac_rc=$?
+ st_expect 'TERM-ignoring process group deadline' 0 "$ac_rc"
+ ac_pid=$(awk '/"child-pid"/{gsub(/[^0-9]/, ""); print}' "$ac_dir/deadline/run.sandbox")
+ if [ -n "$ac_pid" ] && ! kill -0 "$ac_pid" 2>/dev/null; then
+ st_ok 'timed-out PID namespace is gone'
+ else
+ st_bad 'timed-out sandbox process is still alive'
+ fi
+
+ mkdir -p "$ac_dir/tools"
+ printf '#!/bin/sh\nexit 1\n' > "$ac_dir/tools/bwrap"
+ chmod +x "$ac_dir/tools/bwrap"
+ ac_rc=0
+ ac_out=$(PATH="$ac_dir/tools:$PATH" sh "$SCRIPT_DIR/driver.sh" --run-model \
+ --endpoint http://127.0.0.1:1 --model fake --langs py --arms plain \
+ --out "$ac_dir/unavailable" 2>&1) || ac_rc=$?
+ st_expect 'unavailable sandbox NOT_RUN' 3 "$ac_rc"
+ case $ac_out in *'bubblewrap sandbox is unavailable'*) st_ok 'sandbox failure is closed' ;;
+ *) st_bad 'sandbox failure did not stop at sandbox preflight' ;; esac
+ st_expect 'sandbox failure creates no run' no "$([ -e "$ac_dir/unavailable" ] && say yes || say no)"
+ for ac_option in --langs --arms; do
+ for ac_value in '' ','; do
+ ac_rc=0
+ sh "$SCRIPT_DIR/driver.sh" --run-model --endpoint http://127.0.0.1:1 \
+ --model fake "$ac_option" "$ac_value" --out "$ac_dir/empty" >/dev/null 2>&1 || ac_rc=$?
+ st_expect "empty $ac_option '$ac_value' rejected" 2 "$ac_rc"
+ done
+ done
+ mkdir "$ac_dir/empty-output"
+ ac_rc=0
+ sh "$SCRIPT_DIR/driver.sh" --output-probe "$ac_dir/empty-output" || ac_rc=$?
+ st_expect 'existing empty output can be claimed' 0 "$ac_rc"
+ mkdir "$ac_dir/link-target"
+ ln -s "$ac_dir/link-target" "$ac_dir/output-link"
+ for ac_link in "$ac_dir/output-link" "$ac_dir/output-link/"; do
+ ac_rc=0
+ sh "$SCRIPT_DIR/driver.sh" --output-probe "$ac_link" >/dev/null 2>&1 || ac_rc=$?
+ st_expect 'symlink output rejected, including trailing slash' 2 "$ac_rc"
+ done
+ st_expect 'symlink target left empty' '' "$(find "$ac_dir/link-target" -mindepth 1 -print -quit)"
+ # Force both processes past the initial emptiness check before either tries
+ # mkdir on the ownership marker; this exercises the actual acquisition race.
+ mkdir -p "$ac_dir/claim-tools" "$ac_dir/claim-barrier"
+ ac_mkdir=$(command -v mkdir)
+ cat > "$ac_dir/claim-tools/mkdir" <<EOF
+#!/bin/sh
+for arg do :; done
+if [ "\$arg" = "$ac_dir/raced-output/.inference-cost-owner" ]; then
+ : > "$ac_dir/claim-barrier/\$\$"
+ while [ "\$(find "$ac_dir/claim-barrier" -type f | wc -l)" -lt 2 ]; do
+ sleep 0.01
+ done
+fi
+exec "$ac_mkdir" "\$@"
+EOF
+ chmod +x "$ac_dir/claim-tools/mkdir"
+ (
+ ac_rc=0
+ PATH="$ac_dir/claim-tools:$PATH" timeout --kill-after=1s 5s sh "$SCRIPT_DIR/driver.sh" \
+ --output-probe "$ac_dir/raced-output" >"$ac_dir/race1.log" 2>&1 || ac_rc=$?
+ say "$ac_rc" > "$ac_dir/race1.rc"
+ ) &
+ ac_pid1=$!
+ (
+ ac_rc=0
+ PATH="$ac_dir/claim-tools:$PATH" timeout --kill-after=1s 5s sh "$SCRIPT_DIR/driver.sh" \
+ --output-probe "$ac_dir/raced-output" >"$ac_dir/race2.log" 2>&1 || ac_rc=$?
+ say "$ac_rc" > "$ac_dir/race2.rc"
+ ) &
+ ac_pid2=$!
+ wait "$ac_pid1"
+ wait "$ac_pid2"
+ case $(cat "$ac_dir/race1.rc"):$(cat "$ac_dir/race2.rc") in
+ 0:2|2:0) st_ok 'only one concurrent output claimant succeeds' ;;
+ *) st_bad 'concurrent output claim did not have exactly one owner' ;;
+ esac
+}
+
+audit_reuse_check() {
+ find "$BUILD_DIR/selftest/good" -type f -exec sha256sum {} \; | sort > "$BUILD_DIR/selftest/before.sha256"
+ ac_rc=0
+ ac_out=$(sh "$SCRIPT_DIR/driver.sh" --run-model --endpoint http://127.0.0.1:1 --model fake \
+ --langs py --arms feedback --out "$BUILD_DIR/selftest/good" 2>&1) || ac_rc=$?
+ st_expect 'nonempty output rejected' 2 "$ac_rc"
+ case $ac_out in *'--out must be empty'*) st_ok 'output refused before HTTP' ;; *) st_bad 'wrong output refusal' ;; esac
+ ln -s "$BUILD_DIR/selftest/good" "$BUILD_DIR/selftest/good-link"
+ for ac_link in "$BUILD_DIR/selftest/good-link" "$BUILD_DIR/selftest/good-link/"; do
+ ac_rc=0
+ sh "$SCRIPT_DIR/driver.sh" --run-model --endpoint http://127.0.0.1:1 --model fake \
+ --langs py --arms feedback --out "$ac_link" >/dev/null 2>&1 || ac_rc=$?
+ st_expect 'run-model refuses symlink to completed run' 2 "$ac_rc"
+ done
+ find "$BUILD_DIR/selftest/good" -type f -exec sha256sum {} \; | sort > "$BUILD_DIR/selftest/after.sha256"
+ if cmp -s "$BUILD_DIR/selftest/before.sha256" "$BUILD_DIR/selftest/after.sha256"; then
+ st_ok 'reused output remains byte-identical'
+ else
+ st_bad 'reused output changed'
+ fi
+}
diff --git a/bench/inference_cost/driver.sh b/bench/inference_cost/driver.sh
index 058bf0cb2 ..a58671405 100755
--- a/bench/inference_cost/driver.sh
+++ b/bench/inference_cost/driver.sh
@@ -199,6 +199,85 @@ EOF
esac
}
+# Candidate execution has no host root, home, network or inherited environment. Only
+# system runtime libraries and the single executable/source are exposed read-only;
+# stdin carries inputs, and the host compares stdout against the oracle afterward.
+# Never fall back to direct execution if bubblewrap cannot establish its namespaces.
+sandbox() { # mode candidate_file
+ sb_mode=$1
+ sb_file=$2
+ # Only the trusted shell can write readiness; fd 3 is closed before candidate code.
+ # bwrap's fd 4 namespace JSON is useful telemetry, not proof mount/setup succeeded.
+ sb_start='for fd in /proc/self/fd/*; do
+ fd=${fd##*/}
+ case $fd in
+ 0|1|2|3) ;;
+ *[!0-9]*) exit 125 ;;
+ *) eval "exec ${fd}>&-" || exit 125 ;;
+ esac
+ done
+ printf "ready\n" >&3 || exit 125
+ exec 3>&-
+ exec "$@"'
+ set -- bwrap --unshare-all --unshare-user --disable-userns --die-with-parent --new-session --clearenv --info-fd 4 \
+ --setenv PATH /usr/bin --setenv LC_ALL C \
+ --ro-bind /usr/lib /usr/lib --symlink usr/lib /lib \
+ --dir /usr/bin --ro-bind "$(readlink -f "$(command -v bash)")" /usr/bin/sh \
+ --ro-bind "$(readlink -f "$(command -v python3)")" /usr/bin/python3 --symlink usr/bin /bin \
+ --proc /proc --dev /dev --tmpfs /tmp --dir /work --chdir /work \
+ --ro-bind "$sb_file" /work/candidate
+ # Compiler-only system headers/tools; never mount home, /tmp or the checkout.
+ case $sb_mode in
+ c|rs)
+ set -- "$@" --ro-bind /usr/include /usr/include \
+ --ro-bind /usr/libexec /usr/libexec \
+ --ro-bind "$(readlink -f "$(command -v cc)")" /usr/bin/cc \
+ --ro-bind "$(readlink -f "$(command -v as)")" /usr/bin/as \
+ --ro-bind "$(readlink -f "$(command -v ld)")" /usr/bin/ld \
+ --ro-bind "$(readlink -f "$(command -v cat)")" /usr/bin/cat ;;
+ esac
+ case $sb_mode in
+ om)
+ "$@" --ro-bind "$OMC" /compiler --remount-ro / /usr/bin/sh -c "$sb_start" ready /compiler ;;
+ c)
+ "$@" --remount-ro / /usr/bin/sh -c "$sb_start" ready /usr/bin/sh -c 'cc -O2 -x c -include stdint.h -include stdio.h -include stdlib.h -o /tmp/bin /work/candidate -lm && cat /tmp/bin' ;;
+ py)
+ "$@" --remount-ro / /usr/bin/sh -c "$sb_start" ready /usr/bin/python3 -I -c \
+ 'import py_compile; py_compile.compile("/work/candidate", cfile="/tmp/candidate.pyc", doraise=True)' ;;
+ rs)
+ sb_root=$(rustc --print sysroot) || not_run "cannot resolve Rust sysroot"
+ "$@" --ro-bind "$sb_root/bin/rustc" /toolchain/bin/rustc \
+ --ro-bind "$sb_root/lib" /toolchain/lib --setenv LD_LIBRARY_PATH /toolchain/lib \
+ --remount-ro / /usr/bin/sh -c "$sb_start" ready /usr/bin/sh -c '/toolchain/bin/rustc --sysroot /toolchain -O --edition 2021 -A warnings --crate-name bench -o /tmp/bin /work/candidate && cat /tmp/bin' ;;
+ run)
+ if [ "$sb_file" = /dev/null ]; then
+ "$@" --remount-ro / /usr/bin/sh -c "$sb_start" ready /usr/bin/python3 -I -c 'pass'
+ elif [ "${sb_file##*.}" = py ]; then
+ "$@" --remount-ro / /usr/bin/sh -c "$sb_start" ready /usr/bin/python3 -I /work/candidate
+ else
+ "$@" --remount-ro / /usr/bin/sh -c "$sb_start" ready /work/candidate
+ fi ;;
+ *) die "unknown sandbox mode" ;;
+ esac
+}
+
+check_sandbox() {
+ need_tool bwrap
+ need_tool timeout
+ need_tool python3
+ # The sandbox-only shell needs numeric fd redirections above 9 (dash does not).
+ need_tool bash
+ # Exercise the actual namespace setup, not merely bwrap's presence in PATH.
+ sandbox run /dev/null 3>/dev/null 4>/dev/null >/dev/null 2>&1 ||
+ not_run "bubblewrap sandbox is unavailable; no candidate was run"
+}
+
+run_candidate() { # file command [args...]
+ # GNU timeout owns a process group; bubblewrap also owns a PID namespace.
+ # TERM gets a short grace period, then KILL tears down every descendant.
+ timeout --kill-after=1s 10s sh "$SCRIPT_DIR/driver.sh" --sandbox run "$1"
+}
+
# ---- evaluate one candidate: sets COMP_RC, RUN_RC and VERIFIED; the work dir holds src, err.txt,
# out.txt. A compiler refusal (COMP_RC != 0) is never verified and its output is never run (#910).
# sh has no locals: every name set here starts with ev_.
@@ -216,27 +295,31 @@ evaluate() { # lang task_dir candidate work
om)
# om2 diag: the human "omc: line N: error K" plus an "omc-diag 1 ..." record on refusal.
{ printf 'om2 diag\n'; sed '1{/^om2\( .*\)\{0,1\}$/d;}' "$ev_c"; printf '\n'; cat "$SCRIPT_DIR/io.om"; gen_main om "$ev_s"; } > "$ev_w/src.om"
- "$OMC" < "$ev_w/src.om" > "$ev_w/bin" 2> "$ev_w/err.txt" || COMP_RC=$? ;;
+ timeout --kill-after=1s 10s sh "$SCRIPT_DIR/driver.sh" --sandbox om "$ev_w/src.om" < "$ev_w/src.om" > "$ev_w/bin" 2> "$ev_w/err.txt" 3> "$ev_w/compile.ready" 4> "$ev_w/compile.sandbox" || COMP_RC=$? ;;
c)
{ cat "$ev_c"; gen_main c "$ev_s"; } > "$ev_w/src.c"
- cc -O2 -include stdint.h -include stdio.h -include stdlib.h -o "$ev_w/bin" "$ev_w/src.c" -lm 2> "$ev_w/err.txt" || COMP_RC=$? ;;
+ timeout --kill-after=1s 10s sh "$SCRIPT_DIR/driver.sh" --sandbox c "$ev_w/src.c" > "$ev_w/bin" 2> "$ev_w/err.txt" 3> "$ev_w/compile.ready" 4> "$ev_w/compile.sandbox" || COMP_RC=$? ;;
py)
{ cat "$ev_c"; gen_main py "$ev_s"; } > "$ev_w/src.py"
- python3 -m py_compile "$ev_w/src.py" 2> "$ev_w/err.txt" || COMP_RC=$? ;;
+ timeout --kill-after=1s 10s sh "$SCRIPT_DIR/driver.sh" --sandbox py "$ev_w/src.py" > "$ev_w/compile.out" 2> "$ev_w/err.txt" 3> "$ev_w/compile.ready" 4> "$ev_w/compile.sandbox" || COMP_RC=$? ;;
rs)
{ cat "$ev_c"; gen_main rs "$ev_s"; } > "$ev_w/src.rs"
- rustc -O --edition 2021 -A warnings -o "$ev_w/bin" "$ev_w/src.rs" 2> "$ev_w/err.txt" || COMP_RC=$? ;;
+ timeout --kill-after=1s 10s sh "$SCRIPT_DIR/driver.sh" --sandbox rs "$ev_w/src.rs" > "$ev_w/bin" 2> "$ev_w/err.txt" 3> "$ev_w/compile.ready" 4> "$ev_w/compile.sandbox" || COMP_RC=$? ;;
esac
+ [ "$(cat "$ev_w/compile.ready")" = ready ] ||
+ not_run "bubblewrap could not start the compiler sandbox; no unsandboxed fallback"
VERIFIED=0
RUN_RC=-
if [ "$COMP_RC" -eq 0 ]; then
RUN_RC=0
if [ "$ev_l" = py ]; then
- timeout 10 python3 -I "$ev_w/src.py" < "$ev_t/inputs.txt" > "$ev_w/out.txt" 2> "$ev_w/run.err" || RUN_RC=$?
+ run_candidate "$ev_w/src.py" < "$ev_t/inputs.txt" > "$ev_w/out.txt" 2> "$ev_w/run.err" 3> "$ev_w/run.ready" 4> "$ev_w/run.sandbox" || RUN_RC=$?
else
chmod +x "$ev_w/bin"
- timeout 10 "$ev_w/bin" < "$ev_t/inputs.txt" > "$ev_w/out.txt" 2> "$ev_w/run.err" || RUN_RC=$?
+ run_candidate "$ev_w/bin" < "$ev_t/inputs.txt" > "$ev_w/out.txt" 2> "$ev_w/run.err" 3> "$ev_w/run.ready" 4> "$ev_w/run.sandbox" || RUN_RC=$?
fi
+ [ "$(cat "$ev_w/run.ready")" = ready ] ||
+ not_run "bubblewrap could not start the candidate sandbox; no unsandboxed fallback"
if [ "$RUN_RC" -eq 0 ] && tail -n +3 "$ev_t/expected.txt" | cmp -s - "$ev_w/out.txt"; then
VERIFIED=1
fi
@@ -248,6 +331,7 @@ evaluate() { # lang task_dir candidate work
task_ids() { for d in "$TASKS_DIR"/task*/; do basename "$d"; done; }
check_tasks() {
+ check_sandbox
need_lang_tools "$ALL_LANGS"
cwork="$BUILD_DIR/check"
rm -rf "$cwork"
@@ -332,6 +416,31 @@ $r}" ;;
meta() { awk -v k="$1" '$1==k{print $2; exit}' "$2"; }
+claim_output() { # output directory; a persistent marker gives one invocation ownership
+ OUT=$1
+ while :; do
+ case $OUT in /) die "--out must be a fresh directory" ;;
+ */) OUT=${OUT%/} ;; *) break ;; esac
+ done
+ [ ! -L "$OUT" ] || die "--out must not be a symbolic link"
+ if [ -e "$OUT" ]; then
+ [ -d "$OUT" ] || die "--out must be a directory"
+ co_entries=$(find -H "$OUT" -mindepth 1 -maxdepth 1 -print -quit) ||
+ die "--out cannot be inspected"
+ [ -z "$co_entries" ] || die "--out must be empty; existing runs are never reused"
+ fi
+ mkdir -p "$OUT"
+ [ ! -L "$OUT" ] || die "--out must not be a symbolic link"
+ mkdir "$OUT/.inference-cost-owner" 2>/dev/null ||
+ die "--out is already claimed; existing runs are never reused"
+ co_entries=$(find -H "$OUT" -mindepth 1 -maxdepth 1 ! -name .inference-cost-owner -print -quit) ||
+ die "--out cannot be inspected"
+ if [ -n "$co_entries" ]; then
+ rmdir "$OUT/.inference-cost-owner"
+ die "--out must be empty; existing runs are never reused"
+ fi
+}
+
run_model() {
ENDPOINT=""
MODEL=""
@@ -359,14 +468,17 @@ run_model() {
case $MODEL in *[!A-Za-z0-9._:/@+-]*) die "--model must be one word of [A-Za-z0-9._:/@+-]" ;; esac
case $ATTEMPTS in ''|*[!0-9]*|0) die "--attempts must be a positive integer" ;; esac
case $MAXTOK in ''|*[!0-9]*|0) die "--max-tokens must be a positive integer" ;; esac
+ case $LANGS in ''|,*|*,|*,,*|*[!a-z,]*) die "--langs requires a nonempty comma-separated language list" ;; esac
+ case $ARMS in ''|,*|*,|*,,*|*[!a-z,]*) die "--arms requires a nonempty comma-separated arm list" ;; esac
langs=$(printf '%s' "$LANGS" | tr ',' ' ')
arms=$(printf '%s' "$ARMS" | tr ',' ' ')
for a in $arms; do case $a in plain|feedback) ;; *) die "unknown arm '$a' (plain feedback)" ;; esac; done
need_lang_tools "$langs"
need_tool curl
+ check_sandbox
ENDPOINT=${ENDPOINT%/}
[ -n "$OUT" ] || OUT="$BUILD_DIR/run-$(date -u +%Y%m%dT%H%M%SZ)-$$"
- mkdir -p "$OUT"
+ claim_output "$OUT"
{
say "version 1"
say "endpoint $ENDPOINT"
@@ -494,7 +606,9 @@ fake_run() { # name mode arms attempts -> sets FR_RC, SUMMARY
}
self_test() {
+ . "$SCRIPT_DIR/audit.sh"
need_lang_tools "$ALL_LANGS"
+ check_sandbox
need_tool curl
rm -rf "$BUILD_DIR/selftest"
mkdir -p "$BUILD_DIR/selftest"
@@ -517,6 +631,7 @@ self_test() {
rc=0
printf 'version 2\nattempts 1\ntask01 om plain 1 1 1 0 10 111 37 148\n' | "$BIN_DIR/scorer" > /dev/null || rc=$?
st_expect "scorer v2 refused compile rc (FAIL)" 1 "$rc"
+ audit_checks
say "== JSON edge (chat.om)"
rc=0
@@ -534,7 +649,9 @@ self_test() {
fake_run good good plain 1
st_expect "good rc" 0 "$FR_RC"
+ st_expect "good global verdict" PASS "$(summary_status "$SUMMARY")"
for l in $ALL_LANGS; do
+ st_expect "good $l plain verdict" PASS "$(group_field "$SUMMARY" "$l" plain status)"
st_expect "good $l plain verified" "$ntask" "$(group_field "$SUMMARY" "$l" plain verified_count)"
st_expect "good $l plain first_attempt_verified" "$ntask" "$(group_field "$SUMMARY" "$l" plain first_attempt_verified)"
st_expect "good $l plain prompt_tokens" "$((ntask * 111))" "$(group_field "$SUMMARY" "$l" plain total_prompt_tokens)"
@@ -545,14 +662,19 @@ self_test() {
fake_run bad bad plain 1
st_expect "bad rc" 0 "$FR_RC"
+ st_expect "bad global verdict" FAIL "$(summary_status "$SUMMARY")"
for l in $ALL_LANGS; do
+ st_expect "bad $l plain verdict" FAIL "$(group_field "$SUMMARY" "$l" plain status)"
st_expect "bad $l plain compiled" "$ntask" "$(group_field "$SUMMARY" "$l" plain compiled_count)"
st_expect "bad $l plain verified" 0 "$(group_field "$SUMMARY" "$l" plain verified_count)"
done
fake_run bad-then-good bad-then-good plain,feedback 2
st_expect "bad-then-good rc" 0 "$FR_RC"
+ st_expect "bad-then-good global verdict" FAIL "$(summary_status "$SUMMARY")"
for l in $ALL_LANGS; do
+ st_expect "bad-then-good $l plain verdict" FAIL "$(group_field "$SUMMARY" "$l" plain status)"
+ st_expect "bad-then-good $l feedback verdict" PASS "$(group_field "$SUMMARY" "$l" feedback status)"
st_expect "bad-then-good $l plain verified" 0 "$(group_field "$SUMMARY" "$l" plain verified_count)"
st_expect "bad-then-good $l plain attempts" "$((ntask * 2))" "$(group_field "$SUMMARY" "$l" plain attempts_total)"
st_expect "bad-then-good $l feedback verified" "$ntask" "$(group_field "$SUMMARY" "$l" feedback verified_count)"
@@ -566,11 +688,14 @@ self_test() {
fake_run refuse refuse plain 1
st_expect "refuse rc" 0 "$FR_RC"
+ st_expect "refuse global verdict" FAIL "$(summary_status "$SUMMARY")"
for l in $ALL_LANGS; do
+ st_expect "refuse $l plain verdict" FAIL "$(group_field "$SUMMARY" "$l" plain status)"
st_expect "refuse $l plain compiled" 0 "$(group_field "$SUMMARY" "$l" plain compiled_count)"
st_expect "refuse $l plain verified" 0 "$(group_field "$SUMMARY" "$l" plain verified_count)"
done
st_expect "refuse never ran a binary" 0 "$(find "$BUILD_DIR/selftest/refuse" -name out.txt | wc -l)"
+ audit_reuse_check
say "== NOT_RUN paths"
start_fake good "$TASKS_DIR"
@@ -608,6 +733,15 @@ self_test() {
mode=$1
shift
case $mode in
+ --sandbox) sandbox "$@" ;;
+ --output-probe) claim_output "$1" ;;
+ --evaluate-probe)
+ evaluate "$1" "$TASKS_DIR/task01" "$2" "$3"
+ say "COMP_RC=$COMP_RC RUN_RC=$RUN_RC VERIFIED=$VERIFIED" ;;
+ --deadline-probe)
+ evaluate py "$TASKS_DIR/task01" "$1" "$2"
+ [ "$COMP_RC" -eq 0 ] && [ "$VERIFIED" -eq 0 ] &&
+ { [ "$RUN_RC" -eq 124 ] || [ "$RUN_RC" -eq 137 ]; } ;;
--check-tasks) build_tools; check_tasks ;;
--self-test) build_tools; self_test ;;
--run-model)
diff --git a/bench/inference_cost/scorer.om b/bench/inference_cost/scorer.om
index d8412f882 ..48da69715 100644
--- a/bench/inference_cost/scorer.om
+++ b/bench/inference_cost/scorer.om
@@ -25,6 +25,102 @@ note 8 groups (lang * 2 + arm) of 12 counters: 0 tasks (first rows), 1 compiled,
note 2 verified, 3 first-attempt verified, 4..6 prompt/completion/total tokens,
note 7 wall ms, 8 rows, 9 present
global stats ulong 96
+note Exact task identity per group. Open-addressed entries point into immutable inbuf.
+note A row has at least 18 bytes, so the input byte limit cannot fill 65536 entries.
+global taskbeg ulong 65536
+global tasklen ulong 65536
+global taskgrp ulong 65536
+global taskatt ulong 65536
+global taskver ulong 65536
+global rowbeg ulong 1
+global rowlen ulong 1
+
+fn read_task to void
+read_tok
+put rowbeg 0 get tokb 0
+put rowlen 0 sub get pos 0 get tokb 0
+end
+
+fn same_task slot ulong b ulong to bool
+if ne get taskgrp slot b
+ret false
+end
+if ne get tasklen slot get rowlen 0
+ret false
+end
+start = get taskbeg slot
+other = get rowbeg 0
+for i ulong get rowlen 0
+left = get inbuf add start i
+right = get inbuf add other i
+if ne left right
+ret false
+end
+end
+ret true
+end
+
+fn task_slot b ulong to ulong
+h = b
+start = get rowbeg 0
+for i ulong get rowlen 0
+c = ulong get inbuf add start i
+mix = add h shl h 5
+h = rem xor mix c 65536
+end
+for i ulong 65536
+if eq get tasklen h 0
+put taskbeg h get rowbeg 0
+put tasklen h get rowlen 0
+put taskgrp h b
+ret h
+end
+if same_task h b
+ret h
+end
+h = rem add h 1 65536
+end
+fail 2
+ret 0
+end
+
+fn record_task b ulong att ulong first ulong comp ulong ver ulong to void
+if or gt first 1 gt ver 1
+fail 2
+end
+if and ne comp 0 eq ver 1
+fail 2
+end
+s = task_slot b
+prev = get taskatt s
+if ne att add prev 1
+fail 2
+end
+if ne (eq first 1) (eq prev 0)
+fail 2
+end
+if eq get taskver s 1
+fail 2
+end
+if eq prev 0
+bump b 1
+end
+put taskatt s att
+if eq ver 1
+put taskver s 1
+bump add b 2 1
+if eq first 1
+bump add b 3 1
+end
+end
+end
+
+fn require_eof to void
+skip_ws
+if ne get pos 0 get inlen 0
+fail 2
+end
+end
text err "scorer: error\n"
fn fail code int to void
@@ -261,23 +357,15 @@ att_n = read_uint
first = read_uint
comp_rc = read_uint
ver_ok = read_uint
+record_task b att_n first comp_rc ver_ok
wms = read_uint
ptok = read_uint
ctok = read_uint
ttok = read_uint
-if eq first 1
-bump b 1
-end
if eq comp_rc 0
bump add b 1 1
end
-if eq ver_ok 1
-bump add b 2 1
-if eq first 1
-bump add b 3 1
-end
-end
bump add b 4 ptok
bump add b 5 ctok
bump add b 6 ttok
@@ -424,17 +512,19 @@ att_cnt = read_uint
if eq v 1
for i ulong att_cnt
-skip_token
+read_task
parse_row 0
end
+require_eof
wtext t_ver
ret print_group 0 false
end
for i ulong att_cnt
-skip_token
+read_task
lg = lang_idx
am = arm_idx
parse_row mul add mul lg 2 am 12
end
+require_eof
ret print_v2
end