@tangle-network/agent-bench 6.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 +8 -0
- package/README.md +4 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/pier_agents/graph_driver.mjs +187 -27
- package/pier_agents/graph_process.py +59 -4
- package/pier_agents/tangle_candidate.py +103 -31
- package/src/pier-agent.ts +8 -1
- package/src/pier-trial-controller.ts +34 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 6.0.0
|
|
4
12
|
|
|
5
13
|
Bench uses Runtime 14's protected candidate-execution types. Consumers that
|
package/README.md
CHANGED
|
@@ -129,6 +129,10 @@ For a zero-model task, set `graphDispatch: true` on `createPierTaskTrialControll
|
|
|
129
129
|
|
|
130
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
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
|
+
|
|
132
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.
|
|
133
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.
|
|
134
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -242,6 +242,8 @@ type PierCandidateTrialIdentity = Readonly<AgentCandidateExecutorStopRequest>;
|
|
|
242
242
|
interface PierCandidateTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'> {
|
|
243
243
|
/** This controller runs the sealed graph through the protected Pier trial. */
|
|
244
244
|
readonly graphDispatch?: true;
|
|
245
|
+
/** This controller can launch the signed profile as a leaf of the sealed graph. */
|
|
246
|
+
readonly graphLeafDispatch?: true;
|
|
245
247
|
start(staged: StagedPierCandidateExecution, context: {
|
|
246
248
|
readonly request: AgentCandidateExecutorRequest<Format>;
|
|
247
249
|
readonly traceStore: TraceStore;
|
|
@@ -264,6 +266,8 @@ interface PierCandidateTrialResult {
|
|
|
264
266
|
readonly graphExecution?: AgentCandidateExecutorFinalCapture['graphExecution'];
|
|
265
267
|
/** The trusted coordinator reached a graph deliverable that may be independently graded. */
|
|
266
268
|
readonly graphDelivered?: boolean;
|
|
269
|
+
/** Evaluator-side observation of the signed native graph leaf. */
|
|
270
|
+
readonly nativeEvidence?: Uint8Array;
|
|
267
271
|
}
|
|
268
272
|
interface PierCandidateOfficialResult {
|
|
269
273
|
readonly value: unknown;
|
|
@@ -323,6 +327,8 @@ interface FilePierCandidateTrialControllerOptions<Format extends AgentCandidateE
|
|
|
323
327
|
readonly directory: string;
|
|
324
328
|
/** Both the registered launch and durable result reader handle sealed graph dispatch. */
|
|
325
329
|
readonly graphDispatch?: true;
|
|
330
|
+
/** Registered graph dispatch can start the signed profile as a leaf. */
|
|
331
|
+
readonly graphLeafDispatch?: true;
|
|
326
332
|
readonly launch?: (staged: StagedPierCandidateExecution, context: {
|
|
327
333
|
readonly request: AgentCandidateExecutorRequest<Format>;
|
|
328
334
|
readonly traceStore: TraceStore;
|
|
@@ -354,13 +360,16 @@ interface CreatePierTaskTrialControllerOptions {
|
|
|
354
360
|
readonly prefix?: readonly string[];
|
|
355
361
|
};
|
|
356
362
|
readonly dockerConnection?: PierDockerConnection;
|
|
357
|
-
/** Allow the bundled graph coordinator for
|
|
363
|
+
/** Allow the bundled graph coordinator for approved tasks. */
|
|
358
364
|
readonly graphDispatch?: true;
|
|
365
|
+
/** Allow the signed process launch to run once as the admitted graph leaf. */
|
|
366
|
+
readonly graphLeafDispatch?: true;
|
|
359
367
|
}
|
|
360
368
|
/** Run one approved Pier task and reopen its official result through the durable controller. */
|
|
361
369
|
export declare function createPierTaskTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'>(options: CreatePierTaskTrialControllerOptions): FilePierCandidateTrialController<Format>;
|
|
362
370
|
export declare class FilePierCandidateTrialController<Format extends AgentCandidateExecutionFormat = 'experiment'> implements PierCandidateTrialController<Format> {
|
|
363
371
|
readonly graphDispatch?: true;
|
|
372
|
+
readonly graphLeafDispatch?: true;
|
|
364
373
|
private readonly directory;
|
|
365
374
|
private readonly launch?;
|
|
366
375
|
private readonly readResult?;
|
package/dist/index.js
CHANGED
|
@@ -1361,6 +1361,7 @@ function sealPierTrialResult(value) {
|
|
|
1361
1361
|
...graph,
|
|
1362
1362
|
record: Uint8Array.from(graph.record)
|
|
1363
1363
|
});
|
|
1364
|
+
const nativeEvidence = value.nativeEvidence && Uint8Array.from(value.nativeEvidence);
|
|
1364
1365
|
return Object.freeze({
|
|
1365
1366
|
value: parsed,
|
|
1366
1367
|
get resultBytes() {
|
|
@@ -1370,7 +1371,8 @@ function sealPierTrialResult(value) {
|
|
|
1370
1371
|
return Uint8Array.from(taskPatch);
|
|
1371
1372
|
},
|
|
1372
1373
|
...graphExecution ? { graphExecution } : {},
|
|
1373
|
-
...value.graphDelivered === void 0 ? {} : { graphDelivered: value.graphDelivered }
|
|
1374
|
+
...value.graphDelivered === void 0 ? {} : { graphDelivered: value.graphDelivered },
|
|
1375
|
+
...nativeEvidence ? { nativeEvidence } : {}
|
|
1374
1376
|
});
|
|
1375
1377
|
}
|
|
1376
1378
|
function abortReason(signal) {
|
|
@@ -1482,7 +1484,10 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1482
1484
|
if (result.graphExecution && result.graphDelivered === false) {
|
|
1483
1485
|
trials.delete(identity);
|
|
1484
1486
|
officialResults.delete(request.executionId);
|
|
1485
|
-
return {
|
|
1487
|
+
return {
|
|
1488
|
+
graphExecution: result.graphExecution,
|
|
1489
|
+
...result.nativeEvidence ? { evidence: result.nativeEvidence } : {}
|
|
1490
|
+
};
|
|
1486
1491
|
}
|
|
1487
1492
|
officialResults.set(request.executionId, result);
|
|
1488
1493
|
const task = options.prepared.benchmark.task;
|
|
@@ -1498,7 +1503,8 @@ function createPierCandidateExecutionOptions(options) {
|
|
|
1498
1503
|
trials.delete(identity);
|
|
1499
1504
|
return {
|
|
1500
1505
|
taskOutcome,
|
|
1501
|
-
...result.graphExecution ? { graphExecution: result.graphExecution } : {}
|
|
1506
|
+
...result.graphExecution ? { graphExecution: result.graphExecution } : {},
|
|
1507
|
+
...result.nativeEvidence ? { evidence: result.nativeEvidence } : {}
|
|
1502
1508
|
};
|
|
1503
1509
|
}
|
|
1504
1510
|
},
|
|
@@ -1557,12 +1563,16 @@ function createPierTaskTrialController(options) {
|
|
|
1557
1563
|
directory: options.directory,
|
|
1558
1564
|
dockerConnection: options.dockerConnection,
|
|
1559
1565
|
...options.graphDispatch ? { graphDispatch: true } : {},
|
|
1566
|
+
...options.graphLeafDispatch ? { graphLeafDispatch: true } : {},
|
|
1560
1567
|
readResult,
|
|
1561
1568
|
launch(staged, { request }) {
|
|
1562
1569
|
const task = tasks.get(request.benchmark.task.digest);
|
|
1563
1570
|
if (!task) throw new Error("Pier has no directory for this approved task");
|
|
1564
1571
|
assertRealDirectory(task, "Pier task directory");
|
|
1565
|
-
if (staged.graphInvocationPath && request.benchmark.task.limits.maxModelCalls !== 0)
|
|
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
|
+
}
|
|
1566
1576
|
const jobName = `candidate-${trialKey({
|
|
1567
1577
|
executionId: request.executionId,
|
|
1568
1578
|
executionPlanDigest: request.executionPlan.value.digest
|
|
@@ -1581,7 +1591,8 @@ function createPierTaskTrialController(options) {
|
|
|
1581
1591
|
"--agent-kwarg",
|
|
1582
1592
|
`graph_node_path=${process.execPath}`,
|
|
1583
1593
|
"--agent-kwarg",
|
|
1584
|
-
`graph_driver_path=${graphDriver}
|
|
1594
|
+
`graph_driver_path=${graphDriver}`,
|
|
1595
|
+
...options.graphLeafDispatch ? ["--agent-kwarg", "graph_leaf_dispatch=true"] : []
|
|
1585
1596
|
] : [],
|
|
1586
1597
|
...staged.attemptArgs,
|
|
1587
1598
|
...Object.keys(staged.evaluatorEnv).flatMap((name) => ["--agent-env", `${name}=\${${name}}`]),
|
|
@@ -1641,12 +1652,20 @@ function readOfficialTrial(directory, maxEvidenceBytes) {
|
|
|
1641
1652
|
function readOfficialGraph(value, patch) {
|
|
1642
1653
|
const raw = value.agent_result?.metadata?.graphExecution;
|
|
1643
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");
|
|
1644
1656
|
const graph = raw;
|
|
1645
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");
|
|
1646
1658
|
const record = Buffer.from(graph.record, "base64");
|
|
1647
1659
|
if (!record.length || record.toString("base64") !== graph.record) throw new Error("Pier emitted invalid evaluator graph record bytes");
|
|
1648
1660
|
return {
|
|
1649
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
|
+
})) } : {},
|
|
1650
1669
|
graphExecution: {
|
|
1651
1670
|
runId: graph.runId,
|
|
1652
1671
|
graphDigest: graph.graphDigest,
|
|
@@ -1932,6 +1951,7 @@ function assertRealDirectory(path, label) {
|
|
|
1932
1951
|
}
|
|
1933
1952
|
var FilePierCandidateTrialController = class {
|
|
1934
1953
|
graphDispatch;
|
|
1954
|
+
graphLeafDispatch;
|
|
1935
1955
|
directory;
|
|
1936
1956
|
launch;
|
|
1937
1957
|
readResult;
|
|
@@ -1943,7 +1963,9 @@ var FilePierCandidateTrialController = class {
|
|
|
1943
1963
|
this.launch = options.launch;
|
|
1944
1964
|
this.readResult = options.readResult;
|
|
1945
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");
|
|
1946
1967
|
this.graphDispatch = options.graphDispatch;
|
|
1968
|
+
this.graphLeafDispatch = options.graphLeafDispatch;
|
|
1947
1969
|
const configuredDocker = options.dockerConnection;
|
|
1948
1970
|
if (configuredDocker?.id === defaultDockerConnectionId) throw new Error(`${defaultDockerConnectionId} is reserved for the implicit local connection`);
|
|
1949
1971
|
const dockerConnection = configuredDocker ?? {
|