@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.
- package/CHANGELOG.md +20 -0
- package/README.md +24 -2
- package/dist/adapters.d.ts +3 -3
- package/dist/adapters.js +3 -5
- package/dist/adapters.js.map +1 -1
- package/dist/benchmarks/_harness.d.ts +4 -4
- package/dist/benchmarks/_harness.js +5 -2
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +2 -2
- package/dist/benchmarks/aec-bench.js +49 -42
- package/dist/benchmarks/aec-bench.js.map +1 -1
- package/dist/benchmarks/agentbench.d.ts +2 -2
- package/dist/benchmarks/agentbench.js +41 -34
- package/dist/benchmarks/agentbench.js.map +1 -1
- package/dist/benchmarks/appworld.d.ts +4 -4
- package/dist/benchmarks/appworld.js +67 -53
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -2
- package/dist/benchmarks/bfcl.js +52 -44
- package/dist/benchmarks/bfcl.js.map +1 -1
- package/dist/benchmarks/cad-design.d.ts +2 -2
- package/dist/benchmarks/cad-design.js +53 -44
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +2 -2
- package/dist/benchmarks/cadbench.js +1 -1
- package/dist/benchmarks/cadgenbench.d.ts +2 -2
- package/dist/benchmarks/cadgenbench.js +1 -1
- package/dist/benchmarks/commit0.d.ts +2 -2
- package/dist/benchmarks/commit0.js +38 -31
- package/dist/benchmarks/commit0.js.map +1 -1
- package/dist/benchmarks/crag.d.ts +2 -2
- package/dist/benchmarks/crag.js +37 -32
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -2
- package/dist/benchmarks/dabstep.js +41 -34
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/finresearchbench.d.ts +4 -4
- package/dist/benchmarks/finresearchbench.js +61 -48
- package/dist/benchmarks/finresearchbench.js.map +1 -1
- package/dist/benchmarks/finsearchcomp.d.ts +3 -3
- package/dist/benchmarks/finsearchcomp.js +54 -43
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +2 -2
- package/dist/benchmarks/frames.js +66 -51
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +2 -2
- package/dist/benchmarks/hotpotqa.js +59 -47
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +3 -3
- package/dist/benchmarks/humaneval.js +39 -35
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-bench.js +68 -56
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
- package/dist/benchmarks/mcad-cq-bench.js +69 -57
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-cq-golds.js +1 -1
- package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
- package/dist/benchmarks/mcad-golds.d.ts +1 -1
- package/dist/benchmarks/mcad-golds.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -3
- package/dist/benchmarks/mind2web.js +62 -49
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +2 -2
- package/dist/benchmarks/nomiracl.js +43 -36
- package/dist/benchmarks/nomiracl.js.map +1 -1
- package/dist/benchmarks/open-rag-bench.d.ts +2 -2
- package/dist/benchmarks/open-rag-bench.js +37 -32
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -2
- package/dist/benchmarks/programbench.js +28 -23
- package/dist/benchmarks/programbench.js.map +1 -1
- package/dist/benchmarks/rag-shared.d.ts +2 -2
- package/dist/benchmarks/rag-shared.js +15 -13
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +2 -2
- package/dist/benchmarks/ragbench.js +34 -29
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -2
- package/dist/benchmarks/simpleqa.js +62 -51
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +4 -4
- package/dist/benchmarks/swe-bench.js +47 -41
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +2 -2
- package/dist/benchmarks/t2-ragbench.js +37 -32
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
- package/dist/benchmarks/tau-bench-shared.js +43 -36
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -2
- package/dist/benchmarks/tau2-bench.js.map +1 -1
- package/dist/benchmarks/tau3-banking.d.ts +2 -2
- package/dist/benchmarks/tau3-banking.js.map +1 -1
- package/dist/benchmarks/terminal-bench.d.ts +2 -2
- package/dist/benchmarks/terminal-bench.js +29 -23
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -2
- package/dist/benchmarks/toollm.js +40 -34
- package/dist/benchmarks/toollm.js.map +1 -1
- package/dist/benchmarks/trata-hedge.d.ts +2 -2
- package/dist/benchmarks/trata-hedge.js +46 -38
- package/dist/benchmarks/trata-hedge.js.map +1 -1
- package/dist/benchmarks/types.d.ts +33 -63
- package/dist/benchmarks/types.js +36 -1
- package/dist/benchmarks/types.js.map +1 -0
- package/dist/benchmarks/webarena-verified.d.ts +2 -2
- package/dist/benchmarks/webarena-verified.js +29 -24
- package/dist/benchmarks/webarena-verified.js.map +1 -1
- package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
- package/dist/cadbench-htzAmMaI.js.map +1 -0
- package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
- package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +667 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +61 -56
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/scripts/enterpriseops-gym-run.sh +82 -0
- package/scripts/grade-recorded-evidence.mjs +6 -6
- package/scripts/harvey-lab-judge.py +50 -0
- package/scripts/harvey-lab-run.sh +53 -0
- package/scripts/harvey-lab-sandbox.sh +21 -0
- package/scripts/healthbench-professional-run.sh +30 -0
- package/scripts/healthbench_professional_run.py +112 -0
- package/scripts/mlcr-run.sh +17 -0
- package/scripts/mlcr_run.py +133 -0
- package/scripts/prbench-run.sh +39 -0
- package/scripts/prbench_run.py +53 -0
- package/scripts/verify-packed-consumer.mjs +32 -27
- package/src/adapters.ts +5 -7
- package/src/benchmarks/_harness.test.mts +18 -1
- package/src/benchmarks/_harness.ts +12 -7
- package/src/benchmarks/aec-bench.test.mts +14 -14
- package/src/benchmarks/aec-bench.ts +62 -56
- package/src/benchmarks/agent-eval-contract.test.mts +38 -0
- package/src/benchmarks/agentbench.ts +44 -37
- package/src/benchmarks/appworld.test.mts +7 -7
- package/src/benchmarks/appworld.ts +88 -75
- package/src/benchmarks/bfcl.ts +60 -53
- package/src/benchmarks/cad-design.ts +34 -32
- package/src/benchmarks/cadbench.ts +34 -32
- package/src/benchmarks/cadgenbench.ts +30 -28
- package/src/benchmarks/commit0.test.mts +9 -9
- package/src/benchmarks/commit0.ts +50 -43
- package/src/benchmarks/crag.ts +45 -40
- package/src/benchmarks/dabstep-official.test.mts +8 -8
- package/src/benchmarks/dabstep.test.mts +11 -11
- package/src/benchmarks/dabstep.ts +47 -40
- package/src/benchmarks/external-adapters.test.mts +43 -44
- package/src/benchmarks/finresearchbench.ts +57 -47
- package/src/benchmarks/finsearchcomp.ts +72 -67
- package/src/benchmarks/frames.ts +76 -69
- package/src/benchmarks/hotpotqa.ts +69 -64
- package/src/benchmarks/humaneval.ts +37 -35
- package/src/benchmarks/mcad-bench.test.mts +30 -30
- package/src/benchmarks/mcad-bench.ts +66 -60
- package/src/benchmarks/mcad-cq-bench.ts +69 -63
- package/src/benchmarks/mcad-cq-golds.ts +1 -1
- package/src/benchmarks/mcad-cq.test.mts +40 -40
- package/src/benchmarks/mcad-golds.ts +1 -1
- package/src/benchmarks/mind2web.ts +66 -58
- package/src/benchmarks/nomiracl.ts +53 -46
- package/src/benchmarks/open-rag-bench.ts +47 -42
- package/src/benchmarks/programbench.test.mts +10 -10
- package/src/benchmarks/programbench.ts +38 -33
- package/src/benchmarks/rag-benchmarks.test.mts +31 -31
- package/src/benchmarks/rag-shared.ts +13 -16
- package/src/benchmarks/ragbench.ts +44 -39
- package/src/benchmarks/simpleqa.ts +78 -73
- package/src/benchmarks/swe-bench.test.mts +3 -3
- package/src/benchmarks/swe-bench.ts +66 -61
- package/src/benchmarks/t2-ragbench.ts +47 -42
- package/src/benchmarks/tau-bench-shared.ts +51 -44
- package/src/benchmarks/tau-pin.test.mts +1 -1
- package/src/benchmarks/tau2-bench.ts +2 -2
- package/src/benchmarks/tau3-banking.ts +2 -2
- package/src/benchmarks/terminal-bench.test.mts +3 -3
- package/src/benchmarks/terminal-bench.ts +41 -36
- package/src/benchmarks/toollm.ts +54 -47
- package/src/benchmarks/trata-hedge.ts +57 -52
- package/src/benchmarks/types.ts +70 -59
- package/src/benchmarks/webarena-verified.ts +49 -42
- package/src/cli.ts +74 -0
- package/src/corpus-replay.mts +9 -9
- package/src/examples/benchmark-matrix.mts +13 -10
- package/src/gate-cli.mts +5 -5
- package/src/gate.test.mts +14 -12
- package/src/gate.ts +23 -22
- package/src/index.ts +17 -11
- package/src/published.test.mts +534 -0
- package/src/published.ts +524 -0
- package/src/run-benchmarks-cli.mts +2 -2
- package/src/run-benchmarks.test.mts +58 -48
- package/src/run-benchmarks.ts +64 -57
- package/src/swe-bench-env.ts +6 -6
- package/src/worker.ts +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
- package/dist/benchmarks/enterpriseops-gym.js +0 -236
- package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
- package/dist/cadbench-Byr5gO1M.js.map +0 -1
- package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
- package/fixtures/enterpriseops-gym.json +0 -103
- package/scripts/enterpriseops_gym_judge.py +0 -281
- package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
- package/src/benchmarks/enterpriseops-gym.ts +0 -343
- package/src/eops-skills/address-every-subtask.md +0 -5
- package/src/eops-skills/exact-tools-and-args.md +0 -5
- package/src/eops-skills/full-sequence-to-goal.md +0 -5
- package/src/eops-skills/ground-every-value.md +0 -5
- package/src/eops-skills/honor-the-policies.md +0 -5
|
@@ -21,7 +21,7 @@ import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'nod
|
|
|
21
21
|
import { tmpdir } from 'node:os'
|
|
22
22
|
import { join } from 'node:path'
|
|
23
23
|
import { gunzipSync } from 'node:zlib'
|
|
24
|
-
import
|
|
24
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
25
25
|
|
|
26
26
|
const humanevalUrl = 'https://github.com/openai/human-eval/raw/master/data/HumanEval.jsonl.gz'
|
|
27
27
|
const dockerImage = 'python:3.12-slim'
|
|
@@ -279,7 +279,7 @@ function toBenchTask(t: HumanEvalTask): BenchTask {
|
|
|
279
279
|
entryPoint: t.entryPoint,
|
|
280
280
|
...(t.canonicalSolution ? { canonicalSolution: t.canonicalSolution } : {}),
|
|
281
281
|
}
|
|
282
|
-
return { id: t.taskId, prompt: basePrompt(t), metadata }
|
|
282
|
+
return { id: t.taskId, payload: { prompt: basePrompt(t) }, metadata }
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
function taskFromMeta(task: BenchTask): HumanEvalTask {
|
|
@@ -291,46 +291,48 @@ function taskFromMeta(task: BenchTask): HumanEvalTask {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/** The HumanEval `BenchmarkAdapter`. OFFSET (env) selects the correctable middle
|
|
294
|
-
* band;
|
|
295
|
-
export function createHumanEvalAdapter():
|
|
296
|
-
return {
|
|
297
|
-
|
|
298
|
-
async
|
|
299
|
-
// Prove the daemon and exact local image before any model call. Scoring uses
|
|
300
|
-
// --pull=never so a registry or cold pull cannot become a candidate outcome.
|
|
301
|
-
await new Promise<void>((resolve, reject) => {
|
|
302
|
-
execFile('docker', ['version', '--format', '{{.Server.Version}}'], (err) => {
|
|
303
|
-
if (err) reject(new Error('HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)'))
|
|
304
|
-
else resolve()
|
|
305
|
-
})
|
|
306
|
-
})
|
|
307
|
-
await new Promise<void>((resolve, reject) => {
|
|
308
|
-
execFile('docker', ['image', 'inspect', dockerImage], (err) => {
|
|
309
|
-
if (err) reject(new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`))
|
|
310
|
-
else resolve()
|
|
311
|
-
})
|
|
312
|
-
})
|
|
313
|
-
},
|
|
314
|
-
async loadTasks(opts?: LoadOptions) {
|
|
294
|
+
* band; loadAll honors `limit`/`ids`. The judge is the Docker deployable checker. */
|
|
295
|
+
export function createHumanEvalAdapter(): RuntimeBenchmark {
|
|
296
|
+
return runtimeBenchmark({
|
|
297
|
+
id: 'humaneval',
|
|
298
|
+
async loadAll(opts?: LoadOptions) {
|
|
315
299
|
const offset = Number(process.env.OFFSET ?? 0)
|
|
316
300
|
// Pull a generous window when filtering by id, else exactly `limit` from offset.
|
|
317
301
|
const all = await loadHumanEval(opts?.ids ? 164 : (opts?.limit ?? 8), offset)
|
|
318
302
|
const picked = opts?.ids ? all.filter((t) => opts.ids?.includes(t.taskId)) : all
|
|
319
303
|
return picked.map(toBenchTask)
|
|
320
304
|
},
|
|
321
|
-
async
|
|
305
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
322
306
|
const { pass } = await runChecker(taskFromMeta(task), extractCode(artifact))
|
|
323
|
-
return {
|
|
307
|
+
return { passed: pass === 1, score: pass, notes: pass === 1 ? 'tests passed' : 'tests failed', raw: {} }
|
|
324
308
|
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
309
|
+
runtime: {
|
|
310
|
+
async preflight() {
|
|
311
|
+
// Prove the daemon and exact local image before any model call. Scoring uses
|
|
312
|
+
// --pull=never so a registry or cold pull cannot become a candidate outcome.
|
|
313
|
+
await new Promise<void>((resolve, reject) => {
|
|
314
|
+
execFile('docker', ['version', '--format', '{{.Server.Version}}'], (err) => {
|
|
315
|
+
if (err) reject(new Error('HumanEval judge needs a running Docker daemon (python:3.12-slim, --network=none)'))
|
|
316
|
+
else resolve()
|
|
317
|
+
})
|
|
318
|
+
})
|
|
319
|
+
await new Promise<void>((resolve, reject) => {
|
|
320
|
+
execFile('docker', ['image', 'inspect', dockerImage], (err) => {
|
|
321
|
+
if (err) reject(new Error(`HumanEval judge needs the cached Docker image ${dockerImage}`))
|
|
322
|
+
else resolve()
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
},
|
|
326
|
+
async goldArtifact(task: BenchTask) {
|
|
327
|
+
const m = task.metadata as HumanEvalMeta | undefined
|
|
328
|
+
const sol = m?.canonicalSolution
|
|
329
|
+
// Return the COMPLETE function (signature header + canonical body), i.e. what a
|
|
330
|
+
// real worker emits — NOT the body alone. The judge runs `extractCode`, whose
|
|
331
|
+
// unfenced fallback is `reply.trim()`; trimming a body-only string strips its
|
|
332
|
+
// leading indent and breaks it, so a body-only gold fails its own judge. A full
|
|
333
|
+
// def starts at column 0, trims safely, and self-verifies.
|
|
334
|
+
return sol ? `${m!.promptHeader}${sol}` : undefined
|
|
335
|
+
},
|
|
334
336
|
},
|
|
335
|
-
}
|
|
337
|
+
})
|
|
336
338
|
}
|
|
@@ -287,21 +287,21 @@ describe('artifact handling', () => {
|
|
|
287
287
|
|
|
288
288
|
it('loads tasks with spec/source/calibrated metadata and no openscad', async () => {
|
|
289
289
|
const a = createMcadBenchAdapter()
|
|
290
|
-
const tasks = await a.
|
|
290
|
+
const tasks = await a.loadAll()
|
|
291
291
|
expect(tasks).toHaveLength(MCAD_TASKS.length)
|
|
292
292
|
for (const t of tasks) {
|
|
293
293
|
const md = t.metadata as { spec: unknown; source: string; calibrated: boolean }
|
|
294
294
|
expect(md.spec).toBeTruthy()
|
|
295
295
|
expect(typeof md.source).toBe('string')
|
|
296
296
|
expect(typeof md.calibrated).toBe('boolean')
|
|
297
|
-
expect(typeof (await a.goldArtifact(t))).toBe('string')
|
|
297
|
+
expect(typeof (await a.runtime.goldArtifact?.(t))).toBe('string')
|
|
298
298
|
}
|
|
299
299
|
})
|
|
300
300
|
|
|
301
301
|
it('honours ids and limit', async () => {
|
|
302
302
|
const a = createMcadBenchAdapter()
|
|
303
|
-
expect((await a.
|
|
304
|
-
expect(await a.
|
|
303
|
+
expect((await a.loadAll({ ids: ['l-bracket'] })).map((t) => t.id)).toEqual(['l-bracket'])
|
|
304
|
+
expect(await a.loadAll({ limit: 3 })).toHaveLength(3)
|
|
305
305
|
})
|
|
306
306
|
|
|
307
307
|
it('task 10 asks for separate bodies, never "one fused solid"', () => {
|
|
@@ -317,11 +317,11 @@ describe('artifact handling', () => {
|
|
|
317
317
|
|
|
318
318
|
it('scores an empty artifact 0 without touching openscad', async () => {
|
|
319
319
|
const a = createMcadBenchAdapter()
|
|
320
|
-
const [t] = await a.
|
|
321
|
-
const s = await a.
|
|
322
|
-
expect(s.
|
|
320
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
321
|
+
const s = await a.evaluate(t!, ' ')
|
|
322
|
+
expect(s.passed).toBe(false)
|
|
323
323
|
expect(s.score).toBe(0)
|
|
324
|
-
expect(s.
|
|
324
|
+
expect(s.notes).toBe('empty artifact')
|
|
325
325
|
})
|
|
326
326
|
})
|
|
327
327
|
|
|
@@ -361,7 +361,7 @@ const BLOCK_SCALED_90 = `module gold() {\n${MCAD_GOLDS['calibration-block']}\n}\
|
|
|
361
361
|
|
|
362
362
|
describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
363
363
|
it('preflight passes when the toolchain is present', async () => {
|
|
364
|
-
await expect(createMcadBenchAdapter().preflight()).resolves.toBeUndefined()
|
|
364
|
+
await expect(createMcadBenchAdapter().runtime.preflight!()).resolves.toBeUndefined()
|
|
365
365
|
})
|
|
366
366
|
|
|
367
367
|
for (const task of MCAD_TASKS.filter((t) => t.calibrated)) {
|
|
@@ -369,14 +369,14 @@ describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
|
369
369
|
`gold for ${task.id} resolves at score 1.0`,
|
|
370
370
|
async () => {
|
|
371
371
|
const a = createMcadBenchAdapter()
|
|
372
|
-
const [t] = await a.
|
|
373
|
-
const gold = await a.goldArtifact(t!)
|
|
372
|
+
const [t] = await a.loadAll({ ids: [task.id] })
|
|
373
|
+
const gold = await a.runtime.goldArtifact?.(t!)
|
|
374
374
|
expect(typeof gold).toBe('string')
|
|
375
|
-
const s = await a.
|
|
376
|
-
const failed = JSON.parse(s.
|
|
375
|
+
const s = await a.evaluate(t!, gold as string)
|
|
376
|
+
const failed = JSON.parse(s.notes ?? '{}').failed ?? []
|
|
377
377
|
expect(failed, `failed checks: ${JSON.stringify(failed)}`).toEqual([])
|
|
378
378
|
expect(s.score).toBe(1)
|
|
379
|
-
expect(s.
|
|
379
|
+
expect(s.passed).toBe(true)
|
|
380
380
|
},
|
|
381
381
|
JUDGE_TIMEOUT,
|
|
382
382
|
)
|
|
@@ -386,11 +386,11 @@ describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
|
386
386
|
'MUST REJECT: the calibration block with its four holes removed fails the bore probes',
|
|
387
387
|
async () => {
|
|
388
388
|
const a = createMcadBenchAdapter()
|
|
389
|
-
const [t] = await a.
|
|
390
|
-
const s = await a.
|
|
391
|
-
expect(s.
|
|
389
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
390
|
+
const s = await a.evaluate(t!, BLOCK_WITHOUT_HOLES)
|
|
391
|
+
expect(s.passed).toBe(false)
|
|
392
392
|
expect(s.score).toBeLessThan(1)
|
|
393
|
-
const failed = (JSON.parse(s.
|
|
393
|
+
const failed = (JSON.parse(s.notes as string).failed as Array<{ name: string; measured: string }>).map(
|
|
394
394
|
(f) => f.name,
|
|
395
395
|
)
|
|
396
396
|
// all five "must be outside" probes now sit in solid material
|
|
@@ -408,10 +408,10 @@ describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
|
408
408
|
'MUST REJECT: the calibration block scaled to 90 x 54 x 18 fails every bbox axis',
|
|
409
409
|
async () => {
|
|
410
410
|
const a = createMcadBenchAdapter()
|
|
411
|
-
const [t] = await a.
|
|
412
|
-
const s = await a.
|
|
413
|
-
expect(s.
|
|
414
|
-
const detail = JSON.parse(s.
|
|
411
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
412
|
+
const s = await a.evaluate(t!, BLOCK_SCALED_90)
|
|
413
|
+
expect(s.passed).toBe(false)
|
|
414
|
+
const detail = JSON.parse(s.notes as string) as {
|
|
415
415
|
failed: Array<{ name: string; measured: string; expected: string }>
|
|
416
416
|
geo: { bbox: { x: number; y: number; z: number } }
|
|
417
417
|
}
|
|
@@ -431,11 +431,11 @@ describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
|
431
431
|
'MUST REJECT: a non-watertight surface is scored 0 by the hard gate',
|
|
432
432
|
async () => {
|
|
433
433
|
const a = createMcadBenchAdapter()
|
|
434
|
-
const [t] = await a.
|
|
435
|
-
const s = await a.
|
|
436
|
-
expect(s.
|
|
434
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
435
|
+
const s = await a.evaluate(t!, 'polyhedron(points=[[0,0,0],[10,0,0],[0,10,0]], faces=[[0,1,2]]);')
|
|
436
|
+
expect(s.passed).toBe(false)
|
|
437
437
|
expect(s.score).toBe(0)
|
|
438
|
-
expect(JSON.parse(s.
|
|
438
|
+
expect(JSON.parse(s.notes as string).gate).toBe('watertight')
|
|
439
439
|
},
|
|
440
440
|
JUDGE_TIMEOUT,
|
|
441
441
|
)
|
|
@@ -444,11 +444,11 @@ describe.skipIf(!OPENSCAD)('mcad judge, live openscad', () => {
|
|
|
444
444
|
'MUST REJECT: source that does not compile is scored 0',
|
|
445
445
|
async () => {
|
|
446
446
|
const a = createMcadBenchAdapter()
|
|
447
|
-
const [t] = await a.
|
|
448
|
-
const s = await a.
|
|
449
|
-
expect(s.
|
|
447
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
448
|
+
const s = await a.evaluate(t!, 'this is not openscad {{{')
|
|
449
|
+
expect(s.passed).toBe(false)
|
|
450
450
|
expect(s.score).toBe(0)
|
|
451
|
-
expect(s.
|
|
451
|
+
expect(s.notes).toMatch(/compile failed/)
|
|
452
452
|
},
|
|
453
453
|
JUDGE_TIMEOUT,
|
|
454
454
|
)
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
* is not a closed solid has no well-defined volume or interior, so every downstream
|
|
19
19
|
* number would be fiction. Otherwise the score is the fraction of ASSERTED spec
|
|
20
20
|
* checks passed (each bbox axis, the volume band, the solids band, the triangle
|
|
21
|
-
* floor, and EACH probe count as one check), and `
|
|
21
|
+
* floor, and EACH probe count as one check), and `passed` requires all of them.
|
|
22
22
|
*
|
|
23
|
-
* Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `
|
|
23
|
+
* Requires `openscad` + `xvfb-run` on PATH at JUDGE time only; `loadAll` and the
|
|
24
24
|
* geometry engine below are dependency-free and run anywhere.
|
|
25
25
|
*
|
|
26
26
|
* Geometry checks 1-3 are ported from supervisor-lab's `bench/cad-stl-gate.ts`
|
|
@@ -35,7 +35,7 @@ import { join } from 'node:path'
|
|
|
35
35
|
import { promisify } from 'node:util'
|
|
36
36
|
import { MCAD_GOLDS } from './mcad-golds'
|
|
37
37
|
import { MCAD_TASKS, type McadSpec, type McadTask } from './mcad-tasks'
|
|
38
|
-
import
|
|
38
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
39
39
|
|
|
40
40
|
const execFileAsync = promisify(execFile)
|
|
41
41
|
|
|
@@ -471,91 +471,97 @@ export async function compileAndMeasure(
|
|
|
471
471
|
return { ok: true, geo: measureMesh(tris), tris, stlPath }
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
export function createMcadBenchAdapter():
|
|
475
|
-
return {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
async preflight() {
|
|
479
|
-
try {
|
|
480
|
-
await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })
|
|
481
|
-
} catch (err) {
|
|
482
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
483
|
-
throw new Error(
|
|
484
|
-
`mcad preflight failed: ${msg}\n` +
|
|
485
|
-
'Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ' +
|
|
486
|
-
'The judge runs `xvfb-run -a openscad --export-format=asciistl -o out.stl model.scad` — both must be on PATH.',
|
|
487
|
-
)
|
|
488
|
-
}
|
|
489
|
-
},
|
|
474
|
+
export function createMcadBenchAdapter(): RuntimeBenchmark {
|
|
475
|
+
return runtimeBenchmark({
|
|
476
|
+
id: 'mcad',
|
|
490
477
|
|
|
491
|
-
async
|
|
478
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
492
479
|
let tasks: McadTask[] = MCAD_TASKS
|
|
493
480
|
if (opts.ids) tasks = tasks.filter((t) => opts.ids?.includes(t.id))
|
|
494
481
|
if (opts.limit != null) tasks = tasks.slice(0, opts.limit)
|
|
495
482
|
return tasks.map(
|
|
496
483
|
(t): BenchTask => ({
|
|
497
484
|
id: t.id,
|
|
498
|
-
prompt: t.prompt,
|
|
485
|
+
payload: { prompt: t.prompt },
|
|
499
486
|
metadata: { spec: t.spec, source: t.source, calibrated: t.calibrated } satisfies McadTaskMeta,
|
|
500
487
|
}),
|
|
501
488
|
)
|
|
502
489
|
},
|
|
503
490
|
|
|
504
|
-
async
|
|
505
|
-
return MCAD_GOLDS[task.id]
|
|
506
|
-
},
|
|
507
|
-
|
|
508
|
-
async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
|
|
491
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
509
492
|
const spec = (task.metadata as McadTaskMeta | undefined)?.spec
|
|
510
|
-
if (!spec) return {
|
|
493
|
+
if (!spec) return { passed: false, score: 0, notes: `task ${task.id} carries no mcad spec`, raw: {} }
|
|
511
494
|
|
|
512
495
|
const src = stripCodeFence(artifact)
|
|
513
|
-
if (!src) return {
|
|
496
|
+
if (!src) return { passed: false, score: 0, notes: 'empty artifact', raw: {} }
|
|
514
497
|
|
|
515
498
|
const built = await compileAndMeasure(src)
|
|
516
|
-
if (!built.ok) return {
|
|
499
|
+
if (!built.ok) return { passed: false, score: 0, notes: built.detail, raw: {} }
|
|
517
500
|
|
|
518
501
|
const { geo, tris, stlPath } = built
|
|
519
502
|
if (!geo.watertight) {
|
|
503
|
+
const raw = {
|
|
504
|
+
gate: 'watertight',
|
|
505
|
+
failed: [
|
|
506
|
+
{
|
|
507
|
+
name: 'watertight',
|
|
508
|
+
measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,
|
|
509
|
+
expected: '0 open edges (closed 2-manifold solid)',
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },
|
|
513
|
+
stlPath,
|
|
514
|
+
}
|
|
520
515
|
return {
|
|
521
|
-
|
|
516
|
+
passed: false,
|
|
522
517
|
score: 0,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
failed: [
|
|
526
|
-
{
|
|
527
|
-
name: 'watertight',
|
|
528
|
-
measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,
|
|
529
|
-
expected: '0 open edges (closed 2-manifold solid)',
|
|
530
|
-
},
|
|
531
|
-
],
|
|
532
|
-
geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },
|
|
533
|
-
stlPath,
|
|
534
|
-
}),
|
|
518
|
+
notes: JSON.stringify(raw),
|
|
519
|
+
raw,
|
|
535
520
|
}
|
|
536
521
|
}
|
|
537
522
|
|
|
538
523
|
const scored = scoreAgainstSpec(geo, tris, spec)
|
|
524
|
+
const raw = {
|
|
525
|
+
failed: scored.failed.map((c) => ({ name: c.name, measured: c.measured, expected: c.expected })),
|
|
526
|
+
checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
|
|
527
|
+
geo: {
|
|
528
|
+
triangles: geo.triangles,
|
|
529
|
+
solids: geo.solids,
|
|
530
|
+
volume: +geo.volume.toFixed(2),
|
|
531
|
+
degenerateFaces: geo.degenerateFaces,
|
|
532
|
+
bbox: {
|
|
533
|
+
x: +geo.bbox.size.x.toFixed(3),
|
|
534
|
+
y: +geo.bbox.size.y.toFixed(3),
|
|
535
|
+
z: +geo.bbox.size.z.toFixed(3),
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
stlPath,
|
|
539
|
+
}
|
|
539
540
|
return {
|
|
540
|
-
|
|
541
|
+
passed: scored.resolved,
|
|
541
542
|
score: scored.score,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
|
|
545
|
-
geo: {
|
|
546
|
-
triangles: geo.triangles,
|
|
547
|
-
solids: geo.solids,
|
|
548
|
-
volume: +geo.volume.toFixed(2),
|
|
549
|
-
degenerateFaces: geo.degenerateFaces,
|
|
550
|
-
bbox: {
|
|
551
|
-
x: +geo.bbox.size.x.toFixed(3),
|
|
552
|
-
y: +geo.bbox.size.y.toFixed(3),
|
|
553
|
-
z: +geo.bbox.size.z.toFixed(3),
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
stlPath,
|
|
557
|
-
}),
|
|
543
|
+
notes: JSON.stringify(raw),
|
|
544
|
+
raw,
|
|
558
545
|
}
|
|
559
546
|
},
|
|
560
|
-
|
|
547
|
+
|
|
548
|
+
runtime: {
|
|
549
|
+
async preflight() {
|
|
550
|
+
try {
|
|
551
|
+
await execFileAsync('xvfb-run', ['-a', 'openscad', '--version'], { timeout: 30_000 })
|
|
552
|
+
} catch (err) {
|
|
553
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
554
|
+
throw new Error(
|
|
555
|
+
`mcad preflight failed: ${msg}\n` +
|
|
556
|
+
'Fix: install OpenSCAD + Xvfb (Debian/Ubuntu: sudo apt-get install -y openscad xvfb). ' +
|
|
557
|
+
'The judge runs `xvfb-run -a openscad --export-format=asciistl -o out.stl model.scad` — both must be on PATH.',
|
|
558
|
+
)
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
async goldArtifact(task: BenchTask) {
|
|
563
|
+
return MCAD_GOLDS[task.id]
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
})
|
|
561
567
|
}
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
} from './mcad-bench'
|
|
66
66
|
import { MCAD_CQ_GOLDS, MCAD_CQ_UNCALIBRATED } from './mcad-cq-golds'
|
|
67
67
|
import { MCAD_DELIVERABLE, MCAD_DELIVERABLE_MULTIBODY, MCAD_TASKS, type McadTask } from './mcad-tasks'
|
|
68
|
-
import
|
|
68
|
+
import { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'
|
|
69
69
|
|
|
70
70
|
const execFileAsync = promisify(execFile)
|
|
71
71
|
|
|
@@ -320,32 +320,18 @@ export function withStepCheck(scored: McadScoring, stepEmitted: boolean): McadSc
|
|
|
320
320
|
// Adapter
|
|
321
321
|
// ---------------------------------------------------------------------------
|
|
322
322
|
|
|
323
|
-
export function createMcadCqAdapter():
|
|
324
|
-
return {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
async preflight() {
|
|
328
|
-
const python = resolveCadqueryPython()
|
|
329
|
-
if (!existsSync(python)) throw cadqueryMissingError(python)
|
|
330
|
-
try {
|
|
331
|
-
await execFileAsync(python, ['-c', 'import cadquery; print(cadquery.__version__)'], {
|
|
332
|
-
timeout: 300_000,
|
|
333
|
-
env: scriptEnv(tmpdir()),
|
|
334
|
-
})
|
|
335
|
-
} catch (err) {
|
|
336
|
-
const e = err as NodeJS.ErrnoException & { stderr?: string }
|
|
337
|
-
throw cadqueryMissingError(python, `\`import cadquery\` failed: ${(e.stderr ?? e.message ?? '').trim().slice(-800)}`)
|
|
338
|
-
}
|
|
339
|
-
},
|
|
323
|
+
export function createMcadCqAdapter(): RuntimeBenchmark {
|
|
324
|
+
return runtimeBenchmark({
|
|
325
|
+
id: 'mcad-cq',
|
|
340
326
|
|
|
341
|
-
async
|
|
327
|
+
async loadAll(opts: LoadOptions = {}) {
|
|
342
328
|
let tasks: McadTask[] = MCAD_TASKS
|
|
343
329
|
if (opts.ids) tasks = tasks.filter((t) => opts.ids?.includes(t.id))
|
|
344
330
|
if (opts.limit != null) tasks = tasks.slice(0, opts.limit)
|
|
345
331
|
return tasks.map(
|
|
346
332
|
(t): BenchTask => ({
|
|
347
333
|
id: t.id,
|
|
348
|
-
prompt: toCadQueryPrompt(t),
|
|
334
|
+
payload: { prompt: toCadQueryPrompt(t) },
|
|
349
335
|
metadata: {
|
|
350
336
|
spec: t.spec,
|
|
351
337
|
source: t.source,
|
|
@@ -357,67 +343,87 @@ export function createMcadCqAdapter(): BenchmarkAdapter {
|
|
|
357
343
|
)
|
|
358
344
|
},
|
|
359
345
|
|
|
360
|
-
async
|
|
361
|
-
return MCAD_CQ_GOLDS[task.id]
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
async judge(task: BenchTask, artifact: string): Promise<BenchScore> {
|
|
346
|
+
async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {
|
|
365
347
|
const spec = (task.metadata as McadTaskMeta | undefined)?.spec
|
|
366
|
-
if (!spec) return {
|
|
348
|
+
if (!spec) return { passed: false, score: 0, notes: `task ${task.id} carries no mcad spec`, raw: {} }
|
|
367
349
|
|
|
368
350
|
const src = stripCodeFence(artifact)
|
|
369
|
-
if (!src) return {
|
|
351
|
+
if (!src) return { passed: false, score: 0, notes: 'empty artifact', raw: {} }
|
|
370
352
|
|
|
371
353
|
const built = await runAndMeasureCadQuery(src)
|
|
372
354
|
if (!built.ok) {
|
|
373
|
-
return {
|
|
355
|
+
return { passed: false, score: 0, notes: `${built.detail} [dir ${built.dir}, stepEmitted ${built.stepEmitted}]`, raw: {} }
|
|
374
356
|
}
|
|
375
357
|
|
|
376
358
|
const { geo, tris, stlPath, stepEmitted, dir } = built
|
|
377
359
|
if (!geo.watertight) {
|
|
360
|
+
const raw = {
|
|
361
|
+
gate: 'watertight',
|
|
362
|
+
failed: [
|
|
363
|
+
{
|
|
364
|
+
name: 'watertight',
|
|
365
|
+
measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,
|
|
366
|
+
expected: '0 open edges (closed 2-manifold solid)',
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },
|
|
370
|
+
stepEmitted,
|
|
371
|
+
stlPath,
|
|
372
|
+
dir,
|
|
373
|
+
}
|
|
378
374
|
return {
|
|
379
|
-
|
|
375
|
+
passed: false,
|
|
380
376
|
score: 0,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
failed: [
|
|
384
|
-
{
|
|
385
|
-
name: 'watertight',
|
|
386
|
-
measured: `${geo.openEdges} edge(s) not shared by exactly two faces`,
|
|
387
|
-
expected: '0 open edges (closed 2-manifold solid)',
|
|
388
|
-
},
|
|
389
|
-
],
|
|
390
|
-
geo: { triangles: geo.triangles, degenerateFaces: geo.degenerateFaces },
|
|
391
|
-
stepEmitted,
|
|
392
|
-
stlPath,
|
|
393
|
-
dir,
|
|
394
|
-
}),
|
|
377
|
+
notes: JSON.stringify(raw),
|
|
378
|
+
raw,
|
|
395
379
|
}
|
|
396
380
|
}
|
|
397
381
|
|
|
398
382
|
const scored = withStepCheck(scoreAgainstSpec(geo, tris, spec), stepEmitted)
|
|
383
|
+
const raw = {
|
|
384
|
+
failed: scored.failed.map((c) => ({ name: c.name, measured: c.measured, expected: c.expected })),
|
|
385
|
+
checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
|
|
386
|
+
geo: {
|
|
387
|
+
triangles: geo.triangles,
|
|
388
|
+
solids: geo.solids,
|
|
389
|
+
volume: +geo.volume.toFixed(2),
|
|
390
|
+
degenerateFaces: geo.degenerateFaces,
|
|
391
|
+
bbox: {
|
|
392
|
+
x: +geo.bbox.size.x.toFixed(3),
|
|
393
|
+
y: +geo.bbox.size.y.toFixed(3),
|
|
394
|
+
z: +geo.bbox.size.z.toFixed(3),
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
stepEmitted,
|
|
398
|
+
stlPath,
|
|
399
|
+
dir,
|
|
400
|
+
}
|
|
399
401
|
return {
|
|
400
|
-
|
|
402
|
+
passed: scored.resolved,
|
|
401
403
|
score: scored.score,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
checks: Object.fromEntries(scored.checks.map((c) => [c.name, c.ok])),
|
|
405
|
-
geo: {
|
|
406
|
-
triangles: geo.triangles,
|
|
407
|
-
solids: geo.solids,
|
|
408
|
-
volume: +geo.volume.toFixed(2),
|
|
409
|
-
degenerateFaces: geo.degenerateFaces,
|
|
410
|
-
bbox: {
|
|
411
|
-
x: +geo.bbox.size.x.toFixed(3),
|
|
412
|
-
y: +geo.bbox.size.y.toFixed(3),
|
|
413
|
-
z: +geo.bbox.size.z.toFixed(3),
|
|
414
|
-
},
|
|
415
|
-
},
|
|
416
|
-
stepEmitted,
|
|
417
|
-
stlPath,
|
|
418
|
-
dir,
|
|
419
|
-
}),
|
|
404
|
+
notes: JSON.stringify(raw),
|
|
405
|
+
raw,
|
|
420
406
|
}
|
|
421
407
|
},
|
|
422
|
-
|
|
408
|
+
|
|
409
|
+
runtime: {
|
|
410
|
+
async preflight() {
|
|
411
|
+
const python = resolveCadqueryPython()
|
|
412
|
+
if (!existsSync(python)) throw cadqueryMissingError(python)
|
|
413
|
+
try {
|
|
414
|
+
await execFileAsync(python, ['-c', 'import cadquery; print(cadquery.__version__)'], {
|
|
415
|
+
timeout: 300_000,
|
|
416
|
+
env: scriptEnv(tmpdir()),
|
|
417
|
+
})
|
|
418
|
+
} catch (err) {
|
|
419
|
+
const e = err as NodeJS.ErrnoException & { stderr?: string }
|
|
420
|
+
throw cadqueryMissingError(python, `\`import cadquery\` failed: ${(e.stderr ?? e.message ?? '').trim().slice(-800)}`)
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
async goldArtifact(task: BenchTask) {
|
|
425
|
+
return MCAD_CQ_GOLDS[task.id]
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
})
|
|
423
429
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These are CALIBRATION artifacts, not exemplar answers: their whole job is to
|
|
5
5
|
* prove this adapter's accept direction fires. Every one has been run through
|
|
6
|
-
* `createMcadCqAdapter().
|
|
6
|
+
* `createMcadCqAdapter().evaluate()` on this host, and a task is reported calibrated
|
|
7
7
|
* only when its gold below scores 1.0 — including the `stepEmitted` check, so
|
|
8
8
|
* every gold really does write a STEP file, which is the deviation v1 could not
|
|
9
9
|
* close.
|