@tangle-network/agent-bench 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +24 -2
  3. package/dist/adapters.d.ts +3 -3
  4. package/dist/adapters.js +3 -5
  5. package/dist/adapters.js.map +1 -1
  6. package/dist/benchmarks/_harness.d.ts +4 -4
  7. package/dist/benchmarks/_harness.js +5 -2
  8. package/dist/benchmarks/_harness.js.map +1 -1
  9. package/dist/benchmarks/aec-bench.d.ts +2 -2
  10. package/dist/benchmarks/aec-bench.js +49 -42
  11. package/dist/benchmarks/aec-bench.js.map +1 -1
  12. package/dist/benchmarks/agentbench.d.ts +2 -2
  13. package/dist/benchmarks/agentbench.js +41 -34
  14. package/dist/benchmarks/agentbench.js.map +1 -1
  15. package/dist/benchmarks/appworld.d.ts +4 -4
  16. package/dist/benchmarks/appworld.js +67 -53
  17. package/dist/benchmarks/appworld.js.map +1 -1
  18. package/dist/benchmarks/bfcl.d.ts +2 -2
  19. package/dist/benchmarks/bfcl.js +52 -44
  20. package/dist/benchmarks/bfcl.js.map +1 -1
  21. package/dist/benchmarks/cad-design.d.ts +2 -2
  22. package/dist/benchmarks/cad-design.js +53 -44
  23. package/dist/benchmarks/cad-design.js.map +1 -1
  24. package/dist/benchmarks/cadbench.d.ts +2 -2
  25. package/dist/benchmarks/cadbench.js +1 -1
  26. package/dist/benchmarks/cadgenbench.d.ts +2 -2
  27. package/dist/benchmarks/cadgenbench.js +1 -1
  28. package/dist/benchmarks/commit0.d.ts +2 -2
  29. package/dist/benchmarks/commit0.js +38 -31
  30. package/dist/benchmarks/commit0.js.map +1 -1
  31. package/dist/benchmarks/crag.d.ts +2 -2
  32. package/dist/benchmarks/crag.js +37 -32
  33. package/dist/benchmarks/crag.js.map +1 -1
  34. package/dist/benchmarks/dabstep.d.ts +2 -2
  35. package/dist/benchmarks/dabstep.js +41 -34
  36. package/dist/benchmarks/dabstep.js.map +1 -1
  37. package/dist/benchmarks/finresearchbench.d.ts +4 -4
  38. package/dist/benchmarks/finresearchbench.js +61 -48
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +54 -43
  42. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  43. package/dist/benchmarks/frames.d.ts +2 -2
  44. package/dist/benchmarks/frames.js +66 -51
  45. package/dist/benchmarks/frames.js.map +1 -1
  46. package/dist/benchmarks/hotpotqa.d.ts +2 -2
  47. package/dist/benchmarks/hotpotqa.js +59 -47
  48. package/dist/benchmarks/hotpotqa.js.map +1 -1
  49. package/dist/benchmarks/humaneval.d.ts +3 -3
  50. package/dist/benchmarks/humaneval.js +39 -35
  51. package/dist/benchmarks/humaneval.js.map +1 -1
  52. package/dist/benchmarks/mcad-bench.d.ts +2 -2
  53. package/dist/benchmarks/mcad-bench.js +68 -56
  54. package/dist/benchmarks/mcad-bench.js.map +1 -1
  55. package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
  56. package/dist/benchmarks/mcad-cq-bench.js +69 -57
  57. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  58. package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
  59. package/dist/benchmarks/mcad-cq-golds.js +1 -1
  60. package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
  61. package/dist/benchmarks/mcad-golds.d.ts +1 -1
  62. package/dist/benchmarks/mcad-golds.js.map +1 -1
  63. package/dist/benchmarks/mind2web.d.ts +3 -3
  64. package/dist/benchmarks/mind2web.js +62 -49
  65. package/dist/benchmarks/mind2web.js.map +1 -1
  66. package/dist/benchmarks/nomiracl.d.ts +2 -2
  67. package/dist/benchmarks/nomiracl.js +43 -36
  68. package/dist/benchmarks/nomiracl.js.map +1 -1
  69. package/dist/benchmarks/open-rag-bench.d.ts +2 -2
  70. package/dist/benchmarks/open-rag-bench.js +37 -32
  71. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  72. package/dist/benchmarks/programbench.d.ts +2 -2
  73. package/dist/benchmarks/programbench.js +28 -23
  74. package/dist/benchmarks/programbench.js.map +1 -1
  75. package/dist/benchmarks/rag-shared.d.ts +2 -2
  76. package/dist/benchmarks/rag-shared.js +15 -13
  77. package/dist/benchmarks/rag-shared.js.map +1 -1
  78. package/dist/benchmarks/ragbench.d.ts +2 -2
  79. package/dist/benchmarks/ragbench.js +34 -29
  80. package/dist/benchmarks/ragbench.js.map +1 -1
  81. package/dist/benchmarks/simpleqa.d.ts +2 -2
  82. package/dist/benchmarks/simpleqa.js +62 -51
  83. package/dist/benchmarks/simpleqa.js.map +1 -1
  84. package/dist/benchmarks/swe-bench.d.ts +4 -4
  85. package/dist/benchmarks/swe-bench.js +47 -41
  86. package/dist/benchmarks/swe-bench.js.map +1 -1
  87. package/dist/benchmarks/t2-ragbench.d.ts +2 -2
  88. package/dist/benchmarks/t2-ragbench.js +37 -32
  89. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  90. package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
  91. package/dist/benchmarks/tau-bench-shared.js +43 -36
  92. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  93. package/dist/benchmarks/tau2-bench.d.ts +2 -2
  94. package/dist/benchmarks/tau2-bench.js.map +1 -1
  95. package/dist/benchmarks/tau3-banking.d.ts +2 -2
  96. package/dist/benchmarks/tau3-banking.js.map +1 -1
  97. package/dist/benchmarks/terminal-bench.d.ts +2 -2
  98. package/dist/benchmarks/terminal-bench.js +29 -23
  99. package/dist/benchmarks/terminal-bench.js.map +1 -1
  100. package/dist/benchmarks/toollm.d.ts +2 -2
  101. package/dist/benchmarks/toollm.js +40 -34
  102. package/dist/benchmarks/toollm.js.map +1 -1
  103. package/dist/benchmarks/trata-hedge.d.ts +2 -2
  104. package/dist/benchmarks/trata-hedge.js +46 -38
  105. package/dist/benchmarks/trata-hedge.js.map +1 -1
  106. package/dist/benchmarks/types.d.ts +33 -63
  107. package/dist/benchmarks/types.js +36 -1
  108. package/dist/benchmarks/types.js.map +1 -0
  109. package/dist/benchmarks/webarena-verified.d.ts +2 -2
  110. package/dist/benchmarks/webarena-verified.js +29 -24
  111. package/dist/benchmarks/webarena-verified.js.map +1 -1
  112. package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
  113. package/dist/cadbench-htzAmMaI.js.map +1 -0
  114. package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
  115. package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
  116. package/dist/cli.d.ts +1 -0
  117. package/dist/cli.js +667 -0
  118. package/dist/cli.js.map +1 -0
  119. package/dist/index.d.ts +9 -8
  120. package/dist/index.js +61 -56
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/scripts/enterpriseops-gym-run.sh +82 -0
  124. package/scripts/grade-recorded-evidence.mjs +6 -6
  125. package/scripts/harvey-lab-judge.py +50 -0
  126. package/scripts/harvey-lab-run.sh +53 -0
  127. package/scripts/harvey-lab-sandbox.sh +21 -0
  128. package/scripts/healthbench-professional-run.sh +30 -0
  129. package/scripts/healthbench_professional_run.py +112 -0
  130. package/scripts/mlcr-run.sh +17 -0
  131. package/scripts/mlcr_run.py +133 -0
  132. package/scripts/prbench-run.sh +39 -0
  133. package/scripts/prbench_run.py +53 -0
  134. package/scripts/verify-packed-consumer.mjs +32 -27
  135. package/src/adapters.ts +5 -7
  136. package/src/benchmarks/_harness.test.mts +18 -1
  137. package/src/benchmarks/_harness.ts +12 -7
  138. package/src/benchmarks/aec-bench.test.mts +14 -14
  139. package/src/benchmarks/aec-bench.ts +62 -56
  140. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  141. package/src/benchmarks/agentbench.ts +44 -37
  142. package/src/benchmarks/appworld.test.mts +7 -7
  143. package/src/benchmarks/appworld.ts +88 -75
  144. package/src/benchmarks/bfcl.ts +60 -53
  145. package/src/benchmarks/cad-design.ts +34 -32
  146. package/src/benchmarks/cadbench.ts +34 -32
  147. package/src/benchmarks/cadgenbench.ts +30 -28
  148. package/src/benchmarks/commit0.test.mts +9 -9
  149. package/src/benchmarks/commit0.ts +50 -43
  150. package/src/benchmarks/crag.ts +45 -40
  151. package/src/benchmarks/dabstep-official.test.mts +8 -8
  152. package/src/benchmarks/dabstep.test.mts +11 -11
  153. package/src/benchmarks/dabstep.ts +47 -40
  154. package/src/benchmarks/external-adapters.test.mts +43 -44
  155. package/src/benchmarks/finresearchbench.ts +57 -47
  156. package/src/benchmarks/finsearchcomp.ts +72 -67
  157. package/src/benchmarks/frames.ts +76 -69
  158. package/src/benchmarks/hotpotqa.ts +69 -64
  159. package/src/benchmarks/humaneval.ts +37 -35
  160. package/src/benchmarks/mcad-bench.test.mts +30 -30
  161. package/src/benchmarks/mcad-bench.ts +66 -60
  162. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  163. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  164. package/src/benchmarks/mcad-cq.test.mts +40 -40
  165. package/src/benchmarks/mcad-golds.ts +1 -1
  166. package/src/benchmarks/mind2web.ts +66 -58
  167. package/src/benchmarks/nomiracl.ts +53 -46
  168. package/src/benchmarks/open-rag-bench.ts +47 -42
  169. package/src/benchmarks/programbench.test.mts +10 -10
  170. package/src/benchmarks/programbench.ts +38 -33
  171. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  172. package/src/benchmarks/rag-shared.ts +13 -16
  173. package/src/benchmarks/ragbench.ts +44 -39
  174. package/src/benchmarks/simpleqa.ts +78 -73
  175. package/src/benchmarks/swe-bench.test.mts +3 -3
  176. package/src/benchmarks/swe-bench.ts +66 -61
  177. package/src/benchmarks/t2-ragbench.ts +47 -42
  178. package/src/benchmarks/tau-bench-shared.ts +51 -44
  179. package/src/benchmarks/tau-pin.test.mts +1 -1
  180. package/src/benchmarks/tau2-bench.ts +2 -2
  181. package/src/benchmarks/tau3-banking.ts +2 -2
  182. package/src/benchmarks/terminal-bench.test.mts +3 -3
  183. package/src/benchmarks/terminal-bench.ts +41 -36
  184. package/src/benchmarks/toollm.ts +54 -47
  185. package/src/benchmarks/trata-hedge.ts +57 -52
  186. package/src/benchmarks/types.ts +70 -59
  187. package/src/benchmarks/webarena-verified.ts +49 -42
  188. package/src/cli.ts +74 -0
  189. package/src/corpus-replay.mts +9 -9
  190. package/src/examples/benchmark-matrix.mts +13 -10
  191. package/src/gate-cli.mts +5 -5
  192. package/src/gate.test.mts +14 -12
  193. package/src/gate.ts +23 -22
  194. package/src/index.ts +17 -11
  195. package/src/published.test.mts +534 -0
  196. package/src/published.ts +524 -0
  197. package/src/run-benchmarks-cli.mts +2 -2
  198. package/src/run-benchmarks.test.mts +58 -48
  199. package/src/run-benchmarks.ts +64 -57
  200. package/src/swe-bench-env.ts +6 -6
  201. package/src/worker.ts +1 -1
  202. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  203. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  204. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  205. package/dist/cadbench-Byr5gO1M.js.map +0 -1
  206. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  207. package/fixtures/enterpriseops-gym.json +0 -103
  208. package/scripts/enterpriseops_gym_judge.py +0 -281
  209. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  210. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  211. package/src/eops-skills/address-every-subtask.md +0 -5
  212. package/src/eops-skills/exact-tools-and-args.md +0 -5
  213. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  214. package/src/eops-skills/ground-every-value.md +0 -5
  215. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -1,3 +1,4 @@
1
+ import { runtimeBenchmark } from "./types.js";
1
2
  import { join } from "node:path";
2
3
  import { execFile } from "node:child_process";
3
4
  import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -213,7 +214,7 @@ function toBenchTask(t) {
213
214
  };
214
215
  return {
215
216
  id: t.taskId,
216
- prompt: basePrompt(t),
217
+ payload: { prompt: basePrompt(t) },
217
218
  metadata
218
219
  };
219
220
  }
@@ -228,51 +229,54 @@ function taskFromMeta(task) {
228
229
  };
229
230
  }
230
231
  /** The HumanEval `BenchmarkAdapter`. OFFSET (env) selects the correctable middle
231
- * band; loadTasks honors `limit`/`ids`. The judge is the Docker deployable checker. */
232
+ * band; loadAll honors `limit`/`ids`. The judge is the Docker deployable checker. */
232
233
  function createHumanEvalAdapter() {
233
- return {
234
- name: "humaneval",
235
- async preflight() {
236
- await new Promise((resolve, reject) => {
237
- execFile("docker", [
238
- "version",
239
- "--format",
240
- "{{.Server.Version}}"
241
- ], (err) => {
242
- if (err) reject(/* @__PURE__ */ new Error("HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)"));
243
- else resolve();
244
- });
245
- });
246
- await new Promise((resolve, reject) => {
247
- execFile("docker", [
248
- "image",
249
- "inspect",
250
- dockerImage
251
- ], (err) => {
252
- if (err) reject(/* @__PURE__ */ new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`));
253
- else resolve();
254
- });
255
- });
256
- },
257
- async loadTasks(opts) {
234
+ return runtimeBenchmark({
235
+ id: "humaneval",
236
+ async loadAll(opts) {
258
237
  const offset = Number(process.env.OFFSET ?? 0);
259
238
  const all = await loadHumanEval(opts?.ids ? 164 : opts?.limit ?? 8, offset);
260
239
  return (opts?.ids ? all.filter((t) => opts.ids?.includes(t.taskId)) : all).map(toBenchTask);
261
240
  },
262
- async judge(task, artifact) {
241
+ async evaluate(task, artifact) {
263
242
  const { pass } = await runChecker(taskFromMeta(task), extractCode(artifact));
264
243
  return {
265
- resolved: pass === 1,
244
+ passed: pass === 1,
266
245
  score: pass,
267
- detail: pass === 1 ? "tests passed" : "tests failed"
246
+ notes: pass === 1 ? "tests passed" : "tests failed",
247
+ raw: {}
268
248
  };
269
249
  },
270
- async goldArtifact(task) {
271
- const m = task.metadata;
272
- const sol = m?.canonicalSolution;
273
- return sol ? `${m.promptHeader}${sol}` : void 0;
250
+ runtime: {
251
+ async preflight() {
252
+ await new Promise((resolve, reject) => {
253
+ execFile("docker", [
254
+ "version",
255
+ "--format",
256
+ "{{.Server.Version}}"
257
+ ], (err) => {
258
+ if (err) reject(/* @__PURE__ */ new Error("HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)"));
259
+ else resolve();
260
+ });
261
+ });
262
+ await new Promise((resolve, reject) => {
263
+ execFile("docker", [
264
+ "image",
265
+ "inspect",
266
+ dockerImage
267
+ ], (err) => {
268
+ if (err) reject(/* @__PURE__ */ new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`));
269
+ else resolve();
270
+ });
271
+ });
272
+ },
273
+ async goldArtifact(task) {
274
+ const m = task.metadata;
275
+ const sol = m?.canonicalSolution;
276
+ return sol ? `${m.promptHeader}${sol}` : void 0;
277
+ }
274
278
  }
275
- };
279
+ });
276
280
  }
277
281
  export { basePrompt, createHumanEvalAdapter, extractCode, loadHumanEval, runChecker, runPythonProgram };
278
282
 
@@ -1 +1 @@
1
- {"version":3,"file":"humaneval.js","names":[],"sources":["../../src/benchmarks/humaneval.ts"],"sourcesContent":["/**\n * HumanEval adapter — the deployable-checker domain as a `BenchmarkAdapter`, so the\n * gate runner (`runGate`) can A/B the STEERING regime on it: a real rollout\n * through the `Supervisor` that self-corrects across rounds, vs blind\n * random@k. This is the experiment `humaneval-gate.mts` names as \"the next one\" —\n * the gate measures SELECTION over stateless single completions; this measures\n * whether observe→steer (self-correction) beats blind compute at equal k.\n *\n * Worker artifact = the model's reply (a Python function, fenced or raw). The\n * DETERMINISTIC judge runs the candidate against the task's own `test` in an\n * isolated `--network=none` python container — exit 0 = pass. No gold\n * `canonical_solution` is ever shown to the model; `goldArtifact` returns it only\n * to self-verify the judge before spending tokens.\n *\n * The primitives (loader / extractor / Docker checker) live here and are reused by\n * `humaneval-gate.mts` — one home, no duplication.\n */\n\nimport { execFile } from 'node:child_process'\nimport { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { gunzipSync } from 'node:zlib'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst humanevalUrl = 'https://github.com/openai/human-eval/raw/master/data/HumanEval.jsonl.gz'\nconst dockerImage = 'python:3.12-slim'\nconst dockerTimeoutMs = Number(process.env.DOCKER_TIMEOUT_MS ?? 20000)\n\nexport interface HumanEvalTask {\n taskId: string\n prompt: string\n test: string\n entryPoint: string\n /** Reference solution body — used ONLY to self-verify the judge, never shown to the worker. */\n canonicalSolution?: string\n}\n\n/** Pull the 164-task HumanEval JSONL.gz and parse it. Fail loud on a non-OK fetch\n * or a malformed line — a silently-short task set would poison the gate. `offset`\n * selects a deeper slice (the later tasks are harder) so the worker has a\n * correctable middle band rather than a saturated easy prefix. */\nexport async function loadHumanEval(limit: number, offset = 0): Promise<HumanEvalTask[]> {\n // Prefer a locally-cached .jsonl.gz (HUMANEVAL_GZ) — the GitHub raw URL rate-limits\n // (429) under repeated runs. Fall back to the network fetch when unset.\n const localGz = process.env.HUMANEVAL_GZ\n let gz: Buffer\n if (localGz) {\n gz = readFileSync(localGz)\n } else {\n const res = await fetch(humanevalUrl)\n if (!res.ok) throw new Error(`HumanEval fetch HTTP ${res.status}: ${humanevalUrl}`)\n gz = Buffer.from(await res.arrayBuffer())\n }\n const text = gunzipSync(gz).toString('utf8')\n const tasks: HumanEvalTask[] = []\n for (const line of text.split('\\n')) {\n if (line.trim() === '') continue\n const d = JSON.parse(line) as {\n task_id?: string\n prompt?: string\n test?: string\n entry_point?: string\n canonical_solution?: string\n }\n if (!d.task_id || !d.prompt || !d.test || !d.entry_point) {\n throw new Error(`malformed HumanEval record: ${line.slice(0, 120)}`)\n }\n tasks.push({\n taskId: d.task_id,\n prompt: d.prompt,\n test: d.test,\n entryPoint: d.entry_point,\n ...(d.canonical_solution ? { canonicalSolution: d.canonical_solution } : {}),\n })\n }\n if (tasks.length === 0) throw new Error('HumanEval parsed to 0 tasks')\n if (offset >= tasks.length) throw new Error(`OFFSET ${offset} >= dataset size ${tasks.length}`)\n return tasks.slice(offset, offset + limit)\n}\n\nconst solveInstruction =\n 'Complete the following Python function. Output the COMPLETE function definition (signature, docstring optional, body) inside a single ```python code block. Include any imports the function needs. Do not write tests or example calls.'\n\nexport function basePrompt(task: HumanEvalTask): string {\n return `${solveInstruction}\\n\\n\\`\\`\\`python\\n${task.prompt}\\`\\`\\``\n}\n\n/** Extract the function source from a model reply: prefer a fenced ```python (or\n * bare ```) block, else fall back to the raw text. The deployable program adds the\n * prompt header (imports + signature context), so a candidate that returns only a\n * body still runs; a candidate that re-defines the function shadows the header. */\nexport function extractCode(reply: string): string {\n const fenced = reply.match(/```(?:python|py)?\\s*\\n([\\s\\S]*?)```/i)\n if (fenced && typeof fenced[1] === 'string') return fenced[1].trim()\n return reply.trim()\n}\n\n/** The deployable test program: the prompt header (imports + signature/docstring the\n * model was given), then the candidate (its def shadows the header's stub), then the\n * task's own check() suite and the call. No gold solution anywhere. */\nfunction buildProgram(task: HumanEvalTask, candidate: string): string {\n return `${task.prompt}\\n${candidate}\\n\\n${task.test}\\n\\ncheck(${task.entryPoint})\\n`\n}\n\nexport interface CheckResult {\n /** {0,1} pass-count for this candidate (1 = the check() suite passed). */\n pass: number\n /** On failure: the interpreter stderr tail (traceback / failing assertion). The\n * execution-grounded feedback a self-repair loop steers on; ignored by selection. */\n detail?: string\n}\n\nexport interface PythonProgramResult {\n exitCode: number\n stdout: string\n stderr: string\n}\n\n/** Run one candidate's deployable test program in an isolated container:\n * read-only root, bounded writable `/tmp`, no network, one CPU, and 512 MiB.\n * Exit 0 → pass. A docker invocation error (binary missing, daemon down, image\n * unavailable) is NOT a test failure — it throws so the harness fails loud rather\n * than scoring every candidate 0 from a broken checker. */\nlet dockerRunSeq = 0\n\n/** Run arbitrary Python in the same isolated container used by the HumanEval\n * checker. This is also the execution-tool primitive for experiments that let\n * a model test its own snippets; model-written code must never run on the host. */\nexport function runPythonProgram(\n program: string,\n timeoutMs = dockerTimeoutMs,\n): Promise<PythonProgramResult> {\n const dir = mkdtempSync(join(tmpdir(), 'hev-'))\n // Rootless Docker maps container root to a subordinate host uid that cannot\n // traverse mkdtemp's default 0700 directory. The directory contains only the\n // disposable candidate script and is mounted read-only into the container.\n chmodSync(dir, 0o755)\n writeFileSync(join(dir, 'p.py'), program, { mode: 0o644 })\n // Unique container name so we can force-reap it regardless of the docker client's state.\n const name = `hev-${process.pid}-${dockerRunSeq++}`\n const startMarker = `__AGENT_RUNTIME_CANDIDATE_STARTED_${name}__`\n return new Promise<PythonProgramResult>((resolvePromise, reject) => {\n let settled = false\n const cleanup = () => {\n rmSync(dir, { recursive: true, force: true })\n // `execFile`'s `timeout` kills the docker CLIENT, not the container — a hung\n // `python` would otherwise pin a CPU forever. Force-reap by name (fire-and-forget;\n // the name is unique, so no reuse race).\n execFile('docker', ['rm', '-f', name], () => {})\n }\n const finish = (res: PythonProgramResult) => {\n if (settled) return\n settled = true\n clearTimeout(backstop)\n cleanup()\n resolvePromise(res)\n }\n const fail = (e: Error) => {\n if (settled) return\n settled = true\n clearTimeout(backstop)\n cleanup()\n reject(e)\n }\n // Candidate timeouts are enforced inside the container. If the outer Docker\n // client or daemon misses this larger deadline, that is infrastructure failure,\n // not a wrong answer.\n const outerTimeoutMs = timeoutMs + 3_000\n const backstop = setTimeout(\n () => fail(new Error(`docker checker did not return within ${outerTimeoutMs + 3_000}ms`)),\n outerTimeoutMs + 3_000,\n )\n const inContainerSeconds = Math.max(1, Math.ceil(timeoutMs / 1_000))\n execFile(\n 'docker',\n [\n 'run',\n '--rm',\n '--pull=never',\n '--name',\n name,\n '--network=none',\n '--cpus=1',\n '--memory=512m',\n '--pids-limit=64',\n '--cap-drop=ALL',\n '--security-opt=no-new-privileges',\n '--read-only',\n '--tmpfs',\n '/tmp:rw,nosuid,nodev,noexec,size=64m,mode=1777',\n '--user',\n '65534:65534',\n '-v',\n `${dir}:/w:ro`,\n '-w',\n '/w',\n dockerImage,\n 'sh',\n '-c',\n 'command -v timeout >/dev/null 2>&1 && command -v python >/dev/null 2>&1 && [ -r /w/p.py ] || exit 126; printf \"%s\\\\n\" \"$1\"; exec timeout -s KILL \"$2\" python /w/p.py',\n 'agent-runtime-checker',\n startMarker,\n `${inContainerSeconds}s`,\n ],\n { timeout: outerTimeoutMs, killSignal: 'SIGKILL', maxBuffer: 4 * 1024 * 1024 },\n (err, stdout, stderr) => {\n const markerLine = `${startMarker}\\n`\n const candidateStarted = stdout?.startsWith(markerLine) === true\n const candidateStdout = candidateStarted ? stdout.slice(markerLine.length) : (stdout ?? '')\n if (err) {\n const e = err as Error & { killed?: boolean; code?: number | string }\n if (e.code === 'ENOENT') {\n fail(new Error('docker binary not found on PATH — cannot run the deployable checker'))\n return\n }\n if (e.killed) {\n fail(new Error(`docker checker exceeded its ${outerTimeoutMs}ms outer timeout`))\n return\n }\n if (!candidateStarted) {\n if (\n /cannot connect to the docker daemon|is the docker daemon running|permission denied while trying to connect/i.test(\n stderr,\n )\n ) {\n fail(new Error(`docker daemon unreachable: ${stderr.slice(0, 200)}`))\n return\n }\n if (/unable to find image|no such image|pull access denied|manifest unknown/i.test(stderr)) {\n fail(new Error(`docker image ${dockerImage} unavailable: ${stderr.slice(0, 200)}`))\n return\n }\n fail(\n new Error(\n `docker checker did not start the candidate: ${stderr.slice(0, 200) || e.message}`,\n ),\n )\n return\n }\n const exitCode = typeof e.code === 'number' ? e.code : 1\n finish({\n exitCode,\n stdout: candidateStdout,\n stderr: stderr ?? '',\n })\n return\n }\n if (!candidateStarted) {\n fail(new Error('docker checker exited without starting the candidate'))\n return\n }\n finish({ exitCode: 0, stdout: candidateStdout, stderr: stderr ?? '' })\n },\n )\n })\n}\n\nexport async function runChecker(task: HumanEvalTask, candidate: string): Promise<CheckResult> {\n const result = await runPythonProgram(buildProgram(task, candidate))\n return result.exitCode === 0\n ? { pass: 1 }\n : { pass: 0, detail: result.stderr.slice(-600) || 'timed out (no output)' }\n}\n\n/** A HumanEval task carries its checker inputs in metadata so the deterministic\n * judge can rebuild the deployable program from a `BenchTask` alone. */\ninterface HumanEvalMeta extends Record<string, unknown> {\n promptHeader: string\n test: string\n entryPoint: string\n canonicalSolution?: string\n}\n\nfunction toBenchTask(t: HumanEvalTask): BenchTask {\n const metadata: HumanEvalMeta = {\n promptHeader: t.prompt,\n test: t.test,\n entryPoint: t.entryPoint,\n ...(t.canonicalSolution ? { canonicalSolution: t.canonicalSolution } : {}),\n }\n return { id: t.taskId, prompt: basePrompt(t), metadata }\n}\n\nfunction taskFromMeta(task: BenchTask): HumanEvalTask {\n const m = task.metadata as HumanEvalMeta | undefined\n if (!m?.promptHeader || !m.test || !m.entryPoint) {\n throw new Error(`HumanEval judge: task ${task.id} missing checker metadata`)\n }\n return { taskId: task.id, prompt: m.promptHeader, test: m.test, entryPoint: m.entryPoint }\n}\n\n/** The HumanEval `BenchmarkAdapter`. OFFSET (env) selects the correctable middle\n * band; loadTasks honors `limit`/`ids`. The judge is the Docker deployable checker. */\nexport function createHumanEvalAdapter(): BenchmarkAdapter {\n return {\n name: 'humaneval',\n async preflight() {\n // Prove the daemon and exact local image before any model call. Scoring uses\n // --pull=never so a registry or cold pull cannot become a candidate outcome.\n await new Promise<void>((resolve, reject) => {\n execFile('docker', ['version', '--format', '{{.Server.Version}}'], (err) => {\n if (err) reject(new Error('HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)'))\n else resolve()\n })\n })\n await new Promise<void>((resolve, reject) => {\n execFile('docker', ['image', 'inspect', dockerImage], (err) => {\n if (err) reject(new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`))\n else resolve()\n })\n })\n },\n async loadTasks(opts?: LoadOptions) {\n const offset = Number(process.env.OFFSET ?? 0)\n // Pull a generous window when filtering by id, else exactly `limit` from offset.\n const all = await loadHumanEval(opts?.ids ? 164 : (opts?.limit ?? 8), offset)\n const picked = opts?.ids ? all.filter((t) => opts.ids?.includes(t.taskId)) : all\n return picked.map(toBenchTask)\n },\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const { pass } = await runChecker(taskFromMeta(task), extractCode(artifact))\n return { resolved: pass === 1, score: pass, detail: pass === 1 ? 'tests passed' : 'tests failed' }\n },\n async goldArtifact(task: BenchTask) {\n const m = task.metadata as HumanEvalMeta | undefined\n const sol = m?.canonicalSolution\n // Return the COMPLETE function (signature header + canonical body), i.e. what a\n // real worker emits — NOT the body alone. The judge runs `extractCode`, whose\n // unfenced fallback is `reply.trim()`; trimming a body-only string strips its\n // leading indent and breaks it, so a body-only gold fails its own judge. A full\n // def starts at column 0, trims safely, and self-verifies.\n return sol ? `${m!.promptHeader}${sol}` : undefined\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,kBAAkB,OAAO,QAAQ,IAAI,qBAAqB,GAAK;;;;;AAerE,eAAsB,cAAc,OAAe,SAAS,GAA6B;CAGvF,MAAM,UAAU,QAAQ,IAAI;CAC5B,IAAI;CACJ,IAAI,SACF,KAAK,aAAa,OAAO;MACpB;EACL,MAAM,MAAM,MAAM,MAAM,YAAY;EACpC,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,wBAAwB,IAAI,OAAO,IAAI,cAAc;EAClF,KAAK,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC;CAC1C;CACA,MAAM,OAAO,WAAW,EAAE,CAAC,CAAC,SAAS,MAAM;CAC3C,MAAM,QAAyB,CAAC;CAChC,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;EACnC,IAAI,KAAK,KAAK,MAAM,IAAI;EACxB,MAAM,IAAI,KAAK,MAAM,IAAI;EAOzB,IAAI,CAAC,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE,aAC3C,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,SAAgB,yBAA2C;CACzD,OAAO;EACL,MAAM;EACN,MAAM,YAAY;GAGhB,MAAM,IAAI,SAAe,SAAS,WAAW;IAC3C,SAAS,UAAU;KAAC;KAAW;KAAY;IAAqB,IAAI,QAAQ;KAC1E,IAAI,KAAK,uBAAO,IAAI,MAAM,kFAAkF,CAAC;UACxG,QAAQ;IACf,CAAC;GACH,CAAC;GACD,MAAM,IAAI,SAAe,SAAS,WAAW;IAC3C,SAAS,UAAU;KAAC;KAAS;KAAW;IAAW,IAAI,QAAQ;KAC7D,IAAI,KAAK,uBAAO,IAAI,MAAM,iDAAiD,aAAa,CAAC;UACpF,QAAQ;IACf,CAAC;GACH,CAAC;EACH;EACA,MAAM,UAAU,MAAoB;GAClC,MAAM,SAAS,OAAO,QAAQ,IAAI,UAAU,CAAC;GAE7C,MAAM,MAAM,MAAM,cAAc,MAAM,MAAM,MAAO,MAAM,SAAS,GAAI,MAAM;GAE5E,QADe,MAAM,MAAM,IAAI,QAAQ,MAAM,KAAK,KAAK,SAAS,EAAE,MAAM,CAAC,IAAI,IAAA,CAC/D,IAAI,WAAW;EAC/B;EACA,MAAM,MAAM,MAAiB,UAAuC;GAClE,MAAM,EAAE,SAAS,MAAM,WAAW,aAAa,IAAI,GAAG,YAAY,QAAQ,CAAC;GAC3E,OAAO;IAAE,UAAU,SAAS;IAAG,OAAO;IAAM,QAAQ,SAAS,IAAI,iBAAiB;GAAe;EACnG;EACA,MAAM,aAAa,MAAiB;GAClC,MAAM,IAAI,KAAK;GACf,MAAM,MAAM,GAAG;GAMf,OAAO,MAAM,GAAG,EAAG,eAAe,QAAQ,KAAA;EAC5C;CACF;AACF"}
1
+ {"version":3,"file":"humaneval.js","names":[],"sources":["../../src/benchmarks/humaneval.ts"],"sourcesContent":["/**\n * HumanEval adapter — the deployable-checker domain as a `BenchmarkAdapter`, so the\n * gate runner (`runGate`) can A/B the STEERING regime on it: a real rollout\n * through the `Supervisor` that self-corrects across rounds, vs blind\n * random@k. This is the experiment `humaneval-gate.mts` names as \"the next one\" —\n * the gate measures SELECTION over stateless single completions; this measures\n * whether observe→steer (self-correction) beats blind compute at equal k.\n *\n * Worker artifact = the model's reply (a Python function, fenced or raw). The\n * DETERMINISTIC judge runs the candidate against the task's own `test` in an\n * isolated `--network=none` python container — exit 0 = pass. No gold\n * `canonical_solution` is ever shown to the model; `goldArtifact` returns it only\n * to self-verify the judge before spending tokens.\n *\n * The primitives (loader / extractor / Docker checker) live here and are reused by\n * `humaneval-gate.mts` — one home, no duplication.\n */\n\nimport { execFile } from 'node:child_process'\nimport { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { gunzipSync } from 'node:zlib'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\nconst humanevalUrl = 'https://github.com/openai/human-eval/raw/master/data/HumanEval.jsonl.gz'\nconst dockerImage = 'python:3.12-slim'\nconst dockerTimeoutMs = Number(process.env.DOCKER_TIMEOUT_MS ?? 20000)\n\nexport interface HumanEvalTask {\n taskId: string\n prompt: string\n test: string\n entryPoint: string\n /** Reference solution body — used ONLY to self-verify the judge, never shown to the worker. */\n canonicalSolution?: string\n}\n\n/** Pull the 164-task HumanEval JSONL.gz and parse it. Fail loud on a non-OK fetch\n * or a malformed line — a silently-short task set would poison the gate. `offset`\n * selects a deeper slice (the later tasks are harder) so the worker has a\n * correctable middle band rather than a saturated easy prefix. */\nexport async function loadHumanEval(limit: number, offset = 0): Promise<HumanEvalTask[]> {\n // Prefer a locally-cached .jsonl.gz (HUMANEVAL_GZ) — the GitHub raw URL rate-limits\n // (429) under repeated runs. Fall back to the network fetch when unset.\n const localGz = process.env.HUMANEVAL_GZ\n let gz: Buffer\n if (localGz) {\n gz = readFileSync(localGz)\n } else {\n const res = await fetch(humanevalUrl)\n if (!res.ok) throw new Error(`HumanEval fetch HTTP ${res.status}: ${humanevalUrl}`)\n gz = Buffer.from(await res.arrayBuffer())\n }\n const text = gunzipSync(gz).toString('utf8')\n const tasks: HumanEvalTask[] = []\n for (const line of text.split('\\n')) {\n if (line.trim() === '') continue\n const d = JSON.parse(line) as {\n task_id?: string\n prompt?: string\n test?: string\n entry_point?: string\n canonical_solution?: string\n }\n if (!d.task_id || !d.prompt || !d.test || !d.entry_point) {\n throw new Error(`malformed HumanEval record: ${line.slice(0, 120)}`)\n }\n tasks.push({\n taskId: d.task_id,\n prompt: d.prompt,\n test: d.test,\n entryPoint: d.entry_point,\n ...(d.canonical_solution ? { canonicalSolution: d.canonical_solution } : {}),\n })\n }\n if (tasks.length === 0) throw new Error('HumanEval parsed to 0 tasks')\n if (offset >= tasks.length) throw new Error(`OFFSET ${offset} >= dataset size ${tasks.length}`)\n return tasks.slice(offset, offset + limit)\n}\n\nconst solveInstruction =\n 'Complete the following Python function. Output the COMPLETE function definition (signature, docstring optional, body) inside a single ```python code block. Include any imports the function needs. Do not write tests or example calls.'\n\nexport function basePrompt(task: HumanEvalTask): string {\n return `${solveInstruction}\\n\\n\\`\\`\\`python\\n${task.prompt}\\`\\`\\``\n}\n\n/** Extract the function source from a model reply: prefer a fenced ```python (or\n * bare ```) block, else fall back to the raw text. The deployable program adds the\n * prompt header (imports + signature context), so a candidate that returns only a\n * body still runs; a candidate that re-defines the function shadows the header. */\nexport function extractCode(reply: string): string {\n const fenced = reply.match(/```(?:python|py)?\\s*\\n([\\s\\S]*?)```/i)\n if (fenced && typeof fenced[1] === 'string') return fenced[1].trim()\n return reply.trim()\n}\n\n/** The deployable test program: the prompt header (imports + signature/docstring the\n * model was given), then the candidate (its def shadows the header's stub), then the\n * task's own check() suite and the call. No gold solution anywhere. */\nfunction buildProgram(task: HumanEvalTask, candidate: string): string {\n return `${task.prompt}\\n${candidate}\\n\\n${task.test}\\n\\ncheck(${task.entryPoint})\\n`\n}\n\nexport interface CheckResult {\n /** {0,1} pass-count for this candidate (1 = the check() suite passed). */\n pass: number\n /** On failure: the interpreter stderr tail (traceback / failing assertion). The\n * execution-grounded feedback a self-repair loop steers on; ignored by selection. */\n detail?: string\n}\n\nexport interface PythonProgramResult {\n exitCode: number\n stdout: string\n stderr: string\n}\n\n/** Run one candidate's deployable test program in an isolated container:\n * read-only root, bounded writable `/tmp`, no network, one CPU, and 512 MiB.\n * Exit 0 → pass. A docker invocation error (binary missing, daemon down, image\n * unavailable) is NOT a test failure — it throws so the harness fails loud rather\n * than scoring every candidate 0 from a broken checker. */\nlet dockerRunSeq = 0\n\n/** Run arbitrary Python in the same isolated container used by the HumanEval\n * checker. This is also the execution-tool primitive for experiments that let\n * a model test its own snippets; model-written code must never run on the host. */\nexport function runPythonProgram(\n program: string,\n timeoutMs = dockerTimeoutMs,\n): Promise<PythonProgramResult> {\n const dir = mkdtempSync(join(tmpdir(), 'hev-'))\n // Rootless Docker maps container root to a subordinate host uid that cannot\n // traverse mkdtemp's default 0700 directory. The directory contains only the\n // disposable candidate script and is mounted read-only into the container.\n chmodSync(dir, 0o755)\n writeFileSync(join(dir, 'p.py'), program, { mode: 0o644 })\n // Unique container name so we can force-reap it regardless of the docker client's state.\n const name = `hev-${process.pid}-${dockerRunSeq++}`\n const startMarker = `__AGENT_RUNTIME_CANDIDATE_STARTED_${name}__`\n return new Promise<PythonProgramResult>((resolvePromise, reject) => {\n let settled = false\n const cleanup = () => {\n rmSync(dir, { recursive: true, force: true })\n // `execFile`'s `timeout` kills the docker CLIENT, not the container — a hung\n // `python` would otherwise pin a CPU forever. Force-reap by name (fire-and-forget;\n // the name is unique, so no reuse race).\n execFile('docker', ['rm', '-f', name], () => {})\n }\n const finish = (res: PythonProgramResult) => {\n if (settled) return\n settled = true\n clearTimeout(backstop)\n cleanup()\n resolvePromise(res)\n }\n const fail = (e: Error) => {\n if (settled) return\n settled = true\n clearTimeout(backstop)\n cleanup()\n reject(e)\n }\n // Candidate timeouts are enforced inside the container. If the outer Docker\n // client or daemon misses this larger deadline, that is infrastructure failure,\n // not a wrong answer.\n const outerTimeoutMs = timeoutMs + 3_000\n const backstop = setTimeout(\n () => fail(new Error(`docker checker did not return within ${outerTimeoutMs + 3_000}ms`)),\n outerTimeoutMs + 3_000,\n )\n const inContainerSeconds = Math.max(1, Math.ceil(timeoutMs / 1_000))\n execFile(\n 'docker',\n [\n 'run',\n '--rm',\n '--pull=never',\n '--name',\n name,\n '--network=none',\n '--cpus=1',\n '--memory=512m',\n '--pids-limit=64',\n '--cap-drop=ALL',\n '--security-opt=no-new-privileges',\n '--read-only',\n '--tmpfs',\n '/tmp:rw,nosuid,nodev,noexec,size=64m,mode=1777',\n '--user',\n '65534:65534',\n '-v',\n `${dir}:/w:ro`,\n '-w',\n '/w',\n dockerImage,\n 'sh',\n '-c',\n 'command -v timeout >/dev/null 2>&1 && command -v python >/dev/null 2>&1 && [ -r /w/p.py ] || exit 126; printf \"%s\\\\n\" \"$1\"; exec timeout -s KILL \"$2\" python /w/p.py',\n 'agent-runtime-checker',\n startMarker,\n `${inContainerSeconds}s`,\n ],\n { timeout: outerTimeoutMs, killSignal: 'SIGKILL', maxBuffer: 4 * 1024 * 1024 },\n (err, stdout, stderr) => {\n const markerLine = `${startMarker}\\n`\n const candidateStarted = stdout?.startsWith(markerLine) === true\n const candidateStdout = candidateStarted ? stdout.slice(markerLine.length) : (stdout ?? '')\n if (err) {\n const e = err as Error & { killed?: boolean; code?: number | string }\n if (e.code === 'ENOENT') {\n fail(new Error('docker binary not found on PATH — cannot run the deployable checker'))\n return\n }\n if (e.killed) {\n fail(new Error(`docker checker exceeded its ${outerTimeoutMs}ms outer timeout`))\n return\n }\n if (!candidateStarted) {\n if (\n /cannot connect to the docker daemon|is the docker daemon running|permission denied while trying to connect/i.test(\n stderr,\n )\n ) {\n fail(new Error(`docker daemon unreachable: ${stderr.slice(0, 200)}`))\n return\n }\n if (/unable to find image|no such image|pull access denied|manifest unknown/i.test(stderr)) {\n fail(new Error(`docker image ${dockerImage} unavailable: ${stderr.slice(0, 200)}`))\n return\n }\n fail(\n new Error(\n `docker checker did not start the candidate: ${stderr.slice(0, 200) || e.message}`,\n ),\n )\n return\n }\n const exitCode = typeof e.code === 'number' ? e.code : 1\n finish({\n exitCode,\n stdout: candidateStdout,\n stderr: stderr ?? '',\n })\n return\n }\n if (!candidateStarted) {\n fail(new Error('docker checker exited without starting the candidate'))\n return\n }\n finish({ exitCode: 0, stdout: candidateStdout, stderr: stderr ?? '' })\n },\n )\n })\n}\n\nexport async function runChecker(task: HumanEvalTask, candidate: string): Promise<CheckResult> {\n const result = await runPythonProgram(buildProgram(task, candidate))\n return result.exitCode === 0\n ? { pass: 1 }\n : { pass: 0, detail: result.stderr.slice(-600) || 'timed out (no output)' }\n}\n\n/** A HumanEval task carries its checker inputs in metadata so the deterministic\n * judge can rebuild the deployable program from a `BenchTask` alone. */\ninterface HumanEvalMeta extends Record<string, unknown> {\n promptHeader: string\n test: string\n entryPoint: string\n canonicalSolution?: string\n}\n\nfunction toBenchTask(t: HumanEvalTask): BenchTask {\n const metadata: HumanEvalMeta = {\n promptHeader: t.prompt,\n test: t.test,\n entryPoint: t.entryPoint,\n ...(t.canonicalSolution ? { canonicalSolution: t.canonicalSolution } : {}),\n }\n return { id: t.taskId, payload: { prompt: basePrompt(t) }, metadata }\n}\n\nfunction taskFromMeta(task: BenchTask): HumanEvalTask {\n const m = task.metadata as HumanEvalMeta | undefined\n if (!m?.promptHeader || !m.test || !m.entryPoint) {\n throw new Error(`HumanEval judge: task ${task.id} missing checker metadata`)\n }\n return { taskId: task.id, prompt: m.promptHeader, test: m.test, entryPoint: m.entryPoint }\n}\n\n/** The HumanEval `BenchmarkAdapter`. OFFSET (env) selects the correctable middle\n * band; loadAll honors `limit`/`ids`. The judge is the Docker deployable checker. */\nexport function createHumanEvalAdapter(): RuntimeBenchmark {\n return runtimeBenchmark({\n id: 'humaneval',\n async loadAll(opts?: LoadOptions) {\n const offset = Number(process.env.OFFSET ?? 0)\n // Pull a generous window when filtering by id, else exactly `limit` from offset.\n const all = await loadHumanEval(opts?.ids ? 164 : (opts?.limit ?? 8), offset)\n const picked = opts?.ids ? all.filter((t) => opts.ids?.includes(t.taskId)) : all\n return picked.map(toBenchTask)\n },\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const { pass } = await runChecker(taskFromMeta(task), extractCode(artifact))\n return { passed: pass === 1, score: pass, notes: pass === 1 ? 'tests passed' : 'tests failed', raw: {} }\n },\n runtime: {\n async preflight() {\n // Prove the daemon and exact local image before any model call. Scoring uses\n // --pull=never so a registry or cold pull cannot become a candidate outcome.\n await new Promise<void>((resolve, reject) => {\n execFile('docker', ['version', '--format', '{{.Server.Version}}'], (err) => {\n if (err) reject(new Error('HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)'))\n else resolve()\n })\n })\n await new Promise<void>((resolve, reject) => {\n execFile('docker', ['image', 'inspect', dockerImage], (err) => {\n if (err) reject(new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`))\n else resolve()\n })\n })\n },\n async goldArtifact(task: BenchTask) {\n const m = task.metadata as HumanEvalMeta | undefined\n const sol = m?.canonicalSolution\n // Return the COMPLETE function (signature header + canonical body), i.e. what a\n // real worker emits — NOT the body alone. The judge runs `extractCode`, whose\n // unfenced fallback is `reply.trim()`; trimming a body-only string strips its\n // leading indent and breaks it, so a body-only gold fails its own judge. A full\n // def starts at column 0, trims safely, and self-verifies.\n return sol ? `${m!.promptHeader}${sol}` : undefined\n },\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,kBAAkB,OAAO,QAAQ,IAAI,qBAAqB,GAAK;;;;;AAerE,eAAsB,cAAc,OAAe,SAAS,GAA6B;CAGvF,MAAM,UAAU,QAAQ,IAAI;CAC5B,IAAI;CACJ,IAAI,SACF,KAAK,aAAa,OAAO;MACpB;EACL,MAAM,MAAM,MAAM,MAAM,YAAY;EACpC,IAAI,CAAC,IAAI,IAAI,MAAM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,QAAQ;MAC7D,IAAI,KAAK,uBAAO,IAAI,MAAM,iDAAiD,aAAa,CAAC;WACpF,QAAQ;KACf,CAAC;IACH,CAAC;GACH;GACA,MAAM,aAAa,MAAiB;IAClC,MAAM,IAAI,KAAK;IACf,MAAM,MAAM,GAAG;IAMf,OAAO,MAAM,GAAG,EAAG,eAAe,QAAQ,KAAA;GAC5C;EACF;CACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  import { McadSpec } from "./mcad-tasks.js";
2
- import { BenchmarkAdapter } from "./types.js";
2
+ import { RuntimeBenchmark } from "./types.js";
3
3
  export interface Vec3 {
4
4
  x: number;
5
5
  y: number;
@@ -99,5 +99,5 @@ export declare function compileAndMeasure(src: string): Promise<{
99
99
  ok: false;
100
100
  detail: string;
101
101
  }>;
102
- export declare function createMcadBenchAdapter(): BenchmarkAdapter;
102
+ export declare function createMcadBenchAdapter(): RuntimeBenchmark;
103
103
  //# sourceMappingURL=mcad-bench.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { MCAD_GOLDS } from "./mcad-golds.js";
2
2
  import { MCAD_TASKS } from "./mcad-tasks.js";
3
+ import { runtimeBenchmark } from "./types.js";
3
4
  import { mkdtemp, readFile, writeFile } from "node:fs/promises";
4
5
  import { join } from "node:path";
5
6
  import { execFile } from "node:child_process";
@@ -26,9 +27,9 @@ import { promisify } from "node:util";
26
27
  * is not a closed solid has no well-defined volume or interior, so every downstream
27
28
  * number would be fiction. Otherwise the score is the fraction of ASSERTED spec
28
29
  * checks passed (each bbox axis, the volume band, the solids band, the triangle
29
- * floor, and EACH probe count as one check), and `resolved` requires all of them.
30
+ * floor, and EACH probe count as one check), and `passed` requires all of them.
30
31
  *
31
- * Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `loadTasks` and the
32
+ * Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `loadAll` and the
32
33
  * geometry engine below are dependency-free and run anywhere.
33
34
  *
34
35
  * Geometry checks 1-3 are ported from supervisor-lab's `bench/cad-stl-gate.ts`
@@ -467,27 +468,15 @@ async function compileAndMeasure(src) {
467
468
  };
468
469
  }
469
470
  function createMcadBenchAdapter() {
470
- return {
471
- name: "mcad",
472
- async preflight() {
473
- try {
474
- await execFileAsync("xvfb-run", [
475
- "-a",
476
- "openscad",
477
- "--version"
478
- ], { timeout: 3e4 });
479
- } catch (err) {
480
- const msg = err instanceof Error ? err.message : String(err);
481
- throw new Error(`mcad preflight failed: ${msg}\nFix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). The judge runs \`xvfb-run -a openscad --export-format=asciistl -o out.stl model.scad\` — both must be on PATH.`);
482
- }
483
- },
484
- async loadTasks(opts = {}) {
471
+ return runtimeBenchmark({
472
+ id: "mcad",
473
+ async loadAll(opts = {}) {
485
474
  let tasks = MCAD_TASKS;
486
475
  if (opts.ids) tasks = tasks.filter((t) => opts.ids?.includes(t.id));
487
476
  if (opts.limit != null) tasks = tasks.slice(0, opts.limit);
488
477
  return tasks.map((t) => ({
489
478
  id: t.id,
490
- prompt: t.prompt,
479
+ payload: { prompt: t.prompt },
491
480
  metadata: {
492
481
  spec: t.spec,
493
482
  source: t.source,
@@ -495,33 +484,31 @@ function createMcadBenchAdapter() {
495
484
  }
496
485
  }));
497
486
  },
498
- async goldArtifact(task) {
499
- return MCAD_GOLDS[task.id];
500
- },
501
- async judge(task, artifact) {
487
+ async evaluate(task, artifact) {
502
488
  const spec = task.metadata?.spec;
503
489
  if (!spec) return {
504
- resolved: false,
490
+ passed: false,
505
491
  score: 0,
506
- detail: `task ${task.id} carries no mcad spec`
492
+ notes: `task ${task.id} carries no mcad spec`,
493
+ raw: {}
507
494
  };
508
495
  const src = stripCodeFence(artifact);
509
496
  if (!src) return {
510
- resolved: false,
497
+ passed: false,
511
498
  score: 0,
512
- detail: "empty artifact"
499
+ notes: "empty artifact",
500
+ raw: {}
513
501
  };
514
502
  const built = await compileAndMeasure(src);
515
503
  if (!built.ok) return {
516
- resolved: false,
504
+ passed: false,
517
505
  score: 0,
518
- detail: built.detail
506
+ notes: built.detail,
507
+ raw: {}
519
508
  };
520
509
  const { geo, tris, stlPath } = built;
521
- if (!geo.watertight) return {
522
- resolved: false,
523
- score: 0,
524
- detail: JSON.stringify({
510
+ if (!geo.watertight) {
511
+ const raw = {
525
512
  gate: "watertight",
526
513
  failed: [{
527
514
  name: "watertight",
@@ -533,35 +520,60 @@ function createMcadBenchAdapter() {
533
520
  degenerateFaces: geo.degenerateFaces
534
521
  },
535
522
  stlPath
536
- })
537
- };
523
+ };
524
+ return {
525
+ passed: false,
526
+ score: 0,
527
+ notes: JSON.stringify(raw),
528
+ raw
529
+ };
530
+ }
538
531
  const scored = scoreAgainstSpec(geo, tris, spec);
532
+ const raw = {
533
+ failed: scored.failed.map((c) => ({
534
+ name: c.name,
535
+ measured: c.measured,
536
+ expected: c.expected
537
+ })),
538
+ checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
539
+ geo: {
540
+ triangles: geo.triangles,
541
+ solids: geo.solids,
542
+ volume: +geo.volume.toFixed(2),
543
+ degenerateFaces: geo.degenerateFaces,
544
+ bbox: {
545
+ x: +geo.bbox.size.x.toFixed(3),
546
+ y: +geo.bbox.size.y.toFixed(3),
547
+ z: +geo.bbox.size.z.toFixed(3)
548
+ }
549
+ },
550
+ stlPath
551
+ };
539
552
  return {
540
- resolved: scored.resolved,
553
+ passed: scored.resolved,
541
554
  score: scored.score,
542
- detail: JSON.stringify({
543
- failed: scored.failed.map((c) => ({
544
- name: c.name,
545
- measured: c.measured,
546
- expected: c.expected
547
- })),
548
- checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
549
- geo: {
550
- triangles: geo.triangles,
551
- solids: geo.solids,
552
- volume: +geo.volume.toFixed(2),
553
- degenerateFaces: geo.degenerateFaces,
554
- bbox: {
555
- x: +geo.bbox.size.x.toFixed(3),
556
- y: +geo.bbox.size.y.toFixed(3),
557
- z: +geo.bbox.size.z.toFixed(3)
558
- }
559
- },
560
- stlPath
561
- })
555
+ notes: JSON.stringify(raw),
556
+ raw
562
557
  };
558
+ },
559
+ runtime: {
560
+ async preflight() {
561
+ try {
562
+ await execFileAsync("xvfb-run", [
563
+ "-a",
564
+ "openscad",
565
+ "--version"
566
+ ], { timeout: 3e4 });
567
+ } catch (err) {
568
+ const msg = err instanceof Error ? err.message : String(err);
569
+ throw new Error(`mcad preflight failed: ${msg}\nFix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). The judge runs \`xvfb-run -a openscad --export-format=asciistl -o out.stl model.scad\` — both must be on PATH.`);
570
+ }
571
+ },
572
+ async goldArtifact(task) {
573
+ return MCAD_GOLDS[task.id];
574
+ }
563
575
  }
564
- };
576
+ });
565
577
  }
566
578
  export { compileAndMeasure, createMcadBenchAdapter, measureMesh, parseAsciiStl, pointInSolid, scoreAgainstSpec, stripCodeFence };
567
579
 
@@ -1 +1 @@
1
- {"version":3,"file":"mcad-bench.js","names":[],"sources":["../../src/benchmarks/mcad-bench.ts"],"sourcesContent":["/**\n * MCAD adapter. Worker artifact = OpenSCAD source for a dimensioned mechanical\n * part; judge = the REAL OpenSCAD kernel (compile + ASCII-STL export) followed by\n * pure-TS mesh measurement against the task's `McadSpec`. No LLM, no self-report:\n * the part either has the stated extents, volume, body count and holes, or it does\n * not.\n *\n * Pipeline, in order, and every stage is a hard fact about the produced mesh:\n * 1. compile : `xvfb-run -a openscad --export-format=asciistl -o out.stl` exits 0\n * 2. watertight : every undirected edge shared by exactly two faces (2-manifold)\n * 3. measure : bbox extents, enclosed volume (divergence theorem), connected\n * -component count (\"solids\"), triangle count\n * 4. probe : ray-parity point-in-solid at the spec's pinned hole/material\n * coordinates — this is what makes a missing or misplaced bore\n * fail, which no aggregate measure can catch\n *\n * Scoring: compile failure or a non-watertight mesh is 0 / unresolved — a mesh that\n * is not a closed solid has no well-defined volume or interior, so every downstream\n * number would be fiction. Otherwise the score is the fraction of ASSERTED spec\n * checks passed (each bbox axis, the volume band, the solids band, the triangle\n * floor, and EACH probe count as one check), and `resolved` requires all of them.\n *\n * Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `loadTasks` and the\n * geometry engine below are dependency-free and run anywhere.\n *\n * Geometry checks 1-3 are ported from supervisor-lab's `bench/cad-stl-gate.ts`\n * (edge-key manifold parity + signed-tetrahedron volume). Ported, not imported:\n * these packages do not share a dependency edge.\n */\n\nimport { execFile } from 'node:child_process'\nimport { mkdtemp, readFile, writeFile } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { promisify } from 'node:util'\nimport { MCAD_GOLDS } from './mcad-golds'\nimport { MCAD_TASKS, type McadSpec, type McadTask } from './mcad-tasks'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst execFileAsync = promisify(execFile)\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\n/** One triangle as three vertices, in the STL's stated winding order. */\nexport type Tri = readonly [Vec3, Vec3, Vec3]\n\nexport interface McadGeometry {\n triangles: number\n /** Edges NOT shared by exactly two faces. 0 iff the surface is closed + 2-manifold. */\n openEdges: number\n watertight: boolean\n /** Zero-area faces — bad geometry even when the topology closes. */\n degenerateFaces: number\n /** Enclosed volume (absolute) via the signed-tetrahedron sum. */\n volume: number\n /** Connected components of the triangle-adjacency graph = disconnected bodies. */\n solids: number\n bbox: { min: Vec3; max: Vec3; size: Vec3 }\n}\n\n/** Coincident-vertex quantisation, in model units (mm). */\nconst VERTEX_QUANTUM = 1e-6\nconst AREA_EPS = 1e-9\nconst VOLUME_EPS = 1e-9\n\n// ---------------------------------------------------------------------------\n// Mesh parsing + measurement (ported from supervisor-lab bench/cad-stl-gate.ts)\n// ---------------------------------------------------------------------------\n\n/** Parse an ASCII STL into triangles by reading `vertex x y z` lines in groups of three. */\nexport function parseAsciiStl(stl: string): Tri[] {\n const verts: Vec3[] = []\n for (const line of stl.split('\\n')) {\n const m = line.trim().match(/^vertex\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)/i)\n if (!m) continue\n const x = Number(m[1])\n const y = Number(m[2])\n const z = Number(m[3])\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) continue\n verts.push({ x, y, z })\n }\n const tris: Tri[] = []\n for (let i = 0; i + 2 < verts.length; i += 3) tris.push([verts[i]!, verts[i + 1]!, verts[i + 2]!])\n return tris\n}\n\n/** Quantise a vertex so shared edges match despite float authoring noise. */\nfunction vertexKey(v: Vec3): string {\n const r = (n: number) => (Math.round(n / VERTEX_QUANTUM) * VERTEX_QUANTUM).toFixed(6)\n return `${r(v.x)},${r(v.y)},${r(v.z)}`\n}\n\nfunction sub(a: Vec3, b: Vec3): Vec3 {\n return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }\n}\nfunction cross(a: Vec3, b: Vec3): Vec3 {\n return { x: a.y * b.z - a.z * b.y, y: a.z * b.x - a.x * b.z, z: a.x * b.y - a.y * b.x }\n}\nfunction dot(a: Vec3, b: Vec3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z\n}\nfunction norm(a: Vec3): number {\n return Math.sqrt(dot(a, a))\n}\nfunction normalize(a: Vec3): Vec3 {\n const n = norm(a)\n return { x: a.x / n, y: a.y / n, z: a.z / n }\n}\n\n/** Disjoint-set over triangle indices — the \"how many separate bodies\" primitive. */\nfunction findRoot(parent: Int32Array, i: number): number {\n let r = i\n while (parent[r] !== r) r = parent[r]!\n let c = i\n while (parent[c] !== c) {\n const next = parent[c]!\n parent[c] = r\n c = next\n }\n return r\n}\n\n/**\n * Measure the closed-solid properties of a triangle soup. Pure: no I/O, no deps.\n *\n * `solids` is the number of connected components of the graph whose nodes are\n * triangles and whose edges join two triangles that share a quantised mesh edge.\n * On a watertight mesh that count IS the number of disconnected bodies (an\n * enclosed internal cavity is its own shell and counts, which is the behaviour\n * the specs want — a \"hollow\" body that is really two nested shells is not one\n * fused solid).\n */\nexport function measureMesh(tris: Tri[]): McadGeometry {\n if (tris.length === 0) {\n const zero = { x: 0, y: 0, z: 0 }\n return {\n triangles: 0,\n openEdges: 0,\n watertight: false,\n degenerateFaces: 0,\n volume: 0,\n solids: 0,\n bbox: { min: zero, max: zero, size: zero },\n }\n }\n\n const min: Vec3 = { x: Number.POSITIVE_INFINITY, y: Number.POSITIVE_INFINITY, z: Number.POSITIVE_INFINITY }\n const max: Vec3 = { x: Number.NEGATIVE_INFINITY, y: Number.NEGATIVE_INFINITY, z: Number.NEGATIVE_INFINITY }\n const edgeFaces = new Map<string, number[]>()\n const parent = new Int32Array(tris.length)\n for (let i = 0; i < tris.length; i++) parent[i] = i\n let degenerateFaces = 0\n let volume6 = 0\n\n for (let i = 0; i < tris.length; i++) {\n const [a, b, c] = tris[i]!\n for (const v of [a, b, c]) {\n if (v.x < min.x) min.x = v.x\n if (v.y < min.y) min.y = v.y\n if (v.z < min.z) min.z = v.z\n if (v.x > max.x) max.x = v.x\n if (v.y > max.y) max.y = v.y\n if (v.z > max.z) max.z = v.z\n }\n if (norm(cross(sub(b, a), sub(c, a))) < AREA_EPS) degenerateFaces += 1\n volume6 += dot(a, cross(b, c))\n\n const ka = vertexKey(a)\n const kb = vertexKey(b)\n const kc = vertexKey(c)\n for (const [p, q] of [\n [ka, kb],\n [kb, kc],\n [kc, ka],\n ] as const) {\n const key = p < q ? `${p}|${q}` : `${q}|${p}`\n const seen = edgeFaces.get(key)\n if (seen) seen.push(i)\n else edgeFaces.set(key, [i])\n }\n }\n\n let openEdges = 0\n for (const faces of edgeFaces.values()) {\n if (faces.length !== 2) openEdges += 1\n // Union every face pair on this edge (a >2-face edge still connects bodies).\n const first = findRoot(parent, faces[0]!)\n for (let k = 1; k < faces.length; k++) {\n const other = findRoot(parent, faces[k]!)\n if (other !== first) parent[other] = first\n }\n }\n\n const roots = new Set<number>()\n for (let i = 0; i < tris.length; i++) roots.add(findRoot(parent, i))\n\n return {\n triangles: tris.length,\n openEdges,\n watertight: openEdges === 0,\n degenerateFaces,\n volume: Math.abs(volume6) / 6,\n solids: roots.size,\n bbox: {\n min: { ...min },\n max: { ...max },\n size: { x: max.x - min.x, y: max.y - min.y, z: max.z - min.z },\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Point-in-solid by ray parity\n// ---------------------------------------------------------------------------\n\n/**\n * Three fixed, mutually linearly-independent directions built from irrational\n * constants (sqrt(3)-1, sqrt(2)-1, 1/sqrt(5), 1/sqrt(3) and the plastic-number\n * pair 0.7548777 / 0.5698403). Their 3x3 determinant is ~1.77, so no two are\n * near-parallel and no plane contains all three.\n */\nconst RAY_DIRECTIONS: readonly Vec3[] = [\n normalize({ x: 1, y: 0.7548777, z: 0.5698403 }),\n normalize({ x: -0.7320508, y: 1, z: 0.236068 }),\n normalize({ x: 0.4472136, y: -0.5773503, z: 1 }),\n]\n\n/** Barycentric / parametric tolerances for calling a crossing \"on the boundary\". */\nconst BARY_EPS = 1e-9\nconst DET_EPS = 1e-12\nconst T_EPS = 1e-9\nconst MAX_JITTERS = 8\n\n/** Deterministic 32-bit PRNG (mulberry32) — seeded, so probes never use Math.random. */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** Stable integer hash of a probe point so its jitter sequence is reproducible. */\nfunction seedForPoint(p: Vec3, rayIndex: number): number {\n let h = 2166136261 ^ rayIndex\n for (const n of [p.x, p.y, p.z]) {\n const bits = Math.round(n * 1e6) | 0\n h = Math.imul(h ^ (bits & 0xffff), 16777619)\n h = Math.imul(h ^ ((bits >>> 16) & 0xffff), 16777619)\n }\n return h >>> 0\n}\n\ntype CastResult = { crossings: number } | { degenerate: true }\n\n/**\n * Moller-Trumbore crossing count along one ray. Returns `degenerate` when the ray\n * touches a triangle edge/vertex, lies in a triangle's plane, or starts on a face\n * — the three cases where a parity count is not trustworthy.\n */\nfunction castRay(tris: Tri[], origin: Vec3, dir: Vec3): CastResult {\n let crossings = 0\n for (const [v0, v1, v2] of tris) {\n const e1 = sub(v1, v0)\n const e2 = sub(v2, v0)\n const h = cross(dir, e2)\n const det = dot(e1, h)\n const scale = norm(e1) * norm(e2)\n if (Math.abs(det) <= DET_EPS * Math.max(scale, 1)) {\n // Ray parallel to (or inside) this triangle's plane. Only a problem when the\n // ray could actually meet the triangle; distinguishing that costs more than a\n // re-cast, so treat it as degenerate whenever the origin is near the plane.\n const n = cross(e1, e2)\n const nl = norm(n)\n if (nl > AREA_EPS && Math.abs(dot(sub(origin, v0), n)) / nl <= T_EPS) return { degenerate: true }\n continue\n }\n const f = 1 / det\n const s = sub(origin, v0)\n const u = f * dot(s, h)\n const q = cross(s, e1)\n const v = f * dot(dir, q)\n const w = 1 - u - v\n if (u < -BARY_EPS || v < -BARY_EPS || w < -BARY_EPS) continue\n const t = f * dot(e2, q)\n if (t < -T_EPS) continue\n // Inside the triangle (or within EPS of its border). Anything within EPS of a\n // border, or of the origin plane, makes the parity ambiguous.\n if (Math.abs(t) <= T_EPS) return { degenerate: true }\n if (u <= BARY_EPS || v <= BARY_EPS || w <= BARY_EPS) return { degenerate: true }\n crossings += 1\n }\n return { crossings }\n}\n\n/**\n * Point-in-solid membership by ray parity, made robust three ways.\n *\n * ROBUSTNESS ARGUMENT. A parity test is exact except on a measure-zero set: rays\n * that graze a triangle edge or vertex (the crossing is counted twice or zero\n * times), rays coplanar with a face, and origins lying on the surface. Those cases\n * are not merely rare here — they are SYSTEMATIC, because OpenSCAD emits\n * axis-aligned meshes whose vertices land on the same round millimetre lattice the\n * spec's probe coordinates come from, so an axis-aligned ray from a probe point\n * hits shared edges constantly. Three defences, in order:\n * 1. DIRECTIONS. The three fixed directions are irrational combinations, so a ray\n * from a lattice point cannot stay in an axis-aligned face plane and cannot\n * run along a lattice edge.\n * 2. DETECTION + DETERMINISTIC RE-JITTER. Grazing is DETECTED (a barycentric\n * coordinate within BARY_EPS of 0, |det| below DET_EPS with the origin in the\n * plane, or |t| within T_EPS) rather than hoped away. A detected ray is re-cast\n * with a small direction perturbation drawn from a mulberry32 PRNG seeded by\n * the probe coordinates and ray index, so the whole judge stays deterministic:\n * the same mesh and the same point always take the same sequence of re-casts.\n * 3. MAJORITY VOTE. The verdict is the majority of three independent directions,\n * so even an undetected miscount on one ray cannot flip the answer.\n * A point sitting exactly ON the surface has no correct answer; every direction\n * degenerates there and the vote falls back to whatever the jittered casts say.\n * The specs therefore place probes with >=1 mm clearance from any surface.\n */\nexport function pointInSolid(tris: Tri[], point: Vec3): boolean {\n let inside = 0\n let votes = 0\n for (let i = 0; i < RAY_DIRECTIONS.length; i++) {\n const base = RAY_DIRECTIONS[i]!\n const rand = mulberry32(seedForPoint(point, i))\n let dir = base\n for (let attempt = 0; attempt <= MAX_JITTERS; attempt++) {\n const r = castRay(tris, point, dir)\n if (!('degenerate' in r)) {\n votes += 1\n if (r.crossings % 2 === 1) inside += 1\n break\n }\n dir = normalize({\n x: base.x + (rand() - 0.5) * 1e-3,\n y: base.y + (rand() - 0.5) * 1e-3,\n z: base.z + (rand() - 0.5) * 1e-3,\n })\n }\n }\n // Every direction degenerating means the point is on the surface; call it outside\n // (fail-closed: a probe that must be inside the material will report a failure).\n if (votes === 0) return false\n return inside * 2 > votes\n}\n\n// ---------------------------------------------------------------------------\n// Spec scoring\n// ---------------------------------------------------------------------------\n\nexport interface McadCheck {\n name: string\n ok: boolean\n measured: string\n expected: string\n}\n\nexport interface McadScoring {\n checks: McadCheck[]\n failed: McadCheck[]\n score: number\n resolved: boolean\n}\n\nfunction inBand(v: number, [lo, hi]: [number, number]): boolean {\n return v >= lo && v <= hi\n}\n\nfunction fmt(n: number): string {\n return String(Math.round(n * 1000) / 1000)\n}\n\nfunction pt(p: readonly [number, number, number]): string {\n return `(${p[0]}, ${p[1]}, ${p[2]})`\n}\n\n/** Score a measured mesh against the task's spec — one named check per assertion. */\nexport function scoreAgainstSpec(geo: McadGeometry, tris: Tri[], spec: McadSpec): McadScoring {\n const checks: McadCheck[] = []\n const add = (name: string, ok: boolean, measured: string, expected: string) =>\n checks.push({ name, ok, measured, expected })\n\n for (const axis of ['x', 'y', 'z'] as const) {\n const band = spec.bbox?.[axis]\n if (!band) continue\n const got = geo.bbox.size[axis]\n add(`bbox${axis.toUpperCase()}`, inBand(got, band), fmt(got), `[${band[0]}, ${band[1]}]`)\n }\n if (spec.volume) add('volume', inBand(geo.volume, spec.volume), fmt(geo.volume), `[${spec.volume[0]}, ${spec.volume[1]}]`)\n if (spec.solids) add('solids', inBand(geo.solids, spec.solids), String(geo.solids), `[${spec.solids[0]}, ${spec.solids[1]}]`)\n if (spec.minTriangles != null)\n add('minTriangles', geo.triangles >= spec.minTriangles, String(geo.triangles), `>= ${spec.minTriangles}`)\n\n for (const [i, p] of (spec.probesInsideSolid ?? []).entries()) {\n const got = pointInSolid(tris, { x: p[0], y: p[1], z: p[2] })\n add(`probeInside[${i}] ${pt(p)}`, got, got ? 'inside' : 'outside', 'inside')\n }\n for (const [i, p] of (spec.probesOutsideSolid ?? []).entries()) {\n const got = pointInSolid(tris, { x: p[0], y: p[1], z: p[2] })\n add(`probeOutside[${i}] ${pt(p)}`, !got, got ? 'inside' : 'outside', 'outside')\n }\n\n const failed = checks.filter((c) => !c.ok)\n const score = checks.length ? (checks.length - failed.length) / checks.length : 0\n return { checks, failed, score, resolved: checks.length > 0 && failed.length === 0 }\n}\n\n// ---------------------------------------------------------------------------\n// Adapter\n// ---------------------------------------------------------------------------\n\n/** Task metadata carried onto every `BenchTask`, so the judge needs no lookup table. */\nexport interface McadTaskMeta extends Record<string, unknown> {\n spec: McadSpec\n source: string\n calibrated: boolean\n}\n\n/** Run openscad under xvfb (it wants a GL context even headless). */\nasync function openscad(args: string[], cwd: string): Promise<{ stdout: string; stderr: string }> {\n return execFileAsync('xvfb-run', ['-a', 'openscad', ...args], {\n cwd,\n maxBuffer: 1024 * 1024 * 64,\n timeout: 600_000,\n })\n}\n\n/**\n * Strip a markdown fence if the model wrapped its answer in one. The prompt asks\n * for bare source; a fenced answer is a formatting slip, not a geometry failure,\n * and the geometric gate downstream is unchanged either way.\n */\nexport function stripCodeFence(artifact: string): string {\n const trimmed = artifact.trim()\n const fenced = /^```[a-zA-Z]*\\n([\\s\\S]*?)\\n?```$/.exec(trimmed)\n return (fenced ? fenced[1]! : trimmed).trim()\n}\n\n/** Compile OpenSCAD source and measure the resulting mesh. Judge-time only. */\nexport async function compileAndMeasure(\n src: string,\n): Promise<{ ok: true; geo: McadGeometry; tris: Tri[]; stlPath: string } | { ok: false; detail: string }> {\n const dir = await mkdtemp(join(tmpdir(), 'mcad-'))\n const scadPath = join(dir, 'model.scad')\n const stlPath = join(dir, 'model.stl')\n await writeFile(scadPath, `${src}\\n`)\n\n try {\n await openscad(['--export-format=asciistl', '-o', stlPath, scadPath], dir)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n return { ok: false, detail: `compile failed: ${msg.slice(0, 400)}` }\n }\n\n let stl: string\n try {\n stl = await readFile(stlPath, 'utf8')\n } catch {\n return { ok: false, detail: 'compiled but produced no STL (empty geometry)' }\n }\n const tris = parseAsciiStl(stl)\n if (tris.length === 0) return { ok: false, detail: 'STL parsed to zero triangles (empty geometry)' }\n return { ok: true, geo: measureMesh(tris), tris, stlPath }\n}\n\nexport function createMcadBenchAdapter(): BenchmarkAdapter {\n return {\n name: 'mcad',\n\n async preflight() {\n try {\n await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(\n `mcad preflight failed: ${msg}\\n` +\n 'Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ' +\n 'The judge runs `xvfb-run -a openscad --export-format=asciistl -o out.stl model.scad` — both must be on PATH.',\n )\n }\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n let tasks: McadTask[] = MCAD_TASKS\n if (opts.ids) tasks = tasks.filter((t) => opts.ids?.includes(t.id))\n if (opts.limit != null) tasks = tasks.slice(0, opts.limit)\n return tasks.map(\n (t): BenchTask => ({\n id: t.id,\n prompt: t.prompt,\n metadata: { spec: t.spec, source: t.source, calibrated: t.calibrated } satisfies McadTaskMeta,\n }),\n )\n },\n\n async goldArtifact(task: BenchTask) {\n return MCAD_GOLDS[task.id]\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const spec = (task.metadata as McadTaskMeta | undefined)?.spec\n if (!spec) return { resolved: false, score: 0, detail: `task ${task.id} carries no mcad spec` }\n\n const src = stripCodeFence(artifact)\n if (!src) return { resolved: false, score: 0, detail: 'empty artifact' }\n\n const built = await compileAndMeasure(src)\n if (!built.ok) return { resolved: false, score: 0, detail: built.detail }\n\n const { geo, tris, stlPath } = built\n if (!geo.watertight) {\n return {\n resolved: false,\n score: 0,\n detail: JSON.stringify({\n gate: 'watertight',\n failed: [\n {\n name: 'watertight',\n measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,\n expected: '0 open edges (closed 2-manifold solid)',\n },\n ],\n geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },\n stlPath,\n }),\n }\n }\n\n const scored = scoreAgainstSpec(geo, tris, spec)\n return {\n resolved: scored.resolved,\n score: scored.score,\n detail: JSON.stringify({\n failed: scored.failed.map((c) => ({ name: c.name, measured: c.measured, expected: c.expected })),\n checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),\n geo: {\n triangles: geo.triangles,\n solids: geo.solids,\n volume: +geo.volume.toFixed(2),\n degenerateFaces: geo.degenerateFaces,\n bbox: {\n x: +geo.bbox.size.x.toFixed(3),\n y: +geo.bbox.size.y.toFixed(3),\n z: +geo.bbox.size.z.toFixed(3),\n },\n },\n stlPath,\n }),\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,gBAAg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GAGF,MAAM,SAAS,iBAAiB,KAAK,MAAM,IAAI;GAC/C,OAAO;IACL,UAAU,OAAO;IACjB,OAAO,OAAO;IACd,QAAQ,KAAK,UAAU;KACrB,QAAQ,OAAO,OAAO,KAAK,OAAO;MAAE,MAAM,EAAE;MAAM,UAAU,EAAE;MAAU,UAAU,EAAE;KAAS,EAAE;KAC/F,QAAQ,OAAO,YAAY,OAAO,OAAO,KAAK,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;KACnE,KAAK;MACH,WAAW,IAAI;MACf,QAAQ,IAAI;MACZ,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC;MAC7B,iBAAiB,IAAI;MACrB,MAAM;OACJ,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;OAC7B,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;OAC7B,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;MAC/B;KACF;KACA;IACF,CAAC;GACH;EACF;CACF;AACF"}
1
+ {"version":3,"file":"mcad-bench.js","names":[],"sources":["../../src/benchmarks/mcad-bench.ts"],"sourcesContent":["/**\n * MCAD adapter. Worker artifact = OpenSCAD source for a dimensioned mechanical\n * part; judge = the REAL OpenSCAD kernel (compile + ASCII-STL export) followed by\n * pure-TS mesh measurement against the task's `McadSpec`. No LLM, no self-report:\n * the part either has the stated extents, volume, body count and holes, or it does\n * not.\n *\n * Pipeline, in order, and every stage is a hard fact about the produced mesh:\n * 1. compile : `xvfb-run -a openscad --export-format=asciistl -o out.stl` exits 0\n * 2. watertight : every undirected edge shared by exactly two faces (2-manifold)\n * 3. measure : bbox extents, enclosed volume (divergence theorem), connected\n * -component count (\"solids\"), triangle count\n * 4. probe : ray-parity point-in-solid at the spec's pinned hole/material\n * coordinates — this is what makes a missing or misplaced bore\n * fail, which no aggregate measure can catch\n *\n * Scoring: compile failure or a non-watertight mesh is 0 / unresolved — a mesh that\n * is not a closed solid has no well-defined volume or interior, so every downstream\n * number would be fiction. Otherwise the score is the fraction of ASSERTED spec\n * checks passed (each bbox axis, the volume band, the solids band, the triangle\n * floor, and EACH probe count as one check), and `passed` requires all of them.\n *\n * Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `loadAll` and the\n * geometry engine below are dependency-free and run anywhere.\n *\n * Geometry checks 1-3 are ported from supervisor-lab's `bench/cad-stl-gate.ts`\n * (edge-key manifold parity + signed-tetrahedron volume). Ported, not imported:\n * these packages do not share a dependency edge.\n */\n\nimport { execFile } from 'node:child_process'\nimport { mkdtemp, readFile, writeFile } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { promisify } from 'node:util'\nimport { MCAD_GOLDS } from './mcad-golds'\nimport { MCAD_TASKS, type McadSpec, type McadTask } from './mcad-tasks'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\nconst execFileAsync = promisify(execFile)\n\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\n/** One triangle as three vertices, in the STL's stated winding order. */\nexport type Tri = readonly [Vec3, Vec3, Vec3]\n\nexport interface McadGeometry {\n triangles: number\n /** Edges NOT shared by exactly two faces. 0 iff the surface is closed + 2-manifold. */\n openEdges: number\n watertight: boolean\n /** Zero-area faces — bad geometry even when the topology closes. */\n degenerateFaces: number\n /** Enclosed volume (absolute) via the signed-tetrahedron sum. */\n volume: number\n /** Connected components of the triangle-adjacency graph = disconnected bodies. */\n solids: number\n bbox: { min: Vec3; max: Vec3; size: Vec3 }\n}\n\n/** Coincident-vertex quantisation, in model units (mm). */\nconst VERTEX_QUANTUM = 1e-6\nconst AREA_EPS = 1e-9\nconst VOLUME_EPS = 1e-9\n\n// ---------------------------------------------------------------------------\n// Mesh parsing + measurement (ported from supervisor-lab bench/cad-stl-gate.ts)\n// ---------------------------------------------------------------------------\n\n/** Parse an ASCII STL into triangles by reading `vertex x y z` lines in groups of three. */\nexport function parseAsciiStl(stl: string): Tri[] {\n const verts: Vec3[] = []\n for (const line of stl.split('\\n')) {\n const m = line.trim().match(/^vertex\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)/i)\n if (!m) continue\n const x = Number(m[1])\n const y = Number(m[2])\n const z = Number(m[3])\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) continue\n verts.push({ x, y, z })\n }\n const tris: Tri[] = []\n for (let i = 0; i + 2 < verts.length; i += 3) tris.push([verts[i]!, verts[i + 1]!, verts[i + 2]!])\n return tris\n}\n\n/** Quantise a vertex so shared edges match despite float authoring noise. */\nfunction vertexKey(v: Vec3): string {\n const r = (n: number) => (Math.round(n / VERTEX_QUANTUM) * VERTEX_QUANTUM).toFixed(6)\n return `${r(v.x)},${r(v.y)},${r(v.z)}`\n}\n\nfunction sub(a: Vec3, b: Vec3): Vec3 {\n return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }\n}\nfunction cross(a: Vec3, b: Vec3): Vec3 {\n return { x: a.y * b.z - a.z * b.y, y: a.z * b.x - a.x * b.z, z: a.x * b.y - a.y * b.x }\n}\nfunction dot(a: Vec3, b: Vec3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z\n}\nfunction norm(a: Vec3): number {\n return Math.sqrt(dot(a, a))\n}\nfunction normalize(a: Vec3): Vec3 {\n const n = norm(a)\n return { x: a.x / n, y: a.y / n, z: a.z / n }\n}\n\n/** Disjoint-set over triangle indices — the \"how many separate bodies\" primitive. */\nfunction findRoot(parent: Int32Array, i: number): number {\n let r = i\n while (parent[r] !== r) r = parent[r]!\n let c = i\n while (parent[c] !== c) {\n const next = parent[c]!\n parent[c] = r\n c = next\n }\n return r\n}\n\n/**\n * Measure the closed-solid properties of a triangle soup. Pure: no I/O, no deps.\n *\n * `solids` is the number of connected components of the graph whose nodes are\n * triangles and whose edges join two triangles that share a quantised mesh edge.\n * On a watertight mesh that count IS the number of disconnected bodies (an\n * enclosed internal cavity is its own shell and counts, which is the behaviour\n * the specs want — a \"hollow\" body that is really two nested shells is not one\n * fused solid).\n */\nexport function measureMesh(tris: Tri[]): McadGeometry {\n if (tris.length === 0) {\n const zero = { x: 0, y: 0, z: 0 }\n return {\n triangles: 0,\n openEdges: 0,\n watertight: false,\n degenerateFaces: 0,\n volume: 0,\n solids: 0,\n bbox: { min: zero, max: zero, size: zero },\n }\n }\n\n const min: Vec3 = { x: Number.POSITIVE_INFINITY, y: Number.POSITIVE_INFINITY, z: Number.POSITIVE_INFINITY }\n const max: Vec3 = { x: Number.NEGATIVE_INFINITY, y: Number.NEGATIVE_INFINITY, z: Number.NEGATIVE_INFINITY }\n const edgeFaces = new Map<string, number[]>()\n const parent = new Int32Array(tris.length)\n for (let i = 0; i < tris.length; i++) parent[i] = i\n let degenerateFaces = 0\n let volume6 = 0\n\n for (let i = 0; i < tris.length; i++) {\n const [a, b, c] = tris[i]!\n for (const v of [a, b, c]) {\n if (v.x < min.x) min.x = v.x\n if (v.y < min.y) min.y = v.y\n if (v.z < min.z) min.z = v.z\n if (v.x > max.x) max.x = v.x\n if (v.y > max.y) max.y = v.y\n if (v.z > max.z) max.z = v.z\n }\n if (norm(cross(sub(b, a), sub(c, a))) < AREA_EPS) degenerateFaces += 1\n volume6 += dot(a, cross(b, c))\n\n const ka = vertexKey(a)\n const kb = vertexKey(b)\n const kc = vertexKey(c)\n for (const [p, q] of [\n [ka, kb],\n [kb, kc],\n [kc, ka],\n ] as const) {\n const key = p < q ? `${p}|${q}` : `${q}|${p}`\n const seen = edgeFaces.get(key)\n if (seen) seen.push(i)\n else edgeFaces.set(key, [i])\n }\n }\n\n let openEdges = 0\n for (const faces of edgeFaces.values()) {\n if (faces.length !== 2) openEdges += 1\n // Union every face pair on this edge (a >2-face edge still connects bodies).\n const first = findRoot(parent, faces[0]!)\n for (let k = 1; k < faces.length; k++) {\n const other = findRoot(parent, faces[k]!)\n if (other !== first) parent[other] = first\n }\n }\n\n const roots = new Set<number>()\n for (let i = 0; i < tris.length; i++) roots.add(findRoot(parent, i))\n\n return {\n triangles: tris.length,\n openEdges,\n watertight: openEdges === 0,\n degenerateFaces,\n volume: Math.abs(volume6) / 6,\n solids: roots.size,\n bbox: {\n min: { ...min },\n max: { ...max },\n size: { x: max.x - min.x, y: max.y - min.y, z: max.z - min.z },\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Point-in-solid by ray parity\n// ---------------------------------------------------------------------------\n\n/**\n * Three fixed, mutually linearly-independent directions built from irrational\n * constants (sqrt(3)-1, sqrt(2)-1, 1/sqrt(5), 1/sqrt(3) and the plastic-number\n * pair 0.7548777 / 0.5698403). Their 3x3 determinant is ~1.77, so no two are\n * near-parallel and no plane contains all three.\n */\nconst RAY_DIRECTIONS: readonly Vec3[] = [\n normalize({ x: 1, y: 0.7548777, z: 0.5698403 }),\n normalize({ x: -0.7320508, y: 1, z: 0.236068 }),\n normalize({ x: 0.4472136, y: -0.5773503, z: 1 }),\n]\n\n/** Barycentric / parametric tolerances for calling a crossing \"on the boundary\". */\nconst BARY_EPS = 1e-9\nconst DET_EPS = 1e-12\nconst T_EPS = 1e-9\nconst MAX_JITTERS = 8\n\n/** Deterministic 32-bit PRNG (mulberry32) — seeded, so probes never use Math.random. */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** Stable integer hash of a probe point so its jitter sequence is reproducible. */\nfunction seedForPoint(p: Vec3, rayIndex: number): number {\n let h = 2166136261 ^ rayIndex\n for (const n of [p.x, p.y, p.z]) {\n const bits = Math.round(n * 1e6) | 0\n h = Math.imul(h ^ (bits & 0xffff), 16777619)\n h = Math.imul(h ^ ((bits >>> 16) & 0xffff), 16777619)\n }\n return h >>> 0\n}\n\ntype CastResult = { crossings: number } | { degenerate: true }\n\n/**\n * Moller-Trumbore crossing count along one ray. Returns `degenerate` when the ray\n * touches a triangle edge/vertex, lies in a triangle's plane, or starts on a face\n * — the three cases where a parity count is not trustworthy.\n */\nfunction castRay(tris: Tri[], origin: Vec3, dir: Vec3): CastResult {\n let crossings = 0\n for (const [v0, v1, v2] of tris) {\n const e1 = sub(v1, v0)\n const e2 = sub(v2, v0)\n const h = cross(dir, e2)\n const det = dot(e1, h)\n const scale = norm(e1) * norm(e2)\n if (Math.abs(det) <= DET_EPS * Math.max(scale, 1)) {\n // Ray parallel to (or inside) this triangle's plane. Only a problem when the\n // ray could actually meet the triangle; distinguishing that costs more than a\n // re-cast, so treat it as degenerate whenever the origin is near the plane.\n const n = cross(e1, e2)\n const nl = norm(n)\n if (nl > AREA_EPS && Math.abs(dot(sub(origin, v0), n)) / nl <= T_EPS) return { degenerate: true }\n continue\n }\n const f = 1 / det\n const s = sub(origin, v0)\n const u = f * dot(s, h)\n const q = cross(s, e1)\n const v = f * dot(dir, q)\n const w = 1 - u - v\n if (u < -BARY_EPS || v < -BARY_EPS || w < -BARY_EPS) continue\n const t = f * dot(e2, q)\n if (t < -T_EPS) continue\n // Inside the triangle (or within EPS of its border). Anything within EPS of a\n // border, or of the origin plane, makes the parity ambiguous.\n if (Math.abs(t) <= T_EPS) return { degenerate: true }\n if (u <= BARY_EPS || v <= BARY_EPS || w <= BARY_EPS) return { degenerate: true }\n crossings += 1\n }\n return { crossings }\n}\n\n/**\n * Point-in-solid membership by ray parity, made robust three ways.\n *\n * ROBUSTNESS ARGUMENT. A parity test is exact except on a measure-zero set: rays\n * that graze a triangle edge or vertex (the crossing is counted twice or zero\n * times), rays coplanar with a face, and origins lying on the surface. Those cases\n * are not merely rare here — they are SYSTEMATIC, because OpenSCAD emits\n * axis-aligned meshes whose vertices land on the same round millimetre lattice the\n * spec's probe coordinates come from, so an axis-aligned ray from a probe point\n * hits shared edges constantly. Three defences, in order:\n * 1. DIRECTIONS. The three fixed directions are irrational combinations, so a ray\n * from a lattice point cannot stay in an axis-aligned face plane and cannot\n * run along a lattice edge.\n * 2. DETECTION + DETERMINISTIC RE-JITTER. Grazing is DETECTED (a barycentric\n * coordinate within BARY_EPS of 0, |det| below DET_EPS with the origin in the\n * plane, or |t| within T_EPS) rather than hoped away. A detected ray is re-cast\n * with a small direction perturbation drawn from a mulberry32 PRNG seeded by\n * the probe coordinates and ray index, so the whole judge stays deterministic:\n * the same mesh and the same point always take the same sequence of re-casts.\n * 3. MAJORITY VOTE. The verdict is the majority of three independent directions,\n * so even an undetected miscount on one ray cannot flip the answer.\n * A point sitting exactly ON the surface has no correct answer; every direction\n * degenerates there and the vote falls back to whatever the jittered casts say.\n * The specs therefore place probes with >=1 mm clearance from any surface.\n */\nexport function pointInSolid(tris: Tri[], point: Vec3): boolean {\n let inside = 0\n let votes = 0\n for (let i = 0; i < RAY_DIRECTIONS.length; i++) {\n const base = RAY_DIRECTIONS[i]!\n const rand = mulberry32(seedForPoint(point, i))\n let dir = base\n for (let attempt = 0; attempt <= MAX_JITTERS; attempt++) {\n const r = castRay(tris, point, dir)\n if (!('degenerate' in r)) {\n votes += 1\n if (r.crossings % 2 === 1) inside += 1\n break\n }\n dir = normalize({\n x: base.x + (rand() - 0.5) * 1e-3,\n y: base.y + (rand() - 0.5) * 1e-3,\n z: base.z + (rand() - 0.5) * 1e-3,\n })\n }\n }\n // Every direction degenerating means the point is on the surface; call it outside\n // (fail-closed: a probe that must be inside the material will report a failure).\n if (votes === 0) return false\n return inside * 2 > votes\n}\n\n// ---------------------------------------------------------------------------\n// Spec scoring\n// ---------------------------------------------------------------------------\n\nexport interface McadCheck {\n name: string\n ok: boolean\n measured: string\n expected: string\n}\n\nexport interface McadScoring {\n checks: McadCheck[]\n failed: McadCheck[]\n score: number\n resolved: boolean\n}\n\nfunction inBand(v: number, [lo, hi]: [number, number]): boolean {\n return v >= lo && v <= hi\n}\n\nfunction fmt(n: number): string {\n return String(Math.round(n * 1000) / 1000)\n}\n\nfunction pt(p: readonly [number, number, number]): string {\n return `(${p[0]}, ${p[1]}, ${p[2]})`\n}\n\n/** Score a measured mesh against the task's spec — one named check per assertion. */\nexport function scoreAgainstSpec(geo: McadGeometry, tris: Tri[], spec: McadSpec): McadScoring {\n const checks: McadCheck[] = []\n const add = (name: string, ok: boolean, measured: string, expected: string) =>\n checks.push({ name, ok, measured, expected })\n\n for (const axis of ['x', 'y', 'z'] as const) {\n const band = spec.bbox?.[axis]\n if (!band) continue\n const got = geo.bbox.size[axis]\n add(`bbox${axis.toUpperCase()}`, inBand(got, band), fmt(got), `[${band[0]}, ${band[1]}]`)\n }\n if (spec.volume) add('volume', inBand(geo.volume, spec.volume), fmt(geo.volume), `[${spec.volume[0]}, ${spec.volume[1]}]`)\n if (spec.solids) add('solids', inBand(geo.solids, spec.solids), String(geo.solids), `[${spec.solids[0]}, ${spec.solids[1]}]`)\n if (spec.minTriangles != null)\n add('minTriangles', geo.triangles >= spec.minTriangles, String(geo.triangles), `>= ${spec.minTriangles}`)\n\n for (const [i, p] of (spec.probesInsideSolid ?? []).entries()) {\n const got = pointInSolid(tris, { x: p[0], y: p[1], z: p[2] })\n add(`probeInside[${i}] ${pt(p)}`, got, got ? 'inside' : 'outside', 'inside')\n }\n for (const [i, p] of (spec.probesOutsideSolid ?? []).entries()) {\n const got = pointInSolid(tris, { x: p[0], y: p[1], z: p[2] })\n add(`probeOutside[${i}] ${pt(p)}`, !got, got ? 'inside' : 'outside', 'outside')\n }\n\n const failed = checks.filter((c) => !c.ok)\n const score = checks.length ? (checks.length - failed.length) / checks.length : 0\n return { checks, failed, score, resolved: checks.length > 0 && failed.length === 0 }\n}\n\n// ---------------------------------------------------------------------------\n// Adapter\n// ---------------------------------------------------------------------------\n\n/** Task metadata carried onto every `BenchTask`, so the judge needs no lookup table. */\nexport interface McadTaskMeta extends Record<string, unknown> {\n spec: McadSpec\n source: string\n calibrated: boolean\n}\n\n/** Run openscad under xvfb (it wants a GL context even headless). */\nasync function openscad(args: string[], cwd: string): Promise<{ stdout: string; stderr: string }> {\n return execFileAsync('xvfb-run', ['-a', 'openscad', ...args], {\n cwd,\n maxBuffer: 1024 * 1024 * 64,\n timeout: 600_000,\n })\n}\n\n/**\n * Strip a markdown fence if the model wrapped its answer in one. The prompt asks\n * for bare source; a fenced answer is a formatting slip, not a geometry failure,\n * and the geometric gate downstream is unchanged either way.\n */\nexport function stripCodeFence(artifact: string): string {\n const trimmed = artifact.trim()\n const fenced = /^```[a-zA-Z]*\\n([\\s\\S]*?)\\n?```$/.exec(trimmed)\n return (fenced ? fenced[1]! : trimmed).trim()\n}\n\n/** Compile OpenSCAD source and measure the resulting mesh. Judge-time only. */\nexport async function compileAndMeasure(\n src: string,\n): Promise<{ ok: true; geo: McadGeometry; tris: Tri[]; stlPath: string } | { ok: false; detail: string }> {\n const dir = await mkdtemp(join(tmpdir(), 'mcad-'))\n const scadPath = join(dir, 'model.scad')\n const stlPath = join(dir, 'model.stl')\n await writeFile(scadPath, `${src}\\n`)\n\n try {\n await openscad(['--export-format=asciistl', '-o', stlPath, scadPath], dir)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n return { ok: false, detail: `compile failed: ${msg.slice(0, 400)}` }\n }\n\n let stl: string\n try {\n stl = await readFile(stlPath, 'utf8')\n } catch {\n return { ok: false, detail: 'compiled but produced no STL (empty geometry)' }\n }\n const tris = parseAsciiStl(stl)\n if (tris.length === 0) return { ok: false, detail: 'STL parsed to zero triangles (empty geometry)' }\n return { ok: true, geo: measureMesh(tris), tris, stlPath }\n}\n\nexport function createMcadBenchAdapter(): RuntimeBenchmark {\n return runtimeBenchmark({\n id: 'mcad',\n\n async loadAll(opts: LoadOptions = {}) {\n let tasks: McadTask[] = MCAD_TASKS\n if (opts.ids) tasks = tasks.filter((t) => opts.ids?.includes(t.id))\n if (opts.limit != null) tasks = tasks.slice(0, opts.limit)\n return tasks.map(\n (t): BenchTask => ({\n id: t.id,\n payload: { prompt: t.prompt },\n metadata: { spec: t.spec, source: t.source, calibrated: t.calibrated } satisfies McadTaskMeta,\n }),\n )\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const spec = (task.metadata as McadTaskMeta | undefined)?.spec\n if (!spec) return { passed: false, score: 0, notes: `task ${task.id} carries no mcad spec`, raw: {} }\n\n const src = stripCodeFence(artifact)\n if (!src) return { passed: false, score: 0, notes: 'empty artifact', raw: {} }\n\n const built = await compileAndMeasure(src)\n if (!built.ok) return { passed: false, score: 0, notes: built.detail, raw: {} }\n\n const { geo, tris, stlPath } = built\n if (!geo.watertight) {\n const raw = {\n gate: 'watertight',\n failed: [\n {\n name: 'watertight',\n measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,\n expected: '0 open edges (closed 2-manifold solid)',\n },\n ],\n geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },\n stlPath,\n }\n return {\n passed: false,\n score: 0,\n notes: JSON.stringify(raw),\n raw,\n }\n }\n\n const scored = scoreAgainstSpec(geo, tris, spec)\n const raw = {\n failed: scored.failed.map((c) => ({ name: c.name, measured: c.measured, expected: c.expected })),\n checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),\n geo: {\n triangles: geo.triangles,\n solids: geo.solids,\n volume: +geo.volume.toFixed(2),\n degenerateFaces: geo.degenerateFaces,\n bbox: {\n x: +geo.bbox.size.x.toFixed(3),\n y: +geo.bbox.size.y.toFixed(3),\n z: +geo.bbox.size.z.toFixed(3),\n },\n },\n stlPath,\n }\n return {\n passed: scored.resolved,\n score: scored.score,\n notes: JSON.stringify(raw),\n raw,\n }\n },\n\n runtime: {\n async preflight() {\n try {\n await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n throw new Error(\n `mcad preflight failed: ${msg}\\n` +\n 'Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ' +\n 'The judge runs `xvfb-run -a openscad --export-format=asciistl -o out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;GAEA,MAAM,SAAS,iBAAiB,KAAK,MAAM,IAAI;GAC/C,MAAM,MAAM;IACV,QAAQ,OAAO,OAAO,KAAK,OAAO;KAAE,MAAM,EAAE;KAAM,UAAU,EAAE;KAAU,UAAU,EAAE;IAAS,EAAE;IAC/F,QAAQ,OAAO,YAAY,OAAO,OAAO,KAAK,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACnE,KAAK;KACH,WAAW,IAAI;KACf,QAAQ,IAAI;KACZ,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC;KAC7B,iBAAiB,IAAI;KACrB,MAAM;MACJ,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;MAC7B,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;MAC7B,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,QAAQ,CAAC;KAC/B;IACF;IACA;GACF;GACA,OAAO;IACL,QAAQ,OAAO;IACf,OAAO,OAAO;IACd,OAAO,KAAK,UAAU,GAAG;IACzB;GACF;EACF;EAEA,SAAS;GACP,MAAM,YAAY;IAChB,IAAI;KACF,MAAM,cAAc,YAAY;MAAC;MAAM;MAAY;KAAW,GAAG,EAAE,SAAS,IAAO,CAAC;IACtF,SAAS,KAAK;KACZ,MAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;KAC3D,MAAM,IAAI,MACR,0BAA0B,IAAI,sMAGhC;IACF;GACF;GAEA,MAAM,aAAa,MAAiB;IAClC,OAAO,WAAW,KAAK;GACzB;EACF;CACF,CAAC;AACH"}
@@ -1,6 +1,6 @@
1
1
  import { McadGeometry, McadScoring, Tri } from "./mcad-bench.js";
2
2
  import { McadTask } from "./mcad-tasks.js";
3
- import { BenchmarkAdapter } from "./types.js";
3
+ import { RuntimeBenchmark } from "./types.js";
4
4
  /** Package-relative venv, resolved through `_harness`'s bench-root lookup. */
5
5
  export declare const CADQUERY_VENV = ".venv-cadquery";
6
6
  /** Files the worker's script must leave in its working directory. */
@@ -75,5 +75,5 @@ export declare function runAndMeasureCadQuery(src: string, timeoutMs?: number):
75
75
  * file, so failing to produce one costs exactly what failing a dimension costs.
76
76
  */
77
77
  export declare function withStepCheck(scored: McadScoring, stepEmitted: boolean): McadScoring;
78
- export declare function createMcadCqAdapter(): BenchmarkAdapter;
78
+ export declare function createMcadCqAdapter(): RuntimeBenchmark;
79
79
  //# sourceMappingURL=mcad-cq-bench.d.ts.map