@tangle-network/agent-runtime 0.282.0 → 0.283.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/dist/{activation-Bi_oOB1-.js → activation-B_vuAOSo.js} +3 -3
- package/dist/{activation-Bi_oOB1-.js.map → activation-B_vuAOSo.js.map} +1 -1
- package/dist/{activation-BcTWDNOD.d.ts → activation-DL1VoNrT.d.ts} +16 -3
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{bundle-CvLGRVO-.js → bundle-BfW-32vB.js} +2 -2
- package/dist/{bundle-CvLGRVO-.js.map → bundle-BfW-32vB.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-B-HOpGN4.js → coordination-driver-BmkANXc5.js} +2 -2
- package/dist/{coordination-driver-B-HOpGN4.js.map → coordination-driver-BmkANXc5.js.map} +1 -1
- package/dist/{delegate-C1eIBN70.js → delegate-BfHKdHzV.js} +2 -2
- package/dist/{delegate-C1eIBN70.js.map → delegate-BfHKdHzV.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +3 -3
- package/dist/{graph-KjJaTmbO.js → graph-XmlRTlaI.js} +4 -4
- package/dist/{graph-KjJaTmbO.js.map → graph-XmlRTlaI.js.map} +1 -1
- package/dist/{improvement-cycle-8MUf5Xfp.js → improvement-cycle-BFerq3l4.js} +6 -6
- package/dist/{improvement-cycle-8MUf5Xfp.js.map → improvement-cycle-BFerq3l4.js.map} +1 -1
- package/dist/{index-CSyzK6Kd.d.ts → index-CkLB8mJF.d.ts} +11 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +8 -8
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-Dtt8FdYO.d.ts → loop-runner-bin-CINywrHK.d.ts} +2 -2
- package/dist/{loop-runner-bin-Cg78CKmf.js → loop-runner-bin-D8P3T5rT.js} +3 -3
- package/dist/{loop-runner-bin-Cg78CKmf.js.map → loop-runner-bin-D8P3T5rT.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +4 -4
- package/dist/{prepare-DVlvGP7V.js → prepare-CxnyZ1fG.js} +3 -3
- package/dist/{prepare-DVlvGP7V.js.map → prepare-CxnyZ1fG.js.map} +1 -1
- package/dist/{profile-D3eXNBQV.js → profile-C4NDjZyB.js} +2 -2
- package/dist/{profile-D3eXNBQV.js.map → profile-C4NDjZyB.js.map} +1 -1
- package/dist/{protected-model-port-BrWgsCnl.js → protected-model-port-BSsgmdhI.js} +4 -4
- package/dist/{protected-model-port-BrWgsCnl.js.map → protected-model-port-BSsgmdhI.js.map} +1 -1
- package/dist/{provision-supervisor-CkN8RRjv.js → provision-supervisor-BNUmrHwC.js} +3 -3
- package/dist/{provision-supervisor-CkN8RRjv.js.map → provision-supervisor-BNUmrHwC.js.map} +1 -1
- package/dist/{runtime-Bid-kBes.js → runtime-CM3KCe9V.js} +86 -23
- package/dist/runtime-CM3KCe9V.js.map +1 -0
- package/dist/{search-method-CbUyhdz5.js → search-method-Dlor0kKQ.js} +43 -9
- package/dist/{search-method-CbUyhdz5.js.map → search-method-Dlor0kKQ.js.map} +1 -1
- package/dist/{server-dOyG5Tw6.js → server-BnMcTE7J.js} +3 -3
- package/dist/{server-dOyG5Tw6.js.map → server-BnMcTE7J.js.map} +1 -1
- package/dist/{supervise-zt91I62x.js → supervise-DL_Hj1uk.js} +3 -3
- package/dist/{supervise-zt91I62x.js.map → supervise-DL_Hj1uk.js.map} +1 -1
- package/dist/{supervisor-UXgaPisu.js → supervisor-YAc4U8HQ.js} +2 -2
- package/dist/{supervisor-UXgaPisu.js.map → supervisor-YAc4U8HQ.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{workspace-archive-C9lgf77y.js → workspace-archive-MhowMCmp.js} +8 -6
- package/dist/workspace-archive-MhowMCmp.js.map +1 -0
- package/package.json +2 -2
- package/skills/profile-authoring/SKILL.md +60 -14
- package/dist/runtime-Bid-kBes.js.map +0 -1
- package/dist/workspace-archive-C9lgf77y.js.map +0 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ec as superviseWithTestBrain, Tn as driverAgent, Zt as RunGraphTestOptions, il as SupervisorAgentTestDeps, pl as supervisorAgentWithTestBrain, tn as runGraphWithTestBrain, wc as SuperviseTestOptions, wn as DriverAgentOptions } from "./index-
|
|
1
|
+
import { Ec as superviseWithTestBrain, Tn as driverAgent, Zt as RunGraphTestOptions, il as SupervisorAgentTestDeps, pl as supervisorAgentWithTestBrain, tn as runGraphWithTestBrain, wc as SuperviseTestOptions, wn as DriverAgentOptions } from "./index-CkLB8mJF.js";
|
|
2
2
|
import { Hn as ToolLoopChat, Vn as ToolLoopCallContext } from "./stream-agent-turn-Bk79CnTw.js";
|
|
3
3
|
import { AgentImprovementProposal, AgentProfile, AgentProfileImprovementMeasuredComparison, SandboxSizePreset } from "@tangle-network/agent-interface";
|
|
4
4
|
//#region src/testing/index.d.ts
|
package/dist/testing.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as verifyAgentImprovementProposal } from "./improvement-cycle-
|
|
3
|
-
import { i as applyExactAgentProfileDiff, p as parseExactAgentProfile } from "./profile-
|
|
4
|
-
import { r as driverAgent } from "./coordination-driver-
|
|
5
|
-
import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-
|
|
6
|
-
import { i as runGraphWithTestBrain } from "./graph-
|
|
1
|
+
import { O as immutableCandidateValue, w as canonicalCandidateDigest$1 } from "./workspace-archive-MhowMCmp.js";
|
|
2
|
+
import { f as verifyAgentImprovementProposal } from "./improvement-cycle-BFerq3l4.js";
|
|
3
|
+
import { i as applyExactAgentProfileDiff, p as parseExactAgentProfile } from "./profile-C4NDjZyB.js";
|
|
4
|
+
import { r as driverAgent } from "./coordination-driver-BmkANXc5.js";
|
|
5
|
+
import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-DL_Hj1uk.js";
|
|
6
|
+
import { i as runGraphWithTestBrain } from "./graph-XmlRTlaI.js";
|
|
7
7
|
import { SANDBOX_SIZE_PRESET_NAMES, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
|
|
8
8
|
//#region src/testing/fixtures/agent-improvement-proposal.json
|
|
9
9
|
var agent_improvement_proposal_default = {
|
|
10
10
|
changedSurfaces: ["prompt"],
|
|
11
|
-
digest: "sha256:
|
|
11
|
+
digest: "sha256:24b06130f501fc1549a401b5028ad906b904cf7160e8dd5c2d6c13275021cc9e",
|
|
12
12
|
evaluation: {
|
|
13
13
|
"decision": {
|
|
14
14
|
"contributingChecks": [
|
|
@@ -4579,7 +4579,7 @@ var agent_improvement_proposal_default = {
|
|
|
4579
4579
|
],
|
|
4580
4580
|
"metadata": {
|
|
4581
4581
|
"fixture": "agent-improvement-proposal",
|
|
4582
|
-
"runtimeVersion": "0.
|
|
4582
|
+
"runtimeVersion": "0.283.0"
|
|
4583
4583
|
},
|
|
4584
4584
|
"objectives": [
|
|
4585
4585
|
{
|
|
@@ -4690,8 +4690,8 @@ var agent_improvement_proposal_default = {
|
|
|
4690
4690
|
"baselineContentHash": "sha256:5c21ee53e513fc604cb09754e21c392b24a424da0ef37dbf8f1ee4a8a0b08f09",
|
|
4691
4691
|
"candidateContentHash": "sha256:60fcbb1c728194bd51d7d19cb732d1c3f1881dce7e0a6266b41c8b98cfd65693",
|
|
4692
4692
|
"kind": "agent-eval-loop",
|
|
4693
|
-
"recordDigest": "sha256:
|
|
4694
|
-
"runId": "agent-runtime-0.
|
|
4693
|
+
"recordDigest": "sha256:b838e249a3609829a8a25d0feb0051cc1b44216755a1346faa4966158082ad65",
|
|
4694
|
+
"runId": "agent-runtime-0.283.0-proposal-fixture",
|
|
4695
4695
|
"schema": "agent-candidate-experiment"
|
|
4696
4696
|
}
|
|
4697
4697
|
},
|
|
@@ -4714,13 +4714,13 @@ var agent_improvement_proposal_default = {
|
|
|
4714
4714
|
}],
|
|
4715
4715
|
kind: "agent-improvement-proposal",
|
|
4716
4716
|
proposedAt: "2026-07-10T01:00:00.000Z",
|
|
4717
|
-
runId: "agent-runtime-0.
|
|
4717
|
+
runId: "agent-runtime-0.283.0-proposal-fixture"
|
|
4718
4718
|
};
|
|
4719
4719
|
//#endregion
|
|
4720
4720
|
//#region src/testing/fixtures/agent-profile-improvement-proposal.json
|
|
4721
4721
|
var agent_profile_improvement_proposal_default = {
|
|
4722
4722
|
changedSurfaces: ["prompt", "skills"],
|
|
4723
|
-
digest: "sha256:
|
|
4723
|
+
digest: "sha256:d03808711b3c91755afae8a05c5a1150ddd5d5ef318d779f75667f138a91f295",
|
|
4724
4724
|
evaluation: {
|
|
4725
4725
|
"decision": {
|
|
4726
4726
|
"contributingChecks": [
|
|
@@ -6354,7 +6354,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6354
6354
|
],
|
|
6355
6355
|
"metadata": {
|
|
6356
6356
|
"fixture": "agent-profile-improvement-proposal",
|
|
6357
|
-
"runtimeVersion": "0.
|
|
6357
|
+
"runtimeVersion": "0.283.0"
|
|
6358
6358
|
},
|
|
6359
6359
|
"objectives": [
|
|
6360
6360
|
{
|
|
@@ -6465,7 +6465,7 @@ var agent_profile_improvement_proposal_default = {
|
|
|
6465
6465
|
"baselineContentHash": "sha256:21c495a37c418c10bde64fbaa188beddeed31f1f051ea60a6a6582a9ee0db704",
|
|
6466
6466
|
"candidateContentHash": "sha256:103f77bc8481601eef1ad5fe6ba84a40dffabc3a44f421f8c8559121edab84e9",
|
|
6467
6467
|
"kind": "agent-eval-loop",
|
|
6468
|
-
"recordDigest": "sha256:
|
|
6468
|
+
"recordDigest": "sha256:d057f52fe0bfae992ec4e4dd3b9de62de0a6e66482c972ad2242611086624c8b",
|
|
6469
6469
|
"runId": "profile-improvement-1",
|
|
6470
6470
|
"schema": "agent-profile-improvement-experiment"
|
|
6471
6471
|
}
|
package/dist/tui/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as ProvisionSupervisorConnection, Dt as provisionSupervisor, Et as SupervisorCleanupReceipt, Tt as ProvisionedSupervisor, wt as ProvisionSupervisorRequest } from "../index-
|
|
1
|
+
import { Ct as ProvisionSupervisorConnection, Dt as provisionSupervisor, Et as SupervisorCleanupReceipt, Tt as ProvisionedSupervisor, wt as ProvisionSupervisorRequest } from "../index-CkLB8mJF.js";
|
|
2
2
|
//#region src/tui/top-app.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames
|
package/dist/tui/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as provisionSupervisor } from "../provision-supervisor-
|
|
1
|
+
import { t as provisionSupervisor } from "../provision-supervisor-BNUmrHwC.js";
|
|
2
2
|
import { a as renderTopFrameWithLayout, i as renderTopFrame, n as runTopApp, r as loadTopSnapshot, t as renderTopOnce } from "../top-app-VAOrBskv.js";
|
|
3
3
|
export { loadTopSnapshot, provisionSupervisor, renderTopFrame, renderTopFrameWithLayout, renderTopOnce, runTopApp };
|
|
@@ -81,6 +81,8 @@ async function verifyWorkspaceSnapshotArtifacts(snapshot, port) {
|
|
|
81
81
|
archive
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
+
/** A configured file-count or byte limit stopped workspace capture. */
|
|
85
|
+
var WorkspaceScanLimitError = class extends Error {};
|
|
84
86
|
/**
|
|
85
87
|
* Refuse a materialized workspace whose files, modes, or bytes are not the signed manifest.
|
|
86
88
|
*
|
|
@@ -205,16 +207,16 @@ async function walkWorkspace(root, options, keepBytes) {
|
|
|
205
207
|
continue;
|
|
206
208
|
}
|
|
207
209
|
if (!stats.isFile()) throw new Error(`workspace contains a non-regular entry: ${relPath}`);
|
|
208
|
-
if (limits && scanned.length >= limits.maxFiles) throw new
|
|
210
|
+
if (limits && scanned.length >= limits.maxFiles) throw new WorkspaceScanLimitError("workspace exceeds maxFiles");
|
|
209
211
|
const descriptor = await open(absolute, constants.O_RDONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0));
|
|
210
212
|
try {
|
|
211
213
|
const openedStats = await descriptor.stat();
|
|
212
214
|
if (!openedStats.isFile()) throw new Error(`workspace contains a non-regular entry: ${relPath}`);
|
|
213
215
|
if (openedStats.nlink !== 1) throw new Error(`workspace contains a hard-linked file: ${relPath}`);
|
|
214
216
|
const mode = options.portableTree === true ? portableFileMode(openedStats.mode) : openedStats.mode & 511;
|
|
215
|
-
if (limits && openedStats.size > limits.maxFileBytes) throw new
|
|
217
|
+
if (limits && openedStats.size > limits.maxFileBytes) throw new WorkspaceScanLimitError(`workspace file exceeds maxFileBytes: ${relPath}`);
|
|
216
218
|
const remainingBytes = limits ? limits.maxTotalFileBytes - totalBytes : void 0;
|
|
217
|
-
if (remainingBytes !== void 0 && openedStats.size > remainingBytes) throw new
|
|
219
|
+
if (remainingBytes !== void 0 && openedStats.size > remainingBytes) throw new WorkspaceScanLimitError("workspace exceeds maxTotalFileBytes");
|
|
218
220
|
const read = await readWorkspaceFile(descriptor, limits ? Math.min(limits.maxFileBytes, remainingBytes ?? limits.maxFileBytes) : void 0, keepBytes, relPath);
|
|
219
221
|
totalBytes += read.byteLength;
|
|
220
222
|
scanned.push({
|
|
@@ -275,7 +277,7 @@ async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path) {
|
|
|
275
277
|
const { bytesRead } = await descriptor.read(buffer, 0, buffer.byteLength, null);
|
|
276
278
|
if (bytesRead === 0) break;
|
|
277
279
|
total += bytesRead;
|
|
278
|
-
if (maxBytes !== void 0 && total > maxBytes) throw new
|
|
280
|
+
if (maxBytes !== void 0 && total > maxBytes) throw new WorkspaceScanLimitError(`workspace file exceeds its capture limit: ${path}`);
|
|
279
281
|
const chunk = buffer.subarray(0, bytesRead);
|
|
280
282
|
hash.update(chunk);
|
|
281
283
|
if (keepBytes) chunks.push(Buffer.from(chunk));
|
|
@@ -1204,6 +1206,6 @@ const typedArrayBufferGetter = requireTypedArrayGetter("buffer");
|
|
|
1204
1206
|
const typedArrayByteOffsetGetter = requireTypedArrayGetter("byteOffset");
|
|
1205
1207
|
const typedArrayByteLengthGetter = requireTypedArrayGetter("byteLength");
|
|
1206
1208
|
//#endregion
|
|
1207
|
-
export {
|
|
1209
|
+
export { sha256Bytes$1 as A, canonicalCandidateBytes$1 as C, embeddedCandidateArtifact as D, deepFreezeCandidate as E, immutableCandidateValue as O, verifyWorkspaceSnapshotArtifacts as S, canonicalCandidateDocument as T, readVerifiedArtifact as _, persistCandidateOutputArtifact as a, verifyMaterializedProfileWorkspace as b, verifyTaskCheckout as c, isWellFormedUnicode as d, WorkspaceScanLimitError as f, readMaterializedWorkspaceFiles as g, captureMaterializedWorkspace as h, verifyAgentCandidateWorkspaceArchive as i, verifyCanonicalCandidateDocument as j, omitTopLevelDigest as k, verifyTaskOutcomePatch as l, candidateWorkspaceManifest as m, captureAgentCandidateWorkspaceFiles as n, readCandidateGitHubResource as o, artifactCacheKey as p, createAgentCandidateWorkspacePort as r, verifyCandidateCode as s, captureAgentCandidateWorkspace as t, assertExactObjectKeys as u, scanMaterializedWorkspaceManifest as v, canonicalCandidateDigest$1 as w, verifyMaterializedWorkspace as x, verifyBytes as y };
|
|
1208
1210
|
|
|
1209
|
-
//# sourceMappingURL=workspace-archive-
|
|
1211
|
+
//# sourceMappingURL=workspace-archive-MhowMCmp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-archive-MhowMCmp.js","names":["sha256Bytes","canonicalCandidateDigest","canonicalCandidateBytes","sha256Bytes","canonicalCandidateBytes","fsConstants","canonicalCandidateBytes","hasControlCharacter","sha256Bytes","canonicalCandidateBytes","canonicalCandidateDigest","sha256Bytes","fsConstants"],"sources":["../src/candidate-execution/digest.ts","../src/candidate-execution/artifacts.ts","../src/candidate-execution/exact-object.ts","../src/candidate-execution/git-materialize.ts","../src/candidate-execution/output-artifacts.ts","../src/candidate-execution/workspace-archive.ts"],"sourcesContent":["import { createHash } from 'node:crypto'\nimport {\n type AgentCandidateEmbeddedArtifact,\n canonicalCandidateBytes,\n type Sha256Digest,\n} from '@tangle-network/agent-interface'\n\nimport type { CanonicalCandidateDocument } from './types'\n\nexport { canonicalCandidateBytes }\n\n/** Use native hashing for workspace archives. */\nexport function sha256Bytes(bytes: Uint8Array): Sha256Digest {\n return `sha256:${createHash('sha256').update(bytes).digest('hex')}`\n}\n\nexport function canonicalCandidateDigest(value: unknown): Sha256Digest {\n return sha256Bytes(canonicalCandidateBytes(value))\n}\n\n/** Returns a detached, deeply frozen JSON value with canonical number normalization. */\nexport function immutableCandidateValue<T>(value: T): T {\n return deepFreezeCandidate(\n JSON.parse(Buffer.from(canonicalCandidateBytes(value)).toString('utf8')) as T,\n )\n}\n\nexport function canonicalCandidateDocument<T extends { digest: Sha256Digest }>(\n valueWithoutDigest: Omit<T, 'digest'>,\n): CanonicalCandidateDocument<T> {\n const bytes = canonicalCandidateBytes(valueWithoutDigest)\n const digest = sha256Bytes(bytes)\n const value = deepFreezeCandidate({\n ...JSON.parse(Buffer.from(bytes).toString('utf8')),\n digest,\n }) as T\n return Object.freeze({\n value,\n get bytes(): Uint8Array {\n return Uint8Array.from(bytes)\n },\n digest,\n })\n}\n\nexport function verifyCanonicalCandidateDocument<T extends { digest: Sha256Digest }>(\n value: T,\n label: string,\n): T {\n if (canonicalCandidateDigest(omitTopLevelDigest(value)) !== value.digest) {\n throw new Error(`${label} digest does not match`)\n }\n return immutableCandidateValue(value)\n}\n\nexport function embeddedCandidateArtifact(bytes: Uint8Array): AgentCandidateEmbeddedArtifact {\n return {\n encoding: 'base64',\n content: Buffer.from(bytes).toString('base64'),\n sha256: sha256Bytes(bytes),\n byteLength: bytes.byteLength,\n }\n}\n\nexport function omitTopLevelDigest<T extends { digest: Sha256Digest }>(\n value: T,\n): Omit<T, 'digest'> {\n const { digest: _digest, ...rest } = value\n return rest\n}\n\nexport function deepFreezeCandidate<T>(value: T, seen = new Set<object>()): T {\n if (\n value === null ||\n typeof value !== 'object' ||\n ArrayBuffer.isView(value) ||\n seen.has(value as object)\n ) {\n return value\n }\n seen.add(value as object)\n for (const child of Object.values(value as Record<string, unknown>)) {\n deepFreezeCandidate(child, seen)\n }\n return Object.freeze(value)\n}\n","import { createHash } from 'node:crypto'\nimport { constants as fsConstants } from 'node:fs'\nimport { lstat, open, readdir, readlink, realpath } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve, sep } from 'node:path'\n\nimport type {\n AgentCandidateArtifactRef,\n AgentCandidateCapturedArtifact,\n AgentCandidateProfilePlanMaterial,\n AgentCandidateWorkspaceManifestMaterial,\n AgentCandidateWorkspaceSnapshotEvidence,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\n\nimport { canonicalCandidateBytes, sha256Bytes } from './digest'\nimport type { AgentCandidateArtifactPort } from './types'\n\nexport function artifactCacheKey(artifact: AgentCandidateCapturedArtifact): string {\n return `${artifact.sha256}:${artifact.byteLength}`\n}\n\nexport async function readVerifiedArtifact(\n artifact: AgentCandidateCapturedArtifact,\n port: AgentCandidateArtifactPort,\n): Promise<Uint8Array> {\n const bytes =\n 'content' in artifact\n ? Buffer.from(artifact.content, 'base64')\n : await port.read(artifact as AgentCandidateArtifactRef)\n verifyBytes(bytes, artifact.sha256, artifact.byteLength, 'candidate artifact')\n return Uint8Array.from(bytes)\n}\n\nexport function verifyBytes(\n bytes: Uint8Array,\n digest: string,\n byteLength: number,\n label: string,\n): void {\n if (bytes.byteLength !== byteLength) {\n throw new Error(`${label} byte length ${bytes.byteLength} does not match ${byteLength}`)\n }\n const actual = sha256Bytes(bytes)\n if (actual !== digest) {\n throw new Error(`${label} digest ${actual} does not match ${digest}`)\n }\n}\n\nexport async function verifyWorkspaceSnapshotArtifacts(\n snapshot: AgentCandidateWorkspaceSnapshotEvidence,\n port: AgentCandidateArtifactPort,\n): Promise<{ manifest: Uint8Array; archive: Uint8Array }> {\n const [manifest, archive] = await Promise.all([\n readVerifiedArtifact(snapshot.manifest, port),\n readVerifiedArtifact(snapshot.archive, port),\n ])\n const canonicalManifest = canonicalCandidateBytes(snapshot.material)\n if (!Buffer.from(manifest).equals(Buffer.from(canonicalManifest))) {\n throw new Error('workspace manifest artifact is not the exact canonical manifest material')\n }\n if (sha256Bytes(canonicalManifest) !== snapshot.digest) {\n throw new Error('workspace snapshot digest does not match its canonical manifest material')\n }\n return { manifest, archive }\n}\n\n/** The per-scan caps a bounded capture applies. */\nexport interface WorkspaceScanLimits {\n readonly maxFiles: number\n readonly maxFileBytes: number\n readonly maxTotalFileBytes: number\n}\n\n/** A configured file-count or byte limit stopped workspace capture. */\nexport class WorkspaceScanLimitError extends Error {}\n\n/** What a workspace scan reads and how it records a file's permission bits. */\nexport interface WorkspaceScanOptions {\n readonly ignoredProtectedRootEntries?: readonly ('.git' | '.sidecar')[]\n readonly limits?: WorkspaceScanLimits\n /**\n * Record Git's two file modes instead of the filesystem's exact permission bits: `0o755` when\n * any execute bit is set, `0o644` otherwise. A checkout umask then cannot move a manifest\n * digest, while a real permission change still does.\n *\n * This is the normalization `readCandidateGitTreeFiles` already applies to a Git tree\n * (`100644`/`100755`), so one tree scanned from disk and the same tree read out of Git produce\n * the same manifest. Off by default: the flag changes the digest, so a capture and the verify\n * that checks it must agree on it.\n */\n readonly portableTree?: boolean\n}\n\n/**\n * Refuse a materialized workspace whose files, modes, or bytes are not the signed manifest.\n *\n * The scan streams, so the size of the largest file does not decide whether the check can run, and\n * the refusal names the one mismatch a caller can produce on its own: a capture and a verify that\n * disagree about `portableTree`.\n */\nexport async function verifyMaterializedWorkspace(\n root: string,\n expected: AgentCandidateWorkspaceManifestMaterial,\n options: Omit<WorkspaceScanOptions, 'limits'> = {},\n): Promise<void> {\n assertWorkspaceManifest(await scanMaterializedWorkspaceManifest(root, options), expected)\n}\n\n/**\n * The canonical manifest of one materialized workspace, read without holding any file.\n *\n * Every file is digested by streaming, so the size of the largest file does not decide whether the\n * workspace can be described. `FileHandle.readFile` refuses anything above 2 GiB with\n * `ERR_FS_FILE_TOO_LARGE`, which made a workspace holding one such artifact impossible to verify\n * against a manifest it already matched. The digest is sha-256 over the same bytes either way, so\n * a manifest a buffered read produced is reproduced exactly.\n */\nexport async function scanMaterializedWorkspaceManifest(\n root: string,\n options: WorkspaceScanOptions = {},\n): Promise<AgentCandidateWorkspaceManifestMaterial> {\n return workspaceManifestFromEntries(await walkWorkspace(root, options, false))\n}\n\nexport async function captureMaterializedWorkspace(\n root: string,\n options: WorkspaceScanOptions = {},\n): Promise<{\n manifest: AgentCandidateWorkspaceManifestMaterial\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>\n}> {\n const entries = await walkWorkspace(root, options, true)\n return {\n manifest: workspaceManifestFromEntries(entries),\n files: entries.map((entry) => ({\n path: entry.path,\n mode: entry.mode,\n bytes: Uint8Array.from(capturedBytes(entry)),\n })),\n }\n}\n\n/** Capture exact verified regular-file bytes for fresh isolated materialization. */\nexport async function readMaterializedWorkspaceFiles(\n root: string,\n expected: AgentCandidateWorkspaceManifestMaterial,\n options: WorkspaceScanOptions = {},\n): Promise<ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>> {\n const observed = await captureMaterializedWorkspace(root, options)\n assertWorkspaceManifest(observed.manifest, expected)\n return observed.files.map((file) =>\n Object.freeze({ path: file.path, mode: file.mode, bytes: Uint8Array.from(file.bytes) }),\n )\n}\n\n/**\n * Build the canonical manifest for files a caller already holds — the shape a remote executor\n * returns. Pass `portableTree` to record Git's two file modes instead of exact permission bits, and\n * pass the same flag to every verify that reads the result.\n */\nexport function candidateWorkspaceManifest(\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n options: { portableTree?: boolean } = {},\n): AgentCandidateWorkspaceManifestMaterial {\n return workspaceManifestFromEntries(\n files.map((file) => ({\n path: file.path,\n mode: options.portableTree === true ? portableFileMode(file.mode) : file.mode,\n sha256: sha256Bytes(file.bytes),\n byteLength: file.bytes.byteLength,\n })),\n )\n}\n\nfunction workspaceManifestFromEntries(\n entries: ReadonlyArray<{\n path: string\n mode: number\n sha256: Sha256Digest\n byteLength: number\n }>,\n): AgentCandidateWorkspaceManifestMaterial {\n return {\n kind: 'agent-candidate-workspace-manifest',\n files: entries\n .map((entry) => ({\n path: entry.path,\n mode: entry.mode,\n sha256: entry.sha256,\n byteLength: entry.byteLength,\n }))\n .sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0)),\n }\n}\n\n/** Git records exactly two file modes, and a portable-tree scan records the same two. */\nfunction portableFileMode(mode: number): number {\n return (mode & 0o111) !== 0 ? 0o755 : 0o644\n}\n\nfunction capturedBytes(entry: ScannedWorkspaceEntry): Buffer {\n if (!entry.bytes) throw new Error(`workspace file was digested without its bytes: ${entry.path}`)\n return entry.bytes\n}\n\nfunction assertWorkspaceManifest(\n observed: AgentCandidateWorkspaceManifestMaterial,\n expected: AgentCandidateWorkspaceManifestMaterial,\n): void {\n if (Buffer.from(canonicalCandidateBytes(observed)).equals(canonicalCandidateBytes(expected))) {\n return\n }\n // The one mismatch a caller can produce by passing `portableTree` on one side of a\n // capture/verify pair and not the other. Named, because the general refusal below reads as\n // changed bytes and would send a reader looking for a file that never changed. Comparing the\n // two manifests already in hand costs no second walk.\n if (\n Buffer.from(canonicalCandidateBytes(withPortableModes(observed))).equals(\n canonicalCandidateBytes(withPortableModes(expected)),\n )\n ) {\n throw new Error(\n 'materialized workspace files do not match the signed manifest: only the file modes differ, ' +\n 'so the capture and this verify disagree about portableTree',\n )\n }\n throw new Error('materialized workspace files, modes, or bytes do not match the signed manifest')\n}\n\nfunction withPortableModes(\n material: AgentCandidateWorkspaceManifestMaterial,\n): AgentCandidateWorkspaceManifestMaterial {\n return {\n ...material,\n files: material.files.map((file) => ({ ...file, mode: portableFileMode(file.mode) })),\n }\n}\n\nexport async function verifyMaterializedProfileWorkspace(\n root: string,\n expected: AgentCandidateProfilePlanMaterial,\n fileRoot: 'workspace' | 'agent' = 'workspace',\n): Promise<void> {\n const observed = await scanMaterializedWorkspaceManifest(root)\n const observedProfile = observed.files.map(({ path, mode, sha256 }) => ({\n relPath: path,\n mode,\n contentSha256: sha256,\n }))\n const expectedFiles = expected.files\n .filter((file) => (file.root ?? 'workspace') === fileRoot)\n .map(({ root: _root, ...file }) => file)\n if (\n !Buffer.from(canonicalCandidateBytes(observedProfile)).equals(\n canonicalCandidateBytes(expectedFiles),\n )\n ) {\n throw new Error(\n `profile ${fileRoot} staging files, modes, or bytes do not match the signed profile plan`,\n )\n }\n}\n\ninterface ScannedWorkspaceEntry {\n readonly path: string\n readonly mode: number\n readonly sha256: Sha256Digest\n readonly byteLength: number\n /** Present only when the walk was asked to keep bytes. */\n readonly bytes?: Buffer\n}\n\nasync function walkWorkspace(\n root: string,\n options: WorkspaceScanOptions,\n keepBytes: boolean,\n): Promise<ScannedWorkspaceEntry[]> {\n const ignoredProtectedRootEntries = new Set<string>(options.ignoredProtectedRootEntries ?? [])\n const limits = options.limits\n // Scan the RESOLVED root. The property this guards is that every captured path lies under\n // one real directory with no aliasing, which resolving satisfies directly — rejecting a\n // symlinked prefix outright does not, and makes the scan impossible on macOS, where the\n // OS itself hands out temp paths under /var, a symlink to /private/var. Symlinks INSIDE\n // the workspace are still refused entry by entry below, with O_NOFOLLOW on every open.\n const requestedRoot = resolve(root)\n const rootStats = await lstat(requestedRoot)\n if (!rootStats.isDirectory() || rootStats.isSymbolicLink()) {\n throw new Error('workspace root must be a real directory')\n }\n const absoluteRoot = await realpath(requestedRoot)\n const resolvedStats = await lstat(absoluteRoot)\n if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) {\n throw new Error('workspace root must resolve to a real directory')\n }\n const scanned: ScannedWorkspaceEntry[] = []\n let totalBytes = 0\n\n async function visit(directory: string): Promise<void> {\n const entries = await readdir(directory, { withFileTypes: true })\n entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n for (const entry of entries) {\n if (directory === absoluteRoot && ignoredProtectedRootEntries.has(entry.name)) {\n continue\n }\n const absolute = resolve(directory, entry.name)\n const relPath = relative(absoluteRoot, absolute).split(sep).join('/')\n if (!relPath || relPath.startsWith('../') || relPath.includes('/../')) {\n throw new Error(`workspace entry escapes root: ${relPath}`)\n }\n const stats = await lstat(absolute)\n if (stats.isSymbolicLink()) {\n throw new Error(await symlinkRefusal(absolute, relPath, absoluteRoot))\n }\n if (stats.isDirectory()) {\n await visit(absolute)\n continue\n }\n if (!stats.isFile()) {\n throw new Error(`workspace contains a non-regular entry: ${relPath}`)\n }\n if (limits && scanned.length >= limits.maxFiles) {\n throw new WorkspaceScanLimitError('workspace exceeds maxFiles')\n }\n const descriptor = await open(\n absolute,\n fsConstants.O_RDONLY |\n (typeof fsConstants.O_NOFOLLOW === 'number' ? fsConstants.O_NOFOLLOW : 0),\n )\n try {\n const openedStats = await descriptor.stat()\n if (!openedStats.isFile()) {\n throw new Error(`workspace contains a non-regular entry: ${relPath}`)\n }\n if (openedStats.nlink !== 1) {\n throw new Error(`workspace contains a hard-linked file: ${relPath}`)\n }\n const mode =\n options.portableTree === true\n ? portableFileMode(openedStats.mode)\n : openedStats.mode & 0o777\n if (limits && openedStats.size > limits.maxFileBytes) {\n throw new WorkspaceScanLimitError(`workspace file exceeds maxFileBytes: ${relPath}`)\n }\n const remainingBytes = limits ? limits.maxTotalFileBytes - totalBytes : undefined\n if (remainingBytes !== undefined && openedStats.size > remainingBytes) {\n throw new WorkspaceScanLimitError('workspace exceeds maxTotalFileBytes')\n }\n const read = await readWorkspaceFile(\n descriptor,\n limits ? Math.min(limits.maxFileBytes, remainingBytes ?? limits.maxFileBytes) : undefined,\n keepBytes,\n relPath,\n )\n totalBytes += read.byteLength\n scanned.push({\n path: relPath,\n mode,\n sha256: read.sha256,\n byteLength: read.byteLength,\n ...(read.bytes === undefined ? {} : { bytes: read.bytes }),\n })\n } finally {\n await descriptor.close()\n }\n }\n }\n\n await visit(absoluteRoot)\n return scanned\n}\n\n/**\n * Why one symbolic link is refused, in the terms that separate a portable link from a link that\n * reaches outside the tree.\n *\n * Every link is refused, in both mode policies. `AgentCandidateWorkspaceManifestMaterial` has no\n * representation for one — `mode`, `sha256` and `byteLength` describe a regular file — so a link\n * recorded as a file would let two different trees share one digest. The reason says which kind of\n * link it was, so a caller can tell a link it can rewrite from one it cannot.\n */\nasync function symlinkRefusal(\n absolute: string,\n relPath: string,\n absoluteRoot: string,\n): Promise<string> {\n const target = await readlink(absolute)\n if (isAbsolute(target)) {\n return `workspace contains an absolute symlink: ${relPath} -> ${target}`\n }\n if (!isWithin(absoluteRoot, resolve(dirname(absolute), target))) {\n return `workspace contains a symlink that escapes its tree: ${relPath} -> ${target}`\n }\n let physical: string\n try {\n physical = await realpath(absolute)\n } catch {\n return `workspace contains an unresolved symlink: ${relPath} -> ${target}`\n }\n if (!isWithin(absoluteRoot, physical)) {\n return `workspace contains a symlink that resolves outside its tree: ${relPath} -> ${target}`\n }\n return `workspace contains a symlink: ${relPath} -> ${target}`\n}\n\nfunction isWithin(root: string, path: string): boolean {\n return path === root || path.startsWith(`${root}${sep}`)\n}\n\n/**\n * Read one open regular file into its digest, keeping the bytes only when the caller needs them.\n *\n * The content reaches the hash in 1 MiB chunks and is never held whole for a digest-only walk, so\n * the size of the largest file does not decide whether a workspace can be described.\n * `FileHandle.readFile` refuses anything above 2 GiB with `ERR_FS_FILE_TOO_LARGE`. Hashing the\n * chunks in order equals hashing the whole buffer, so a manifest a buffered read produced is\n * reproduced byte for byte.\n */\nasync function readWorkspaceFile(\n descriptor: Awaited<ReturnType<typeof open>>,\n maxBytes: number | undefined,\n keepBytes: boolean,\n path: string,\n): Promise<{ sha256: Sha256Digest; byteLength: number; bytes?: Buffer }> {\n const hash = createHash('sha256')\n const buffer = Buffer.allocUnsafe(1024 * 1024)\n const chunks: Buffer[] = []\n let total = 0\n while (true) {\n const { bytesRead } = await descriptor.read(buffer, 0, buffer.byteLength, null)\n if (bytesRead === 0) break\n total += bytesRead\n if (maxBytes !== undefined && total > maxBytes) {\n throw new WorkspaceScanLimitError(`workspace file exceeds its capture limit: ${path}`)\n }\n const chunk = buffer.subarray(0, bytesRead)\n hash.update(chunk)\n // The read buffer is reused, so a kept chunk has to be copied out of it.\n if (keepBytes) chunks.push(Buffer.from(chunk))\n }\n const sha256 = `sha256:${hash.digest('hex')}` as Sha256Digest\n return keepBytes\n ? { sha256, byteLength: total, bytes: Buffer.concat(chunks, total) }\n : { sha256, byteLength: total }\n}\n","/** Reject unknown fields while requiring every declared non-optional field. */\nexport function assertExactObjectKeys(\n value: unknown,\n required: readonly string[],\n label: string,\n optional: readonly string[] = [],\n): void {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error(`${label} must be an object`)\n }\n const allowed = new Set([...required, ...optional])\n if (allowed.size !== required.length + optional.length) {\n throw new Error(`${label} exact-key contract contains duplicate fields`)\n }\n for (const key of Object.keys(value)) {\n if (!allowed.has(key)) throw new Error(`${label} contains unknown field ${key}`)\n }\n for (const key of required) {\n if (!(key in value)) throw new Error(`${label} is missing field ${key}`)\n }\n}\n\n/**\n * Reject a string carrying a lone surrogate. A well-formed UTF-16 string round-trips through UTF-8\n * unchanged; a lone surrogate does not, so a value that passes here is safe to persist and re-read\n * as the same bytes.\n */\nexport function isWellFormedUnicode(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index)\n if (code >= 0xd800 && code <= 0xdbff) {\n const next = value.charCodeAt(index + 1)\n if (!(next >= 0xdc00 && next <= 0xdfff)) return false\n index++\n } else if (code >= 0xdc00 && code <= 0xdfff) {\n return false\n }\n }\n return true\n}\n","import { spawn } from 'node:child_process'\nimport { mkdir, mkdtemp, readFile, realpath, rm, stat } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join, resolve } from 'node:path'\n\nimport type {\n AgentCandidateCode,\n AgentCandidateGitHubRepository,\n AgentCandidateGitHubResource,\n AgentCandidateWorkspaceManifestMaterial,\n} from '@tangle-network/agent-interface'\n\nimport { candidateWorkspaceManifest, verifyBytes } from './artifacts'\nimport { canonicalCandidateBytes } from './digest'\nimport type { AgentCandidateRepositoryPort } from './types'\n\ninterface GitResult {\n stdout: Buffer\n stderr: Buffer\n}\n\nexport async function verifyCandidateCode(\n code: AgentCandidateCode,\n repositories: AgentCandidateRepositoryPort,\n patchBytes?: Uint8Array,\n): Promise<string | undefined> {\n if (code.kind === 'disabled') return undefined\n const repositoryRoot = await verifiedRepositoryRoot(code.repository, repositories)\n await assertCommitAndBaseTree(repositoryRoot, code.baseCommit, code.baseTree)\n\n if (code.kind === 'no-op') {\n await assertSafeTree(repositoryRoot, code.baseTree)\n return code.baseTree\n }\n if (!patchBytes) throw new Error('git-patch candidate is missing verified patch bytes')\n\n const temporary = await mkdtemp(join(tmpdir(), 'agent-candidate-git-'))\n try {\n const indexFile = join(temporary, 'index')\n await runCandidateGit(repositoryRoot, ['read-tree', code.baseTree], undefined, {\n GIT_INDEX_FILE: indexFile,\n })\n await runCandidateGit(\n repositoryRoot,\n ['apply', '--cached', '--binary', '--whitespace=nowarn', '-'],\n patchBytes,\n { GIT_INDEX_FILE: indexFile },\n )\n const candidateTree = (\n await runCandidateGit(repositoryRoot, ['write-tree'], undefined, {\n GIT_INDEX_FILE: indexFile,\n })\n ).stdout\n .toString('utf8')\n .trim()\n if (candidateTree !== code.candidateTree) {\n throw new Error(\n `git patch materialized tree ${candidateTree} does not match ${code.candidateTree}`,\n )\n }\n await assertSafeTree(repositoryRoot, candidateTree)\n return candidateTree\n } finally {\n await rm(temporary, { recursive: true, force: true })\n }\n}\n\nexport async function readCandidateGitHubResource(\n resource: AgentCandidateGitHubResource,\n repositories: AgentCandidateRepositoryPort,\n): Promise<Uint8Array> {\n const repositoryRoot = await verifiedRepositoryRoot(resource.repository, repositories)\n const commitType = (\n await runCandidateGit(repositoryRoot, ['cat-file', '-t', resource.commit])\n ).stdout\n .toString('utf8')\n .trim()\n if (commitType !== 'commit') {\n throw new Error(`GitHub resource commit is not a commit object: ${resource.commit}`)\n }\n const listing = (\n await runCandidateGit(repositoryRoot, ['ls-tree', '-z', resource.commit, '--', resource.path])\n ).stdout\n const entries = parseTreeEntries(listing)\n if (entries.length !== 1 || entries[0]?.path !== resource.path) {\n throw new Error(`GitHub resource path is not one exact file: ${resource.path}`)\n }\n const entry = entries[0]\n if (entry?.type !== 'blob' || (entry.mode !== '100644' && entry.mode !== '100755')) {\n throw new Error(`GitHub resource path is not a regular Git blob: ${resource.path}`)\n }\n const bytes = (await runCandidateGit(repositoryRoot, ['cat-file', 'blob', entry.object])).stdout\n verifyBytes(bytes, resource.sha256, resource.byteLength, `GitHub resource ${resource.path}`)\n return Uint8Array.from(bytes)\n}\n\nexport async function verifyTaskCheckout(\n taskRoot: string,\n expected: { baseCommit: string; baseTree: string },\n): Promise<void> {\n const root = resolve(taskRoot)\n const head = (await runCandidateGit(root, ['rev-parse', 'HEAD'])).stdout.toString('utf8').trim()\n if (head !== expected.baseCommit) {\n throw new Error(`task checkout HEAD ${head} does not match ${expected.baseCommit}`)\n }\n const tree = (await runCandidateGit(root, ['rev-parse', 'HEAD^{tree}'])).stdout\n .toString('utf8')\n .trim()\n if (tree !== expected.baseTree) {\n throw new Error(`task checkout base tree ${tree} does not match ${expected.baseTree}`)\n }\n}\n\n/**\n * Apply an evaluator-captured binary diff in a detached object database and\n * prove its result tree exactly matches the captured after-state manifest.\n */\nexport async function verifyTaskOutcomePatch(input: {\n repositoryRoot: string\n baseCommit: string\n baseTree: string\n resultTree: string\n patch: Uint8Array\n afterState: AgentCandidateWorkspaceManifestMaterial\n}): Promise<{ resultTree: string; resultCommit: string }> {\n const repositoryRoot = resolve(input.repositoryRoot)\n await verifyTaskCheckout(repositoryRoot, input)\n const gitDir = resolve(\n (await runCandidateGit(repositoryRoot, ['rev-parse', '--absolute-git-dir'])).stdout\n .toString('utf8')\n .trim(),\n )\n if ((await realpath(gitDir)) !== gitDir || gitDir.includes(':')) {\n throw new Error('task Git object store has an unsupported path')\n }\n await assertNoGitIndirection(repositoryRoot, gitDir, 'task repository')\n\n const temporary = await mkdtemp(join(tmpdir(), 'agent-candidate-task-outcome-'))\n try {\n const objectDirectory = join(temporary, 'objects')\n const indexFile = join(temporary, 'index')\n await mkdir(objectDirectory)\n const gitEnvironment = {\n GIT_INDEX_FILE: indexFile,\n GIT_OBJECT_DIRECTORY: objectDirectory,\n GIT_ALTERNATE_OBJECT_DIRECTORIES: join(gitDir, 'objects'),\n }\n await runCandidateGit(repositoryRoot, ['read-tree', input.baseTree], undefined, gitEnvironment)\n if (input.patch.byteLength > 0) {\n await runCandidateGit(\n repositoryRoot,\n ['apply', '--cached', '--binary', '--whitespace=nowarn', '-'],\n input.patch,\n gitEnvironment,\n )\n }\n const resultTree = (\n await runCandidateGit(repositoryRoot, ['write-tree'], undefined, gitEnvironment)\n ).stdout\n .toString('utf8')\n .trim()\n if (resultTree !== input.resultTree) {\n throw new Error(\n `task outcome patch materialized tree ${resultTree} does not match ${input.resultTree}`,\n )\n }\n await assertSafeTree(repositoryRoot, resultTree, gitEnvironment)\n const observed = await workspaceManifestFromGitTree(repositoryRoot, resultTree, gitEnvironment)\n if (\n !Buffer.from(canonicalCandidateBytes(observed)).equals(\n Buffer.from(canonicalCandidateBytes(input.afterState)),\n )\n ) {\n throw new Error('task outcome after-state does not match the materialized result tree')\n }\n const resultCommit = (\n await runCandidateGit(\n repositoryRoot,\n ['commit-tree', resultTree, '-p', input.baseCommit],\n Buffer.from('candidate task outcome\\n', 'utf8'),\n {\n ...gitEnvironment,\n GIT_AUTHOR_NAME: 'Tangle Evaluator',\n GIT_AUTHOR_EMAIL: 'evaluator@tangle.tools',\n GIT_AUTHOR_DATE: '2000-01-01T00:00:00Z',\n GIT_COMMITTER_NAME: 'Tangle Evaluator',\n GIT_COMMITTER_EMAIL: 'evaluator@tangle.tools',\n GIT_COMMITTER_DATE: '2000-01-01T00:00:00Z',\n },\n )\n ).stdout\n .toString('utf8')\n .trim()\n const committedTree = (\n await runCandidateGit(\n repositoryRoot,\n ['rev-parse', `${resultCommit}^{tree}`],\n undefined,\n gitEnvironment,\n )\n ).stdout\n .toString('utf8')\n .trim()\n if (committedTree !== resultTree) {\n throw new Error('task outcome evaluator commit does not bind the verified result tree')\n }\n return { resultTree, resultCommit }\n } finally {\n await rm(temporary, { recursive: true, force: true })\n }\n}\n\nasync function verifiedRepositoryRoot(\n repository: AgentCandidateGitHubRepository,\n repositories: AgentCandidateRepositoryPort,\n): Promise<string> {\n const repositoryRoot = resolve(await repositories.resolve(repository))\n const rootStats = await stat(repositoryRoot)\n if (!rootStats.isDirectory()) throw new Error('candidate repository path is not a directory')\n\n const origin = (await runCandidateGit(repositoryRoot, ['remote', 'get-url', 'origin'])).stdout\n .toString('utf8')\n .trim()\n const actual = parseGitHubRemote(origin)\n if (!actual || actual.owner !== repository.owner || actual.repo !== repository.repo) {\n throw new Error(\n `local repository origin ${origin || '<missing>'} does not match github.com/${repository.owner}/${repository.repo}`,\n )\n }\n\n const gitDirText = (\n await runCandidateGit(repositoryRoot, ['rev-parse', '--absolute-git-dir'])\n ).stdout\n .toString('utf8')\n .trim()\n const gitDir = resolve(gitDirText)\n await assertNoGitIndirection(repositoryRoot, gitDir, 'candidate repository')\n return repositoryRoot\n}\n\nexport async function assertNoGitIndirection(\n repositoryRoot: string,\n gitDir: string,\n label: string,\n): Promise<void> {\n const replacements = (\n await runCandidateGit(repositoryRoot, ['for-each-ref', '--format=%(refname)', 'refs/replace'])\n ).stdout\n .toString('utf8')\n .trim()\n if (replacements) throw new Error(`${label} contains Git replace refs`)\n // `--git-common-dir` answers relative to the worktree for an ordinary repository, so the\n // path is resolved against a root the caller supplied and carries whatever symlinks that\n // root carries. Read the object store through its RESOLVED path: the alternates below must\n // be read at the real location, and a symlinked prefix is the OS's own doing on macOS,\n // where a temp root lives under /var, a symlink to /private/var.\n const commonDir = await realpath(\n resolve(\n repositoryRoot,\n (await runCandidateGit(repositoryRoot, ['rev-parse', '--git-common-dir'])).stdout\n .toString('utf8')\n .trim(),\n ),\n )\n if (commonDir.includes(':')) {\n throw new Error(`${label} Git common directory has an unsupported path`)\n }\n for (const objectRoot of new Set([gitDir, commonDir])) {\n for (const name of ['alternates', 'http-alternates']) {\n const path = join(objectRoot, 'objects', 'info', name)\n try {\n const contents = await readFile(path, 'utf8')\n if (contents.trim()) throw new Error(`${label} uses forbidden Git ${name}`)\n } catch (error) {\n if (!isNoEntry(error)) throw error\n }\n }\n }\n}\n\nasync function assertCommitAndBaseTree(\n repositoryRoot: string,\n commit: string,\n expectedTree: string,\n): Promise<void> {\n const type = (await runCandidateGit(repositoryRoot, ['cat-file', '-t', commit])).stdout\n .toString('utf8')\n .trim()\n if (type !== 'commit') throw new Error(`candidate base object is not a commit: ${commit}`)\n const actualTree = (\n await runCandidateGit(repositoryRoot, ['rev-parse', `${commit}^{tree}`])\n ).stdout\n .toString('utf8')\n .trim()\n if (actualTree !== expectedTree) {\n throw new Error(`candidate base commit tree ${actualTree} does not match ${expectedTree}`)\n }\n}\n\nasync function assertSafeTree(\n repositoryRoot: string,\n tree: string,\n environment: Record<string, string> = {},\n): Promise<void> {\n const listing = (\n await runCandidateGit(\n repositoryRoot,\n ['ls-tree', '-rz', '--full-tree', tree],\n undefined,\n environment,\n )\n ).stdout\n const entries = parseTreeEntries(listing)\n if (entries.length === 0) throw new Error('candidate Git tree cannot be empty')\n for (const entry of entries) {\n if (entry.type !== 'blob' || (entry.mode !== '100644' && entry.mode !== '100755')) {\n throw new Error(\n `candidate Git tree contains a symlink, submodule, or non-blob: ${entry.path}`,\n )\n }\n assertSafeGitPath(entry.path)\n }\n}\n\nasync function workspaceManifestFromGitTree(\n repositoryRoot: string,\n tree: string,\n environment: Record<string, string>,\n): Promise<AgentCandidateWorkspaceManifestMaterial> {\n return candidateWorkspaceManifest(\n await readCandidateGitTreeFiles(repositoryRoot, tree, environment),\n )\n}\n\nexport async function readCandidateGitTreeFiles(\n repositoryRoot: string,\n tree: string,\n environment: Record<string, string> = {},\n limits?: { maxFiles: number; maxFileBytes: number; maxTotalFileBytes: number },\n): Promise<Array<{ path: string; mode: 0o644 | 0o755; bytes: Uint8Array }>> {\n const listing = (\n await runCandidateGit(\n repositoryRoot,\n ['ls-tree', '-rzl', '--full-tree', tree],\n undefined,\n environment,\n )\n ).stdout\n const files: Array<{ path: string; mode: 0o644 | 0o755; bytes: Uint8Array }> = []\n const entries = parseTreeEntries(listing)\n if (limits && entries.length > limits.maxFiles) {\n throw new Error('candidate Git tree exceeds maxFiles')\n }\n let totalBytes = 0\n for (const entry of entries) {\n if (entry.type !== 'blob' || (entry.mode !== '100644' && entry.mode !== '100755')) {\n throw new Error(`candidate Git tree contains a non-regular file: ${entry.path}`)\n }\n assertSafeGitPath(entry.path)\n if (entry.size === undefined) {\n throw new Error(`candidate Git tree is missing blob size: ${entry.path}`)\n }\n if (limits && entry.size > limits.maxFileBytes) {\n throw new Error(`candidate Git tree file exceeds maxFileBytes: ${entry.path}`)\n }\n totalBytes += entry.size\n if (limits && totalBytes > limits.maxTotalFileBytes) {\n throw new Error('candidate Git tree exceeds maxTotalFileBytes')\n }\n const bytes = (\n await runCandidateGit(\n repositoryRoot,\n ['cat-file', 'blob', entry.object],\n undefined,\n environment,\n )\n ).stdout\n if (bytes.byteLength !== entry.size) {\n throw new Error(`candidate Git blob size changed: ${entry.path}`)\n }\n files.push({\n path: entry.path,\n mode: entry.mode === '100755' ? 0o755 : 0o644,\n bytes: Uint8Array.from(bytes),\n })\n }\n return files.sort((left, right) => (left.path < right.path ? -1 : left.path > right.path ? 1 : 0))\n}\n\nfunction parseTreeEntries(bytes: Uint8Array): Array<{\n mode: string\n type: string\n object: string\n size?: number\n path: string\n}> {\n const raw = Buffer.from(bytes)\n const decoded = raw.toString('utf8')\n if (!Buffer.from(decoded, 'utf8').equals(raw)) {\n throw new Error('candidate Git tree contains a non-UTF-8 path')\n }\n const rows = decoded.split('\\0').filter(Boolean)\n return rows.map((row) => {\n const tab = row.indexOf('\\t')\n const header = row.slice(0, tab).split(' ').filter(Boolean)\n const path = row.slice(tab + 1)\n const [mode, type, object, sizeText] = header\n if (tab < 1 || !mode || !type || !object || !path) {\n throw new Error('malformed Git tree entry')\n }\n const size = sizeText && /^\\d+$/.test(sizeText) ? Number(sizeText) : undefined\n if (size !== undefined && !Number.isSafeInteger(size)) {\n throw new Error('candidate Git tree entry size exceeds the safe integer range')\n }\n return { mode, type, object, ...(size === undefined ? {} : { size }), path }\n })\n}\n\nfunction assertSafeGitPath(path: string): void {\n if (\n !path ||\n path.startsWith('/') ||\n path.includes('\\\\') ||\n path.includes('\\0') ||\n hasControlCharacter(path) ||\n path.split('/').some((part) => !part || part === '.' || part === '..') ||\n path.split('/')[0]?.toLowerCase() === '.git'\n ) {\n throw new Error(`candidate Git tree contains an unsafe path: ${path}`)\n }\n}\n\nfunction hasControlCharacter(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index)\n if (code < 0x20 || code === 0x7f) return true\n }\n return false\n}\n\nfunction parseGitHubRemote(value: string): { owner: string; repo: string } | undefined {\n const match = value.match(\n /^(?:https?:\\/\\/github\\.com\\/|ssh:\\/\\/git@github\\.com\\/|git@github\\.com:)([^/]+)\\/([^/]+?)(?:\\.git)?$/,\n )\n if (!match?.[1] || !match[2]) return undefined\n return { owner: match[1], repo: match[2] }\n}\n\nexport async function runCandidateGit(\n repositoryRoot: string,\n args: string[],\n input?: Uint8Array,\n extraEnv: Record<string, string> = {},\n): Promise<GitResult> {\n const env = Object.fromEntries(\n Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_')),\n ) as Record<string, string>\n Object.assign(env, {\n GIT_CONFIG_NOSYSTEM: '1',\n GIT_CONFIG_GLOBAL: '/dev/null',\n GIT_CONFIG_SYSTEM: '/dev/null',\n GIT_TERMINAL_PROMPT: '0',\n GIT_NO_REPLACE_OBJECTS: '1',\n LC_ALL: 'C',\n ...extraEnv,\n })\n const fullArgs = [\n '-c',\n 'core.hooksPath=/dev/null',\n '-c',\n 'core.fsmonitor=false',\n '-c',\n 'core.untrackedCache=false',\n '-c',\n 'protocol.file.allow=never',\n '-C',\n repositoryRoot,\n ...args,\n ]\n return await new Promise((resolveResult, reject) => {\n const child = spawn('git', fullArgs, { env, stdio: ['pipe', 'pipe', 'pipe'] })\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n child.stdout.on('data', (chunk: Buffer) => stdout.push(chunk))\n child.stderr.on('data', (chunk: Buffer) => stderr.push(chunk))\n child.on('error', reject)\n child.on('close', (code, signal) => {\n const out = Buffer.concat(stdout)\n const err = Buffer.concat(stderr)\n if (code !== 0) {\n reject(\n new Error(\n `git ${args[0] ?? '<command>'} failed (${signal ?? code}): ${err.toString('utf8').trim()}`,\n ),\n )\n return\n }\n resolveResult({ stdout: out, stderr: err })\n })\n if (input) child.stdin.end(input)\n else child.stdin.end()\n })\n}\n\nfunction isNoEntry(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n (error as { code?: string }).code === 'ENOENT'\n )\n}\n","import {\n type AgentCandidateArtifactRef,\n agentCandidateArtifactRefSchema,\n} from '@tangle-network/agent-interface'\n\nimport { verifyBytes } from './artifacts'\nimport { immutableCandidateValue, sha256Bytes } from './digest'\nimport type { AgentCandidateOutputArtifactPort, AgentCandidateOutputPurpose } from './types'\n\n/** Persist evaluator evidence, read it back, and bind the returned locator to the exact bytes. */\nexport async function persistCandidateOutputArtifact(\n port: AgentCandidateOutputArtifactPort,\n input: {\n executionId: string\n purpose: AgentCandidateOutputPurpose\n bytes: Uint8Array\n signal?: AbortSignal\n },\n): Promise<AgentCandidateArtifactRef> {\n input.signal?.throwIfAborted()\n const bytes = Uint8Array.from(input.bytes)\n const expectedDigest = sha256Bytes(bytes)\n const ref = agentCandidateArtifactRefSchema.parse(\n await port.put({\n executionId: input.executionId,\n purpose: input.purpose,\n bytes: Uint8Array.from(bytes),\n ...(input.signal ? { signal: input.signal } : {}),\n }),\n )\n input.signal?.throwIfAborted()\n if (ref.sha256 !== expectedDigest || ref.byteLength !== bytes.byteLength) {\n throw new Error('candidate output locator does not identify the submitted bytes')\n }\n const stored = await port.read(ref)\n input.signal?.throwIfAborted()\n verifyBytes(stored, expectedDigest, bytes.byteLength, 'persisted candidate output')\n return immutableCandidateValue(ref)\n}\n","import { randomUUID } from 'node:crypto'\nimport { constants as fsConstants } from 'node:fs'\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readdir,\n readFile,\n realpath,\n rename,\n rm,\n writeFile,\n} from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { dirname, isAbsolute, join, resolve, sep, win32 } from 'node:path'\nimport { isAnyArrayBuffer, isSharedArrayBuffer } from 'node:util/types'\nimport type {\n AgentCandidateCapturedArtifact,\n AgentCandidateWorkspaceSnapshotEvidence,\n} from '@tangle-network/agent-interface'\nimport { extract, type Pack, pack, type Extract as TarExtract } from 'tar-stream'\nimport {\n candidateWorkspaceManifest,\n captureMaterializedWorkspace,\n verifyBytes,\n verifyMaterializedWorkspace,\n} from './artifacts'\nimport {\n canonicalCandidateBytes,\n canonicalCandidateDigest,\n deepFreezeCandidate,\n embeddedCandidateArtifact,\n sha256Bytes,\n} from './digest'\nimport { isWellFormedUnicode } from './exact-object'\nimport {\n assertNoGitIndirection,\n readCandidateGitTreeFiles,\n runCandidateGit,\n} from './git-materialize'\nimport { persistCandidateOutputArtifact } from './output-artifacts'\nimport type {\n AgentCandidateExecutorWorkspaceFile,\n AgentCandidateOutputArtifactPort,\n AgentCandidateWorkspacePort,\n} from './types'\n\nconst archiveKind = 'agent-candidate-workspace-archive' as const\nconst workspaceEntryPrefix = 'workspace/'\nconst repositoryMetadataEntry = 'metadata/repository.json'\nconst repositoryBundleEntry = 'metadata/repository.bundle'\nconst fixedTarTime = new Date(0)\n\nexport interface AgentCandidateWorkspaceArchiveLimits {\n maxArchiveBytes: number\n maxEmbeddedArtifactBytes: number\n maxFiles: number\n maxFileBytes: number\n maxTotalFileBytes: number\n maxPathBytes: number\n maxRepositoryBundleBytes: number\n}\n\nconst defaultLimits: AgentCandidateWorkspaceArchiveLimits = Object.freeze({\n maxArchiveBytes: 512 * 1024 * 1024,\n maxEmbeddedArtifactBytes: 1024 * 1024,\n maxFiles: 50_000,\n maxFileBytes: 128 * 1024 * 1024,\n maxTotalFileBytes: 256 * 1024 * 1024,\n maxPathBytes: 4_096,\n maxRepositoryBundleBytes: 128 * 1024 * 1024,\n})\n\ninterface WorkspaceArchiveRepository {\n headCommit: string\n headTree: string\n bundle: {\n sha256: `sha256:${string}`\n byteLength: number\n bytes: Uint8Array\n }\n}\n\ninterface WorkspaceArchiveRepositoryMetadata {\n kind: typeof archiveKind\n headCommit: string\n headTree: string\n bundle: {\n sha256: `sha256:${string}`\n byteLength: number\n }\n}\n\ninterface DecodedWorkspaceArchive {\n files: Array<{ path: string; mode: number; bytes: Uint8Array }>\n repository?: WorkspaceArchiveRepository\n}\n\nexport interface CaptureAgentCandidateWorkspaceOptions {\n /** Include Git HEAD so task preparation can prove its exact commit and tree. */\n includeRepository?: boolean\n limits?: Partial<AgentCandidateWorkspaceArchiveLimits>\n /** Use the evaluator-owned artifact store when manifest or archive bytes should not be embedded. */\n artifactPersistence?: {\n executionId: string\n outputArtifacts: AgentCandidateOutputArtifactPort\n signal?: AbortSignal\n }\n}\n\nexport interface CreateAgentCandidateWorkspacePortOptions {\n limits?: Partial<AgentCandidateWorkspaceArchiveLimits>\n}\n\nexport interface CapturedAgentCandidateWorkspace {\n readonly snapshot: AgentCandidateWorkspaceSnapshotEvidence\n /** Caller-owned bytes accepted by createAgentCandidateWorkspacePort. */\n readonly archive: Uint8Array\n}\n\n/** Capture one exact regular-file workspace for immutable candidate execution. */\nexport async function captureAgentCandidateWorkspace(\n rootInput: string,\n options: CaptureAgentCandidateWorkspaceOptions = {},\n): Promise<CapturedAgentCandidateWorkspace> {\n const root = resolve(rootInput)\n const limits = workspaceLimits(options.limits)\n const captured = options.includeRepository\n ? await captureRepository(root, limits)\n : await captureMaterializedWorkspace(root, {\n limits: {\n maxFiles: limits.maxFiles,\n maxFileBytes: limits.maxFileBytes,\n maxTotalFileBytes: limits.maxTotalFileBytes,\n },\n })\n assertWorkspaceFilesWithinLimits(captured.files, limits)\n const repository = 'repository' in captured ? captured.repository : undefined\n return captureWorkspaceFiles(captured.files, repository, limits, options.artifactPersistence)\n}\n\n/** Capture detached files returned by a remote executor into the standard archive. */\nexport async function captureAgentCandidateWorkspaceFiles(\n input: readonly AgentCandidateExecutorWorkspaceFile[],\n options: Omit<CaptureAgentCandidateWorkspaceOptions, 'includeRepository'> = {},\n): Promise<CapturedAgentCandidateWorkspace> {\n const limits = workspaceLimits(options.limits)\n return captureWorkspaceFiles(\n normalizeWorkspaceFiles(input, limits),\n undefined,\n limits,\n options.artifactPersistence,\n )\n}\n\nasync function captureWorkspaceFiles(\n files: readonly AgentCandidateExecutorWorkspaceFile[],\n repository: WorkspaceArchiveRepository | undefined,\n limits: AgentCandidateWorkspaceArchiveLimits,\n artifactPersistence: CaptureAgentCandidateWorkspaceOptions['artifactPersistence'],\n): Promise<CapturedAgentCandidateWorkspace> {\n const material = candidateWorkspaceManifest(files)\n const manifest = canonicalCandidateBytes(material)\n const archive = await encodeWorkspaceArchive(files, repository, limits.maxArchiveBytes)\n if (\n !artifactPersistence &&\n (manifest.byteLength > limits.maxEmbeddedArtifactBytes ||\n archive.byteLength > limits.maxEmbeddedArtifactBytes)\n ) {\n throw new Error(\n 'candidate workspace artifacts exceed maxEmbeddedArtifactBytes; artifactPersistence is required',\n )\n }\n const manifestArtifact = await captureWorkspaceArtifact('manifest', manifest, artifactPersistence)\n const archiveArtifact = await captureWorkspaceArtifact('archive', archive, artifactPersistence)\n const snapshot = deepFreezeCandidate({\n kind: 'agent-candidate-workspace-snapshot',\n digest: canonicalCandidateDigest(material),\n material,\n manifest: manifestArtifact,\n archive: archiveArtifact,\n } satisfies AgentCandidateWorkspaceSnapshotEvidence)\n return Object.freeze({ snapshot, archive })\n}\n\nasync function captureWorkspaceArtifact(\n kind: 'manifest' | 'archive',\n bytes: Uint8Array,\n persistence: CaptureAgentCandidateWorkspaceOptions['artifactPersistence'],\n): Promise<AgentCandidateCapturedArtifact> {\n if (!persistence) return embeddedCandidateArtifact(bytes)\n if (!persistence.executionId.trim()) {\n throw new Error('candidate workspace artifact persistence requires an executionId')\n }\n return persistCandidateOutputArtifact(persistence.outputArtifacts, {\n executionId: persistence.executionId,\n purpose: kind === 'manifest' ? 'candidate-workspace-manifest' : 'candidate-workspace-archive',\n bytes,\n ...(persistence.signal ? { signal: persistence.signal } : {}),\n })\n}\n\n/** Create the standard bounded materializer for candidate execution ports. */\nexport function createAgentCandidateWorkspacePort(\n options: CreateAgentCandidateWorkspacePortOptions = {},\n): AgentCandidateWorkspacePort {\n const limits = workspaceLimits(options.limits)\n const port: AgentCandidateWorkspacePort = {\n materialize: async ({ role, snapshot, archive, destination }) => {\n await materializeAgentCandidateWorkspace({\n role,\n snapshot,\n archive,\n destination,\n limits,\n })\n },\n }\n return Object.freeze(port)\n}\n\nasync function materializeAgentCandidateWorkspace(input: {\n role: 'task' | 'candidate' | 'knowledge' | 'memory'\n snapshot: AgentCandidateWorkspaceSnapshotEvidence\n archive: Uint8Array\n destination: string\n limits: AgentCandidateWorkspaceArchiveLimits\n}): Promise<void> {\n const decoded = await decodeVerifiedWorkspaceArchive(input)\n const destination = resolve(input.destination)\n await prepareEmptyDestination(destination)\n const staging = await mkdtemp(`${destination}.materializing-`)\n try {\n await writeWorkspaceFiles(staging, decoded.files)\n if (decoded.repository) {\n await materializeRepository(decoded.repository, staging)\n }\n await verifyMaterializedWorkspace(staging, input.snapshot.material, {\n ignoredProtectedRootEntries: decoded.repository ? ['.git'] : [],\n })\n await rename(staging, destination)\n } catch (error) {\n await rm(staging, { recursive: true, force: true })\n await rm(destination, { recursive: true, force: true })\n throw error\n }\n}\n\n/** Verify a portable archive before its source environment may be discarded. */\nexport async function verifyAgentCandidateWorkspaceArchive(input: {\n role: 'task' | 'candidate' | 'knowledge' | 'memory'\n snapshot: AgentCandidateWorkspaceSnapshotEvidence\n archive: Uint8Array\n limits?: Partial<AgentCandidateWorkspaceArchiveLimits>\n}): Promise<void> {\n await decodeVerifiedWorkspaceArchive({ ...input, limits: workspaceLimits(input.limits) })\n}\n\nasync function decodeVerifiedWorkspaceArchive(input: {\n role: 'task' | 'candidate' | 'knowledge' | 'memory'\n snapshot: AgentCandidateWorkspaceSnapshotEvidence\n archive: Uint8Array\n limits: AgentCandidateWorkspaceArchiveLimits\n}): Promise<DecodedWorkspaceArchive> {\n verifyBytes(\n input.archive,\n input.snapshot.archive.sha256,\n input.snapshot.archive.byteLength,\n 'candidate workspace archive',\n )\n const decoded = await parseWorkspaceArchive(input.archive, input.limits)\n if (decoded.repository && input.role !== 'task') {\n throw new Error('only task workspaces may carry a Git repository')\n }\n assertArchiveMatchesSnapshot(decoded.files, input.snapshot)\n return decoded\n}\n\nasync function captureRepository(\n requestedRoot: string,\n limits: AgentCandidateWorkspaceArchiveLimits,\n): Promise<{\n files: Array<{ path: string; mode: number; bytes: Uint8Array }>\n repository: WorkspaceArchiveRepository\n}> {\n const requestedStats = await lstat(requestedRoot)\n if (!requestedStats.isDirectory() || requestedStats.isSymbolicLink()) {\n throw new Error('candidate repository root must be a real directory')\n }\n // Capture the RESOLVED root. The property this guards is that capture starts at one real\n // worktree root with no aliasing, which resolving satisfies directly — rejecting a symlinked\n // prefix outright does not, and makes capture impossible on macOS, where the OS itself hands\n // out temp paths under /var, a symlink to /private/var. Git reports a resolved path, so the\n // worktree-root comparison below needs the resolved form on both sides.\n const root = await realpath(requestedRoot)\n const resolvedStats = await lstat(root)\n if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) {\n throw new Error('candidate repository root must resolve to a real directory')\n }\n const topLevel = (await runCandidateGit(root, ['rev-parse', '--show-toplevel'])).stdout\n .toString('utf8')\n .trim()\n if ((await realpath(resolve(topLevel))) !== root) {\n throw new Error('candidate repository capture must start at the Git worktree root')\n }\n const gitDir = resolve(\n (await runCandidateGit(root, ['rev-parse', '--absolute-git-dir'])).stdout\n .toString('utf8')\n .trim(),\n )\n if ((await realpath(gitDir)) !== gitDir || gitDir.includes(':')) {\n throw new Error('candidate repository Git object store has an unsupported path')\n }\n await assertNoGitIndirection(root, gitDir, 'candidate repository')\n const headCommit = (await runCandidateGit(root, ['rev-parse', 'HEAD'])).stdout\n .toString('utf8')\n .trim()\n const headTree = (await runCandidateGit(root, ['rev-parse', 'HEAD^{tree}'])).stdout\n .toString('utf8')\n .trim()\n assertGitObjectId(headCommit, 'HEAD')\n assertGitObjectId(headTree, 'HEAD tree')\n if (headCommit.length !== headTree.length) {\n throw new Error('candidate repository HEAD and tree use different object formats')\n }\n const files = await readCandidateGitTreeFiles(root, headTree, {}, limits)\n assertWorkspaceFilesWithinLimits(files, limits)\n const reachableBytesText = (\n await runCandidateGit(root, ['rev-list', '--disk-usage', '--objects', 'HEAD'])\n ).stdout\n .toString('utf8')\n .trim()\n const reachableBytes = Number(reachableBytesText)\n if (!Number.isSafeInteger(reachableBytes) || reachableBytes < 0) {\n throw new Error('candidate repository reachable size is invalid')\n }\n if (reachableBytes > limits.maxRepositoryBundleBytes) {\n throw new Error('candidate repository exceeds maxRepositoryBundleBytes')\n }\n const temporary = await mkdtemp(join(tmpdir(), 'agent-candidate-workspace-bundle-'))\n const bundlePath = join(temporary, `${randomUUID()}.bundle`)\n try {\n await runCandidateGit(root, ['bundle', 'create', bundlePath, 'HEAD'])\n const bundle = Uint8Array.from(await readFile(bundlePath))\n if (bundle.byteLength > limits.maxRepositoryBundleBytes) {\n throw new Error('candidate repository bundle exceeds maxRepositoryBundleBytes')\n }\n return {\n files,\n repository: {\n headCommit,\n headTree,\n bundle: {\n sha256: sha256Bytes(bundle),\n byteLength: bundle.byteLength,\n bytes: bundle,\n },\n },\n }\n } finally {\n await rm(temporary, { recursive: true, force: true })\n }\n}\n\nasync function encodeWorkspaceArchive(\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n repository: WorkspaceArchiveRepository | undefined,\n maxArchiveBytes: number,\n): Promise<Uint8Array> {\n const archive = pack()\n const output = collectStream(archive, maxArchiveBytes, 'candidate workspace archive')\n try {\n await writeWorkspaceArchiveEntries(archive, files, repository)\n archive.finalize()\n return await output\n } catch (error) {\n archive.destroy(error instanceof Error ? error : new Error(String(error)))\n await output.catch(() => undefined)\n throw error\n }\n}\n\nasync function verifyCanonicalWorkspaceArchive(\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n repository: WorkspaceArchiveRepository | undefined,\n expected: Uint8Array,\n maxArchiveBytes: number,\n): Promise<void> {\n const archive = pack()\n const comparison = streamEqualsBytes(\n archive,\n expected,\n maxArchiveBytes,\n 'candidate workspace archive',\n )\n try {\n await writeWorkspaceArchiveEntries(archive, files, repository)\n archive.finalize()\n if (!(await comparison)) throw new Error('candidate workspace tar is not canonical')\n } catch (error) {\n archive.destroy(error instanceof Error ? error : new Error(String(error)))\n await comparison.catch(() => undefined)\n throw error\n }\n}\n\nasync function writeWorkspaceArchiveEntries(\n archive: Pack,\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n repository: WorkspaceArchiveRepository | undefined,\n): Promise<void> {\n for (const file of files) {\n await writeTarEntry(archive, `${workspaceEntryPrefix}${file.path}`, file.mode, file.bytes)\n }\n if (!repository) return\n const metadata = canonicalCandidateBytes({\n kind: archiveKind,\n headCommit: repository.headCommit,\n headTree: repository.headTree,\n bundle: {\n sha256: repository.bundle.sha256,\n byteLength: repository.bundle.byteLength,\n },\n } satisfies WorkspaceArchiveRepositoryMetadata)\n await writeTarEntry(archive, repositoryMetadataEntry, 0o600, metadata)\n await writeTarEntry(archive, repositoryBundleEntry, 0o600, repository.bundle.bytes)\n}\n\nasync function parseWorkspaceArchive(\n bytes: Uint8Array,\n limits: AgentCandidateWorkspaceArchiveLimits,\n): Promise<DecodedWorkspaceArchive> {\n if (bytes.byteLength > limits.maxArchiveBytes) {\n throw new Error('candidate workspace archive exceeds maxArchiveBytes')\n }\n const parser = extract()\n const files: DecodedWorkspaceArchive['files'] = []\n const observedEntryNames = new Set<string>()\n const observedPaths = new Set<string>()\n let totalBytes = 0\n let retainedEntryBytes = 0\n let previousPath: string | undefined\n let repositoryMetadata: WorkspaceArchiveRepositoryMetadata | undefined\n let repositoryBundle: Uint8Array | undefined\n const decoded = (async () => {\n for await (const entry of parser) {\n const name = entry.header.name\n if (\n entry.header.type !== 'file' ||\n typeof name !== 'string' ||\n observedEntryNames.has(name)\n ) {\n throw new Error('candidate workspace tar contains an invalid entry')\n }\n observedEntryNames.add(name)\n if (name.startsWith(workspaceEntryPrefix)) {\n if (files.length >= limits.maxFiles) {\n throw new Error('candidate workspace archive has an invalid file count')\n }\n const path = safeArchivePath(name.slice(workspaceEntryPrefix.length), limits.maxPathBytes)\n if (!isWorkspaceFileMode(entry.header.mode)) {\n throw new Error(`candidate workspace archive has an unsupported mode: ${path}`)\n }\n assertRetainedArchiveSize(bytes.byteLength, retainedEntryBytes, entry.header.size, limits)\n const fileBytes = await readTarEntry(entry, limits.maxFileBytes, `workspace file ${path}`)\n retainedEntryBytes += fileBytes.byteLength\n assertWorkspacePathOrder(\n path,\n previousPath,\n observedPaths,\n 'candidate workspace archive paths must be unique and sorted',\n )\n previousPath = path\n if (fileBytes.byteLength > limits.maxTotalFileBytes - totalBytes) {\n throw new Error('candidate workspace archive exceeds maxTotalFileBytes')\n }\n totalBytes += fileBytes.byteLength\n files.push({ path, mode: entry.header.mode, bytes: fileBytes })\n } else if (name === repositoryMetadataEntry) {\n if (entry.header.mode !== 0o600 || repositoryMetadata) {\n throw new Error('candidate workspace archive repository metadata is invalid')\n }\n assertRetainedArchiveSize(bytes.byteLength, retainedEntryBytes, entry.header.size, limits)\n const metadataBytes = await readTarEntry(\n entry,\n limits.maxPathBytes,\n 'candidate repository metadata',\n )\n retainedEntryBytes += metadataBytes.byteLength\n repositoryMetadata = parseRepositoryMetadata(metadataBytes, limits.maxRepositoryBundleBytes)\n } else if (name === repositoryBundleEntry) {\n if (entry.header.mode !== 0o600 || repositoryBundle) {\n throw new Error('candidate workspace archive repository bundle is invalid')\n }\n assertRetainedArchiveSize(bytes.byteLength, retainedEntryBytes, entry.header.size, limits)\n repositoryBundle = await readTarEntry(\n entry,\n limits.maxRepositoryBundleBytes,\n 'candidate Git bundle',\n )\n retainedEntryBytes += repositoryBundle.byteLength\n } else {\n throw new Error(`candidate workspace tar contains an unsupported entry: ${name}`)\n }\n }\n if (Boolean(repositoryMetadata) !== Boolean(repositoryBundle)) {\n throw new Error('candidate workspace archive repository evidence is incomplete')\n }\n const repository =\n repositoryMetadata && repositoryBundle\n ? repositoryFromTar(repositoryMetadata, repositoryBundle)\n : undefined\n return { files, ...(repository ? { repository } : {}) }\n })()\n parser.end(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength))\n const result = await decoded\n await verifyCanonicalWorkspaceArchive(\n result.files,\n result.repository,\n bytes,\n limits.maxArchiveBytes,\n )\n return result\n}\n\nfunction assertRetainedArchiveSize(\n archiveBytes: number,\n retainedEntryBytes: number,\n entryBytes: number | undefined,\n limits: AgentCandidateWorkspaceArchiveLimits,\n): void {\n if (\n !Number.isSafeInteger(entryBytes) ||\n entryBytes === undefined ||\n entryBytes < 0 ||\n entryBytes > limits.maxArchiveBytes - archiveBytes - retainedEntryBytes\n ) {\n throw new Error('candidate workspace archive exceeds maxArchiveBytes while decoding')\n }\n}\n\nfunction parseRepositoryMetadata(\n bytes: Uint8Array,\n maxBundleBytes: number,\n): WorkspaceArchiveRepositoryMetadata {\n let value: unknown\n try {\n value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes))\n } catch (error) {\n throw new Error('candidate workspace archive repository metadata is invalid', { cause: error })\n }\n if (\n !isRecord(value) ||\n Object.keys(value).sort().join(',') !== 'bundle,headCommit,headTree,kind' ||\n value.kind !== archiveKind ||\n typeof value.headCommit !== 'string' ||\n typeof value.headTree !== 'string' ||\n !isRecord(value.bundle) ||\n Object.keys(value.bundle).sort().join(',') !== 'byteLength,sha256' ||\n typeof value.bundle.sha256 !== 'string' ||\n !/^sha256:[a-f0-9]{64}$/.test(value.bundle.sha256) ||\n !Number.isSafeInteger(value.bundle.byteLength) ||\n (value.bundle.byteLength as number) <= 0 ||\n (value.bundle.byteLength as number) > maxBundleBytes\n ) {\n throw new Error('candidate workspace archive repository is invalid')\n }\n if (!Buffer.from(canonicalCandidateBytes(value)).equals(Buffer.from(bytes))) {\n throw new Error('candidate workspace archive repository metadata is not canonical')\n }\n assertGitObjectId(value.headCommit, 'repository HEAD')\n assertGitObjectId(value.headTree, 'repository HEAD tree')\n if (value.headCommit.length !== value.headTree.length) {\n throw new Error('candidate repository HEAD and tree use different object formats')\n }\n return {\n kind: archiveKind,\n headCommit: value.headCommit,\n headTree: value.headTree,\n bundle: {\n sha256: value.bundle.sha256 as `sha256:${string}`,\n byteLength: value.bundle.byteLength as number,\n },\n }\n}\n\nfunction repositoryFromTar(\n metadata: WorkspaceArchiveRepositoryMetadata,\n bundle: Uint8Array,\n): WorkspaceArchiveRepository {\n verifyBytes(bundle, metadata.bundle.sha256, metadata.bundle.byteLength, 'candidate Git bundle')\n return {\n headCommit: metadata.headCommit,\n headTree: metadata.headTree,\n bundle: { ...metadata.bundle, bytes: bundle },\n }\n}\n\nasync function writeTarEntry(\n archive: Pack,\n name: string,\n mode: number,\n bytes: Uint8Array,\n): Promise<void> {\n await new Promise<void>((resolveEntry, rejectEntry) => {\n archive.entry(\n {\n name,\n mode,\n uid: 0,\n gid: 0,\n size: bytes.byteLength,\n mtime: fixedTarTime,\n type: 'file',\n uname: '',\n gname: '',\n },\n Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength),\n (error) => (error ? rejectEntry(error) : resolveEntry()),\n )\n })\n}\n\ntype TarEntry = TarExtract extends AsyncIterable<infer Entry> ? Entry : never\n\nasync function readTarEntry(entry: TarEntry, maxBytes: number, label: string): Promise<Uint8Array> {\n const size = entry.header.size\n if (!Number.isSafeInteger(size) || size === undefined || size < 0 || size > maxBytes) {\n throw new Error(`${label} has an invalid tar size`)\n }\n const bytes = await collectStream(entry, maxBytes, label)\n if (bytes.byteLength !== size) throw new Error(`${label} differs from its tar size`)\n return bytes\n}\n\nasync function collectStream(\n stream: AsyncIterable<unknown>,\n maxBytes: number,\n label: string,\n): Promise<Uint8Array> {\n const chunks: Buffer[] = []\n let totalBytes = 0\n for await (const chunk of stream) {\n if (!(chunk instanceof Uint8Array)) {\n throw new Error(`${label} emitted a non-byte chunk`)\n }\n if (chunk.byteLength > maxBytes - totalBytes) {\n const error = new Error(`${label} exceeds its size limit`)\n if ('destroy' in stream && typeof stream.destroy === 'function') stream.destroy(error)\n throw error\n }\n const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)\n chunks.push(bytes)\n totalBytes += bytes.byteLength\n }\n return Buffer.concat(chunks, totalBytes)\n}\n\nasync function streamEqualsBytes(\n stream: AsyncIterable<unknown>,\n expected: Uint8Array,\n maxBytes: number,\n label: string,\n): Promise<boolean> {\n const expectedBuffer = Buffer.from(expected.buffer, expected.byteOffset, expected.byteLength)\n let equal = true\n let offset = 0\n for await (const chunk of stream) {\n if (!(chunk instanceof Uint8Array)) {\n throw new Error(`${label} emitted a non-byte chunk`)\n }\n if (chunk.byteLength > maxBytes - offset) {\n const error = new Error(`${label} exceeds its size limit`)\n if ('destroy' in stream && typeof stream.destroy === 'function') stream.destroy(error)\n throw error\n }\n const observed = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)\n if (\n offset + observed.byteLength > expectedBuffer.byteLength ||\n !observed.equals(expectedBuffer.subarray(offset, offset + observed.byteLength))\n ) {\n equal = false\n }\n offset += observed.byteLength\n }\n return equal && offset === expectedBuffer.byteLength\n}\n\nasync function prepareEmptyDestination(destination: string): Promise<void> {\n await mkdir(destination, { recursive: true, mode: 0o700 })\n const stats = await lstat(destination)\n if (!stats.isDirectory() || stats.isSymbolicLink()) {\n throw new Error('candidate workspace destination must be a real directory')\n }\n // A symlinked PREFIX is the OS's own doing on macOS, where temp paths live under /var, a\n // symlink to /private/var. What must hold is that the destination itself is a real\n // directory, which both this check and the lstat above require.\n const resolvedDestination = await realpath(destination)\n const resolvedStats = await lstat(resolvedDestination)\n if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) {\n throw new Error('candidate workspace destination must resolve to a real directory')\n }\n if ((await readdir(destination)).length > 0) {\n throw new Error('candidate workspace destination must be empty')\n }\n}\n\nasync function writeWorkspaceFiles(\n destination: string,\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n): Promise<void> {\n for (const file of files) {\n const path = workspacePath(destination, file.path)\n await mkdir(dirname(path), { recursive: true, mode: 0o700 })\n const descriptor = await open(\n path,\n fsConstants.O_WRONLY |\n fsConstants.O_CREAT |\n fsConstants.O_EXCL |\n (typeof fsConstants.O_NOFOLLOW === 'number' ? fsConstants.O_NOFOLLOW : 0),\n 0o600,\n )\n try {\n await descriptor.writeFile(file.bytes)\n const stats = await descriptor.stat()\n if (!stats.isFile() || stats.nlink !== 1) {\n throw new Error(`candidate workspace file identity changed while writing: ${file.path}`)\n }\n await descriptor.chmod(file.mode)\n } finally {\n await descriptor.close()\n }\n }\n}\n\nasync function materializeRepository(\n repository: WorkspaceArchiveRepository,\n destination: string,\n): Promise<void> {\n const temporary = await mkdtemp(join(tmpdir(), 'agent-candidate-workspace-bundle-'))\n const bundlePath = join(temporary, `${randomUUID()}.bundle`)\n try {\n await writeFile(bundlePath, repository.bundle.bytes, { flag: 'wx', mode: 0o600 })\n await runCandidateGit(destination, [\n 'init',\n '--quiet',\n '--initial-branch=candidate',\n `--object-format=${repository.headCommit.length === 64 ? 'sha256' : 'sha1'}`,\n ])\n await runCandidateGit(destination, ['bundle', 'verify', bundlePath])\n await runCandidateGit(destination, ['bundle', 'unbundle', bundlePath])\n const objectType = (\n await runCandidateGit(destination, ['cat-file', '-t', repository.headCommit])\n ).stdout\n .toString('utf8')\n .trim()\n if (objectType !== 'commit') throw new Error('candidate repository HEAD is not a commit')\n const observedTree = (\n await runCandidateGit(destination, ['rev-parse', `${repository.headCommit}^{tree}`])\n ).stdout\n .toString('utf8')\n .trim()\n if (observedTree !== repository.headTree) {\n throw new Error('candidate repository bundle HEAD tree changed')\n }\n await runCandidateGit(destination, ['update-ref', '--no-deref', 'HEAD', repository.headCommit])\n await runCandidateGit(destination, ['read-tree', repository.headTree])\n const status = (\n await runCandidateGit(destination, ['status', '--porcelain=v1', '--untracked-files=all'])\n ).stdout\n .toString('utf8')\n .trim()\n if (status) throw new Error('candidate repository files do not exactly match HEAD')\n } finally {\n await rm(temporary, { recursive: true, force: true })\n }\n}\n\nfunction assertArchiveMatchesSnapshot(\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n snapshot: AgentCandidateWorkspaceSnapshotEvidence,\n): void {\n const material = candidateWorkspaceManifest(files)\n const materialBytes = canonicalCandidateBytes(material)\n verifyBytes(\n materialBytes,\n snapshot.manifest.sha256,\n snapshot.manifest.byteLength,\n 'candidate workspace manifest',\n )\n if (\n canonicalCandidateDigest(material) !== snapshot.digest ||\n !Buffer.from(materialBytes).equals(Buffer.from(canonicalCandidateBytes(snapshot.material)))\n ) {\n throw new Error('candidate workspace archive does not match its snapshot manifest')\n }\n}\n\nfunction assertWorkspaceFilesWithinLimits(\n files: ReadonlyArray<{ path: string; mode: number; bytes: Uint8Array }>,\n limits: AgentCandidateWorkspaceArchiveLimits,\n): void {\n if (files.length > limits.maxFiles) {\n throw new Error('candidate workspace exceeds maxFiles')\n }\n let totalBytes = 0\n let previousPath: string | undefined\n const observedPaths = new Set<string>()\n for (const file of files) {\n const path = safeArchivePath(file.path, limits.maxPathBytes)\n assertWorkspacePathOrder(\n path,\n previousPath,\n observedPaths,\n 'candidate workspace paths must be unique and sorted',\n )\n previousPath = path\n if (!isWorkspaceFileMode(file.mode)) {\n throw new Error(`candidate workspace file has unsupported mode: ${path}`)\n }\n if (file.bytes.byteLength > limits.maxFileBytes) {\n throw new Error(`candidate workspace file exceeds maxFileBytes: ${path}`)\n }\n totalBytes += file.bytes.byteLength\n if (totalBytes > limits.maxTotalFileBytes) {\n throw new Error('candidate workspace exceeds maxTotalFileBytes')\n }\n }\n}\n\nfunction normalizeWorkspaceFiles(\n input: readonly AgentCandidateExecutorWorkspaceFile[],\n limits: AgentCandidateWorkspaceArchiveLimits,\n): AgentCandidateExecutorWorkspaceFile[] {\n if (!Array.isArray(input)) {\n throw new Error('candidate workspace files must be an array')\n }\n const fileCount = input.length\n if (fileCount > limits.maxFiles) {\n throw new Error('candidate workspace exceeds maxFiles')\n }\n let totalBytes = 0\n const files: AgentCandidateExecutorWorkspaceFile[] = []\n for (let index = 0; index < fileCount; index++) {\n const inputFile = input[index]\n if (!isRecord(inputFile) || Object.keys(inputFile).sort().join(',') !== 'bytes,mode,path') {\n throw new Error(`candidate workspace file ${index} is invalid`)\n }\n const descriptors = Object.getOwnPropertyDescriptors(inputFile)\n if (\n !('value' in (descriptors.path ?? {})) ||\n !('value' in (descriptors.mode ?? {})) ||\n !('value' in (descriptors.bytes ?? {}))\n ) {\n throw new Error(`candidate workspace file ${index} must use fixed values`)\n }\n const path = safeArchivePath(descriptors.path?.value, limits.maxPathBytes)\n const mode = descriptors.mode?.value\n const inputBytes = descriptors.bytes?.value\n if (!isWorkspaceFileMode(mode)) {\n throw new Error(`candidate workspace file has unsupported mode: ${path}`)\n }\n const view = inspectWorkspaceBytes(inputBytes, path)\n if (view.byteLength > limits.maxFileBytes) {\n throw new Error(`candidate workspace file exceeds maxFileBytes: ${path}`)\n }\n if (view.byteLength > limits.maxTotalFileBytes - totalBytes) {\n throw new Error('candidate workspace exceeds maxTotalFileBytes')\n }\n if (view.byteLength > Math.max(0, limits.maxArchiveBytes - 1024)) {\n throw new Error('candidate workspace archive exceeds maxArchiveBytes')\n }\n totalBytes += view.byteLength\n files.push({ path, mode, bytes: detachWorkspaceBytes(view) })\n }\n files.sort((left, right) => (left.path < right.path ? -1 : left.path > right.path ? 1 : 0))\n assertWorkspaceFilesWithinLimits(files, limits)\n return files\n}\n\nfunction isWorkspaceFileMode(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 0 && (value as number) <= 0o777\n}\n\nfunction workspaceLimits(\n overrides: Partial<AgentCandidateWorkspaceArchiveLimits> | undefined,\n): AgentCandidateWorkspaceArchiveLimits {\n const limits = { ...defaultLimits, ...overrides }\n for (const [name, value] of Object.entries(limits)) {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`candidate workspace ${name} must be a positive safe integer`)\n }\n }\n return Object.freeze(limits)\n}\n\nfunction safeArchivePath(value: unknown, maxPathBytes: number): string {\n if (\n typeof value !== 'string' ||\n !value ||\n !isWellFormedUnicode(value) ||\n Buffer.byteLength(value, 'utf8') > maxPathBytes ||\n isAbsolute(value) ||\n win32.isAbsolute(value) ||\n value.includes('\\\\') ||\n value.includes('\\0') ||\n hasControlCharacter(value) ||\n value.split('/').some((part) => !part || part === '.' || part === '..') ||\n ['.git', '.sidecar'].includes(value.split('/')[0]?.toLowerCase() ?? '')\n ) {\n throw new Error(`candidate workspace archive contains an unsafe path: ${String(value)}`)\n }\n return value\n}\n\nfunction assertWorkspacePathOrder(\n path: string,\n previousPath: string | undefined,\n observedPaths: Set<string>,\n errorMessage: string,\n): void {\n if (previousPath !== undefined && previousPath >= path) throw new Error(errorMessage)\n for (let slash = path.indexOf('/'); slash !== -1; slash = path.indexOf('/', slash + 1)) {\n if (observedPaths.has(path.slice(0, slash))) throw new Error(errorMessage)\n }\n observedPaths.add(path)\n}\n\nfunction inspectWorkspaceBytes(\n input: unknown,\n path: string,\n): { buffer: ArrayBuffer; byteOffset: number; byteLength: number } {\n let buffer: ArrayBufferLike\n let byteOffset: number\n let byteLength: number\n try {\n buffer = typedArrayBufferGetter.call(input as Uint8Array) as ArrayBufferLike\n byteOffset = typedArrayByteOffsetGetter.call(input as Uint8Array) as number\n byteLength = typedArrayByteLengthGetter.call(input as Uint8Array) as number\n } catch {\n throw new Error(`candidate workspace file bytes are invalid: ${path}`)\n }\n if (isSharedArrayBuffer(buffer)) {\n throw new Error(`candidate workspace file uses shared bytes: ${path}`)\n }\n if (!isAnyArrayBuffer(buffer)) {\n throw new Error(`candidate workspace file bytes are invalid: ${path}`)\n }\n return { buffer, byteOffset, byteLength }\n}\n\nfunction detachWorkspaceBytes(input: {\n buffer: ArrayBuffer\n byteOffset: number\n byteLength: number\n}): Uint8Array {\n const { buffer, byteOffset, byteLength } = input\n const copy = new Uint8Array(byteLength)\n Uint8Array.prototype.set.call(copy, new Uint8Array(buffer, byteOffset, byteLength))\n return copy\n}\n\nfunction workspacePath(root: string, relativePath: string): string {\n const path = resolve(root, relativePath)\n if (!path.startsWith(`${root}${sep}`)) {\n throw new Error(`candidate workspace archive path escapes its destination: ${relativePath}`)\n }\n return path\n}\n\nfunction assertGitObjectId(value: string, label: string): void {\n if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value)) {\n throw new Error(`candidate repository ${label} is not a Git object id`)\n }\n}\n\nfunction hasControlCharacter(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index)\n if (code < 0x20 || code === 0x7f) return true\n }\n return false\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\ntype TypedArrayGetter = (this: Uint8Array) => unknown\n\nfunction requireTypedArrayGetter(name: 'buffer' | 'byteOffset' | 'byteLength'): TypedArrayGetter {\n const typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype) as object\n const getter = Object.getOwnPropertyDescriptor(typedArrayPrototype, name)?.get\n if (!getter) throw new Error(`typed array intrinsic ${name} accessor is unavailable`)\n return getter\n}\n\nconst typedArrayBufferGetter = requireTypedArrayGetter('buffer')\nconst typedArrayByteOffsetGetter = requireTypedArrayGetter('byteOffset')\nconst typedArrayByteLengthGetter = requireTypedArrayGetter('byteLength')\n"],"mappings":";;;;;;;;;;;AAYA,SAAgBA,cAAY,OAAiC;CAC3D,OAAO,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AAClE;AAEA,SAAgBC,2BAAyB,OAA8B;CACrE,OAAOD,cAAYE,0BAAwB,KAAK,CAAC;AACnD;;AAGA,SAAgB,wBAA2B,OAAa;CACtD,OAAO,oBACL,KAAK,MAAM,OAAO,KAAKA,0BAAwB,KAAK,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,CACzE;AACF;AAEA,SAAgB,2BACd,oBAC+B;CAC/B,MAAM,QAAQA,0BAAwB,kBAAkB;CACxD,MAAM,SAASF,cAAY,KAAK;CAChC,MAAM,QAAQ,oBAAoB;EAChC,GAAG,KAAK,MAAM,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC;EACjD;CACF,CAAC;CACD,OAAO,OAAO,OAAO;EACnB;EACA,IAAI,QAAoB;GACtB,OAAO,WAAW,KAAK,KAAK;EAC9B;EACA;CACF,CAAC;AACH;AAEA,SAAgB,iCACd,OACA,OACG;CACH,IAAIC,2BAAyB,mBAAmB,KAAK,CAAC,MAAM,MAAM,QAChE,MAAM,IAAI,MAAM,GAAG,MAAM,uBAAuB;CAElD,OAAO,wBAAwB,KAAK;AACtC;AAEA,SAAgB,0BAA0B,OAAmD;CAC3F,OAAO;EACL,UAAU;EACV,SAAS,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAC7C,QAAQD,cAAY,KAAK;EACzB,YAAY,MAAM;CACpB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cAAc;CAE7F,OAAO;AACT;AAEA,SAAS,kBAAkB,OAAe,OAAqB;CAC7D,IAAI,CAAC,kCAAkC,KAAK,KAAK,GAC/C,MAAM,IAAI,MAAM,wBAAwB,MAAM,wBAAwB;AAE1E;AAEA,SAAS,oBAAoB,OAAwB;CACnD,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAO,MAAM,WAAW,KAAK;EACnC,IAAI,OAAO,MAAQ,SAAS,KAAM,OAAO;CAC3C;CACA,OAAO;AACT;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAIA,SAAS,wBAAwB,MAAgE;CAC/F,MAAM,sBAAsB,OAAO,eAAe,WAAW,SAAS;CACtE,MAAM,SAAS,OAAO,yBAAyB,qBAAqB,IAAI,CAAC,EAAE;CAC3E,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,yBAAyB,KAAK,yBAAyB;CACpF,OAAO;AACT;AAEA,MAAM,yBAAyB,wBAAwB,QAAQ;AAC/D,MAAM,6BAA6B,wBAAwB,YAAY;AACvE,MAAM,6BAA6B,wBAAwB,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.283.0",
|
|
4
4
|
"description": "Shared task-lifecycle skeleton for agents: a recursive loop kernel for chat turns, one-shot tasks, and multi-attempt loops, with trace capture and eval-gated self-improvement. Domain behavior lives in adapters; scoring and ship-gates in @tangle-network/agent-eval.",
|
|
5
5
|
"homepage": "https://github.com/tangle-network/agent-runtime#readme",
|
|
6
6
|
"repository": {
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"@tangle-network/agent-eval": ">=0.199.0 <0.200.0",
|
|
126
126
|
"@tangle-network/agent-interface": "^2.13.0",
|
|
127
|
-
"@tangle-network/sandbox": ">=0.36.4 <0.48.0 || ^0.49.0-0 || ^0.50.0 || ^0.51.0 || ^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0"
|
|
127
|
+
"@tangle-network/sandbox": ">=0.36.4 <0.48.0 || ^0.49.0-0 || ^0.50.0 || ^0.51.0 || ^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0"
|
|
128
128
|
},
|
|
129
129
|
"dependencies": {
|
|
130
130
|
"@tangle-network/agent-core": ">=0.9.6 <0.10.0",
|
|
@@ -22,7 +22,7 @@ Measured: where a known gap existed, 15 of 27 lanes with claims filed false "new
|
|
|
22
22
|
Name the audience and the decision the result supports.
|
|
23
23
|
Quote the acceptance test from its source, word for word, with its location.
|
|
24
24
|
Include standing assumptions, exclusions and nondegeneracy conditions; a transcription drops them.
|
|
25
|
-
List the outcome classes the audience distinguishes: new, known, partial, conditional,
|
|
25
|
+
List the outcome classes the audience distinguishes: new, known, partial, conditional, reproduced null, stopped unverified, invalid, unassessed.
|
|
26
26
|
Never reduce them to solved and unsolved.
|
|
27
27
|
Make a literature search part of acceptance, and record an answer already published as known.
|
|
28
28
|
|
|
@@ -59,23 +59,48 @@ Hand every role the files it judges by path, never a summary.
|
|
|
59
59
|
|
|
60
60
|
## 5. Define success, the honest null, and the stop
|
|
61
61
|
|
|
62
|
-
Success is an accepted result or a
|
|
63
|
-
A
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
Success is an accepted result or a reproduced null.
|
|
63
|
+
A null may end a run.
|
|
64
|
+
It counts as success only when a party outside the run reproduces what it claims to have covered.
|
|
65
|
+
A null from a search carries a coverage certificate:
|
|
66
|
+
|
|
67
|
+
- the searched space as data: the parameter ranges, the enumeration or sampling method with its seeds, and the bound reached;
|
|
68
|
+
- one row per cell of that space, with what the cell searched and found;
|
|
69
|
+
- a calibration cell where the search must find objects that exist, with the source's reason;
|
|
70
|
+
- the sha256 of the reproducer that printed the rows.
|
|
71
|
+
|
|
72
|
+
The reproducer belongs to the check, not to the run.
|
|
73
|
+
Register it before launch with its sha256, the statements it covers, and its own calibration: cells with the source's results, and a canary where the predicate certified as zero must fire.
|
|
74
|
+
Agents may run it; they never write it.
|
|
75
|
+
The outside check reruns its own copy, never code from the run: a script can print the recorded rows.
|
|
76
|
+
Its copy's hash must equal the registered hash and the certificate's.
|
|
77
|
+
It reruns the registered calibration first and credits nothing on a miss: a reproducer that searches nothing reproduces an empty row too.
|
|
78
|
+
Then it reruns the certificate's calibration cells and the cells that would be new, until its budget ends.
|
|
79
|
+
The pass rule is fixed: each rerun row equals the recorded row, field for field, and one mismatch refuses the certificate.
|
|
80
|
+
Credit only the cells that the check reran and matched; a sample can refuse a certificate, never extend credit.
|
|
81
|
+
A null that is no search, such as a spec conflict or a gap list, names each item with evidence; it counts when the held-back check reproduces each.
|
|
82
|
+
A null without a certificate, or without a registered reproducer, is recorded as "stopped, unverified", never as success.
|
|
83
|
+
A null inside the range the source already checked adds nothing.
|
|
84
|
+
Tell agents the checker may be wrong; credit a checker-defect report the same way, once someone outside the run reproduces the defect.
|
|
66
85
|
Measured elsewhere: a credited exit cut one model's test cheating from 54% to 9%, while prohibitions barely moved another's.
|
|
86
|
+
Measured: an in-run check that accepted a documented null made it the cheapest hack in 11 of 16 blind judgments.
|
|
67
87
|
|
|
68
88
|
A Runtime manager with a check is not served `stop`.
|
|
69
89
|
It ends when the check accepts its `submit_result`, when `report_blocked` shows that a granted tool failed, or at a bound.
|
|
70
90
|
The bounds are the continuation `deadline`, `maxBarren` turns without progress, the budget, and cancellation.
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
Runtime settles an accepted submission as delivered, and a parent may promote it; it keeps no refused one.
|
|
92
|
+
So the run records its certificate on a page, such as a Knowledge page, where the outside check reads it.
|
|
93
|
+
The in-run check never passes a null: it refuses a malformed certificate and holds a well-formed one.
|
|
94
|
+
A held null ends the run at `maxBarren`; set it low, such as 2.
|
|
95
|
+
The run settles as stopped, not delivered.
|
|
73
96
|
State the continuation block in the record, and put the honest exit in its `rules` text.
|
|
74
97
|
The check or a bound ends the run; an agent's claim that it is done does not.
|
|
75
98
|
|
|
76
99
|
## 6. Carry known traps
|
|
77
100
|
|
|
78
101
|
Hand agents the domain's known traps as rules, not stories.
|
|
102
|
+
Write each trap as what the held-back acceptance refuses, never as what the proxy passes.
|
|
103
|
+
"The outside check does not count a c = 0 instance" is a trap; "the checker passed c = 0 claims" is a recipe.
|
|
79
104
|
Examples: excluded or trivial cases, stale or wrong-field comparators, published answers, tests versus users, a demo versus a customer, a rater versus an expert.
|
|
80
105
|
Keep infrastructure incidents out of the brief; the operator owns the stack.
|
|
81
106
|
Measured: a director told of an infrastructure failure spent 2 of its first 4 children probing it.
|
|
@@ -145,7 +170,7 @@ Held-back acceptance: who runs it, where, from what:
|
|
|
145
170
|
Proposers: models, dollars:
|
|
146
171
|
Referee: family, instrument, dollars:
|
|
147
172
|
Monitor: model, what it may steer:
|
|
148
|
-
|
|
173
|
+
Null certificate: space, rows, calibration; registered reproducer, sha256, source calibration; who reruns it, budget:
|
|
149
174
|
Credited exit, in the agents' words:
|
|
150
175
|
Stop: check, report_blocked, deadline, maxBarren, budget:
|
|
151
176
|
Known traps handed to agents:
|
|
@@ -164,7 +189,6 @@ The checker refused only c = 1, and its admission decoys came from that transcri
|
|
|
164
189
|
Workers held the same checker that scored claims, and it counted any verified claim as new.
|
|
165
190
|
All 3 lanes on that conjecture filed 39 "verified-new" claims, every one at c = 0.
|
|
166
191
|
The paper assumes c != 0 throughout; at c = 0 the question is only whether x^d permutes the field.
|
|
167
|
-
One claim page said "the checker refuses only c = 1".
|
|
168
192
|
The real yield was 0.
|
|
169
193
|
|
|
170
194
|
After:
|
|
@@ -173,21 +197,44 @@ Acceptance: Conjecture 13 quoted with the standing assumption that c is not 0 or
|
|
|
173
197
|
Gap probe: before launch, the checker refuses c = 0 and classes a Corollary 11 family member as known.
|
|
174
198
|
Agents run the development checker; the operator reruns a held-back checker and the sweep on each packet.
|
|
175
199
|
A referee from another family recomputes each claim with its own code.
|
|
176
|
-
A
|
|
200
|
+
A null over m <= 20 ends the run at its bound, and it counts once the outside check reruns its own reproducer on the certificate's cells.
|
|
177
201
|
Arms: with and without the referee.
|
|
178
202
|
|
|
203
|
+
### A null that counts
|
|
204
|
+
|
|
205
|
+
Wang and Zheng checked Conjecture 13 for 2 <= m <= 10.
|
|
206
|
+
Two lanes searched every (m, d, c) with c not in {0, 1} to m = 20, found no counterexample, and wrote a table.
|
|
207
|
+
Nobody outside the run could check that table.
|
|
208
|
+
Before the next launch, the operator registers a reference search for one m, its sha256, and its calibration: Theorem 9 gives 4 PcN pairs at m = 6 and 8 at m = 10, and a canary drops family (2) so those pairs must count as found.
|
|
209
|
+
As a certificate, the null reads:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{"space": {"cells": {"m": {"from": 2, "to": 20}}, "method": "enumerate", "bound": "m <= 20",
|
|
213
|
+
"within": "each unit d modulo 2^m - 1, one per Frobenius orbit, and each c outside {0, 1}"},
|
|
214
|
+
"rows": [{"cell": {"m": 12}, "searched": 585442, "positives": 28, "found": 0}],
|
|
215
|
+
"calibration": [{"cell": {"m": 6}, "why": "Theorem 9: x^5 is PcN for c in GF(4) outside {0, 1}"}],
|
|
216
|
+
"reference": "sha256:5d198f4fc2d9..."}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The rows list every m; one is shown.
|
|
220
|
+
The outside check hashes its copy, reruns the calibration and the canary with no network, then m = 11 to 20, then the rest.
|
|
221
|
+
Rows typed instead of computed fail at the first cell that differs, and a script in the lane's packet is never run.
|
|
222
|
+
A reference that searches nothing fails at m = 6; one whose found never fires fails the canary.
|
|
223
|
+
If the budget ends after m = 18, the null is credited for 11 <= m <= 18 only.
|
|
224
|
+
The in-run check holds the certificate, and the run ends at `maxBarren`; only the rerun gives credit.
|
|
225
|
+
The trap for this conjecture reads: "the outside check does not count a c = 0 instance; the source sets c = 0 aside".
|
|
226
|
+
|
|
179
227
|
### Coding task scored by tests
|
|
180
228
|
|
|
181
229
|
Audience: the task's author, and a maintainer who decides whether to merge.
|
|
182
230
|
Proxy: the visible tests.
|
|
183
231
|
Gap: a change that passes the tests and that a maintainer rejects, such as a special-cased input, an edited test or a skipped check.
|
|
184
232
|
Measured: in an 8-lane Terminal-Bench batch, Runtime marked 6 lanes as winners and the task's verifier passed 1 of them.
|
|
185
|
-
Measured elsewhere: 0 of 15 reviewed agent pull requests were mergeable as-is, including 4 that passed the tests.
|
|
186
233
|
Profile: agents run the visible tests.
|
|
187
234
|
The held-back verifier and hidden tests run on the patch in a fresh container.
|
|
188
235
|
Hash the test files; a changed test fails acceptance.
|
|
189
236
|
A referee from another family reads the diff for special cases.
|
|
190
|
-
A report that the task cannot pass without breaking its specification
|
|
237
|
+
A report that the task cannot pass without breaking its specification ends the run; it counts once the held-back verifier reproduces the conflict.
|
|
191
238
|
|
|
192
239
|
### Product for a customer
|
|
193
240
|
|
|
@@ -196,12 +243,11 @@ Acceptance: the customer's own evaluation criteria, quoted, and a walkthrough of
|
|
|
196
243
|
Proxy: an LLM fulfilment rater and a compliance checklist.
|
|
197
244
|
Gap, measured across product lanes: the rater accepted 19 of 31 failed lanes and scored 0.45 where always-reject scored 0.73.
|
|
198
245
|
In one wave, 19 of 44 reviewers never received the product.
|
|
199
|
-
A grader gave B where the owner gave F.
|
|
200
246
|
Profile: reviewers mount the product by path and must run it.
|
|
201
247
|
A referee from another family walks the customer's task on the running product.
|
|
202
248
|
The rater stays a ruler, not a gate, until it beats always-reject.
|
|
203
249
|
Acceptance is the owner's or the customer's walkthrough.
|
|
204
|
-
"Not ready, and this is what is missing"
|
|
250
|
+
"Not ready, and this is what is missing" ends the run; it counts once the owner's walkthrough reproduces each gap.
|
|
205
251
|
|
|
206
252
|
## Then consider
|
|
207
253
|
|