@tangle-network/agent-bench 5.0.0 → 7.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 +17 -0
- package/HARNESS.md +6 -0
- package/README.md +10 -0
- package/dist/index.d.ts +23 -1
- package/dist/index.js +91 -5
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/pier_agents/candidate_contract.py +42 -14
- package/pier_agents/graph_driver.mjs +244 -0
- package/pier_agents/graph_process.py +344 -0
- package/pier_agents/tangle_candidate.py +120 -16
- package/scripts/verify-packed-consumer.mjs +6 -0
- package/src/pier-agent.test.mts +6 -0
- package/src/pier-agent.ts +60 -2
- package/src/pier-trial-controller.ts +95 -2
- package/src/swe-self-improve.mts +23 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
Bench uses Runtime 15's protected candidate-execution types. Install Runtime
|
|
6
|
+
15 when using both packages in the same evaluator.
|
|
7
|
+
|
|
8
|
+
Stock Pier binds each captured graph leaf to the Runtime assignment and graph
|
|
9
|
+
route that actually executed it.
|
|
10
|
+
|
|
11
|
+
## 6.0.0
|
|
12
|
+
|
|
13
|
+
Bench uses Runtime 14's protected candidate-execution types. Consumers that
|
|
14
|
+
install Runtime alongside Bench should use Runtime 14 with this release.
|
|
15
|
+
|
|
16
|
+
Stock Pier executes sealed graph commands and binds the exact captured patch
|
|
17
|
+
to the evaluator's graph receipt. Declared check files remain available after
|
|
18
|
+
the sandbox closes. A graph that stops without a delivery stays unscored.
|
|
19
|
+
|
|
3
20
|
## 5.0.0
|
|
4
21
|
|
|
5
22
|
Bench's public candidate-execution types now use Runtime 12. When installing
|
package/HARNESS.md
CHANGED
|
@@ -117,9 +117,15 @@ They establish no live learning gain or provider session restoration.
|
|
|
117
117
|
|
|
118
118
|
```bash
|
|
119
119
|
cd bench
|
|
120
|
+
export FINAL_EVIDENCE_LEDGER=/path/to/shared/final-evidence.jsonl
|
|
121
|
+
export FINAL_EVIDENCE_REQUEST_ID=swe-comparison-01
|
|
120
122
|
pnpm tsx src/swe-self-improve.mts
|
|
121
123
|
```
|
|
122
124
|
|
|
125
|
+
Keep the same ledger, request ID and output directory on resume. For a historical unbound run,
|
|
126
|
+
leave both evidence variables unset and use its original output directory. Calibration does not
|
|
127
|
+
open a sealed search.
|
|
128
|
+
|
|
123
129
|
This fixture uses `runStrategyEvolution` with SWE-bench tasks split into train, selection and sealed test slices.
|
|
124
130
|
It does not exercise `improve`.
|
|
125
131
|
It keeps its run directory, whose search ledger is the checkpoint and the lineage record of one search.
|
package/README.md
CHANGED
|
@@ -124,6 +124,16 @@ An experiment can execute a code workspace, a materialized profile, and a measur
|
|
|
124
124
|
Pier owns the task container and verifier; protected model usage and traces stay in `@tangle-network/agent-eval` and are finalized by the shared runtime.
|
|
125
125
|
`FilePierCandidateTrialController` atomically reserves a unique Pier job, then persists the supervisor PID, process-session identity, and that job's exact Docker projects so a fresh evaluator process can stop and remove an abandoned trial.
|
|
126
126
|
Use `createPierTaskTrialController` when each approved task digest already maps to an evaluator-owned Pier task directory. Give it the pinned Pier command and jobs directory. It launches exactly that task and reads the official result and patch through the same controller on completion or recovery. The evaluator still owns task staging and authorization.
|
|
127
|
+
|
|
128
|
+
For a zero-model task, set `graphDispatch: true` on `createPierTaskTrialController`. The bundled coordinator runs one command at a time in each task container under the candidate UID, so it can stop the command and its descendants before accepting evidence. Separate trials still run concurrently. Pier keeps the graph run record in its evaluator-owned trial log and captures the task patch through its usual artifact hook. A graph that ends without a deliverable retains its run record as failure evidence and skips Runtime grading.
|
|
129
|
+
|
|
130
|
+
Stock Pier copies only the files declared in a command node's `outputs` after its candidate processes have stopped. Runtime checks their size and retains them in the trial's artifact store, including when the command fails. An unchanged, missing or unsafe file makes that check incomplete.
|
|
131
|
+
|
|
132
|
+
Stock Pier can also run the bundle's signed command as the admitted profile leaf. Set `graphLeafDispatch: true` with `graphDispatch: true`. The leaf takes the exact benchmark instruction, starts before other graph commands and returns one JSON object on stdout. The controller accepts one such launch per trial and retains its exit, output, profile plan and graph assignment in the executor receipt. Subsequent verification still uses the official captured task patch.
|
|
133
|
+
|
|
134
|
+
A model-backed leaf needs a zero-cost grant from the evaluator's existing model port and a task container confined to the signed gateway domain. Its graph allocation must cover the entire trial grant. Runtime keeps the leaf's actual token and cost counts unknown until the trial owner closes and checks the authoritative model settlement.
|
|
135
|
+
|
|
136
|
+
Custom evaluators can use `FilePierCandidateTrialController` with a graph-aware launcher and durable result reader. The launcher receives `staged.graphInvocationPath` from Runtime's signed plan and calls `runProtectedCandidateGraph` with its isolated command and agent executors. The durable reader returns the graph registry record and the digest of the evaluator-captured task patch.
|
|
127
137
|
Run `PIER_REPO=/path/to/pier pnpm verify:pier` for the zero-model failure/pass and fresh-process recovery proof, and see `HARNESS.md` for the exact invocation and failure contract.
|
|
128
138
|
From an installed npm package, expose the shipped Python module with `export PYTHONPATH="$(npm root)/@tangle-network/agent-bench${PYTHONPATH:+:$PYTHONPATH}"` before invoking Pier.
|
|
129
139
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { BenchEvaluation, BenchPayload, BenchRuntime, BenchTask, JudgeArtifactFi
|
|
|
11
11
|
import { AgentProfile, SandboxClient, SandboxRun, TurnResult, sumSandboxUsage } from "@tangle-network/agent-runtime/kernel";
|
|
12
12
|
import { RunTerminalOutcome, TraceStore } from "@tangle-network/agent-eval";
|
|
13
13
|
import { SandboxEvent } from "@tangle-network/sandbox";
|
|
14
|
-
import { AgentCandidateBenchmarkGraderPort, AgentCandidateExecutionClaimStore, AgentCandidateExecutionFormat, AgentCandidateExecutorPort, AgentCandidateExecutorRequest, AgentCandidateExecutorStopRequest, AgentCandidateOutputArtifactPort, AgentCandidateRunFinalization, ExecutePreparedAgentCandidateOptions, PreparedAgentCandidateExecution } from "@tangle-network/agent-runtime/candidate-execution";
|
|
14
|
+
import { AgentCandidateBenchmarkGraderPort, AgentCandidateExecutionClaimStore, AgentCandidateExecutionFormat, AgentCandidateExecutorFinalCapture, AgentCandidateExecutorPort, AgentCandidateExecutorRequest, AgentCandidateExecutorStopRequest, AgentCandidateOutputArtifactPort, AgentCandidateRunFinalization, ExecutePreparedAgentCandidateOptions, PreparedAgentCandidateExecution } from "@tangle-network/agent-runtime/candidate-execution";
|
|
15
15
|
interface ResolveBenchClientOptions {
|
|
16
16
|
/** The selector (the `BACKEND` env value): `router` = off-box; anything else = in-box Sandbox. */
|
|
17
17
|
backend: string;
|
|
@@ -212,6 +212,8 @@ interface StagedPierCandidateExecution {
|
|
|
212
212
|
readonly profileDirectory: string;
|
|
213
213
|
readonly planPath: string;
|
|
214
214
|
readonly receiptPath: string;
|
|
215
|
+
/** Evaluator-owned copy of the exact graph invocation when the controller supports it. */
|
|
216
|
+
readonly graphInvocationPath?: string;
|
|
215
217
|
readonly agentArgs: readonly string[];
|
|
216
218
|
/** Executor-only model and trace bindings; never present on the prepared object or disk. */
|
|
217
219
|
readonly evaluatorEnv: Readonly<Record<string, string>>;
|
|
@@ -238,6 +240,10 @@ type PierCandidateTrialIdentity = Readonly<AgentCandidateExecutorStopRequest>;
|
|
|
238
240
|
* handle returned by `start`.
|
|
239
241
|
*/
|
|
240
242
|
interface PierCandidateTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'> {
|
|
243
|
+
/** This controller runs the sealed graph through the protected Pier trial. */
|
|
244
|
+
readonly graphDispatch?: true;
|
|
245
|
+
/** This controller can launch the signed profile as a leaf of the sealed graph. */
|
|
246
|
+
readonly graphLeafDispatch?: true;
|
|
241
247
|
start(staged: StagedPierCandidateExecution, context: {
|
|
242
248
|
readonly request: AgentCandidateExecutorRequest<Format>;
|
|
243
249
|
readonly traceStore: TraceStore;
|
|
@@ -256,6 +262,12 @@ interface PierCandidateTrialResult {
|
|
|
256
262
|
readonly resultBytes: Uint8Array;
|
|
257
263
|
/** Exact `/logs/artifacts/model.patch` bytes emitted before official tests. */
|
|
258
264
|
readonly taskPatch: Uint8Array;
|
|
265
|
+
/** Retained evaluator graph record. Agent metadata and stdout cannot supply this field. */
|
|
266
|
+
readonly graphExecution?: AgentCandidateExecutorFinalCapture['graphExecution'];
|
|
267
|
+
/** The trusted coordinator reached a graph deliverable that may be independently graded. */
|
|
268
|
+
readonly graphDelivered?: boolean;
|
|
269
|
+
/** Evaluator-side observation of the signed native graph leaf. */
|
|
270
|
+
readonly nativeEvidence?: Uint8Array;
|
|
259
271
|
}
|
|
260
272
|
interface PierCandidateOfficialResult {
|
|
261
273
|
readonly value: unknown;
|
|
@@ -313,6 +325,10 @@ interface PierDockerConnection {
|
|
|
313
325
|
interface FilePierCandidateTrialControllerOptions<Format extends AgentCandidateExecutionFormat = 'experiment'> {
|
|
314
326
|
/** Shared evaluator-owned control root, available to crash-recovery workers. */
|
|
315
327
|
readonly directory: string;
|
|
328
|
+
/** Both the registered launch and durable result reader handle sealed graph dispatch. */
|
|
329
|
+
readonly graphDispatch?: true;
|
|
330
|
+
/** Registered graph dispatch can start the signed profile as a leaf. */
|
|
331
|
+
readonly graphLeafDispatch?: true;
|
|
316
332
|
readonly launch?: (staged: StagedPierCandidateExecution, context: {
|
|
317
333
|
readonly request: AgentCandidateExecutorRequest<Format>;
|
|
318
334
|
readonly traceStore: TraceStore;
|
|
@@ -344,10 +360,16 @@ interface CreatePierTaskTrialControllerOptions {
|
|
|
344
360
|
readonly prefix?: readonly string[];
|
|
345
361
|
};
|
|
346
362
|
readonly dockerConnection?: PierDockerConnection;
|
|
363
|
+
/** Allow the bundled graph coordinator for approved tasks. */
|
|
364
|
+
readonly graphDispatch?: true;
|
|
365
|
+
/** Allow the signed process launch to run once as the admitted graph leaf. */
|
|
366
|
+
readonly graphLeafDispatch?: true;
|
|
347
367
|
}
|
|
348
368
|
/** Run one approved Pier task and reopen its official result through the durable controller. */
|
|
349
369
|
export declare function createPierTaskTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'>(options: CreatePierTaskTrialControllerOptions): FilePierCandidateTrialController<Format>;
|
|
350
370
|
export declare class FilePierCandidateTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'> implements PierCandidateTrialController<Format> {
|
|
371
|
+
readonly graphDispatch?: true;
|
|
372
|
+
readonly graphLeafDispatch?: true;
|
|
351
373
|
private readonly directory;
|
|
352
374
|
private readonly launch?;
|
|
353
375
|
private readonly readResult?;
|
package/dist/index.js
CHANGED
|
@@ -1217,8 +1217,10 @@ async function stageKnowledge(directory, prepared, request) {
|
|
|
1217
1217
|
* arguments. No benchmark-specific plan or candidate-authored telemetry exists.
|
|
1218
1218
|
*/
|
|
1219
1219
|
/** @internal Package-private transport seam exercised by adapter tests. */
|
|
1220
|
-
async function stagePreparedPierCandidateExecution(options, request) {
|
|
1220
|
+
async function stagePreparedPierCandidateExecution(options, request, graphDispatch) {
|
|
1221
1221
|
const { prepared } = options;
|
|
1222
|
+
const graph = request.executionPlan.value.material.launch.graph;
|
|
1223
|
+
if (graph && graphDispatch !== true) throw new Error("this Pier process adapter cannot execute a sealed graph invocation");
|
|
1222
1224
|
nonEmpty$1(options.pierVersion, "pierVersion");
|
|
1223
1225
|
const directory = absoluteHostPath(options.directory, "directory");
|
|
1224
1226
|
await mkdir(directory, { mode: 448 });
|
|
@@ -1247,6 +1249,7 @@ async function stagePreparedPierCandidateExecution(options, request) {
|
|
|
1247
1249
|
assert.deepEqual(parseExactJson(request.materializationReceipt.bytes, "materialization receipt"), receiptMaterial, "prepared receipt bytes differ from runtime material");
|
|
1248
1250
|
const planPath = join(directory, "execution-plan.json");
|
|
1249
1251
|
const receiptPath = join(directory, "materialization-receipt.json");
|
|
1252
|
+
const graphInvocationPath = graph ? await stageGraphInvocation(directory, graph.invocation, request.graphInvocation) : void 0;
|
|
1250
1253
|
await Promise.all([writeFile(planPath, request.executionPlan.bytes, {
|
|
1251
1254
|
mode: 384,
|
|
1252
1255
|
flag: "wx"
|
|
@@ -1284,6 +1287,7 @@ async function stagePreparedPierCandidateExecution(options, request) {
|
|
|
1284
1287
|
profileDirectory,
|
|
1285
1288
|
planPath,
|
|
1286
1289
|
receiptPath,
|
|
1290
|
+
...graphInvocationPath ? { graphInvocationPath } : {},
|
|
1287
1291
|
agentArgs,
|
|
1288
1292
|
evaluatorEnv: protectedEnvironment(prepared, request),
|
|
1289
1293
|
attemptArgs: [
|
|
@@ -1294,6 +1298,15 @@ async function stagePreparedPierCandidateExecution(options, request) {
|
|
|
1294
1298
|
]
|
|
1295
1299
|
};
|
|
1296
1300
|
}
|
|
1301
|
+
async function stageGraphInvocation(directory, artifact, bytes) {
|
|
1302
|
+
if (!bytes || bytes.byteLength !== artifact.byteLength || sha256$1(bytes) !== artifact.sha256) throw new Error("Pier graph invocation bytes differ from the sealed plan");
|
|
1303
|
+
const path = join(directory, "graph-invocation.json");
|
|
1304
|
+
await writeFile(path, bytes, {
|
|
1305
|
+
mode: 384,
|
|
1306
|
+
flag: "wx"
|
|
1307
|
+
});
|
|
1308
|
+
return path;
|
|
1309
|
+
}
|
|
1297
1310
|
function exceptionType(value) {
|
|
1298
1311
|
const info = value && typeof value === "object" ? value : void 0;
|
|
1299
1312
|
for (const key of [
|
|
@@ -1342,6 +1355,13 @@ function sealPierTrialResult(value) {
|
|
|
1342
1355
|
assert.deepEqual(parsed, value.value, "Pier parsed result differs from result.json bytes");
|
|
1343
1356
|
const resultBytes = Uint8Array.from(value.resultBytes);
|
|
1344
1357
|
const taskPatch = Uint8Array.from(value.taskPatch);
|
|
1358
|
+
const graph = value.graphExecution;
|
|
1359
|
+
if (graph && !(graph.record instanceof Uint8Array)) throw new Error("Pier graph execution requires raw evaluator record bytes");
|
|
1360
|
+
const graphExecution = graph && Object.freeze({
|
|
1361
|
+
...graph,
|
|
1362
|
+
record: Uint8Array.from(graph.record)
|
|
1363
|
+
});
|
|
1364
|
+
const nativeEvidence = value.nativeEvidence && Uint8Array.from(value.nativeEvidence);
|
|
1345
1365
|
return Object.freeze({
|
|
1346
1366
|
value: parsed,
|
|
1347
1367
|
get resultBytes() {
|
|
@@ -1349,7 +1369,10 @@ function sealPierTrialResult(value) {
|
|
|
1349
1369
|
},
|
|
1350
1370
|
get taskPatch() {
|
|
1351
1371
|
return Uint8Array.from(taskPatch);
|
|
1352
|
-
}
|
|
1372
|
+
},
|
|
1373
|
+
...graphExecution ? { graphExecution } : {},
|
|
1374
|
+
...value.graphDelivered === void 0 ? {} : { graphDelivered: value.graphDelivered },
|
|
1375
|
+
...nativeEvidence ? { nativeEvidence } : {}
|
|
1353
1376
|
});
|
|
1354
1377
|
}
|
|
1355
1378
|
function abortReason(signal) {
|
|
@@ -1401,10 +1424,11 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1401
1424
|
const trialIdentity = (executionId, executionPlanDigest) => JSON.stringify([executionId, executionPlanDigest]);
|
|
1402
1425
|
return {
|
|
1403
1426
|
executor: {
|
|
1427
|
+
...options.controller.graphDispatch ? { graphDispatch: true } : {},
|
|
1404
1428
|
execute: async (request, context) => {
|
|
1405
1429
|
context.signal.throwIfAborted();
|
|
1406
1430
|
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);
|
|
1431
|
+
const staged = await stagePreparedPierCandidateExecution(options, request, options.controller.graphDispatch);
|
|
1408
1432
|
context.signal.throwIfAborted();
|
|
1409
1433
|
const identity = trialIdentity(request.executionId, request.executionPlan.value.digest);
|
|
1410
1434
|
if (trials.has(identity)) throw new Error("Pier trial identity is already active");
|
|
@@ -1457,6 +1481,14 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1457
1481
|
result = recovered ? sealPierTrialResult(recovered) : void 0;
|
|
1458
1482
|
}
|
|
1459
1483
|
if (!result) return {};
|
|
1484
|
+
if (result.graphExecution && result.graphDelivered === false) {
|
|
1485
|
+
trials.delete(identity);
|
|
1486
|
+
officialResults.delete(request.executionId);
|
|
1487
|
+
return {
|
|
1488
|
+
graphExecution: result.graphExecution,
|
|
1489
|
+
...result.nativeEvidence ? { evidence: result.nativeEvidence } : {}
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1460
1492
|
officialResults.set(request.executionId, result);
|
|
1461
1493
|
const task = options.prepared.benchmark.task;
|
|
1462
1494
|
if (task.outcome.kind !== "workspace") throw new Error("Pier candidate execution requires a workspace task outcome");
|
|
@@ -1469,7 +1501,11 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1469
1501
|
patch: result.taskPatch
|
|
1470
1502
|
});
|
|
1471
1503
|
trials.delete(identity);
|
|
1472
|
-
return {
|
|
1504
|
+
return {
|
|
1505
|
+
taskOutcome,
|
|
1506
|
+
...result.graphExecution ? { graphExecution: result.graphExecution } : {},
|
|
1507
|
+
...result.nativeEvidence ? { evidence: result.nativeEvidence } : {}
|
|
1508
|
+
};
|
|
1473
1509
|
}
|
|
1474
1510
|
},
|
|
1475
1511
|
grader: {
|
|
@@ -1521,15 +1557,22 @@ function createPierTaskTrialController(options) {
|
|
|
1521
1557
|
const { prefix = [], env, ...command } = options.command;
|
|
1522
1558
|
const argumentsPrefix = [...prefix];
|
|
1523
1559
|
const environment = { ...env };
|
|
1560
|
+
const graphDriver = fileURLToPath(new URL("../pier_agents/graph_driver.mjs", import.meta.url));
|
|
1524
1561
|
const readResult = async ({ jobsDirectory, jobName }) => readOfficialTrial(join(jobsDirectory, jobName), maxEvidenceBytes);
|
|
1525
1562
|
return new FilePierCandidateTrialController({
|
|
1526
1563
|
directory: options.directory,
|
|
1527
1564
|
dockerConnection: options.dockerConnection,
|
|
1565
|
+
...options.graphDispatch ? { graphDispatch: true } : {},
|
|
1566
|
+
...options.graphLeafDispatch ? { graphLeafDispatch: true } : {},
|
|
1528
1567
|
readResult,
|
|
1529
1568
|
launch(staged, { request }) {
|
|
1530
1569
|
const task = tasks.get(request.benchmark.task.digest);
|
|
1531
1570
|
if (!task) throw new Error("Pier has no directory for this approved task");
|
|
1532
1571
|
assertRealDirectory(task, "Pier task directory");
|
|
1572
|
+
if (staged.graphInvocationPath && request.benchmark.task.limits.maxModelCalls !== 0) {
|
|
1573
|
+
const { limits, model } = request.executionPlan.value.material;
|
|
1574
|
+
if (!options.graphLeafDispatch || limits.maxCostUsd !== 0 || model.access.network.mode !== "gateway-only" || model.access.network.domains.length !== 1) throw new Error("A model-backed Pier graph requires an admitted profile leaf and a zero-cost gateway grant");
|
|
1575
|
+
}
|
|
1533
1576
|
const jobName = `candidate-${trialKey({
|
|
1534
1577
|
executionId: request.executionId,
|
|
1535
1578
|
executionPlanDigest: request.executionPlan.value.digest
|
|
@@ -1542,6 +1585,15 @@ function createPierTaskTrialController(options) {
|
|
|
1542
1585
|
"--path",
|
|
1543
1586
|
task,
|
|
1544
1587
|
...staged.agentArgs,
|
|
1588
|
+
...staged.graphInvocationPath ? [
|
|
1589
|
+
"--agent-kwarg",
|
|
1590
|
+
`graph_invocation_path=${staged.graphInvocationPath}`,
|
|
1591
|
+
"--agent-kwarg",
|
|
1592
|
+
`graph_node_path=${process.execPath}`,
|
|
1593
|
+
"--agent-kwarg",
|
|
1594
|
+
`graph_driver_path=${graphDriver}`,
|
|
1595
|
+
...options.graphLeafDispatch ? ["--agent-kwarg", "graph_leaf_dispatch=true"] : []
|
|
1596
|
+
] : [],
|
|
1545
1597
|
...staged.attemptArgs,
|
|
1546
1598
|
...Object.keys(staged.evaluatorEnv).flatMap((name) => ["--agent-env", `${name}=\${${name}}`]),
|
|
1547
1599
|
"--env",
|
|
@@ -1587,14 +1639,42 @@ function readOfficialTrial(directory, maxEvidenceBytes) {
|
|
|
1587
1639
|
if (result) throw new Error("Expected one official result for the approved Pier task");
|
|
1588
1640
|
const artifacts = join(trial, "artifacts");
|
|
1589
1641
|
assertRealDirectory(artifacts, "Pier trial artifacts directory");
|
|
1642
|
+
const taskPatch = readOfficialTrialFile(join(artifacts, "model.patch"), maxEvidenceBytes);
|
|
1590
1643
|
result = {
|
|
1591
1644
|
value,
|
|
1592
1645
|
resultBytes,
|
|
1593
|
-
taskPatch
|
|
1646
|
+
taskPatch,
|
|
1647
|
+
...readOfficialGraph(value, taskPatch)
|
|
1594
1648
|
};
|
|
1595
1649
|
}
|
|
1596
1650
|
return result;
|
|
1597
1651
|
}
|
|
1652
|
+
function readOfficialGraph(value, patch) {
|
|
1653
|
+
const raw = value.agent_result?.metadata?.graphExecution;
|
|
1654
|
+
if (raw === void 0) return {};
|
|
1655
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new Error("Pier emitted invalid evaluator graph evidence");
|
|
1656
|
+
const graph = raw;
|
|
1657
|
+
if (typeof graph.runId !== "string" || !graph.runId || !sha256Pattern.test(graph.graphDigest) || !sha256Pattern.test(graph.invocationDigest) || typeof graph.delivered !== "boolean" || typeof graph.record !== "string") throw new Error("Pier emitted invalid evaluator graph evidence");
|
|
1658
|
+
const record = Buffer.from(graph.record, "base64");
|
|
1659
|
+
if (!record.length || record.toString("base64") !== graph.record) throw new Error("Pier emitted invalid evaluator graph record bytes");
|
|
1660
|
+
return {
|
|
1661
|
+
graphDelivered: graph.delivered,
|
|
1662
|
+
...graph.nativeEvidence ? { nativeEvidence: Buffer.from(canonicalJson({
|
|
1663
|
+
...graph.nativeEvidence,
|
|
1664
|
+
kind: "pier-native-graph-leaf",
|
|
1665
|
+
runId: graph.runId,
|
|
1666
|
+
graphDigest: graph.graphDigest,
|
|
1667
|
+
invocationDigest: graph.invocationDigest
|
|
1668
|
+
})) } : {},
|
|
1669
|
+
graphExecution: {
|
|
1670
|
+
runId: graph.runId,
|
|
1671
|
+
graphDigest: graph.graphDigest,
|
|
1672
|
+
invocationDigest: graph.invocationDigest,
|
|
1673
|
+
taskArtifactDigest: `sha256:${createHash("sha256").update(patch).digest("hex")}`,
|
|
1674
|
+
record
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1598
1678
|
function readOfficialTrialFile(path, maxEvidenceBytes) {
|
|
1599
1679
|
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1600
1680
|
try {
|
|
@@ -1870,6 +1950,8 @@ function assertRealDirectory(path, label) {
|
|
|
1870
1950
|
if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) throw new Error(`${label} must resolve to a real directory`);
|
|
1871
1951
|
}
|
|
1872
1952
|
var FilePierCandidateTrialController = class {
|
|
1953
|
+
graphDispatch;
|
|
1954
|
+
graphLeafDispatch;
|
|
1873
1955
|
directory;
|
|
1874
1956
|
launch;
|
|
1875
1957
|
readResult;
|
|
@@ -1880,6 +1962,10 @@ var FilePierCandidateTrialController = class {
|
|
|
1880
1962
|
this.directory = absolutePath(options.directory, "Pier controller directory");
|
|
1881
1963
|
this.launch = options.launch;
|
|
1882
1964
|
this.readResult = options.readResult;
|
|
1965
|
+
if (options.graphDispatch && (!options.launch || !options.readResult)) throw new Error("Pier graph dispatch requires both launch and durable graph capture");
|
|
1966
|
+
if (options.graphLeafDispatch && !options.graphDispatch) throw new Error("A protected Pier profile leaf requires graph dispatch");
|
|
1967
|
+
this.graphDispatch = options.graphDispatch;
|
|
1968
|
+
this.graphLeafDispatch = options.graphLeafDispatch;
|
|
1883
1969
|
const configuredDocker = options.dockerConnection;
|
|
1884
1970
|
if (configuredDocker?.id === defaultDockerConnectionId) throw new Error(`${defaultDockerConnectionId} is reserved for the implicit local connection`);
|
|
1885
1971
|
const dockerConnection = configuredDocker ?? {
|