@tangle-network/agent-eval 0.212.0 → 0.214.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -1
  3. package/dist/adapters/http.d.ts +2 -2
  4. package/dist/analyst/index.d.ts +7 -7
  5. package/dist/analyst/index.d.ts.map +1 -1
  6. package/dist/analyst/index.js +3 -3
  7. package/dist/{benchmark-command-aYFvm6vp.js → benchmark-command-CMmeV-_Z.js} +8 -7
  8. package/dist/benchmark-command-CMmeV-_Z.js.map +1 -0
  9. package/dist/benchmarks/index.d.ts +4 -4
  10. package/dist/benchmarks/index.js +3 -3
  11. package/dist/campaign/index.d.ts +4 -4
  12. package/dist/campaign/index.js +8 -8
  13. package/dist/{campaign-CrMj5nYM.js → campaign-Cuw3DQKF.js} +9 -9
  14. package/dist/{campaign-CrMj5nYM.js.map → campaign-Cuw3DQKF.js.map} +1 -1
  15. package/dist/cli.js +6 -6
  16. package/dist/contract/index.d.ts +7 -7
  17. package/dist/contract/index.js +4 -4
  18. package/dist/{default-registry-Crk3QEy1.d.ts → default-registry-BAiTePcB.d.ts} +3 -3
  19. package/dist/{default-registry-Crk3QEy1.d.ts.map → default-registry-BAiTePcB.d.ts.map} +1 -1
  20. package/dist/{define-agent-eval-B_zZY2AZ.d.ts → define-agent-eval-CZdBPUkk.d.ts} +5 -5
  21. package/dist/{define-agent-eval-B_zZY2AZ.d.ts.map → define-agent-eval-CZdBPUkk.d.ts.map} +1 -1
  22. package/dist/{define-agent-eval-BmF0c78X.js → define-agent-eval-FGtpqnh4.js} +4 -4
  23. package/dist/{define-agent-eval-BmF0c78X.js.map → define-agent-eval-FGtpqnh4.js.map} +1 -1
  24. package/dist/{dspy-rlm-engine-D7BIsKyZ.js → dspy-rlm-engine-OMBXVN0u.js} +2 -2
  25. package/dist/{dspy-rlm-engine-D7BIsKyZ.js.map → dspy-rlm-engine-OMBXVN0u.js.map} +1 -1
  26. package/dist/{engine-D-YZ32ZJ.d.ts → engine-BzOR5Ygn.d.ts} +2 -2
  27. package/dist/{engine-D-YZ32ZJ.d.ts.map → engine-BzOR5Ygn.d.ts.map} +1 -1
  28. package/dist/evaluation.d.ts +1 -1
  29. package/dist/experiment/index.d.ts +1 -1
  30. package/dist/{external-optimizer-process-CB3RGyr7.js → external-optimizer-process-DCZx5PdG.js} +2 -2
  31. package/dist/{external-optimizer-process-CB3RGyr7.js.map → external-optimizer-process-DCZx5PdG.js.map} +1 -1
  32. package/dist/{external-optimizer-subprocess-DitxECD3.js → external-optimizer-subprocess-CA3aXT8I.js} +2 -2
  33. package/dist/{external-optimizer-subprocess-DitxECD3.js.map → external-optimizer-subprocess-CA3aXT8I.js.map} +1 -1
  34. package/dist/hosted/index.js +1 -1
  35. package/dist/{index-DnZdBxCL.d.ts → index-BTwxP7L0.d.ts} +6 -6
  36. package/dist/{index-DnZdBxCL.d.ts.map → index-BTwxP7L0.d.ts.map} +1 -1
  37. package/dist/{index-UxNTvn-w.d.ts → index-BWiAAWrk.d.ts} +3 -3
  38. package/dist/{index-UxNTvn-w.d.ts.map → index-BWiAAWrk.d.ts.map} +1 -1
  39. package/dist/{index-Bj96W0jZ.d.ts → index-DHKEAv3s.d.ts} +44 -2
  40. package/dist/index-DHKEAv3s.d.ts.map +1 -0
  41. package/dist/{index-xnhRdqik.d.ts → index-D_rfXep9.d.ts} +4 -4
  42. package/dist/{index-xnhRdqik.d.ts.map → index-D_rfXep9.d.ts.map} +1 -1
  43. package/dist/index.d.ts +9 -9
  44. package/dist/index.js +6 -6
  45. package/dist/ledger-core/index.d.ts +2 -2
  46. package/dist/ledger-core/index.js +2 -1
  47. package/dist/ledger-core-B2hahzrt.js +248 -0
  48. package/dist/ledger-core-B2hahzrt.js.map +1 -0
  49. package/dist/{llm-judge-BtMxSe1e.js → llm-judge-Dw0rDpve.js} +5 -5
  50. package/dist/{llm-judge-BtMxSe1e.js.map → llm-judge-Dw0rDpve.js.map} +1 -1
  51. package/dist/{matrix-jHTsHEkR.d.ts → matrix-CQwid3kj.d.ts} +2 -2
  52. package/dist/{matrix-jHTsHEkR.d.ts.map → matrix-CQwid3kj.d.ts.map} +1 -1
  53. package/dist/multishot/golden/index.d.ts +1 -1
  54. package/dist/multishot/index.d.ts +2 -2
  55. package/dist/openapi.json +1 -1
  56. package/dist/{produced-state-CYhim2We.js → produced-state-C1cTYK6w.js} +2 -2
  57. package/dist/{produced-state-CYhim2We.js.map → produced-state-C1cTYK6w.js.map} +1 -1
  58. package/dist/rl.d.ts +2 -2
  59. package/dist/search/index.d.ts +2 -2
  60. package/dist/search/index.js +2 -2
  61. package/dist/{search-kernel-ah2GESe3.d.ts → search-kernel-BWp7hfJn.d.ts} +3 -3
  62. package/dist/{search-kernel-ah2GESe3.d.ts.map → search-kernel-BWp7hfJn.d.ts.map} +1 -1
  63. package/dist/{search-kernel-BIXWM7YV.js → search-kernel-BztlERLv.js} +3 -3
  64. package/dist/{search-kernel-BIXWM7YV.js.map → search-kernel-BztlERLv.js.map} +1 -1
  65. package/dist/{search-ledger-aMTNQn_m.js → search-ledger-d7V8o9Lk.js} +3 -3
  66. package/dist/{search-ledger-aMTNQn_m.js.map → search-ledger-d7V8o9Lk.js.map} +1 -1
  67. package/dist/{search-ledger-file-DY0AXX3W.js → search-ledger-file-BqOo-bVo.js} +2 -2
  68. package/dist/{search-ledger-file-DY0AXX3W.js.map → search-ledger-file-BqOo-bVo.js.map} +1 -1
  69. package/dist/{search-shipper-DKXWuLnp.js → search-shipper-er4pK5_Y.js} +3 -3
  70. package/dist/{search-shipper-DKXWuLnp.js.map → search-shipper-er4pK5_Y.js.map} +1 -1
  71. package/dist/{search-summary-nwrtXxC_.js → search-summary-CBvz3u_S.js} +3 -3
  72. package/dist/{search-summary-nwrtXxC_.js.map → search-summary-CBvz3u_S.js.map} +1 -1
  73. package/dist/{semantic-concept-judge-B4zwq9Uy.js → semantic-concept-judge-sDBNg_mI.js} +2 -2
  74. package/dist/{semantic-concept-judge-B4zwq9Uy.js.map → semantic-concept-judge-sDBNg_mI.js.map} +1 -1
  75. package/dist/{skillopt-optimization-method-Ds4Ck2Dn.js → skillopt-optimization-method-CvaFGm95.js} +5 -5
  76. package/dist/{skillopt-optimization-method-Ds4Ck2Dn.js.map → skillopt-optimization-method-CvaFGm95.js.map} +1 -1
  77. package/dist/{statistical-heldout-8RGPIeyo.d.ts → statistical-heldout-DZaTo3gZ.d.ts} +2 -2
  78. package/dist/{statistical-heldout-8RGPIeyo.d.ts.map → statistical-heldout-DZaTo3gZ.d.ts.map} +1 -1
  79. package/dist/{store-tool-spans-wQ9idsnn.d.ts → store-tool-spans-DuvZ4YWb.d.ts} +3 -3
  80. package/dist/{store-tool-spans-wQ9idsnn.d.ts.map → store-tool-spans-DuvZ4YWb.d.ts.map} +1 -1
  81. package/dist/systemone.d.ts +1 -1
  82. package/dist/{tool-groups-v28A-ZAF.d.ts → tool-groups-DOriCbkR.d.ts} +2 -2
  83. package/dist/tool-groups-DOriCbkR.d.ts.map +1 -0
  84. package/dist/{trace-questions-C26UvI3D.d.ts → trace-questions-RCaYLkwH.d.ts} +2 -2
  85. package/dist/{trace-questions-C26UvI3D.d.ts.map → trace-questions-RCaYLkwH.d.ts.map} +1 -1
  86. package/dist/trace-repair/index.d.ts +1 -1
  87. package/dist/traces.d.ts +2 -2
  88. package/dist/{tree-kc1d80yF.js → tree-rXLW3M_4.js} +3 -3
  89. package/dist/{tree-kc1d80yF.js.map → tree-rXLW3M_4.js.map} +1 -1
  90. package/dist/{types-Dv9sYwBB.d.ts → types-CMnPcbW5.d.ts} +2 -2
  91. package/dist/{types-Dv9sYwBB.d.ts.map → types-CMnPcbW5.d.ts.map} +1 -1
  92. package/dist/{types-tWFY6bON.d.ts → types-Dj0Qv2qi.d.ts} +2 -2
  93. package/dist/{types-tWFY6bON.d.ts.map → types-Dj0Qv2qi.d.ts.map} +1 -1
  94. package/docs/verified-labels-flywheel.md +2 -2
  95. package/package.json +3 -3
  96. package/dist/benchmark-command-aYFvm6vp.js.map +0 -1
  97. package/dist/index-Bj96W0jZ.d.ts.map +0 -1
  98. package/dist/tool-groups-v28A-ZAF.d.ts.map +0 -1
@@ -0,0 +1,248 @@
1
+ import { s as ValidationError } from "./errors-Dngq5h35.js";
2
+ import { t as LEDGER_HASH_PATTERN } from "./canonical-BsZVgBhW.js";
3
+ import "./journal-DvKCvjty.js";
4
+ import { sha256Bytes } from "@tangle-network/agent-interface";
5
+ //#region src/ledger-core/merkle.ts
6
+ /**
7
+ * Merkle proofs over an append-only list of leaves (RFC 9162 §2.1, the
8
+ * Certificate Transparency tree).
9
+ *
10
+ * A hash chain proves a whole log against its head, but proving one entry means
11
+ * replaying everything before it. This tree proves any one leaf against a root
12
+ * with ⌈log₂ n⌉ hashes (inclusion), and proves that a larger tree only appended
13
+ * to a smaller one (consistency). A verifier holding a root can therefore check
14
+ * a single event, or that a later checkpoint extends an earlier one, without
15
+ * reading the rest of the log.
16
+ *
17
+ * Leaves and interior nodes are domain-separated (0x00 and 0x01 prefixes), so a
18
+ * leaf can never be presented as an interior node. Content that may later be
19
+ * redacted takes a random 32-byte salt: a verifier then needs only the leaf's
20
+ * hash, and short content cannot be guessed back from that hash. The salt must
21
+ * be stored apart from anything that is shared after redaction.
22
+ *
23
+ * Builders refuse malformed input by throwing; verifiers never throw and return
24
+ * a typed outcome, because a proof is external evidence and a bad one is a
25
+ * finding, not a crash.
26
+ */
27
+ const SALT_PATTERN = /^[a-f0-9]{64}$/;
28
+ const LEAF_PREFIX = 0;
29
+ const NODE_PREFIX = 1;
30
+ const encoder = new TextEncoder();
31
+ /** Root of the empty tree: SHA-256 of no bytes. */
32
+ const MERKLE_EMPTY_ROOT = sha256Bytes(/* @__PURE__ */ new Uint8Array(0));
33
+ /** A fresh random salt for {@link merkleLeafHash}: 32 bytes as 64 lowercase hex characters. */
34
+ function merkleSalt() {
35
+ return toHex(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)));
36
+ }
37
+ /**
38
+ * Leaf hash of `content`: SHA-256(0x00 ‖ salt ‖ content). Without a salt this is
39
+ * exactly the RFC 9162 leaf hash. Strings are hashed as UTF-8.
40
+ */
41
+ function merkleLeafHash(content, salt) {
42
+ const bytes = typeof content === "string" ? encoder.encode(content) : content;
43
+ if (salt === void 0) return digest(LEAF_PREFIX, bytes);
44
+ if (!SALT_PATTERN.test(salt)) throw new ValidationError("merkle salt must be 32 bytes as 64 lowercase hex characters");
45
+ return digest(LEAF_PREFIX, fromHex(salt), bytes);
46
+ }
47
+ /** Root over leaf hashes, in order. The empty list has {@link MERKLE_EMPTY_ROOT}. */
48
+ function merkleRoot(leaves) {
49
+ const nodes = decodeLeaves(leaves);
50
+ return nodes.length === 0 ? MERKLE_EMPTY_ROOT : toLedgerHash(subtreeRoot(nodes, 0, nodes.length));
51
+ }
52
+ /** Inclusion proof for the leaf at `leafIndex` (RFC 9162 §2.1.3.1). */
53
+ function merkleInclusionProof(leaves, leafIndex) {
54
+ const nodes = decodeLeaves(leaves);
55
+ if (!Number.isSafeInteger(leafIndex) || leafIndex < 0 || leafIndex >= nodes.length) throw new ValidationError(`merkle leaf index ${leafIndex} is outside a tree of ${nodes.length} leaves`);
56
+ const path = [];
57
+ inclusionPath(nodes, leafIndex, 0, nodes.length, path);
58
+ return {
59
+ leafIndex,
60
+ treeSize: nodes.length,
61
+ path: path.map(toLedgerHash)
62
+ };
63
+ }
64
+ /**
65
+ * Consistency proof that the first `oldSize` leaves are the tree of that size
66
+ * (RFC 9162 §2.1.4.1). Sizes 0 and `leaves.length` need no path.
67
+ */
68
+ function merkleConsistencyProof(leaves, oldSize) {
69
+ const nodes = decodeLeaves(leaves);
70
+ if (!Number.isSafeInteger(oldSize) || oldSize < 0 || oldSize > nodes.length) throw new ValidationError(`merkle old size ${oldSize} is outside a tree of ${nodes.length} leaves`);
71
+ const path = [];
72
+ if (oldSize > 0 && oldSize < nodes.length) subproof(nodes, oldSize, 0, nodes.length, true, path);
73
+ return {
74
+ oldSize,
75
+ newSize: nodes.length,
76
+ path: path.map(toLedgerHash)
77
+ };
78
+ }
79
+ /** Check that `leaf` is in the tree with `root` at the proof's index (RFC 9162 §2.1.3.2). */
80
+ function verifyMerkleInclusion(leaf, proof, root) {
81
+ const { leafIndex, treeSize } = proof;
82
+ if (!isSize(treeSize) || !isSize(leafIndex) || leafIndex >= treeSize) return refused(`leaf index ${leafIndex} is outside a tree of ${treeSize} leaves`);
83
+ const decoded = decodeAll([
84
+ leaf,
85
+ root,
86
+ ...proof.path
87
+ ]);
88
+ if (decoded === void 0) return refused("proof carries a malformed hash");
89
+ const [leafBytes, rootBytes, ...path] = decoded;
90
+ let fn = leafIndex;
91
+ let sn = treeSize - 1;
92
+ let r = leafBytes;
93
+ for (const p of path) {
94
+ if (sn === 0) return refused("proof path is longer than the tree is deep");
95
+ if (fn % 2 === 1 || fn === sn) {
96
+ r = node(p, r);
97
+ if (fn % 2 === 0) while (fn % 2 === 0 && fn !== 0) {
98
+ fn = Math.floor(fn / 2);
99
+ sn = Math.floor(sn / 2);
100
+ }
101
+ } else r = node(r, p);
102
+ fn = Math.floor(fn / 2);
103
+ sn = Math.floor(sn / 2);
104
+ }
105
+ if (sn !== 0) return refused("proof path is shorter than the tree is deep");
106
+ return equal(r, rootBytes) ? { verified: true } : refused("leaf does not hash to the root");
107
+ }
108
+ /** Check that the tree with `newRoot` extends the tree with `oldRoot` (RFC 9162 §2.1.4.2). */
109
+ function verifyMerkleConsistency(proof, oldRoot, newRoot) {
110
+ const { oldSize, newSize } = proof;
111
+ if (!isSize(oldSize) || !isSize(newSize) || oldSize > newSize) return refused(`old size ${oldSize} does not precede new size ${newSize}`);
112
+ const decoded = decodeAll([
113
+ oldRoot,
114
+ newRoot,
115
+ ...proof.path
116
+ ]);
117
+ if (decoded === void 0) return refused("proof carries a malformed hash");
118
+ const [oldBytes, newBytes, ...given] = decoded;
119
+ if (oldSize === 0 || oldSize === newSize) {
120
+ if (given.length !== 0) return refused("a trivial consistency proof must be empty");
121
+ if (oldSize === 0) return oldRoot === MERKLE_EMPTY_ROOT ? { verified: true } : refused("the empty tree has a different root");
122
+ return equal(oldBytes, newBytes) ? { verified: true } : refused("equal sizes with different roots");
123
+ }
124
+ const path = isPowerOfTwo(oldSize) ? [oldBytes, ...given] : given;
125
+ if (path.length === 0) return refused("consistency proof is empty");
126
+ let fn = oldSize - 1;
127
+ let sn = newSize - 1;
128
+ while (fn % 2 === 1) {
129
+ fn = Math.floor(fn / 2);
130
+ sn = Math.floor(sn / 2);
131
+ }
132
+ let fr = path[0];
133
+ let sr = fr;
134
+ for (const c of path.slice(1)) {
135
+ if (sn === 0) return refused("proof path is longer than the tree is deep");
136
+ if (fn % 2 === 1 || fn === sn) {
137
+ fr = node(c, fr);
138
+ sr = node(c, sr);
139
+ if (fn % 2 === 0) while (fn % 2 === 0 && fn !== 0) {
140
+ fn = Math.floor(fn / 2);
141
+ sn = Math.floor(sn / 2);
142
+ }
143
+ } else sr = node(sr, c);
144
+ fn = Math.floor(fn / 2);
145
+ sn = Math.floor(sn / 2);
146
+ }
147
+ if (sn !== 0) return refused("proof path is shorter than the tree is deep");
148
+ if (!equal(fr, oldBytes)) return refused("proof does not rebuild the old root");
149
+ if (!equal(sr, newBytes)) return refused("proof does not rebuild the new root");
150
+ return { verified: true };
151
+ }
152
+ function subtreeRoot(nodes, start, end) {
153
+ if (end - start === 1) return nodes[start];
154
+ const k = largestPowerOfTwoBelow(end - start);
155
+ return node(subtreeRoot(nodes, start, start + k), subtreeRoot(nodes, start + k, end));
156
+ }
157
+ function inclusionPath(nodes, index, start, end, path) {
158
+ if (end - start === 1) return;
159
+ const k = largestPowerOfTwoBelow(end - start);
160
+ if (index < start + k) {
161
+ inclusionPath(nodes, index, start, start + k, path);
162
+ path.push(subtreeRoot(nodes, start + k, end));
163
+ } else {
164
+ inclusionPath(nodes, index, start + k, end, path);
165
+ path.push(subtreeRoot(nodes, start, start + k));
166
+ }
167
+ }
168
+ function subproof(nodes, oldSize, start, end, complete, path) {
169
+ if (end - start === oldSize) {
170
+ if (!complete) path.push(subtreeRoot(nodes, start, end));
171
+ return;
172
+ }
173
+ const k = largestPowerOfTwoBelow(end - start);
174
+ if (oldSize <= k) {
175
+ subproof(nodes, oldSize, start, start + k, complete, path);
176
+ path.push(subtreeRoot(nodes, start + k, end));
177
+ } else {
178
+ subproof(nodes, oldSize - k, start + k, end, false, path);
179
+ path.push(subtreeRoot(nodes, start, start + k));
180
+ }
181
+ }
182
+ function node(left, right) {
183
+ return fromHex(digest(NODE_PREFIX, left, right).slice(7));
184
+ }
185
+ function digest(prefix, ...parts) {
186
+ const length = parts.reduce((total, part) => total + part.length, 1);
187
+ const bytes = new Uint8Array(length);
188
+ bytes[0] = prefix;
189
+ let offset = 1;
190
+ for (const part of parts) {
191
+ bytes.set(part, offset);
192
+ offset += part.length;
193
+ }
194
+ return sha256Bytes(bytes);
195
+ }
196
+ function decodeLeaves(leaves) {
197
+ const decoded = decodeAll(leaves);
198
+ if (decoded === void 0) throw new ValidationError("merkle leaves must be sha256:<64 lowercase hex> hashes");
199
+ return decoded;
200
+ }
201
+ function decodeAll(hashes) {
202
+ const out = [];
203
+ for (const hash of hashes) {
204
+ if (typeof hash !== "string" || !LEDGER_HASH_PATTERN.test(hash)) return void 0;
205
+ out.push(fromHex(hash.slice(7)));
206
+ }
207
+ return out;
208
+ }
209
+ function toLedgerHash(bytes) {
210
+ return `sha256:${toHex(bytes)}`;
211
+ }
212
+ function largestPowerOfTwoBelow(n) {
213
+ let k = 1;
214
+ while (k * 2 < n) k *= 2;
215
+ return k;
216
+ }
217
+ function isPowerOfTwo(n) {
218
+ if (n < 1) return false;
219
+ let m = n;
220
+ while (m % 2 === 0) m /= 2;
221
+ return m === 1;
222
+ }
223
+ function isSize(n) {
224
+ return Number.isSafeInteger(n) && n >= 0;
225
+ }
226
+ function equal(a, b) {
227
+ if (a.length !== b.length) return false;
228
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
229
+ return true;
230
+ }
231
+ function refused(reason) {
232
+ return {
233
+ verified: false,
234
+ reason
235
+ };
236
+ }
237
+ function toHex(bytes) {
238
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
239
+ }
240
+ function fromHex(hex) {
241
+ const bytes = new Uint8Array(hex.length / 2);
242
+ for (let i = 0; i < bytes.length; i++) bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
243
+ return bytes;
244
+ }
245
+ //#endregion
246
+ export { merkleRoot as a, verifyMerkleInclusion as c, merkleLeafHash as i, merkleConsistencyProof as n, merkleSalt as o, merkleInclusionProof as r, verifyMerkleConsistency as s, MERKLE_EMPTY_ROOT as t };
247
+
248
+ //# sourceMappingURL=ledger-core-B2hahzrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger-core-B2hahzrt.js","names":[],"sources":["../src/ledger-core/merkle.ts"],"sourcesContent":["/**\n * Merkle proofs over an append-only list of leaves (RFC 9162 §2.1, the\n * Certificate Transparency tree).\n *\n * A hash chain proves a whole log against its head, but proving one entry means\n * replaying everything before it. This tree proves any one leaf against a root\n * with ⌈log₂ n⌉ hashes (inclusion), and proves that a larger tree only appended\n * to a smaller one (consistency). A verifier holding a root can therefore check\n * a single event, or that a later checkpoint extends an earlier one, without\n * reading the rest of the log.\n *\n * Leaves and interior nodes are domain-separated (0x00 and 0x01 prefixes), so a\n * leaf can never be presented as an interior node. Content that may later be\n * redacted takes a random 32-byte salt: a verifier then needs only the leaf's\n * hash, and short content cannot be guessed back from that hash. The salt must\n * be stored apart from anything that is shared after redaction.\n *\n * Builders refuse malformed input by throwing; verifiers never throw and return\n * a typed outcome, because a proof is external evidence and a bad one is a\n * finding, not a crash.\n */\nimport { sha256Bytes } from '@tangle-network/agent-interface'\nimport { ValidationError } from '../errors'\nimport { LEDGER_HASH_PATTERN, type LedgerHash } from './canonical'\n\n/** Proof that one leaf is at `leafIndex` in a tree of `treeSize` leaves. */\nexport interface MerkleInclusionProof {\n readonly leafIndex: number\n readonly treeSize: number\n readonly path: readonly LedgerHash[]\n}\n\n/** Proof that the first `oldSize` leaves of a `newSize` tree are unchanged. */\nexport interface MerkleConsistencyProof {\n readonly oldSize: number\n readonly newSize: number\n readonly path: readonly LedgerHash[]\n}\n\nexport type MerkleVerification =\n | { readonly verified: true }\n | { readonly verified: false; readonly reason: string }\n\nconst SALT_PATTERN = /^[a-f0-9]{64}$/\nconst LEAF_PREFIX = 0x00\nconst NODE_PREFIX = 0x01\nconst encoder = new TextEncoder()\n\n/** Root of the empty tree: SHA-256 of no bytes. */\nexport const MERKLE_EMPTY_ROOT: LedgerHash = sha256Bytes(new Uint8Array(0)) as LedgerHash\n\n/** A fresh random salt for {@link merkleLeafHash}: 32 bytes as 64 lowercase hex characters. */\nexport function merkleSalt(): string {\n return toHex(globalThis.crypto.getRandomValues(new Uint8Array(32)))\n}\n\n/**\n * Leaf hash of `content`: SHA-256(0x00 ‖ salt ‖ content). Without a salt this is\n * exactly the RFC 9162 leaf hash. Strings are hashed as UTF-8.\n */\nexport function merkleLeafHash(content: Uint8Array | string, salt?: string): LedgerHash {\n const bytes = typeof content === 'string' ? encoder.encode(content) : content\n if (salt === undefined) return digest(LEAF_PREFIX, bytes)\n if (!SALT_PATTERN.test(salt)) {\n throw new ValidationError('merkle salt must be 32 bytes as 64 lowercase hex characters')\n }\n return digest(LEAF_PREFIX, fromHex(salt), bytes)\n}\n\n/** Root over leaf hashes, in order. The empty list has {@link MERKLE_EMPTY_ROOT}. */\nexport function merkleRoot(leaves: readonly LedgerHash[]): LedgerHash {\n const nodes = decodeLeaves(leaves)\n return nodes.length === 0 ? MERKLE_EMPTY_ROOT : toLedgerHash(subtreeRoot(nodes, 0, nodes.length))\n}\n\n/** Inclusion proof for the leaf at `leafIndex` (RFC 9162 §2.1.3.1). */\nexport function merkleInclusionProof(\n leaves: readonly LedgerHash[],\n leafIndex: number,\n): MerkleInclusionProof {\n const nodes = decodeLeaves(leaves)\n if (!Number.isSafeInteger(leafIndex) || leafIndex < 0 || leafIndex >= nodes.length) {\n throw new ValidationError(\n `merkle leaf index ${leafIndex} is outside a tree of ${nodes.length} leaves`,\n )\n }\n const path: Uint8Array[] = []\n inclusionPath(nodes, leafIndex, 0, nodes.length, path)\n return { leafIndex, treeSize: nodes.length, path: path.map(toLedgerHash) }\n}\n\n/**\n * Consistency proof that the first `oldSize` leaves are the tree of that size\n * (RFC 9162 §2.1.4.1). Sizes 0 and `leaves.length` need no path.\n */\nexport function merkleConsistencyProof(\n leaves: readonly LedgerHash[],\n oldSize: number,\n): MerkleConsistencyProof {\n const nodes = decodeLeaves(leaves)\n if (!Number.isSafeInteger(oldSize) || oldSize < 0 || oldSize > nodes.length) {\n throw new ValidationError(\n `merkle old size ${oldSize} is outside a tree of ${nodes.length} leaves`,\n )\n }\n const path: Uint8Array[] = []\n if (oldSize > 0 && oldSize < nodes.length) subproof(nodes, oldSize, 0, nodes.length, true, path)\n return { oldSize, newSize: nodes.length, path: path.map(toLedgerHash) }\n}\n\n/** Check that `leaf` is in the tree with `root` at the proof's index (RFC 9162 §2.1.3.2). */\nexport function verifyMerkleInclusion(\n leaf: LedgerHash,\n proof: MerkleInclusionProof,\n root: LedgerHash,\n): MerkleVerification {\n const { leafIndex, treeSize } = proof\n if (!isSize(treeSize) || !isSize(leafIndex) || leafIndex >= treeSize) {\n return refused(`leaf index ${leafIndex} is outside a tree of ${treeSize} leaves`)\n }\n const decoded = decodeAll([leaf, root, ...proof.path])\n if (decoded === undefined) return refused('proof carries a malformed hash')\n const [leafBytes, rootBytes, ...path] = decoded as [Uint8Array, Uint8Array, ...Uint8Array[]]\n let fn = leafIndex\n let sn = treeSize - 1\n let r = leafBytes\n for (const p of path) {\n if (sn === 0) return refused('proof path is longer than the tree is deep')\n if (fn % 2 === 1 || fn === sn) {\n r = node(p, r)\n if (fn % 2 === 0) {\n while (fn % 2 === 0 && fn !== 0) {\n fn = Math.floor(fn / 2)\n sn = Math.floor(sn / 2)\n }\n }\n } else {\n r = node(r, p)\n }\n fn = Math.floor(fn / 2)\n sn = Math.floor(sn / 2)\n }\n if (sn !== 0) return refused('proof path is shorter than the tree is deep')\n return equal(r, rootBytes) ? { verified: true } : refused('leaf does not hash to the root')\n}\n\n/** Check that the tree with `newRoot` extends the tree with `oldRoot` (RFC 9162 §2.1.4.2). */\nexport function verifyMerkleConsistency(\n proof: MerkleConsistencyProof,\n oldRoot: LedgerHash,\n newRoot: LedgerHash,\n): MerkleVerification {\n const { oldSize, newSize } = proof\n if (!isSize(oldSize) || !isSize(newSize) || oldSize > newSize) {\n return refused(`old size ${oldSize} does not precede new size ${newSize}`)\n }\n const decoded = decodeAll([oldRoot, newRoot, ...proof.path])\n if (decoded === undefined) return refused('proof carries a malformed hash')\n const [oldBytes, newBytes, ...given] = decoded as [Uint8Array, Uint8Array, ...Uint8Array[]]\n if (oldSize === 0 || oldSize === newSize) {\n if (given.length !== 0) return refused('a trivial consistency proof must be empty')\n if (oldSize === 0) {\n return oldRoot === MERKLE_EMPTY_ROOT\n ? { verified: true }\n : refused('the empty tree has a different root')\n }\n return equal(oldBytes, newBytes)\n ? { verified: true }\n : refused('equal sizes with different roots')\n }\n const path = isPowerOfTwo(oldSize) ? [oldBytes, ...given] : given\n if (path.length === 0) return refused('consistency proof is empty')\n let fn = oldSize - 1\n let sn = newSize - 1\n while (fn % 2 === 1) {\n fn = Math.floor(fn / 2)\n sn = Math.floor(sn / 2)\n }\n let fr = path[0] as Uint8Array\n let sr = fr\n for (const c of path.slice(1)) {\n if (sn === 0) return refused('proof path is longer than the tree is deep')\n if (fn % 2 === 1 || fn === sn) {\n fr = node(c, fr)\n sr = node(c, sr)\n if (fn % 2 === 0) {\n while (fn % 2 === 0 && fn !== 0) {\n fn = Math.floor(fn / 2)\n sn = Math.floor(sn / 2)\n }\n }\n } else {\n sr = node(sr, c)\n }\n fn = Math.floor(fn / 2)\n sn = Math.floor(sn / 2)\n }\n if (sn !== 0) return refused('proof path is shorter than the tree is deep')\n if (!equal(fr, oldBytes)) return refused('proof does not rebuild the old root')\n if (!equal(sr, newBytes)) return refused('proof does not rebuild the new root')\n return { verified: true }\n}\n\nfunction subtreeRoot(nodes: readonly Uint8Array[], start: number, end: number): Uint8Array {\n if (end - start === 1) return nodes[start] as Uint8Array\n const k = largestPowerOfTwoBelow(end - start)\n return node(subtreeRoot(nodes, start, start + k), subtreeRoot(nodes, start + k, end))\n}\n\nfunction inclusionPath(\n nodes: readonly Uint8Array[],\n index: number,\n start: number,\n end: number,\n path: Uint8Array[],\n): void {\n if (end - start === 1) return\n const k = largestPowerOfTwoBelow(end - start)\n if (index < start + k) {\n inclusionPath(nodes, index, start, start + k, path)\n path.push(subtreeRoot(nodes, start + k, end))\n } else {\n inclusionPath(nodes, index, start + k, end, path)\n path.push(subtreeRoot(nodes, start, start + k))\n }\n}\n\nfunction subproof(\n nodes: readonly Uint8Array[],\n oldSize: number,\n start: number,\n end: number,\n complete: boolean,\n path: Uint8Array[],\n): void {\n if (end - start === oldSize) {\n if (!complete) path.push(subtreeRoot(nodes, start, end))\n return\n }\n const k = largestPowerOfTwoBelow(end - start)\n if (oldSize <= k) {\n subproof(nodes, oldSize, start, start + k, complete, path)\n path.push(subtreeRoot(nodes, start + k, end))\n } else {\n subproof(nodes, oldSize - k, start + k, end, false, path)\n path.push(subtreeRoot(nodes, start, start + k))\n }\n}\n\nfunction node(left: Uint8Array, right: Uint8Array): Uint8Array {\n return fromHex(digest(NODE_PREFIX, left, right).slice('sha256:'.length))\n}\n\nfunction digest(prefix: number, ...parts: Uint8Array[]): LedgerHash {\n const length = parts.reduce((total, part) => total + part.length, 1)\n const bytes = new Uint8Array(length)\n bytes[0] = prefix\n let offset = 1\n for (const part of parts) {\n bytes.set(part, offset)\n offset += part.length\n }\n return sha256Bytes(bytes) as LedgerHash\n}\n\nfunction decodeLeaves(leaves: readonly LedgerHash[]): Uint8Array[] {\n const decoded = decodeAll(leaves)\n if (decoded === undefined) {\n throw new ValidationError('merkle leaves must be sha256:<64 lowercase hex> hashes')\n }\n return decoded\n}\n\nfunction decodeAll(hashes: readonly string[]): Uint8Array[] | undefined {\n const out: Uint8Array[] = []\n for (const hash of hashes) {\n if (typeof hash !== 'string' || !LEDGER_HASH_PATTERN.test(hash)) return undefined\n out.push(fromHex(hash.slice('sha256:'.length)))\n }\n return out\n}\n\nfunction toLedgerHash(bytes: Uint8Array): LedgerHash {\n return `sha256:${toHex(bytes)}`\n}\n\nfunction largestPowerOfTwoBelow(n: number): number {\n let k = 1\n while (k * 2 < n) k *= 2\n return k\n}\n\nfunction isPowerOfTwo(n: number): boolean {\n if (n < 1) return false\n let m = n\n while (m % 2 === 0) m /= 2\n return m === 1\n}\n\nfunction isSize(n: number): boolean {\n return Number.isSafeInteger(n) && n >= 0\n}\n\nfunction equal(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false\n return true\n}\n\nfunction refused(reason: string): MerkleVerification {\n return { verified: false, reason }\n}\n\nfunction toHex(bytes: Uint8Array): string {\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')\n}\n\nfunction fromHex(hex: string): Uint8Array {\n const bytes = new Uint8Array(hex.length / 2)\n for (let i = 0; i < bytes.length; i++) bytes[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16)\n return bytes\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,UAAU,IAAI,YAAY;;AAGhC,MAAa,oBAAgC,4BAAY,IAAI,WAAW,CAAC,CAAC;;AAG1E,SAAgB,aAAqB;CACnC,OAAO,MAAM,WAAW,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,CAAC;AACpE;;;;;AAMA,SAAgB,eAAe,SAA8B,MAA2B;CACtF,MAAM,QAAQ,OAAO,YAAY,WAAW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E,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AAChF;AAEA,SAAS,QAAQ,KAAyB;CACxC,MAAM,QAAQ,IAAI,WAAW,IAAI,SAAS,CAAC;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,MAAM,KAAK,OAAO,SAAS,IAAI,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE;CACjG,OAAO;AACT"}
@@ -11,14 +11,14 @@ import { i as CostLedger, t as CostAccountingIncompleteError } from "./cost-ledg
11
11
  import { B as assertCampaignDesign, D as FinalEvidenceError, E as FinalEvidenceConflictError, F as surfaceHash, G as campaignSplitDigest, H as assertCompleteCampaign, I as surfaceHashMatches, L as BackendIntegrityError, M as renderSurfaceDiff, N as surfaceContentHash, P as surfaceDispatchRef, U as campaignCoverage, V as assertCampaignSplitIdentity, W as campaignScenarioIdentity, b as campaignMeanCompositeOrNull, q as formatCoverageFailures, t as createCampaignEvidenceReceipt, v as campaignBreakdown, y as campaignMeanComposite } from "./campaign-evidence-OcUciD-N.js";
12
12
  import { m as mapConcurrent } from "./journal-DvKCvjty.js";
13
13
  import { t as deepFreezeCanonicalJson } from "./deep-freeze-CurcOQg3.js";
14
- import { S as fsCampaignStorage, g as isRecord, h as isExternalTextCandidate, x as createRunCostLedger } from "./external-optimizer-subprocess-DitxECD3.js";
14
+ import { S as fsCampaignStorage, g as isRecord, h as isExternalTextCandidate, x as createRunCostLedger } from "./external-optimizer-subprocess-CA3aXT8I.js";
15
15
  import { r as summarizeEvaluationUnits, t as defineEvaluationClaim } from "./claim-BXcZw-jo.js";
16
16
  import { f as redactText, n as REDACTION_VERSION, o as detectCredential, s as detectPersonalData } from "./redact-Dk1ZdJEm.js";
17
17
  import { t as detectRewardHacking } from "./reward-hacking-BFcQgkux.js";
18
18
  import { t as assertProposalFindings } from "./proposal-findings-CXblsskH.js";
19
- import { O as paretoFrontier, a as searchPolicyView, i as searchExpansionIndex, k as paretoFrontierWithCrowding, m as EXPANSION_OPERATORS, n as runSearch, t as SEARCH_KERNEL_SOURCE, x as estimateNode } from "./search-kernel-BIXWM7YV.js";
20
- import { a as validateSearchLedgerEvent, d as searchTaskSetDigest, i as replaySearchLedgerText, l as searchCellId, n as openSearchLedger, u as searchNodeId } from "./search-ledger-aMTNQn_m.js";
21
- import { n as searchProposerView, t as renderSearchSummary } from "./search-summary-nwrtXxC_.js";
19
+ import { O as paretoFrontier, a as searchPolicyView, i as searchExpansionIndex, k as paretoFrontierWithCrowding, m as EXPANSION_OPERATORS, n as runSearch, t as SEARCH_KERNEL_SOURCE, x as estimateNode } from "./search-kernel-BztlERLv.js";
20
+ import { a as validateSearchLedgerEvent, d as searchTaskSetDigest, i as replaySearchLedgerText, l as searchCellId, n as openSearchLedger, u as searchNodeId } from "./search-ledger-d7V8o9Lk.js";
21
+ import { n as searchProposerView, t as renderSearchSummary } from "./search-summary-CBvz3u_S.js";
22
22
  import { C as combineAbortSignals, d as stripFencedJson, o as costReceiptFromLlm, s as costReceiptFromLlmError, u as maximumChargeForLlmRequest } from "./llm-client-C_o62yG1.js";
23
23
  import { createHash } from "node:crypto";
24
24
  import { writeFileSync } from "node:fs";
@@ -6174,4 +6174,4 @@ function firstString(value) {
6174
6174
  //#endregion
6175
6175
  export { captureFinalEvidencePolicy as $, assertCompleteSearchHistory as A, searchReceiptAccounting as B, incumbentWithOperatorBandit as C, surfaceDiff as D, searchEdgeId as E, verifySearchHistoryArtifact as F, captureJudge as G, uniform as H, verifySearchHistoryReceipt as I, redTeamDataset as J, defaultProductionGate as K, campaignCellSearchResult as L, assertSearchHistoryMatchesState as M, createSearchHistoryReceipt as N, surfaceNode as O, searchHistoryCoverageRow as P, assertIndependentEvaluationSplit as Q, searchModelIdentity as R, incumbent as S, developmentClaim as T, runFinalComparison as U, asha as V, openAutoPr as W, scoreRedTeamOutput as X, redTeamReport as Y, runCanaries as Z, isProposedCandidate as _, transientDispatchFailure as a, resolveRunDir as at, beam as b, compareOptimizationMethods as c, buildCellSchedule as ct, combineComparisonCosts as d, evaluationUnitMap as et, costFromLedgerSummary as f, runOptimization as g, runImprovementLoop as h, quotaExhaustedUntil as i, planCampaignRun as it, assertSearchHistoryAdmissionOptions as j, SearchHistoryRequiredError as k, optimizationTokenUsageFromSummary as l, cellCachePath as lt, readGepaCandidatePopulationArtifact as m, JudgeParseError as n, runEval as nt, aggregateRunScore as o, tangleTracesRoot as ot, assertGepaCandidatePopulationSummary as p, DEFAULT_RED_TEAM_CORPUS as q, isTransientTransportFailure as r, runCampaign as rt, clamp01 as s, readCachedCell as st, llmJudge as t, reserveFinalEvidence as tt, executeOptimizationMethod as u, computeManifestHash as ut, labelTrustRank as v, SearchRecorder as w, crowdedFrontierParent as x, aide as y, searchProposalExecution as z };
6176
6176
 
6177
- //# sourceMappingURL=llm-judge-BtMxSe1e.js.map
6177
+ //# sourceMappingURL=llm-judge-Dw0rDpve.js.map