@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-bench",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Benchmark adapters and execution for agent-runtime across coding, tool-use, RAG, memory, browser, and terminal tasks.",
|
|
6
6
|
"repository": {
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"directory": "bench"
|
|
10
10
|
},
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
|
+
"bin": {
|
|
13
|
+
"agent-bench": "./dist/cli.js"
|
|
14
|
+
},
|
|
12
15
|
"types": "./dist/index.d.ts",
|
|
13
16
|
"exports": {
|
|
14
17
|
".": {
|
|
@@ -25,10 +28,10 @@
|
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"@tangle-network/agent-eval": "^
|
|
29
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
31
|
+
"@tangle-network/agent-eval": "^2.0.29",
|
|
32
|
+
"@tangle-network/agent-interface": "^5.10.33",
|
|
30
33
|
"@tangle-network/agent-knowledge": "^23.0.0",
|
|
31
|
-
"@tangle-network/agent-runtime": "^
|
|
34
|
+
"@tangle-network/agent-runtime": "^11.0.0",
|
|
32
35
|
"@tangle-network/sandbox": "^1.0.233"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
|
@@ -37,6 +37,11 @@ _PROFILE_PLAN_KIND = "agent-profile-workspace-plan"
|
|
|
37
37
|
_PROFILE_ACTIVATION_KIND = "agent-candidate-profile-activation"
|
|
38
38
|
_EXECUTION_EVIDENCE_KIND = "agent-candidate-execution-plan"
|
|
39
39
|
_RUN_CELL_KIND = "agent-candidate-run-cell"
|
|
40
|
+
_SEARCH_PLAN_KIND = "agent-candidate-search-execution-plan-material-v1"
|
|
41
|
+
_SEARCH_RECEIPT_KIND = "agent-candidate-search-materialization-v1"
|
|
42
|
+
_SEARCH_EXECUTION_EVIDENCE_KIND = "agent-candidate-search-execution-plan-v1"
|
|
43
|
+
_SEARCH_RUN_CELL_KIND = "agent-candidate-search-run-cell-v1"
|
|
44
|
+
_SEARCH_ADMISSION_KIND = "agent-candidate-search-admission-v1"
|
|
40
45
|
_BENCHMARK_SUITE_KIND = "agent-candidate-benchmark-suite"
|
|
41
46
|
_BENCHMARK_TASK_KIND = "agent-candidate-benchmark-task"
|
|
42
47
|
_STDIN_TASK_PATH = "/tangle/input/stdin.txt"
|
|
@@ -71,6 +76,14 @@ class ProfileFile:
|
|
|
71
76
|
sha256: str
|
|
72
77
|
|
|
73
78
|
|
|
79
|
+
@dataclass(frozen=True)
|
|
80
|
+
class KnowledgeWorkspace:
|
|
81
|
+
root: str
|
|
82
|
+
files: tuple[WorkspaceFile, ...]
|
|
83
|
+
retrieval: WorkspaceFile | None
|
|
84
|
+
retrieval_path: str | None
|
|
85
|
+
|
|
86
|
+
|
|
74
87
|
@dataclass(frozen=True)
|
|
75
88
|
class PreparedCandidateContract:
|
|
76
89
|
plan: dict[str, Any]
|
|
@@ -90,6 +103,7 @@ class PreparedCandidateContract:
|
|
|
90
103
|
candidate_files: tuple[WorkspaceFile, ...]
|
|
91
104
|
profile_target: str
|
|
92
105
|
profile_files: tuple[ProfileFile, ...]
|
|
106
|
+
knowledge: KnowledgeWorkspace | None
|
|
93
107
|
executable: str
|
|
94
108
|
args: tuple[str, ...]
|
|
95
109
|
env: dict[str, str]
|
|
@@ -330,6 +344,64 @@ def _workspace_files(value: Any, label: str) -> tuple[WorkspaceFile, ...]:
|
|
|
330
344
|
return tuple(files)
|
|
331
345
|
|
|
332
346
|
|
|
347
|
+
def _knowledge_workspace(
|
|
348
|
+
digest: str | None,
|
|
349
|
+
receipt_digest: Any,
|
|
350
|
+
bundle_digest: str,
|
|
351
|
+
bundle_path: Path | None,
|
|
352
|
+
task_root: str,
|
|
353
|
+
env: dict[str, str],
|
|
354
|
+
task_paths: tuple[str, ...],
|
|
355
|
+
) -> KnowledgeWorkspace | None:
|
|
356
|
+
root_env = env.get("TANGLE_CANDIDATE_KNOWLEDGE_ROOT")
|
|
357
|
+
config_env = env.get("TANGLE_CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG")
|
|
358
|
+
if digest != receipt_digest:
|
|
359
|
+
raise CandidateContractError("plan and receipt knowledge digests differ")
|
|
360
|
+
if digest is None:
|
|
361
|
+
if bundle_path is not None or root_env is not None or config_env is not None:
|
|
362
|
+
raise CandidateContractError("unexpected knowledge workspace input")
|
|
363
|
+
return None
|
|
364
|
+
if bundle_path is None:
|
|
365
|
+
raise CandidateContractError("signed knowledge requires its sealed bundle")
|
|
366
|
+
|
|
367
|
+
bundle, raw = _read_json(bundle_path, "knowledge bundle")
|
|
368
|
+
_contract_object(bundle, "knowledge bundle", kind="agent-candidate-bundle")
|
|
369
|
+
if sha256_bytes(raw) != bundle_digest:
|
|
370
|
+
raise CandidateContractError("knowledge bundle differs from the sealed candidate")
|
|
371
|
+
knowledge = _object(bundle.get("knowledge"), "bundle.knowledge")
|
|
372
|
+
snapshot = _object(knowledge.get("snapshot"), "bundle.knowledge.snapshot")
|
|
373
|
+
if snapshot.get("digest") != digest or sha256_bytes(
|
|
374
|
+
_canonical_bytes(snapshot.get("material"), "bundle.knowledge.snapshot.material")
|
|
375
|
+
) != digest:
|
|
376
|
+
raise CandidateContractError("knowledge manifest differs from the sealed execution")
|
|
377
|
+
files = _workspace_files(snapshot, "bundle.knowledge.snapshot")
|
|
378
|
+
retrieval = None
|
|
379
|
+
config_path = None
|
|
380
|
+
if "retrievalConfig" in knowledge:
|
|
381
|
+
artifact = _object(knowledge["retrievalConfig"], "bundle.knowledge.retrievalConfig")
|
|
382
|
+
retrieval = WorkspaceFile(
|
|
383
|
+
path="retrieval.json",
|
|
384
|
+
mode=0o644,
|
|
385
|
+
sha256=_digest(artifact.get("sha256"), "retrieval configuration digest"),
|
|
386
|
+
byte_length=_integer(artifact.get("byteLength"), "retrieval configuration length"),
|
|
387
|
+
)
|
|
388
|
+
config_path = f"{task_root}/.tangle/knowledge-retrieval-config.json"
|
|
389
|
+
root = f"{task_root}/.tangle/knowledge"
|
|
390
|
+
if root_env != root or config_env != config_path:
|
|
391
|
+
raise CandidateContractError("knowledge execution paths differ from the sealed launch")
|
|
392
|
+
reserved = tuple(path for path in (root, config_path) if path is not None)
|
|
393
|
+
for path in task_paths:
|
|
394
|
+
full_path = f"{task_root}/{path}"
|
|
395
|
+
if any(
|
|
396
|
+
full_path == target
|
|
397
|
+
or full_path.startswith(f"{target}/")
|
|
398
|
+
or target.startswith(f"{full_path}/")
|
|
399
|
+
for target in reserved
|
|
400
|
+
):
|
|
401
|
+
raise CandidateContractError("knowledge paths overlap signed task or profile files")
|
|
402
|
+
return KnowledgeWorkspace(root, files, retrieval, config_path)
|
|
403
|
+
|
|
404
|
+
|
|
333
405
|
def _profile_files(value: Any) -> tuple[ProfileFile, ...]:
|
|
334
406
|
values = value.get("files") if isinstance(value, dict) else None
|
|
335
407
|
if not isinstance(values, list):
|
|
@@ -393,23 +465,119 @@ def _instruction(value: Any, delivery_value: Any) -> InstructionEvidence:
|
|
|
393
465
|
)
|
|
394
466
|
|
|
395
467
|
|
|
396
|
-
def
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
)
|
|
401
|
-
|
|
468
|
+
def _model_network_domains(
|
|
469
|
+
model: dict[str, Any], max_model_calls: int
|
|
470
|
+
) -> tuple[str, ...]:
|
|
471
|
+
model_access = _object(model.get("access"), "plan.model.access")
|
|
472
|
+
if set(model_access) != {"kind", "grantDigest", "network"}:
|
|
473
|
+
raise CandidateContractError("plan.model.access has unexpected fields")
|
|
474
|
+
if model_access.get("kind") != "evaluator-mediated":
|
|
475
|
+
raise CandidateContractError(
|
|
476
|
+
"plan.model.access.kind must equal evaluator-mediated"
|
|
477
|
+
)
|
|
478
|
+
_digest(model_access.get("grantDigest"), "plan.model.access.grantDigest")
|
|
479
|
+
model_network = _object(
|
|
480
|
+
model_access.get("network"), "plan.model.access.network"
|
|
481
|
+
)
|
|
482
|
+
if max_model_calls == 0:
|
|
483
|
+
if model_network != {"mode": "disabled"}:
|
|
484
|
+
raise CandidateContractError(
|
|
485
|
+
"zero-call plans cannot expose a model gateway"
|
|
486
|
+
)
|
|
487
|
+
model_network_domains: tuple[str, ...] = ()
|
|
488
|
+
else:
|
|
489
|
+
if set(model_network) != {"mode", "domains"} or model_network.get(
|
|
490
|
+
"mode"
|
|
491
|
+
) != "gateway-only":
|
|
492
|
+
raise CandidateContractError(
|
|
493
|
+
"model-calling plans require one frozen gateway allowlist"
|
|
494
|
+
)
|
|
495
|
+
domain_values = model_network.get("domains")
|
|
496
|
+
if not isinstance(domain_values, list) or not domain_values:
|
|
497
|
+
raise CandidateContractError(
|
|
498
|
+
"plan.model.access.network.domains must be a non-empty array"
|
|
499
|
+
)
|
|
500
|
+
model_network_domains = tuple(
|
|
501
|
+
_gateway_domain(
|
|
502
|
+
value, f"plan.model.access.network.domains[{index}]"
|
|
503
|
+
)
|
|
504
|
+
for index, value in enumerate(domain_values)
|
|
505
|
+
)
|
|
506
|
+
if list(model_network_domains) != sorted(set(model_network_domains)):
|
|
507
|
+
raise CandidateContractError(
|
|
508
|
+
"model gateway domains must be unique and sorted"
|
|
509
|
+
)
|
|
510
|
+
return model_network_domains
|
|
402
511
|
|
|
403
|
-
|
|
404
|
-
|
|
512
|
+
|
|
513
|
+
def _verify_material_digest(value: dict[str, Any], label: str) -> None:
|
|
514
|
+
expected = _digest(value.get("digest"), f"{label}.digest")
|
|
515
|
+
material = {key: item for key, item in value.items() if key != "digest"}
|
|
516
|
+
if sha256_bytes(_canonical_bytes(material, label)) != expected:
|
|
517
|
+
raise CandidateContractError(f"{label} digest does not match")
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def _run_cell_coordinates(
|
|
521
|
+
plan: dict[str, Any], execution_id: str, *, search: bool
|
|
522
|
+
) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
523
|
+
label = "plan.runCell"
|
|
524
|
+
run_cell = _contract_object(
|
|
525
|
+
plan.get("runCell"),
|
|
526
|
+
label,
|
|
527
|
+
kind=_SEARCH_RUN_CELL_KIND if search else _RUN_CELL_KIND,
|
|
528
|
+
)
|
|
529
|
+
_verify_material_digest(run_cell, label)
|
|
530
|
+
if not search:
|
|
531
|
+
_digest(run_cell.get("experimentDigest"), f"{label}.experimentDigest")
|
|
532
|
+
if run_cell.get("arm") not in {"baseline", "candidate"}:
|
|
533
|
+
raise CandidateContractError(f"{label}.arm is unsupported")
|
|
534
|
+
return run_cell, run_cell
|
|
535
|
+
|
|
536
|
+
label = f"{label}.admission"
|
|
537
|
+
admission = _contract_object(
|
|
538
|
+
run_cell.get("admission"), label, kind=_SEARCH_ADMISSION_KIND
|
|
539
|
+
)
|
|
540
|
+
_verify_material_digest(admission, label)
|
|
541
|
+
identity = {
|
|
542
|
+
name: _string(admission.get(name), f"{label}.{name}")
|
|
543
|
+
for name in ("searchId", "cellId")
|
|
544
|
+
}
|
|
545
|
+
_string(admission.get("unitId"), f"{label}.unitId")
|
|
546
|
+
_string(admission.get("taskId"), f"{label}.taskId")
|
|
547
|
+
if admission.get("split") not in {"train", "selection"}:
|
|
548
|
+
raise CandidateContractError(f"{label}.split does not admit exploratory execution")
|
|
549
|
+
if "knowledgeRole" in admission and admission["knowledgeRole"] not in {
|
|
550
|
+
"baseline",
|
|
551
|
+
"candidate",
|
|
552
|
+
}:
|
|
553
|
+
raise CandidateContractError(f"{label}.knowledgeRole is unsupported")
|
|
554
|
+
if execution_id != "search:" + sha256_bytes(_canonical_bytes(identity, label))[7:]:
|
|
555
|
+
raise CandidateContractError(
|
|
556
|
+
"plan.executionId does not match the admitted search cell"
|
|
557
|
+
)
|
|
558
|
+
return run_cell, admission
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def _verify_plan_envelope(
|
|
562
|
+
plan: dict[str, Any],
|
|
563
|
+
plan_raw: bytes,
|
|
564
|
+
receipt: dict[str, Any],
|
|
565
|
+
receipt_raw: bytes,
|
|
566
|
+
expected_receipt_digest: str,
|
|
567
|
+
) -> tuple[bool, str, str]:
|
|
405
568
|
receipt_digest = _digest(expected_receipt_digest, "expected receipt digest")
|
|
406
569
|
if sha256_bytes(receipt_raw) != receipt_digest:
|
|
407
570
|
raise CandidateContractError(
|
|
408
571
|
"materialization receipt bytes do not match the expected digest"
|
|
409
572
|
)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
573
|
+
search = plan.get("kind") == _SEARCH_PLAN_KIND
|
|
574
|
+
_contract_object(
|
|
575
|
+
plan, "execution plan", kind=_SEARCH_PLAN_KIND if search else _PLAN_KIND
|
|
576
|
+
)
|
|
577
|
+
_contract_object(
|
|
578
|
+
receipt,
|
|
579
|
+
"materialization receipt",
|
|
580
|
+
kind=_SEARCH_RECEIPT_KIND if search else _RECEIPT_KIND,
|
|
413
581
|
)
|
|
414
582
|
if receipt.get("digestAlgorithm") != "rfc8785-sha256" or "digest" in receipt:
|
|
415
583
|
raise CandidateContractError(
|
|
@@ -419,7 +587,7 @@ def load_prepared_candidate_contract(
|
|
|
419
587
|
execution_evidence = _contract_object(
|
|
420
588
|
receipt.get("executionPlan"),
|
|
421
589
|
"receipt.executionPlan",
|
|
422
|
-
kind=_EXECUTION_EVIDENCE_KIND,
|
|
590
|
+
kind=_SEARCH_EXECUTION_EVIDENCE_KIND if search else _EXECUTION_EVIDENCE_KIND,
|
|
423
591
|
)
|
|
424
592
|
plan_digest = _digest(
|
|
425
593
|
execution_evidence.get("digest"), "receipt.executionPlan.digest"
|
|
@@ -440,29 +608,30 @@ def load_prepared_candidate_contract(
|
|
|
440
608
|
raise CandidateContractError(
|
|
441
609
|
"receipt execution-plan artifact differs from the executed bytes"
|
|
442
610
|
)
|
|
611
|
+
return search, receipt_digest, plan_digest
|
|
443
612
|
|
|
444
|
-
|
|
445
|
-
|
|
613
|
+
|
|
614
|
+
def load_prepared_candidate_contract(
|
|
615
|
+
plan_path: Path,
|
|
616
|
+
receipt_path: Path,
|
|
617
|
+
expected_receipt_digest: str,
|
|
618
|
+
knowledge_bundle_path: Path | None = None,
|
|
619
|
+
) -> PreparedCandidateContract:
|
|
620
|
+
"""Load exact runtime bytes and prove the receipt binds the plan."""
|
|
621
|
+
|
|
622
|
+
plan, plan_raw = _read_json(plan_path, "execution plan")
|
|
623
|
+
receipt, receipt_raw = _read_json(receipt_path, "materialization receipt")
|
|
624
|
+
search, receipt_digest, plan_digest = _verify_plan_envelope(
|
|
625
|
+
plan, plan_raw, receipt, receipt_raw, expected_receipt_digest
|
|
446
626
|
)
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
raise CandidateContractError("plan.runCell.arm is unsupported")
|
|
451
|
-
run_cell_seed = _safe_integer(run_cell.get("seed"), "plan.runCell.seed")
|
|
452
|
-
if sha256_bytes(
|
|
453
|
-
_canonical_bytes(
|
|
454
|
-
{key: value for key, value in run_cell.items() if key != "digest"},
|
|
455
|
-
"plan.runCell",
|
|
456
|
-
)
|
|
457
|
-
) != run_cell_digest:
|
|
458
|
-
raise CandidateContractError("plan.runCell digest does not match")
|
|
627
|
+
execution_id = _string(plan.get("executionId"), "plan.executionId")
|
|
628
|
+
run_cell, coordinates = _run_cell_coordinates(plan, execution_id, search=search)
|
|
629
|
+
run_cell_seed = _safe_integer(coordinates.get("seed"), "plan.runCell.seed")
|
|
459
630
|
bundle_digest = _digest(
|
|
460
|
-
|
|
631
|
+
coordinates.get("bundleDigest"), "plan.runCell.bundleDigest"
|
|
461
632
|
)
|
|
462
633
|
if receipt.get("bundleDigest") != bundle_digest:
|
|
463
634
|
raise CandidateContractError("receipt and plan bundle digests differ")
|
|
464
|
-
execution_id = _string(plan.get("executionId"), "plan.executionId")
|
|
465
|
-
|
|
466
635
|
benchmark = _object(receipt.get("benchmark"), "receipt.benchmark")
|
|
467
636
|
suite, _, suite_digest = _embedded_contract(
|
|
468
637
|
benchmark.get("suite"),
|
|
@@ -475,14 +644,14 @@ def load_prepared_candidate_contract(
|
|
|
475
644
|
kind=_BENCHMARK_TASK_KIND,
|
|
476
645
|
)
|
|
477
646
|
if (
|
|
478
|
-
|
|
479
|
-
or
|
|
647
|
+
coordinates.get("suiteDigest") != suite_digest
|
|
648
|
+
or coordinates.get("taskDigest") != task_digest
|
|
480
649
|
):
|
|
481
650
|
raise CandidateContractError(
|
|
482
651
|
"run cell does not bind the receipt benchmark suite and task"
|
|
483
652
|
)
|
|
484
|
-
task_index = _integer(
|
|
485
|
-
repetition = _integer(
|
|
653
|
+
task_index = _integer(coordinates.get("taskIndex"), "plan.runCell.taskIndex")
|
|
654
|
+
repetition = _integer(coordinates.get("repetition"), "plan.runCell.repetition")
|
|
486
655
|
if suite.get("digestAlgorithm") != "rfc8785-sha256":
|
|
487
656
|
raise CandidateContractError(
|
|
488
657
|
"benchmark suite digestAlgorithm must equal rfc8785-sha256"
|
|
@@ -522,6 +691,13 @@ def load_prepared_candidate_contract(
|
|
|
522
691
|
raise CandidateContractError(
|
|
523
692
|
"benchmark task digestAlgorithm must equal rfc8785-sha256"
|
|
524
693
|
)
|
|
694
|
+
if (
|
|
695
|
+
search
|
|
696
|
+
and _object(task.get("scenario"), "task.scenario").get("id") != coordinates["taskId"]
|
|
697
|
+
):
|
|
698
|
+
raise CandidateContractError(
|
|
699
|
+
"search admission taskId differs from the benchmark task"
|
|
700
|
+
)
|
|
525
701
|
outcome = _object(task.get("outcome"), "plan.task.outcome")
|
|
526
702
|
if outcome.get("kind") != "workspace":
|
|
527
703
|
raise CandidateContractError("Pier requires a workspace task outcome")
|
|
@@ -821,45 +997,7 @@ def load_prepared_candidate_contract(
|
|
|
821
997
|
or task.get("model") != resolved_model
|
|
822
998
|
):
|
|
823
999
|
raise CandidateContractError("receipt and plan resolved models differ")
|
|
824
|
-
|
|
825
|
-
if set(model_access) != {"kind", "grantDigest", "network"}:
|
|
826
|
-
raise CandidateContractError("plan.model.access has unexpected fields")
|
|
827
|
-
if model_access.get("kind") != "evaluator-mediated":
|
|
828
|
-
raise CandidateContractError(
|
|
829
|
-
"plan.model.access.kind must equal evaluator-mediated"
|
|
830
|
-
)
|
|
831
|
-
_digest(model_access.get("grantDigest"), "plan.model.access.grantDigest")
|
|
832
|
-
model_network = _object(
|
|
833
|
-
model_access.get("network"), "plan.model.access.network"
|
|
834
|
-
)
|
|
835
|
-
if max_model_calls == 0:
|
|
836
|
-
if model_network != {"mode": "disabled"}:
|
|
837
|
-
raise CandidateContractError(
|
|
838
|
-
"zero-call plans cannot expose a model gateway"
|
|
839
|
-
)
|
|
840
|
-
model_network_domains: tuple[str, ...] = ()
|
|
841
|
-
else:
|
|
842
|
-
if set(model_network) != {"mode", "domains"} or model_network.get(
|
|
843
|
-
"mode"
|
|
844
|
-
) != "gateway-only":
|
|
845
|
-
raise CandidateContractError(
|
|
846
|
-
"model-calling plans require one frozen gateway allowlist"
|
|
847
|
-
)
|
|
848
|
-
domain_values = model_network.get("domains")
|
|
849
|
-
if not isinstance(domain_values, list) or not domain_values:
|
|
850
|
-
raise CandidateContractError(
|
|
851
|
-
"plan.model.access.network.domains must be a non-empty array"
|
|
852
|
-
)
|
|
853
|
-
model_network_domains = tuple(
|
|
854
|
-
_gateway_domain(
|
|
855
|
-
value, f"plan.model.access.network.domains[{index}]"
|
|
856
|
-
)
|
|
857
|
-
for index, value in enumerate(domain_values)
|
|
858
|
-
)
|
|
859
|
-
if list(model_network_domains) != sorted(set(model_network_domains)):
|
|
860
|
-
raise CandidateContractError(
|
|
861
|
-
"model gateway domains must be unique and sorted"
|
|
862
|
-
)
|
|
1000
|
+
model_network_domains = _model_network_domains(model, max_model_calls)
|
|
863
1001
|
if receipt.get("harness") != plan.get("harness") or receipt.get(
|
|
864
1002
|
"harnessVersion"
|
|
865
1003
|
) != plan.get("harnessVersion"):
|
|
@@ -871,9 +1009,22 @@ def load_prepared_candidate_contract(
|
|
|
871
1009
|
raise CandidateContractError(
|
|
872
1010
|
"Pier adapter does not yet support isolated candidate memory"
|
|
873
1011
|
)
|
|
874
|
-
|
|
1012
|
+
knowledge_digest = plan.get("knowledgeManifestDigest")
|
|
1013
|
+
knowledge = _knowledge_workspace(
|
|
1014
|
+
_digest(knowledge_digest, "plan.knowledgeManifestDigest")
|
|
1015
|
+
if knowledge_digest is not None
|
|
1016
|
+
else None,
|
|
1017
|
+
receipt.get("knowledgeManifestDigest"),
|
|
1018
|
+
bundle_digest,
|
|
1019
|
+
knowledge_bundle_path,
|
|
1020
|
+
task_root,
|
|
1021
|
+
env,
|
|
1022
|
+
tuple(file.path for file in task_files)
|
|
1023
|
+
+ (tuple(file.path for file in profile_files) if profile_target == "task" else ()),
|
|
1024
|
+
)
|
|
1025
|
+
if search and ("knowledgeRole" in coordinates) != (knowledge is not None):
|
|
875
1026
|
raise CandidateContractError(
|
|
876
|
-
"
|
|
1027
|
+
"search admission Knowledge role differs from the mounted inputs"
|
|
877
1028
|
)
|
|
878
1029
|
network = _object(plan.get("network"), "plan.network")
|
|
879
1030
|
if network != {"mode": "disabled"}:
|
|
@@ -899,6 +1050,7 @@ def load_prepared_candidate_contract(
|
|
|
899
1050
|
candidate_files=candidate_files,
|
|
900
1051
|
profile_target=profile_target,
|
|
901
1052
|
profile_files=profile_files,
|
|
1053
|
+
knowledge=knowledge,
|
|
902
1054
|
executable=executable,
|
|
903
1055
|
args=args,
|
|
904
1056
|
env=env,
|
|
@@ -18,7 +18,7 @@ import secrets
|
|
|
18
18
|
import shlex
|
|
19
19
|
import tempfile
|
|
20
20
|
import time
|
|
21
|
-
from dataclasses import dataclass
|
|
21
|
+
from dataclasses import dataclass, replace
|
|
22
22
|
from importlib.metadata import PackageNotFoundError, version as package_version
|
|
23
23
|
from pathlib import Path, PurePosixPath
|
|
24
24
|
from typing import Any
|
|
@@ -170,6 +170,8 @@ class TangleCandidateAgent(BaseAgent):
|
|
|
170
170
|
task_dir: str | None = None,
|
|
171
171
|
profile_dir: str | None = None,
|
|
172
172
|
candidate_dir: str | None = None,
|
|
173
|
+
knowledge_dir: str | None = None,
|
|
174
|
+
knowledge_bundle_path: str | None = None,
|
|
173
175
|
pier_version: str | None = None,
|
|
174
176
|
extra_env: dict[str, str] | None = None,
|
|
175
177
|
*args: Any,
|
|
@@ -193,6 +195,9 @@ class TangleCandidateAgent(BaseAgent):
|
|
|
193
195
|
Path(plan_path).expanduser().resolve(),
|
|
194
196
|
Path(receipt_path).expanduser().resolve(),
|
|
195
197
|
expected_receipt_digest,
|
|
198
|
+
Path(knowledge_bundle_path).expanduser().absolute()
|
|
199
|
+
if knowledge_bundle_path
|
|
200
|
+
else None,
|
|
196
201
|
)
|
|
197
202
|
if model_name != self._contract.requested_model:
|
|
198
203
|
raise PierCandidateError(
|
|
@@ -211,6 +216,7 @@ class TangleCandidateAgent(BaseAgent):
|
|
|
211
216
|
self._task_snapshot = snapshot_root / "task"
|
|
212
217
|
self._profile_snapshot = snapshot_root / "profile"
|
|
213
218
|
self._candidate_snapshot: Path | None = None
|
|
219
|
+
self._knowledge_snapshot: Path | None = None
|
|
214
220
|
try:
|
|
215
221
|
immutable_snapshot(
|
|
216
222
|
Path(os.path.abspath(Path(task_dir).expanduser())),
|
|
@@ -236,6 +242,22 @@ class TangleCandidateAgent(BaseAgent):
|
|
|
236
242
|
)
|
|
237
243
|
elif candidate_dir:
|
|
238
244
|
raise PierCandidateError("disabled code cannot receive candidate_dir")
|
|
245
|
+
if self._contract.knowledge is not None:
|
|
246
|
+
if not knowledge_dir:
|
|
247
|
+
raise PierCandidateError("signed knowledge requires knowledge_dir")
|
|
248
|
+
knowledge = self._contract.knowledge
|
|
249
|
+
self._knowledge_snapshot = snapshot_root / "knowledge"
|
|
250
|
+
staged_files = tuple(
|
|
251
|
+
replace(file, path=f"files/{file.path}") for file in knowledge.files
|
|
252
|
+
) + ((knowledge.retrieval,) if knowledge.retrieval is not None else ())
|
|
253
|
+
immutable_snapshot(
|
|
254
|
+
Path(os.path.abspath(Path(knowledge_dir).expanduser())),
|
|
255
|
+
self._knowledge_snapshot,
|
|
256
|
+
staged_files,
|
|
257
|
+
"prepared knowledge directory",
|
|
258
|
+
)
|
|
259
|
+
elif knowledge_dir:
|
|
260
|
+
raise PierCandidateError("unexpected knowledge directory")
|
|
239
261
|
except Exception:
|
|
240
262
|
self._snapshots.cleanup()
|
|
241
263
|
raise
|
|
@@ -571,6 +593,60 @@ done""", user="root")
|
|
|
571
593
|
byte_length=source.stat().st_size,
|
|
572
594
|
)
|
|
573
595
|
|
|
596
|
+
async def _apply_knowledge(self, environment: BaseEnvironment) -> None:
|
|
597
|
+
knowledge = self._contract.knowledge
|
|
598
|
+
if knowledge is None:
|
|
599
|
+
return
|
|
600
|
+
if self._knowledge_snapshot is None:
|
|
601
|
+
raise PierCandidateError("knowledge snapshot is unavailable")
|
|
602
|
+
parent = str(PurePosixPath(knowledge.root).parent)
|
|
603
|
+
await self._ensure_real_directory(
|
|
604
|
+
environment, parent, anchor=self._contract.task_root
|
|
605
|
+
)
|
|
606
|
+
root = shlex.quote(knowledge.root)
|
|
607
|
+
await self._exec(
|
|
608
|
+
environment,
|
|
609
|
+
f"test ! -e {root} && test ! -L {root} && mkdir -- {root}",
|
|
610
|
+
user="root",
|
|
611
|
+
)
|
|
612
|
+
await environment.upload_dir(self._knowledge_snapshot / "files", knowledge.root)
|
|
613
|
+
await self._workspace_boundary.verify_container_workspace(
|
|
614
|
+
environment, knowledge.root, knowledge.files, allow_task_metadata=False
|
|
615
|
+
)
|
|
616
|
+
if knowledge.retrieval is not None and knowledge.retrieval_path is not None:
|
|
617
|
+
config = shlex.quote(knowledge.retrieval_path)
|
|
618
|
+
await self._exec(
|
|
619
|
+
environment, f"test ! -e {config} && test ! -L {config}", user="root"
|
|
620
|
+
)
|
|
621
|
+
await self._write_verified_file(
|
|
622
|
+
environment,
|
|
623
|
+
self._knowledge_snapshot / knowledge.retrieval.path,
|
|
624
|
+
knowledge.retrieval_path,
|
|
625
|
+
anchor=self._contract.task_root,
|
|
626
|
+
mode=knowledge.retrieval.mode,
|
|
627
|
+
digest=knowledge.retrieval.sha256,
|
|
628
|
+
byte_length=knowledge.retrieval.byte_length,
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
async def _remove_knowledge(self, environment: BaseEnvironment) -> None:
|
|
632
|
+
knowledge = self._contract.knowledge
|
|
633
|
+
if knowledge is None:
|
|
634
|
+
return
|
|
635
|
+
parent = shlex.quote(str(PurePosixPath(knowledge.root).parent))
|
|
636
|
+
targets = [knowledge.root]
|
|
637
|
+
if knowledge.retrieval_path is not None:
|
|
638
|
+
targets.append(knowledge.retrieval_path)
|
|
639
|
+
await self._exec(
|
|
640
|
+
environment,
|
|
641
|
+
f"""set -eu
|
|
642
|
+
if test -e {parent} || test -L {parent}; then
|
|
643
|
+
test -d {parent} && test ! -L {parent}
|
|
644
|
+
test "$(realpath -e -- {parent})" = {parent}
|
|
645
|
+
rm -rf -- {shlex.join(targets)}
|
|
646
|
+
fi""",
|
|
647
|
+
user="root",
|
|
648
|
+
)
|
|
649
|
+
|
|
574
650
|
async def setup(self, environment: BaseEnvironment) -> None:
|
|
575
651
|
try:
|
|
576
652
|
observed_pier = _runtime_pier_version()
|
|
@@ -632,6 +708,7 @@ done""", user="root")
|
|
|
632
708
|
if self._contract.candidate_root is not None
|
|
633
709
|
else ()
|
|
634
710
|
)
|
|
711
|
+
await self._apply_knowledge(environment)
|
|
635
712
|
await self._process_boundary.prepare_identity(environment, workspace_roots)
|
|
636
713
|
await self._apply_profile(environment)
|
|
637
714
|
|
|
@@ -747,6 +824,7 @@ done""", user="root")
|
|
|
747
824
|
env=git_env,
|
|
748
825
|
user="root",
|
|
749
826
|
)
|
|
827
|
+
await self._remove_knowledge(environment)
|
|
750
828
|
for original in self._original_profile_files:
|
|
751
829
|
target = f"{root}/{original.path}"
|
|
752
830
|
quoted = shlex.quote(target)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import re
|
|
5
6
|
import secrets
|
|
6
7
|
import shlex
|
|
7
8
|
import tempfile
|
|
@@ -17,6 +18,13 @@ from .candidate_contract import (
|
|
|
17
18
|
sha256_bytes,
|
|
18
19
|
)
|
|
19
20
|
|
|
21
|
+
_OCI_PATH_COMPONENT = r"[a-z0-9]+(?:(?:[.]|_{1,2}|-+)[a-z0-9]+)*"
|
|
22
|
+
_PREBOUND_OCI = re.compile(
|
|
23
|
+
rf"127\.0\.0\.1:([1-9][0-9]{{0,4}})/{_OCI_PATH_COMPONENT}"
|
|
24
|
+
rf"(?:/{_OCI_PATH_COMPONENT})*(?::[A-Za-z0-9_][A-Za-z0-9_.-]{{0,127}})?"
|
|
25
|
+
r"@(sha256:[0-9a-f]{64})"
|
|
26
|
+
)
|
|
27
|
+
|
|
20
28
|
|
|
21
29
|
def _workspace_check_script(
|
|
22
30
|
root: str,
|
|
@@ -210,7 +218,27 @@ class CandidateWorkspaceBoundary:
|
|
|
210
218
|
expected = self._contract.container
|
|
211
219
|
configured_image = getattr(environment.task_env_config, "docker_image", None)
|
|
212
220
|
pinned_image = f"{expected['image']}@{expected['indexDigest']}"
|
|
213
|
-
|
|
221
|
+
matched = configured_image == pinned_image
|
|
222
|
+
if (
|
|
223
|
+
expected["source"] == "evaluator-task-container"
|
|
224
|
+
and expected["image"] == expected["manifestDigest"]
|
|
225
|
+
):
|
|
226
|
+
from pier.environments.docker.docker import DockerEnvironment
|
|
227
|
+
|
|
228
|
+
# Pin the signed platform manifest directly so Docker uses the exact image.
|
|
229
|
+
pinned_image = f"127.0.0.1:<port>/<repository>@{expected['manifestDigest']}"
|
|
230
|
+
local = (
|
|
231
|
+
_PREBOUND_OCI.fullmatch(configured_image)
|
|
232
|
+
if isinstance(configured_image, str)
|
|
233
|
+
else None
|
|
234
|
+
)
|
|
235
|
+
matched = (
|
|
236
|
+
isinstance(environment, DockerEnvironment)
|
|
237
|
+
and local is not None
|
|
238
|
+
and int(local.group(1)) <= 65535
|
|
239
|
+
and local.group(2) == expected["manifestDigest"]
|
|
240
|
+
)
|
|
241
|
+
if not matched:
|
|
214
242
|
raise self._error(
|
|
215
243
|
"Pier task image does not match the signed immutable image: "
|
|
216
244
|
f"expected={pinned_image} observed={configured_image}"
|