@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
package/dist/index.js
CHANGED
|
@@ -3,22 +3,23 @@ import { createCragAdapter } from "./benchmarks/crag.js";
|
|
|
3
3
|
import { createNoMiraclAdapter } from "./benchmarks/nomiracl.js";
|
|
4
4
|
import { createOpenRagBenchAdapter } from "./benchmarks/open-rag-bench.js";
|
|
5
5
|
import { createRagBenchAdapter } from "./benchmarks/ragbench.js";
|
|
6
|
-
import { FINAL_ANSWER_SENTINEL,
|
|
6
|
+
import { FINAL_ANSWER_SENTINEL, answerScoreToEvaluation, contextBlock, contextsFrom, normalizeAnswer, parseCitations, parseFinalAnswer, ragAnswerOutput, scoreAnswerArtifact, tokenF1 } from "./benchmarks/rag-shared.js";
|
|
7
7
|
import { createT2RagBenchAdapter } from "./benchmarks/t2-ragbench.js";
|
|
8
8
|
import { createSweBenchAdapter, scoreSweReport, sweEvaluationArgv, swePatchOutput } from "./benchmarks/swe-bench.js";
|
|
9
9
|
import { StagedJudgeError, runStagedJudge } from "./benchmarks/_harness.js";
|
|
10
|
+
import { runtimeBenchmark } from "./benchmarks/types.js";
|
|
10
11
|
import { chmod, lstat, mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
11
12
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
12
13
|
import { execFileSync, spawn } from "node:child_process";
|
|
13
14
|
import { createHash } from "node:crypto";
|
|
14
|
-
import { accessSync, closeSync, constants, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { accessSync, closeSync, constants, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
15
16
|
import { tmpdir } from "node:os";
|
|
16
17
|
import { fileURLToPath } from "node:url";
|
|
17
18
|
import { SandboxRunAbortError, createExecutor, inlineSandboxClient, openSandboxRun, resolveSandboxClient, sumSandboxUsage } from "@tangle-network/agent-runtime/kernel";
|
|
19
|
+
import { canonicalJson } from "@tangle-network/agent-eval";
|
|
18
20
|
import { Sandbox } from "@tangle-network/sandbox";
|
|
19
21
|
import assert from "node:assert/strict";
|
|
20
22
|
import { captureAgentCandidateWorkspaceFiles, executePreparedAgentCandidate } from "@tangle-network/agent-runtime/candidate-execution";
|
|
21
|
-
import { canonicalJson } from "@tangle-network/agent-eval";
|
|
22
23
|
// src/refine-loop.ts
|
|
23
24
|
const defaultDecide = (history) => history[history.length - 1]?.verdict?.valid === true;
|
|
24
25
|
async function runRefineLoop(spec) {
|
|
@@ -210,12 +211,12 @@ async function runPool(items, concurrency, worker, opts) {
|
|
|
210
211
|
* It owns no new mechanism. Each cell is one `openSandboxRun` shot (the same per-run primitive the
|
|
211
212
|
* SWE worker uses) driven by `resolveBenchClient` (off-box router completion OR in-box Sandbox; the
|
|
212
213
|
* harness rides `sandboxOverrides.backend.type`). The deliverable is the adapter's OWN parser
|
|
213
|
-
* (`adapter.output`), defaulting to the final answer text — so `runBenchmarks` needs no
|
|
214
|
+
* (`adapter.runtime.output`), defaulting to the final answer text — so `runBenchmarks` needs no
|
|
214
215
|
* per-benchmark branching. Concurrency is the shared `runPool`. The number comes from
|
|
215
|
-
* `adapter.
|
|
216
|
+
* `adapter.evaluate`, never a self-authored judge.
|
|
216
217
|
*
|
|
217
|
-
* Subset = the `benchmarks` and `cells` arrays plus `n`/`ids`/`
|
|
218
|
-
* `preflight()` fails (missing Docker/venv/dataset) is recorded as unavailable and skipped — the
|
|
218
|
+
* Subset = the `benchmarks` and `cells` arrays plus `n`/`ids`/`subset`. A benchmark whose
|
|
219
|
+
* `runtime.preflight()` fails (missing Docker/venv/dataset) is recorded as unavailable and skipped — the
|
|
219
220
|
* sweep never aborts because one bench's harness is absent.
|
|
220
221
|
*
|
|
221
222
|
* const report = await runBenchmarks({
|
|
@@ -261,7 +262,9 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
261
262
|
...timeoutMs ? { timeoutMs } : {}
|
|
262
263
|
});
|
|
263
264
|
const harness = cell.harness ?? cell.profile?.metadata?.backendType ?? "opencode";
|
|
264
|
-
const
|
|
265
|
+
const bridgeRoute = cell.backend === "bridge" && cell.model.startsWith(`${harness}/`) ? cell.model.slice(harness.length + 1) : void 0;
|
|
266
|
+
const bridgeProvider = bridgeRoute?.includes("/") ? bridgeRoute.slice(0, bridgeRoute.indexOf("/")) : void 0;
|
|
267
|
+
const profileProvider = cell.profile?.model?.provider ?? bridgeProvider ?? "tangle-router";
|
|
265
268
|
const profile = {
|
|
266
269
|
...cell.profile ?? { name: cell.label },
|
|
267
270
|
harness,
|
|
@@ -281,7 +284,7 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
281
284
|
name: cell.label,
|
|
282
285
|
taskToPrompt: () => "",
|
|
283
286
|
sandboxOverrides: {
|
|
284
|
-
name: `bench-${adapter.
|
|
287
|
+
name: `bench-${adapter.id}-${task.id}-${uniq}`.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 60),
|
|
285
288
|
environment: "universal",
|
|
286
289
|
backend: {
|
|
287
290
|
type: harness,
|
|
@@ -296,7 +299,7 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
296
299
|
};
|
|
297
300
|
const deliverable = {
|
|
298
301
|
kind: "events",
|
|
299
|
-
fromEvents: (events) => adapter.output ? adapter.output.parse(events) : finalText(events)
|
|
302
|
+
fromEvents: (events) => adapter.runtime.output ? adapter.runtime.output.parse(events) : finalText(events)
|
|
300
303
|
};
|
|
301
304
|
const controller = new AbortController();
|
|
302
305
|
const timer = timeoutMs ? setTimeout(() => controller.abort(), timeoutMs) : void 0;
|
|
@@ -304,21 +307,21 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
304
307
|
const runOptions = {
|
|
305
308
|
agentRun,
|
|
306
309
|
signal: signal ? AbortSignal.any([controller.signal, signal]) : controller.signal,
|
|
307
|
-
runId: `bench:${adapter.
|
|
310
|
+
runId: `bench:${adapter.id}:${task.id}:${uniq}`,
|
|
308
311
|
scenarioId: task.id,
|
|
309
312
|
onSandboxEvent: (event) => {
|
|
310
313
|
observedEvents.push(event);
|
|
311
314
|
}
|
|
312
315
|
};
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const setup =
|
|
316
|
+
const workspaceSetup = adapter.runtime.workspaceSetup;
|
|
317
|
+
if (workspaceSetup) runOptions.beforeStart = async ({ box, sessionId }) => {
|
|
318
|
+
const setup = workspaceSetup(task);
|
|
316
319
|
const sres = await box.exec(setup.command, {
|
|
317
320
|
timeoutMs: 3e5,
|
|
318
321
|
sessionId,
|
|
319
322
|
...setup.cwd ? { cwd: setup.cwd } : {}
|
|
320
323
|
});
|
|
321
|
-
if (sres.exitCode !== 0) throw new Error(`
|
|
324
|
+
if (sres.exitCode !== 0) throw new Error(`workspaceSetup failed (exit ${sres.exitCode}): ${(sres.stderr ?? "").slice(0, 200)}`);
|
|
322
325
|
};
|
|
323
326
|
let run;
|
|
324
327
|
let result = {
|
|
@@ -395,9 +398,9 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
395
398
|
return pending;
|
|
396
399
|
};
|
|
397
400
|
const context = {
|
|
398
|
-
prompt: prompt ??
|
|
401
|
+
prompt: prompt ?? adapter.runtime.prompt(task),
|
|
399
402
|
profile: structuredClone(profile),
|
|
400
|
-
benchmark: adapter.
|
|
403
|
+
benchmark: adapter.id,
|
|
401
404
|
taskId: task.id,
|
|
402
405
|
attempt,
|
|
403
406
|
signal: runOptions.signal,
|
|
@@ -440,20 +443,20 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
440
443
|
}
|
|
441
444
|
};
|
|
442
445
|
let artifact = (turn.out ?? "").trim();
|
|
443
|
-
let
|
|
444
|
-
if (adapter.
|
|
445
|
-
const ex = adapter.
|
|
446
|
+
let workspaceExtractError;
|
|
447
|
+
if (adapter.runtime.workspaceExtract) try {
|
|
448
|
+
const ex = adapter.runtime.workspaceExtract(task);
|
|
446
449
|
const res = await run.box.exec(ex.command, {
|
|
447
450
|
timeoutMs: 12e4,
|
|
448
451
|
sessionId: run.sessionId,
|
|
449
452
|
...ex.cwd ? { cwd: ex.cwd } : {}
|
|
450
453
|
});
|
|
451
454
|
const boxArtifact = (res.stdout ?? "").trim();
|
|
452
|
-
if (res.exitCode !== 0)
|
|
455
|
+
if (res.exitCode !== 0) workspaceExtractError = `exit ${res.exitCode}: ${(res.stderr ?? "").slice(0, 160)}`;
|
|
453
456
|
else if (boxArtifact.length > 0) artifact = boxArtifact;
|
|
454
457
|
if (process.env.BENCH_ARTIFACT_DIR) try {
|
|
455
458
|
mkdirSync(process.env.BENCH_ARTIFACT_DIR, { recursive: true });
|
|
456
|
-
const safe = `${adapter.
|
|
459
|
+
const safe = `${adapter.id}_${task.id}_${uniq}`.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
457
460
|
const map = await run.box.exec("echo \"PWD:\"; pwd; echo \"LS:\"; ls -la; echo \"GITROOTS:\"; find / -maxdepth 5 -type d -name .git 2>/dev/null; echo \"SETTINGS:\"; find / -maxdepth 8 -name global_settings.py -path \"*conf*\" 2>/dev/null", {
|
|
458
461
|
timeoutMs: 6e4,
|
|
459
462
|
sessionId: run.sessionId
|
|
@@ -473,19 +476,19 @@ const openSandboxShot = async ({ adapter, task, cell, prompt, attempt = 1, execu
|
|
|
473
476
|
}, null, 2));
|
|
474
477
|
} catch {}
|
|
475
478
|
} catch (err) {
|
|
476
|
-
|
|
479
|
+
workspaceExtractError = err instanceof Error ? err.message.slice(0, 160) : String(err);
|
|
477
480
|
}
|
|
478
|
-
const detail = !turn.outcome.success ? turn.outcome.error ?? `agent ended with status ${turn.outcome.status}` : turn.readError !== void 0 ? `read: ${turn.readError.slice(0, 160)}` :
|
|
481
|
+
const detail = !turn.outcome.success ? turn.outcome.error ?? `agent ended with status ${turn.outcome.status}` : turn.readError !== void 0 ? `read: ${turn.readError.slice(0, 160)}` : workspaceExtractError !== void 0 ? `workspaceExtract: ${workspaceExtractError}` : void 0;
|
|
479
482
|
if (process.env.BENCH_ARTIFACT_DIR) try {
|
|
480
483
|
mkdirSync(process.env.BENCH_ARTIFACT_DIR, { recursive: true });
|
|
481
|
-
const safe = `${adapter.
|
|
484
|
+
const safe = `${adapter.id}_${task.id}_${uniq}`.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
482
485
|
writeFileSync(`${process.env.BENCH_ARTIFACT_DIR}/${safe}.patch`, artifact);
|
|
483
486
|
} catch {}
|
|
484
487
|
result = {
|
|
485
488
|
artifact,
|
|
486
|
-
ok: turn.outcome.success && artifact.length > 0 && turn.readError === void 0 &&
|
|
489
|
+
ok: turn.outcome.success && artifact.length > 0 && turn.readError === void 0 && workspaceExtractError === void 0,
|
|
487
490
|
execution: result.execution,
|
|
488
|
-
artifactAvailable: turn.readError === void 0 &&
|
|
491
|
+
artifactAvailable: turn.readError === void 0 && workspaceExtractError === void 0,
|
|
489
492
|
usage: result.usage,
|
|
490
493
|
events: observedEvents,
|
|
491
494
|
prompts,
|
|
@@ -561,34 +564,33 @@ function redactJudgeLeak(value) {
|
|
|
561
564
|
}
|
|
562
565
|
function safeFeedback(score) {
|
|
563
566
|
return {
|
|
564
|
-
resolved: score.
|
|
567
|
+
resolved: score.passed === true,
|
|
565
568
|
score: score.score,
|
|
566
|
-
...score.
|
|
569
|
+
...score.notes ? { detail: redactJudgeLeak(parseMaybeJson(score.notes)) } : {}
|
|
567
570
|
};
|
|
568
571
|
}
|
|
569
572
|
function truncate(value, max = 4e3) {
|
|
570
573
|
return value.length <= max ? value : `${value.slice(0, max)}\n...[truncated ${value.length - max} chars]`;
|
|
571
574
|
}
|
|
572
|
-
function retryPrompt(
|
|
573
|
-
const attempts = history.map((h) => {
|
|
574
|
-
const score = scores.get(h.round);
|
|
575
|
-
return [
|
|
576
|
-
`Attempt ${h.round}:`,
|
|
577
|
-
"Artifact:",
|
|
578
|
-
truncate(h.artifact),
|
|
579
|
-
score ? `Checker feedback: ${JSON.stringify(safeFeedback(score))}` : void 0
|
|
580
|
-
].filter(Boolean).join("\n");
|
|
581
|
-
}).join("\n\n");
|
|
575
|
+
function retryPrompt(prompt, history, scores) {
|
|
582
576
|
return [
|
|
583
577
|
"Retry the benchmark task. The previous artifact did not pass the checker.",
|
|
584
578
|
"Use only the original task statement and supplied context. Do not invent facts.",
|
|
585
579
|
"Return the corrected artifact in exactly the format requested by the original task.",
|
|
586
580
|
"",
|
|
587
581
|
"Original task:",
|
|
588
|
-
|
|
582
|
+
prompt,
|
|
589
583
|
"",
|
|
590
584
|
"Previous attempts and safe checker feedback:",
|
|
591
|
-
|
|
585
|
+
history.map((h) => {
|
|
586
|
+
const score = scores.get(h.round);
|
|
587
|
+
return [
|
|
588
|
+
`Attempt ${h.round}:`,
|
|
589
|
+
"Artifact:",
|
|
590
|
+
truncate(h.artifact),
|
|
591
|
+
score ? `Checker feedback: ${JSON.stringify(safeFeedback(score))}` : void 0
|
|
592
|
+
].filter(Boolean).join("\n");
|
|
593
|
+
}).join("\n\n")
|
|
592
594
|
].join("\n");
|
|
593
595
|
}
|
|
594
596
|
async function loopedShot(input, shot, attempts) {
|
|
@@ -599,7 +601,10 @@ async function loopedShot(input, shot, attempts) {
|
|
|
599
601
|
try {
|
|
600
602
|
result = await runRefineLoop({
|
|
601
603
|
rounds: attempts,
|
|
602
|
-
prompt: (round, history) =>
|
|
604
|
+
prompt: (round, history) => {
|
|
605
|
+
const original = input.adapter.runtime.prompt(input.task);
|
|
606
|
+
return round === 1 ? original : retryPrompt(original, history, scores);
|
|
607
|
+
},
|
|
603
608
|
runShot: async (prompt, round) => {
|
|
604
609
|
input.signal?.throwIfAborted();
|
|
605
610
|
pendingShot = true;
|
|
@@ -616,11 +621,11 @@ async function loopedShot(input, shot, attempts) {
|
|
|
616
621
|
};
|
|
617
622
|
},
|
|
618
623
|
judge: async (artifact, round) => {
|
|
619
|
-
const score = await input.adapter.
|
|
624
|
+
const score = await input.adapter.evaluate(input.task, artifact);
|
|
620
625
|
scores.set(round, score);
|
|
621
626
|
const succeeded = shots.get(round)?.ok === true;
|
|
622
627
|
return {
|
|
623
|
-
valid: succeeded && score.
|
|
628
|
+
valid: succeeded && score.passed === true,
|
|
624
629
|
score: succeeded ? score.score : 0
|
|
625
630
|
};
|
|
626
631
|
}
|
|
@@ -653,8 +658,8 @@ async function loopedShot(input, shot, attempts) {
|
|
|
653
658
|
const b = scores.get(candidate.round);
|
|
654
659
|
if (!a) return candidate;
|
|
655
660
|
if (!b) return winner;
|
|
656
|
-
if (b.
|
|
657
|
-
if (b.
|
|
661
|
+
if (b.passed && !a.passed) return candidate;
|
|
662
|
+
if (!!b.passed === !!a.passed && b.score > a.score) return candidate;
|
|
658
663
|
return winner;
|
|
659
664
|
}, result.rounds[0]);
|
|
660
665
|
const bestScore = scores.get(best.round);
|
|
@@ -675,7 +680,7 @@ async function loopedShot(input, shot, attempts) {
|
|
|
675
680
|
rounds: result.rounds.map((round) => ({
|
|
676
681
|
attempt: round.round,
|
|
677
682
|
score: scores.get(round.round)?.score ?? null,
|
|
678
|
-
resolved: scores.get(round.round)?.
|
|
683
|
+
resolved: scores.get(round.round)?.passed ?? null,
|
|
679
684
|
note: round.note ?? null
|
|
680
685
|
}))
|
|
681
686
|
})
|
|
@@ -723,23 +728,23 @@ async function prepareBenchmarks(benchmarks, resolve, opts) {
|
|
|
723
728
|
for (const benchmark of benchmarks) {
|
|
724
729
|
const adapter = resolve(benchmark);
|
|
725
730
|
try {
|
|
726
|
-
await adapter.preflight();
|
|
727
|
-
const tasks = await adapter.
|
|
731
|
+
await adapter.runtime.preflight?.();
|
|
732
|
+
const tasks = await adapter.loadAll({
|
|
728
733
|
...opts.n !== void 0 ? { limit: opts.n } : {},
|
|
729
734
|
...opts.ids ? { ids: opts.ids } : {},
|
|
730
|
-
...opts.
|
|
735
|
+
...opts.subset ? { subset: opts.subset } : {}
|
|
731
736
|
});
|
|
732
737
|
if (tasks.length === 0) {
|
|
733
738
|
unavailable.push({
|
|
734
739
|
benchmark,
|
|
735
|
-
reason: "
|
|
740
|
+
reason: "loadAll returned no tasks"
|
|
736
741
|
});
|
|
737
742
|
continue;
|
|
738
743
|
}
|
|
739
744
|
if (opts.verifyJudge !== false) {
|
|
740
|
-
const gold = await adapter.goldArtifact(tasks[0]);
|
|
745
|
+
const gold = await adapter.runtime.goldArtifact?.(tasks[0]);
|
|
741
746
|
if (gold !== void 0) {
|
|
742
|
-
if (!(await adapter.
|
|
747
|
+
if (!(await adapter.evaluate(tasks[0], gold)).passed) {
|
|
743
748
|
unavailable.push({
|
|
744
749
|
benchmark,
|
|
745
750
|
reason: `judge rejected its own gold on ${tasks[0].id} — judge is miscalibrated`
|
|
@@ -806,13 +811,13 @@ async function runBenchmarks(opts) {
|
|
|
806
811
|
};
|
|
807
812
|
invoked = true;
|
|
808
813
|
out = loopAttempts > 1 ? await loopedShot(shotInput, shot, loopAttempts) : await shot(shotInput);
|
|
809
|
-
const score = await job.adapter.
|
|
814
|
+
const score = await job.adapter.evaluate(job.task, out.artifact);
|
|
810
815
|
result = {
|
|
811
816
|
benchmark: job.benchmark,
|
|
812
817
|
cell: job.cell.label,
|
|
813
818
|
taskId: job.task.id,
|
|
814
819
|
rep: job.rep,
|
|
815
|
-
resolved: out.ok && score.
|
|
820
|
+
resolved: out.ok && score.passed === true,
|
|
816
821
|
score: out.ok ? score.score : 0,
|
|
817
822
|
ok: out.ok,
|
|
818
823
|
execution: out.execution ?? {
|
|
@@ -820,7 +825,7 @@ async function runBenchmarks(opts) {
|
|
|
820
825
|
terminalOutcome: out.ok ? "succeeded" : "unknown"
|
|
821
826
|
},
|
|
822
827
|
measurement: out.artifactAvailable ?? out.ok ? "available" : "unavailable",
|
|
823
|
-
...out.detail ?? score.
|
|
828
|
+
...out.detail ?? score.notes ? { detail: combineDetails(out.detail, score.notes) } : {},
|
|
824
829
|
wallMs: Date.now() - startedAt,
|
|
825
830
|
artifact: out.artifact,
|
|
826
831
|
...out.usage === void 0 ? {} : { usage: out.usage },
|
|
@@ -1160,6 +1165,53 @@ function protectedEnvironment(prepared, request) {
|
|
|
1160
1165
|
for (const name of Object.keys(prepared.launch.env)) if (!(name in request.launch.env)) throw new Error(`executor request omitted signed public environment ${name}`);
|
|
1161
1166
|
return Object.freeze(Object.fromEntries(protectedEntries));
|
|
1162
1167
|
}
|
|
1168
|
+
async function stageKnowledge(directory, prepared, request) {
|
|
1169
|
+
const knowledge = request.knowledge;
|
|
1170
|
+
const declared = prepared.bundle.knowledge;
|
|
1171
|
+
if (!knowledge && !declared) return [];
|
|
1172
|
+
if (!knowledge || !declared || knowledge.snapshot.digest !== declared.snapshot.digest) throw new Error("Pier knowledge input differs from the prepared bundle");
|
|
1173
|
+
const { digest: bundleDigest, ...material } = prepared.bundle;
|
|
1174
|
+
const bundleBytes = Buffer.from(canonicalJson(material), "utf8");
|
|
1175
|
+
if (sha256$1(bundleBytes) !== bundleDigest) throw new Error("Pier bundle bytes do not match their sealed digest");
|
|
1176
|
+
const bundlePath = join(directory, "knowledge-bundle.json");
|
|
1177
|
+
const knowledgeDir = join(directory, "knowledge");
|
|
1178
|
+
const files = knowledge.files.map((file) => ({
|
|
1179
|
+
...file,
|
|
1180
|
+
path: `files/${file.path}`
|
|
1181
|
+
}));
|
|
1182
|
+
const expected = declared.snapshot.material.files.map((file) => ({
|
|
1183
|
+
...file,
|
|
1184
|
+
path: `files/${file.path}`
|
|
1185
|
+
}));
|
|
1186
|
+
if (declared.retrievalConfig && knowledge.retrievalConfig) {
|
|
1187
|
+
files.push({
|
|
1188
|
+
path: "retrieval.json",
|
|
1189
|
+
mode: 420,
|
|
1190
|
+
bytes: knowledge.retrievalConfig
|
|
1191
|
+
});
|
|
1192
|
+
expected.push({
|
|
1193
|
+
path: "retrieval.json",
|
|
1194
|
+
mode: 420,
|
|
1195
|
+
sha256: declared.retrievalConfig.sha256,
|
|
1196
|
+
byteLength: declared.retrievalConfig.byteLength
|
|
1197
|
+
});
|
|
1198
|
+
} else if (declared.retrievalConfig || knowledge.retrievalConfig) throw new Error("Pier retrieval configuration differs from the prepared bundle");
|
|
1199
|
+
await materializeExecutorFiles(knowledgeDir, files, expected, "knowledge executor input");
|
|
1200
|
+
await writeFile(bundlePath, bundleBytes, {
|
|
1201
|
+
mode: 384,
|
|
1202
|
+
flag: "wx"
|
|
1203
|
+
});
|
|
1204
|
+
await mkdir(join(knowledgeDir, "files"), {
|
|
1205
|
+
mode: 448,
|
|
1206
|
+
recursive: true
|
|
1207
|
+
});
|
|
1208
|
+
return [
|
|
1209
|
+
"--agent-kwarg",
|
|
1210
|
+
`knowledge_bundle_path=${bundlePath}`,
|
|
1211
|
+
"--agent-kwarg",
|
|
1212
|
+
`knowledge_dir=${knowledgeDir}`
|
|
1213
|
+
];
|
|
1214
|
+
}
|
|
1163
1215
|
/**
|
|
1164
1216
|
* Persist the runtime's exact canonical bytes and return only Pier transport
|
|
1165
1217
|
* arguments. No benchmark-specific plan or candidate-authored telemetry exists.
|
|
@@ -1223,6 +1275,7 @@ async function stagePreparedPierCandidateExecution(options, request) {
|
|
|
1223
1275
|
`pier_version=${options.pierVersion}`
|
|
1224
1276
|
];
|
|
1225
1277
|
if (candidateDirectory !== void 0) agentArgs.push("--agent-kwarg", `candidate_dir=${candidateDirectory}`);
|
|
1278
|
+
agentArgs.push(...await stageKnowledge(directory, prepared, request));
|
|
1226
1279
|
return {
|
|
1227
1280
|
executionId: request.executionId,
|
|
1228
1281
|
directory,
|
|
@@ -1256,7 +1309,7 @@ function protectedCaptureFromPierResult(request, value) {
|
|
|
1256
1309
|
const metadata = record(record(result.agent_result, "Pier agent_result").metadata, "Pier agent_result.metadata");
|
|
1257
1310
|
const expected = {
|
|
1258
1311
|
executionId: request.executionId,
|
|
1259
|
-
bundleDigest: request.
|
|
1312
|
+
bundleDigest: request.materializationReceipt.value.bundleDigest,
|
|
1260
1313
|
executionPlanDigest: request.executionPlan.value.digest,
|
|
1261
1314
|
materializationReceiptDigest: request.materializationReceipt.digest
|
|
1262
1315
|
};
|
|
@@ -1341,99 +1394,101 @@ async function awaitAbortableTrial(trial, signal) {
|
|
|
1341
1394
|
});
|
|
1342
1395
|
});
|
|
1343
1396
|
}
|
|
1344
|
-
/**
|
|
1345
|
-
|
|
1397
|
+
/** Bind Pier and its separate verifier to Runtime's prepared experiment cell. */
|
|
1398
|
+
function createPierCandidateExecutionOptions(options) {
|
|
1346
1399
|
const trials = /* @__PURE__ */ new Map();
|
|
1347
1400
|
const officialResults = /* @__PURE__ */ new Map();
|
|
1348
1401
|
const trialIdentity = (executionId, executionPlanDigest) => JSON.stringify([executionId, executionPlanDigest]);
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
context
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1402
|
+
return {
|
|
1403
|
+
executor: {
|
|
1404
|
+
execute: async (request, context) => {
|
|
1405
|
+
context.signal.throwIfAborted();
|
|
1406
|
+
if (request.executionId !== options.prepared.executionId || request.materializationReceipt.digest !== options.prepared.materializationReceipt.digest) throw new Error("Pier executor received a different prepared candidate");
|
|
1407
|
+
const staged = await stagePreparedPierCandidateExecution(options, request);
|
|
1408
|
+
context.signal.throwIfAborted();
|
|
1409
|
+
const identity = trialIdentity(request.executionId, request.executionPlan.value.digest);
|
|
1410
|
+
if (trials.has(identity)) throw new Error("Pier trial identity is already active");
|
|
1411
|
+
const trial = options.controller.start(staged, {
|
|
1412
|
+
request,
|
|
1413
|
+
traceStore: context.traceStore,
|
|
1414
|
+
signal: context.signal,
|
|
1415
|
+
deadlineAtMs: context.deadlineAtMs
|
|
1416
|
+
});
|
|
1417
|
+
if (trial.identity.executionId !== request.executionId || trial.identity.executionPlanDigest !== request.executionPlan.value.digest) {
|
|
1418
|
+
assertTerminationAcknowledged(await trial.terminateAndWait());
|
|
1419
|
+
throw new Error("Pier controller returned a different durable trial identity");
|
|
1420
|
+
}
|
|
1421
|
+
const active = { handle: trial };
|
|
1422
|
+
trials.set(identity, active);
|
|
1423
|
+
const result = sealPierTrialResult(await awaitAbortableTrial(trial, context.signal));
|
|
1424
|
+
active.result = result;
|
|
1425
|
+
officialResults.set(request.executionId, result);
|
|
1426
|
+
return protectedCaptureFromPierResult(request, result.value);
|
|
1427
|
+
},
|
|
1428
|
+
stop: async (request) => {
|
|
1429
|
+
assertTerminationAcknowledged(await options.controller.terminateAndWait({
|
|
1430
|
+
executionId: request.executionId,
|
|
1431
|
+
executionPlanDigest: request.executionPlanDigest
|
|
1432
|
+
}));
|
|
1433
|
+
return { stopped: true };
|
|
1434
|
+
},
|
|
1435
|
+
capture: async (request) => {
|
|
1436
|
+
const identity = trialIdentity(request.executionId, request.executionPlanDigest);
|
|
1437
|
+
const active = trials.get(identity);
|
|
1438
|
+
let result = active?.result;
|
|
1439
|
+
if (!result && active) try {
|
|
1440
|
+
result = sealPierTrialResult(await active.handle.result);
|
|
1441
|
+
} catch {
|
|
1442
|
+
result = void 0;
|
|
1443
|
+
}
|
|
1444
|
+
if (!result) {
|
|
1445
|
+
const recovered = await options.controller.captureResult(request);
|
|
1446
|
+
result = recovered ? sealPierTrialResult(recovered) : void 0;
|
|
1447
|
+
}
|
|
1448
|
+
if (!result) return {};
|
|
1449
|
+
officialResults.set(request.executionId, result);
|
|
1450
|
+
const task = options.prepared.benchmark.task;
|
|
1451
|
+
if (task.outcome.kind !== "workspace") throw new Error("Pier candidate execution requires a workspace task outcome");
|
|
1452
|
+
const repository = task.repository;
|
|
1453
|
+
if (!repository) throw new Error("Pier workspace task is missing repository identity");
|
|
1454
|
+
const taskOutcome = await capturePierTaskOutcome({
|
|
1455
|
+
repositoryRoot: options.prepared.roots.staging.taskRoot,
|
|
1456
|
+
baseCommit: repository.baseCommit,
|
|
1457
|
+
baseTree: repository.baseTree,
|
|
1458
|
+
patch: result.taskPatch
|
|
1459
|
+
});
|
|
1460
|
+
trials.delete(identity);
|
|
1461
|
+
return { taskOutcome };
|
|
1365
1462
|
}
|
|
1366
|
-
const active = { handle: trial };
|
|
1367
|
-
trials.set(identity, active);
|
|
1368
|
-
const result = sealPierTrialResult(await awaitAbortableTrial(trial, context.signal));
|
|
1369
|
-
active.result = result;
|
|
1370
|
-
officialResults.set(request.executionId, result);
|
|
1371
|
-
return protectedCaptureFromPierResult(request, result.value);
|
|
1372
1463
|
},
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
const recovered = await options.controller.captureResult(request);
|
|
1391
|
-
result = recovered ? sealPierTrialResult(recovered) : void 0;
|
|
1392
|
-
}
|
|
1393
|
-
if (!result) return {};
|
|
1394
|
-
officialResults.set(request.executionId, result);
|
|
1395
|
-
const task = options.prepared.benchmark.task;
|
|
1396
|
-
if (task.outcome.kind !== "workspace") throw new Error("Pier candidate execution requires a workspace task outcome");
|
|
1397
|
-
const repository = task.repository;
|
|
1398
|
-
if (!repository) throw new Error("Pier workspace task is missing repository identity");
|
|
1399
|
-
const taskOutcome = await capturePierTaskOutcome({
|
|
1400
|
-
repositoryRoot: options.prepared.roots.staging.taskRoot,
|
|
1401
|
-
baseCommit: repository.baseCommit,
|
|
1402
|
-
baseTree: repository.baseTree,
|
|
1403
|
-
patch: result.taskPatch
|
|
1404
|
-
});
|
|
1405
|
-
trials.delete(identity);
|
|
1406
|
-
return { taskOutcome };
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
const grader = {
|
|
1410
|
-
name: options.grader.name,
|
|
1411
|
-
version: options.grader.version,
|
|
1412
|
-
artifact: options.grader.artifact,
|
|
1413
|
-
run: async (input) => {
|
|
1414
|
-
const official = officialResults.get(input.executionId);
|
|
1415
|
-
if (!official) throw new Error("Pier official result is missing for executable grading");
|
|
1416
|
-
return await options.grader.run({
|
|
1417
|
-
...input,
|
|
1418
|
-
officialResult: {
|
|
1419
|
-
value: parseExactJson(official.resultBytes, "Pier result.json"),
|
|
1420
|
-
bytes: Uint8Array.from(official.resultBytes)
|
|
1464
|
+
grader: {
|
|
1465
|
+
name: options.grader.name,
|
|
1466
|
+
version: options.grader.version,
|
|
1467
|
+
artifact: options.grader.artifact,
|
|
1468
|
+
run: async (input) => {
|
|
1469
|
+
const official = officialResults.get(input.executionId);
|
|
1470
|
+
if (!official) throw new Error("Pier official result is missing for executable grading");
|
|
1471
|
+
try {
|
|
1472
|
+
return await options.grader.run({
|
|
1473
|
+
...input,
|
|
1474
|
+
officialResult: {
|
|
1475
|
+
value: parseExactJson(official.resultBytes, "Pier result.json"),
|
|
1476
|
+
bytes: Uint8Array.from(official.resultBytes)
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
} finally {
|
|
1480
|
+
officialResults.delete(input.executionId);
|
|
1421
1481
|
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
outputArtifacts: options.outputArtifacts,
|
|
1485
|
+
traceStore: options.traceStore,
|
|
1486
|
+
claimStore: options.claimStore
|
|
1424
1487
|
};
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
outputArtifacts: options.outputArtifacts,
|
|
1430
|
-
traceStore: options.traceStore,
|
|
1431
|
-
claimStore: options.claimStore
|
|
1432
|
-
});
|
|
1433
|
-
} finally {
|
|
1434
|
-
officialResults.clear();
|
|
1435
|
-
trials.clear();
|
|
1436
|
-
}
|
|
1488
|
+
}
|
|
1489
|
+
/** Execute and finalize through the runtime's only gradable candidate path. */
|
|
1490
|
+
async function executePreparedPierCandidate(options) {
|
|
1491
|
+
return await executePreparedAgentCandidate(options.prepared, createPierCandidateExecutionOptions(options));
|
|
1437
1492
|
}
|
|
1438
1493
|
// src/pier-trial-controller.ts
|
|
1439
1494
|
/** Restart-safe evaluator ownership for one Pier process and its Docker projects. */
|
|
@@ -1442,6 +1497,104 @@ const terminalFile = "terminal.json";
|
|
|
1442
1497
|
const stopFile = "stop-requested";
|
|
1443
1498
|
const sha256Pattern = /^sha256:[a-f0-9]{64}$/;
|
|
1444
1499
|
const defaultDockerConnectionId = "local-default";
|
|
1500
|
+
/** Run one approved Pier task and reopen its official result through the durable controller. */
|
|
1501
|
+
function createPierTaskTrialController(options) {
|
|
1502
|
+
const jobsDirectory = absolutePath(options.jobsDirectory, "Pier jobs directory");
|
|
1503
|
+
const { maxEvidenceBytes } = options;
|
|
1504
|
+
if (!Number.isSafeInteger(maxEvidenceBytes) || maxEvidenceBytes < 1) throw new Error("Pier evidence limit must be a positive safe integer");
|
|
1505
|
+
const tasks = /* @__PURE__ */ new Map();
|
|
1506
|
+
for (const { taskDigest, directory } of options.tasks) {
|
|
1507
|
+
if (!sha256Pattern.test(taskDigest) || tasks.has(taskDigest)) throw new Error("Pier task directories require distinct approved SHA-256 task digests");
|
|
1508
|
+
tasks.set(taskDigest, absolutePath(directory, "Pier task directory"));
|
|
1509
|
+
}
|
|
1510
|
+
const { prefix = [], env, ...command } = options.command;
|
|
1511
|
+
const argumentsPrefix = [...prefix];
|
|
1512
|
+
const environment = { ...env };
|
|
1513
|
+
const readResult = async ({ jobsDirectory, jobName }) => readOfficialTrial(join(jobsDirectory, jobName), maxEvidenceBytes);
|
|
1514
|
+
return new FilePierCandidateTrialController({
|
|
1515
|
+
directory: options.directory,
|
|
1516
|
+
dockerConnection: options.dockerConnection,
|
|
1517
|
+
readResult,
|
|
1518
|
+
launch(staged, { request }) {
|
|
1519
|
+
const task = tasks.get(request.benchmark.task.digest);
|
|
1520
|
+
if (!task) throw new Error("Pier has no directory for this approved task");
|
|
1521
|
+
assertRealDirectory(task, "Pier task directory");
|
|
1522
|
+
const jobName = `candidate-${trialKey({
|
|
1523
|
+
executionId: request.executionId,
|
|
1524
|
+
executionPlanDigest: request.executionPlan.value.digest
|
|
1525
|
+
})}`;
|
|
1526
|
+
return {
|
|
1527
|
+
...command,
|
|
1528
|
+
args: [
|
|
1529
|
+
...argumentsPrefix,
|
|
1530
|
+
"run",
|
|
1531
|
+
"--path",
|
|
1532
|
+
task,
|
|
1533
|
+
...staged.agentArgs,
|
|
1534
|
+
...staged.attemptArgs,
|
|
1535
|
+
...Object.keys(staged.evaluatorEnv).flatMap((name) => ["--agent-env", `${name}=\${${name}}`]),
|
|
1536
|
+
"--env",
|
|
1537
|
+
"docker",
|
|
1538
|
+
"--job-name",
|
|
1539
|
+
jobName,
|
|
1540
|
+
"--jobs-dir",
|
|
1541
|
+
jobsDirectory,
|
|
1542
|
+
"--n-concurrent",
|
|
1543
|
+
"1",
|
|
1544
|
+
"--quiet"
|
|
1545
|
+
],
|
|
1546
|
+
env: {
|
|
1547
|
+
...environment,
|
|
1548
|
+
...staged.evaluatorEnv
|
|
1549
|
+
},
|
|
1550
|
+
jobsDirectory,
|
|
1551
|
+
jobName,
|
|
1552
|
+
readResult: async () => {
|
|
1553
|
+
const result = await readResult({
|
|
1554
|
+
jobsDirectory,
|
|
1555
|
+
jobName
|
|
1556
|
+
});
|
|
1557
|
+
if (!result) throw new Error("Pier emitted no official trial result");
|
|
1558
|
+
return result;
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
function readOfficialTrial(directory, maxEvidenceBytes) {
|
|
1565
|
+
if (!existsSync(directory)) return void 0;
|
|
1566
|
+
assertRealDirectory(directory, "Pier job directory");
|
|
1567
|
+
let result;
|
|
1568
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
1569
|
+
if (!entry.isDirectory()) continue;
|
|
1570
|
+
const trial = join(directory, entry.name);
|
|
1571
|
+
const resultPath = join(trial, "result.json");
|
|
1572
|
+
if (!existsSync(resultPath)) continue;
|
|
1573
|
+
const resultBytes = readOfficialTrialFile(resultPath, maxEvidenceBytes);
|
|
1574
|
+
const value = JSON.parse(resultBytes.toString("utf8"));
|
|
1575
|
+
if (value === null || typeof value !== "object" || !("trial_name" in value) || typeof value.trial_name !== "string") throw new Error("Pier emitted a malformed official trial result");
|
|
1576
|
+
if (result) throw new Error("Expected one official result for the approved Pier task");
|
|
1577
|
+
const artifacts = join(trial, "artifacts");
|
|
1578
|
+
assertRealDirectory(artifacts, "Pier trial artifacts directory");
|
|
1579
|
+
result = {
|
|
1580
|
+
value,
|
|
1581
|
+
resultBytes,
|
|
1582
|
+
taskPatch: readOfficialTrialFile(join(artifacts, "model.patch"), maxEvidenceBytes)
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
return result;
|
|
1586
|
+
}
|
|
1587
|
+
function readOfficialTrialFile(path, maxEvidenceBytes) {
|
|
1588
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1589
|
+
try {
|
|
1590
|
+
const evidence = fstatSync(fd);
|
|
1591
|
+
if (!evidence.isFile()) throw new Error("Pier trial evidence must be a regular file");
|
|
1592
|
+
if (evidence.size > maxEvidenceBytes) throw new Error("Pier trial evidence exceeds its configured limit");
|
|
1593
|
+
return readFileSync(fd);
|
|
1594
|
+
} finally {
|
|
1595
|
+
closeSync(fd);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1445
1598
|
function nonEmpty(value, label) {
|
|
1446
1599
|
if (!value || value.includes("\0")) throw new Error(`${label} must be non-empty without NUL`);
|
|
1447
1600
|
return value;
|
|
@@ -2043,6 +2196,6 @@ async function runNode(script, input, signal) {
|
|
|
2043
2196
|
child.stdin.end(input);
|
|
2044
2197
|
});
|
|
2045
2198
|
}
|
|
2046
|
-
export { ADAPTERS, FINAL_ANSWER_SENTINEL, FilePierCandidateTrialController, StagedJudgeError,
|
|
2199
|
+
export { ADAPTERS, FINAL_ANSWER_SENTINEL, FilePierCandidateTrialController, StagedJudgeError, answerScoreToEvaluation, contextBlock, contextsFrom, createCragAdapter, createNoMiraclAdapter, createOpenRagBenchAdapter, createPierCandidateExecutionOptions, createPierCandidateRecoveryExecutor, createPierResultGrader, createPierTaskTrialController, createRagBenchAdapter, createSweBenchAdapter, createT2RagBenchAdapter, executePreparedPierCandidate, normalizeAnswer, parseCitations, parseFinalAnswer, printBenchmarksReport, ragAnswerOutput, resolveAdapter, runBenchmarks, runStagedJudge, runtimeBenchmark, scoreAnswerArtifact, scoreSweReport, sweEvaluationArgv, swePatchOutput, tokenF1 };
|
|
2047
2200
|
|
|
2048
2201
|
//# sourceMappingURL=index.js.map
|