@tangle-network/agent-bench 2.0.0 → 4.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 +27 -0
- package/README.md +32 -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 +43 -22
- package/dist/index.js +297 -144
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/pier_agents/candidate_contract.py +226 -74
- package/pier_agents/tangle_candidate.py +79 -1
- package/pier_agents/workspace_boundary.py +29 -1
- 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/scripts/verify-pier-agent.mts +142 -25
- 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 +20 -11
- package/src/pier-agent.ts +108 -38
- package/src/pier-trial-controller.test.mts +48 -1
- package/src/pier-trial-controller.ts +121 -8
- 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
|
@@ -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.
|
|
@@ -180,14 +180,14 @@ describe('mcad-cq delivery gates', () => {
|
|
|
180
180
|
describe('mcad-cq task loading', () => {
|
|
181
181
|
it('carries spec/source/calibrated metadata and a CadQuery gold for every task', async () => {
|
|
182
182
|
const a = createMcadCqAdapter()
|
|
183
|
-
const tasks = await a.
|
|
183
|
+
const tasks = await a.loadAll()
|
|
184
184
|
expect(tasks).toHaveLength(MCAD_TASKS.length)
|
|
185
185
|
for (const t of tasks) {
|
|
186
186
|
const md = t.metadata as { spec: unknown; source: string; calibrated: boolean }
|
|
187
187
|
expect(md.spec, t.id).toBeTruthy()
|
|
188
188
|
expect(typeof md.source).toBe('string')
|
|
189
189
|
expect(md.calibrated, t.id).toBe(!MCAD_CQ_UNCALIBRATED.has(t.id))
|
|
190
|
-
const gold = await a.goldArtifact(t)
|
|
190
|
+
const gold = await a.runtime.goldArtifact!(t)
|
|
191
191
|
expect(typeof gold, t.id).toBe('string')
|
|
192
192
|
expect(gold, t.id).toContain('import cadquery as cq')
|
|
193
193
|
expect(gold, t.id).toContain('cq.exporters.export(result, "part.step")')
|
|
@@ -197,17 +197,17 @@ describe('mcad-cq task loading', () => {
|
|
|
197
197
|
|
|
198
198
|
it('honours ids and limit', async () => {
|
|
199
199
|
const a = createMcadCqAdapter()
|
|
200
|
-
expect((await a.
|
|
201
|
-
expect(await a.
|
|
200
|
+
expect((await a.loadAll({ ids: ['l-bracket'] })).map((t) => t.id)).toEqual(['l-bracket'])
|
|
201
|
+
expect(await a.loadAll({ limit: 3 })).toHaveLength(3)
|
|
202
202
|
})
|
|
203
203
|
|
|
204
204
|
it('scores an empty artifact 0 without starting an interpreter', async () => {
|
|
205
205
|
const a = createMcadCqAdapter()
|
|
206
|
-
const [t] = await a.
|
|
207
|
-
const s = await a.
|
|
208
|
-
expect(s.
|
|
206
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
207
|
+
const s = await a.evaluate(t!, ' ')
|
|
208
|
+
expect(s.passed).toBe(false)
|
|
209
209
|
expect(s.score).toBe(0)
|
|
210
|
-
expect(s.
|
|
210
|
+
expect(s.notes).toBe('empty artifact')
|
|
211
211
|
})
|
|
212
212
|
})
|
|
213
213
|
|
|
@@ -252,7 +252,7 @@ const NO_STEP_EXPORT = MCAD_CQ_GOLDS['calibration-block']!.replace('cq.exporters
|
|
|
252
252
|
|
|
253
253
|
describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
254
254
|
it('preflight passes when the interpreter is present', async () => {
|
|
255
|
-
await expect(createMcadCqAdapter().preflight()).resolves.toBeUndefined()
|
|
255
|
+
await expect(createMcadCqAdapter().runtime.preflight!()).resolves.toBeUndefined()
|
|
256
256
|
}, JUDGE_TIMEOUT)
|
|
257
257
|
|
|
258
258
|
for (const task of MCAD_TASKS.filter((t) => !MCAD_CQ_UNCALIBRATED.has(t.id))) {
|
|
@@ -260,15 +260,15 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
260
260
|
`gold for ${task.id} resolves at score 1.0`,
|
|
261
261
|
async () => {
|
|
262
262
|
const a = createMcadCqAdapter()
|
|
263
|
-
const [t] = await a.
|
|
264
|
-
const gold = await a.goldArtifact(t!)
|
|
263
|
+
const [t] = await a.loadAll({ ids: [task.id] })
|
|
264
|
+
const gold = await a.runtime.goldArtifact!(t!)
|
|
265
265
|
expect(typeof gold).toBe('string')
|
|
266
|
-
const s = await a.
|
|
267
|
-
const detail = JSON.parse(s.
|
|
268
|
-
expect(detail.failed ?? [], `failed checks: ${s.
|
|
266
|
+
const s = await a.evaluate(t!, gold as string)
|
|
267
|
+
const detail = JSON.parse(s.notes ?? '{}')
|
|
268
|
+
expect(detail.failed ?? [], `failed checks: ${s.notes}`).toEqual([])
|
|
269
269
|
expect(detail.checks?.stepEmitted).toBe(true)
|
|
270
270
|
expect(s.score).toBe(1)
|
|
271
|
-
expect(s.
|
|
271
|
+
expect(s.passed).toBe(true)
|
|
272
272
|
},
|
|
273
273
|
JUDGE_TIMEOUT,
|
|
274
274
|
)
|
|
@@ -278,10 +278,10 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
278
278
|
'grades a fenced answer identically — the fence is a formatting slip, not geometry',
|
|
279
279
|
async () => {
|
|
280
280
|
const a = createMcadCqAdapter()
|
|
281
|
-
const [t] = await a.
|
|
282
|
-
const s = await a.
|
|
281
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
282
|
+
const s = await a.evaluate(t!, `\`\`\`python\n${MCAD_CQ_GOLDS['calibration-block']!.trim()}\n\`\`\``)
|
|
283
283
|
expect(s.score).toBe(1)
|
|
284
|
-
expect(s.
|
|
284
|
+
expect(s.passed).toBe(true)
|
|
285
285
|
},
|
|
286
286
|
JUDGE_TIMEOUT,
|
|
287
287
|
)
|
|
@@ -290,12 +290,12 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
290
290
|
'MUST REJECT: one bore of four deleted fails its named probes and nothing else',
|
|
291
291
|
async () => {
|
|
292
292
|
const a = createMcadCqAdapter()
|
|
293
|
-
const [t] = await a.
|
|
294
|
-
const s = await a.
|
|
295
|
-
expect(s.
|
|
293
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
294
|
+
const s = await a.evaluate(t!, BLOCK_MISSING_ONE_BORE)
|
|
295
|
+
expect(s.passed).toBe(false)
|
|
296
296
|
expect(s.score).toBeGreaterThan(0)
|
|
297
297
|
expect(s.score).toBeLessThan(1)
|
|
298
|
-
const failed = (JSON.parse(s.
|
|
298
|
+
const failed = (JSON.parse(s.notes as string).failed as Array<{ name: string }>).map((f) => f.name)
|
|
299
299
|
// the deleted bore is the (35, 20) one: its centre probe and the 3 mm-off
|
|
300
300
|
// probe both now sit in solid material
|
|
301
301
|
expect(failed).toContain('probeOutside[0] (35, 20, 10)')
|
|
@@ -314,13 +314,13 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
314
314
|
'MUST REJECT: a script that writes no part.stl scores 0 and the detail says so',
|
|
315
315
|
async () => {
|
|
316
316
|
const a = createMcadCqAdapter()
|
|
317
|
-
const [t] = await a.
|
|
318
|
-
const s = await a.
|
|
319
|
-
expect(s.
|
|
317
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
318
|
+
const s = await a.evaluate(t!, STEP_ONLY)
|
|
319
|
+
expect(s.passed).toBe(false)
|
|
320
320
|
expect(s.score).toBe(0)
|
|
321
|
-
expect(s.
|
|
321
|
+
expect(s.notes).toMatch(/wrote no part\.stl/)
|
|
322
322
|
// it DID write the STEP file, and the detail says that too
|
|
323
|
-
expect(s.
|
|
323
|
+
expect(s.notes).toMatch(/stepEmitted true/)
|
|
324
324
|
},
|
|
325
325
|
JUDGE_TIMEOUT,
|
|
326
326
|
)
|
|
@@ -329,11 +329,11 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
329
329
|
'MUST REJECT: a binary STL is a format miss, not a parse problem',
|
|
330
330
|
async () => {
|
|
331
331
|
const a = createMcadCqAdapter()
|
|
332
|
-
const [t] = await a.
|
|
333
|
-
const s = await a.
|
|
334
|
-
expect(s.
|
|
332
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
333
|
+
const s = await a.evaluate(t!, BINARY_STL)
|
|
334
|
+
expect(s.passed).toBe(false)
|
|
335
335
|
expect(s.score).toBe(0)
|
|
336
|
-
expect(s.
|
|
336
|
+
expect(s.notes).toMatch(/not ASCII/)
|
|
337
337
|
},
|
|
338
338
|
JUDGE_TIMEOUT,
|
|
339
339
|
)
|
|
@@ -342,10 +342,10 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
342
342
|
'MUST REJECT: dropping the STEP export costs exactly the stepEmitted check',
|
|
343
343
|
async () => {
|
|
344
344
|
const a = createMcadCqAdapter()
|
|
345
|
-
const [t] = await a.
|
|
346
|
-
const s = await a.
|
|
347
|
-
expect(s.
|
|
348
|
-
const detail = JSON.parse(s.
|
|
345
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
346
|
+
const s = await a.evaluate(t!, NO_STEP_EXPORT)
|
|
347
|
+
expect(s.passed).toBe(false)
|
|
348
|
+
const detail = JSON.parse(s.notes as string) as {
|
|
349
349
|
failed: Array<{ name: string }>
|
|
350
350
|
checks: Record<string, boolean>
|
|
351
351
|
stepEmitted: boolean
|
|
@@ -374,12 +374,12 @@ describe.skipIf(!CADQUERY)('mcad-cq judge, live cadquery', () => {
|
|
|
374
374
|
'MUST REJECT: a script that raises is scored 0 with its traceback in the detail',
|
|
375
375
|
async () => {
|
|
376
376
|
const a = createMcadCqAdapter()
|
|
377
|
-
const [t] = await a.
|
|
378
|
-
const s = await a.
|
|
379
|
-
expect(s.
|
|
377
|
+
const [t] = await a.loadAll({ ids: ['calibration-block'] })
|
|
378
|
+
const s = await a.evaluate(t!, 'import cadquery as cq\nraise SystemExit("no model here")\n')
|
|
379
|
+
expect(s.passed).toBe(false)
|
|
380
380
|
expect(s.score).toBe(0)
|
|
381
|
-
expect(s.
|
|
382
|
-
expect(s.
|
|
381
|
+
expect(s.notes).toMatch(/script failed:/)
|
|
382
|
+
expect(s.notes).toMatch(/no model here/)
|
|
383
383
|
},
|
|
384
384
|
JUDGE_TIMEOUT,
|
|
385
385
|
)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* These are CALIBRATION artifacts, not exemplar answers: their whole job is to
|
|
5
5
|
* prove the judge's accept direction fires, so they are written plain (no clever
|
|
6
6
|
* parametrics, `$fn=96` on round features) and every one of them has been run
|
|
7
|
-
* through `createMcadBenchAdapter().
|
|
7
|
+
* through `createMcadBenchAdapter().evaluate()` on this host. A task is marked
|
|
8
8
|
* `calibrated: true` in `mcad-tasks.ts` only when its gold below scores 1.0.
|
|
9
9
|
*
|
|
10
10
|
* Where a gold deviates from the prompt's literal dimensions, the deviation is
|