@tangle-network/agent-eval 0.120.1 → 0.120.2

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 (171) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/dist/analyst/index.d.ts +0 -3111
  4. package/dist/analyst/index.js +0 -403
  5. package/dist/analyst/index.js.map +0 -1
  6. package/dist/authenticity/index.d.ts +0 -161
  7. package/dist/authenticity/index.js +0 -215
  8. package/dist/authenticity/index.js.map +0 -1
  9. package/dist/belief-state/index.d.ts +0 -1301
  10. package/dist/belief-state/index.js +0 -2152
  11. package/dist/belief-state/index.js.map +0 -1
  12. package/dist/benchmarks/index.d.ts +0 -974
  13. package/dist/benchmarks/index.js +0 -60
  14. package/dist/benchmarks/index.js.map +0 -1
  15. package/dist/builder-eval/index.d.ts +0 -695
  16. package/dist/builder-eval/index.js +0 -366
  17. package/dist/builder-eval/index.js.map +0 -1
  18. package/dist/campaign/index.d.ts +0 -7454
  19. package/dist/campaign/index.js +0 -272
  20. package/dist/campaign/index.js.map +0 -1
  21. package/dist/chunk-32BZXMSO.js +0 -3878
  22. package/dist/chunk-32BZXMSO.js.map +0 -1
  23. package/dist/chunk-3A246TSA.js +0 -998
  24. package/dist/chunk-3A246TSA.js.map +0 -1
  25. package/dist/chunk-3RF76KTD.js +0 -84
  26. package/dist/chunk-3RF76KTD.js.map +0 -1
  27. package/dist/chunk-3YYRZDON.js +0 -45
  28. package/dist/chunk-3YYRZDON.js.map +0 -1
  29. package/dist/chunk-4I2E3LLO.js +0 -1030
  30. package/dist/chunk-4I2E3LLO.js.map +0 -1
  31. package/dist/chunk-ARU2PZFM.js +0 -312
  32. package/dist/chunk-ARU2PZFM.js.map +0 -1
  33. package/dist/chunk-BOD4O7OF.js +0 -40
  34. package/dist/chunk-BOD4O7OF.js.map +0 -1
  35. package/dist/chunk-DPZAEKA6.js +0 -880
  36. package/dist/chunk-DPZAEKA6.js.map +0 -1
  37. package/dist/chunk-DTJ6QUQB.js +0 -131
  38. package/dist/chunk-DTJ6QUQB.js.map +0 -1
  39. package/dist/chunk-GGE4NNQT.js +0 -65
  40. package/dist/chunk-GGE4NNQT.js.map +0 -1
  41. package/dist/chunk-H5UD2323.js +0 -286
  42. package/dist/chunk-H5UD2323.js.map +0 -1
  43. package/dist/chunk-HHWE3POT.js +0 -94
  44. package/dist/chunk-HHWE3POT.js.map +0 -1
  45. package/dist/chunk-HKUCJ437.js +0 -787
  46. package/dist/chunk-HKUCJ437.js.map +0 -1
  47. package/dist/chunk-JHCHEVET.js +0 -274
  48. package/dist/chunk-JHCHEVET.js.map +0 -1
  49. package/dist/chunk-JHOJHHU7.js +0 -867
  50. package/dist/chunk-JHOJHHU7.js.map +0 -1
  51. package/dist/chunk-JM2SKQMS.js +0 -750
  52. package/dist/chunk-JM2SKQMS.js.map +0 -1
  53. package/dist/chunk-JN2FCO5W.js +0 -7958
  54. package/dist/chunk-JN2FCO5W.js.map +0 -1
  55. package/dist/chunk-K4DBDHLK.js +0 -158
  56. package/dist/chunk-K4DBDHLK.js.map +0 -1
  57. package/dist/chunk-K6N6XJJX.js +0 -306
  58. package/dist/chunk-K6N6XJJX.js.map +0 -1
  59. package/dist/chunk-MA6HLL3S.js +0 -65
  60. package/dist/chunk-MA6HLL3S.js.map +0 -1
  61. package/dist/chunk-MAZ26DC7.js +0 -99
  62. package/dist/chunk-MAZ26DC7.js.map +0 -1
  63. package/dist/chunk-MOXWMGPC.js +0 -577
  64. package/dist/chunk-MOXWMGPC.js.map +0 -1
  65. package/dist/chunk-NJC7U437.js +0 -626
  66. package/dist/chunk-NJC7U437.js.map +0 -1
  67. package/dist/chunk-NPCTHQIO.js +0 -91
  68. package/dist/chunk-NPCTHQIO.js.map +0 -1
  69. package/dist/chunk-ONWEPEDO.js +0 -57
  70. package/dist/chunk-ONWEPEDO.js.map +0 -1
  71. package/dist/chunk-OYZAPX5G.js +0 -1526
  72. package/dist/chunk-OYZAPX5G.js.map +0 -1
  73. package/dist/chunk-PC4UYEBM.js +0 -166
  74. package/dist/chunk-PC4UYEBM.js.map +0 -1
  75. package/dist/chunk-PICTDURQ.js +0 -766
  76. package/dist/chunk-PICTDURQ.js.map +0 -1
  77. package/dist/chunk-PJQFMIOX.js +0 -1182
  78. package/dist/chunk-PJQFMIOX.js.map +0 -1
  79. package/dist/chunk-PXD6ZFNY.js +0 -1107
  80. package/dist/chunk-PXD6ZFNY.js.map +0 -1
  81. package/dist/chunk-PXE2VKMX.js +0 -140
  82. package/dist/chunk-PXE2VKMX.js.map +0 -1
  83. package/dist/chunk-PZ5AY32C.js +0 -10
  84. package/dist/chunk-PZ5AY32C.js.map +0 -1
  85. package/dist/chunk-QBRSJK47.js +0 -622
  86. package/dist/chunk-QBRSJK47.js.map +0 -1
  87. package/dist/chunk-QWMPPZ3X.js +0 -550
  88. package/dist/chunk-QWMPPZ3X.js.map +0 -1
  89. package/dist/chunk-S3UZOQ5Y.js +0 -328
  90. package/dist/chunk-S3UZOQ5Y.js.map +0 -1
  91. package/dist/chunk-S5TT5R3L.js +0 -2668
  92. package/dist/chunk-S5TT5R3L.js.map +0 -1
  93. package/dist/chunk-T4SQEITX.js +0 -95
  94. package/dist/chunk-T4SQEITX.js.map +0 -1
  95. package/dist/chunk-TT4KNT67.js +0 -124
  96. package/dist/chunk-TT4KNT67.js.map +0 -1
  97. package/dist/chunk-U5CHZ5M3.js +0 -357
  98. package/dist/chunk-U5CHZ5M3.js.map +0 -1
  99. package/dist/chunk-ULOKLHIQ.js +0 -1937
  100. package/dist/chunk-ULOKLHIQ.js.map +0 -1
  101. package/dist/chunk-VI2UW6B6.js +0 -162
  102. package/dist/chunk-VI2UW6B6.js.map +0 -1
  103. package/dist/chunk-VQMK5FMP.js +0 -247
  104. package/dist/chunk-VQMK5FMP.js.map +0 -1
  105. package/dist/chunk-VSMTAMNK.js +0 -53
  106. package/dist/chunk-VSMTAMNK.js.map +0 -1
  107. package/dist/chunk-VZSRQ272.js +0 -149
  108. package/dist/chunk-VZSRQ272.js.map +0 -1
  109. package/dist/chunk-WW2A73HW.js +0 -159
  110. package/dist/chunk-WW2A73HW.js.map +0 -1
  111. package/dist/chunk-X4UCIOTZ.js +0 -136
  112. package/dist/chunk-X4UCIOTZ.js.map +0 -1
  113. package/dist/chunk-XDIRG3TO.js +0 -1266
  114. package/dist/chunk-XDIRG3TO.js.map +0 -1
  115. package/dist/chunk-XJYR7XFV.js +0 -317
  116. package/dist/chunk-XJYR7XFV.js.map +0 -1
  117. package/dist/chunk-ZET2UAYW.js +0 -89
  118. package/dist/chunk-ZET2UAYW.js.map +0 -1
  119. package/dist/chunk-ZZUXHH3R.js +0 -99
  120. package/dist/chunk-ZZUXHH3R.js.map +0 -1
  121. package/dist/cli.d.ts +0 -1
  122. package/dist/cli.js +0 -112
  123. package/dist/cli.js.map +0 -1
  124. package/dist/contract/index.d.ts +0 -4972
  125. package/dist/contract/index.js +0 -1654
  126. package/dist/contract/index.js.map +0 -1
  127. package/dist/control.d.ts +0 -1013
  128. package/dist/control.js +0 -34
  129. package/dist/control.js.map +0 -1
  130. package/dist/fuzz.d.ts +0 -759
  131. package/dist/fuzz.js +0 -714
  132. package/dist/fuzz.js.map +0 -1
  133. package/dist/hosted/index.d.ts +0 -730
  134. package/dist/hosted/index.js +0 -14
  135. package/dist/hosted/index.js.map +0 -1
  136. package/dist/index.d.ts +0 -16780
  137. package/dist/index.js +0 -12168
  138. package/dist/index.js.map +0 -1
  139. package/dist/matrix/index.d.ts +0 -155
  140. package/dist/matrix/index.js +0 -8
  141. package/dist/matrix/index.js.map +0 -1
  142. package/dist/meta-eval/index.d.ts +0 -1030
  143. package/dist/meta-eval/index.js +0 -417
  144. package/dist/meta-eval/index.js.map +0 -1
  145. package/dist/multishot/index.d.ts +0 -579
  146. package/dist/multishot/index.js +0 -589
  147. package/dist/multishot/index.js.map +0 -1
  148. package/dist/openapi.json +0 -992
  149. package/dist/pipelines/index.d.ts +0 -567
  150. package/dist/pipelines/index.js +0 -515
  151. package/dist/pipelines/index.js.map +0 -1
  152. package/dist/reporting.d.ts +0 -1277
  153. package/dist/reporting.js +0 -48
  154. package/dist/reporting.js.map +0 -1
  155. package/dist/rl.d.ts +0 -4092
  156. package/dist/rl.js +0 -1724
  157. package/dist/rl.js.map +0 -1
  158. package/dist/run-campaign-HNFPJET4.js +0 -14
  159. package/dist/run-campaign-HNFPJET4.js.map +0 -1
  160. package/dist/storyboard/index.d.ts +0 -279
  161. package/dist/storyboard/index.js +0 -767
  162. package/dist/storyboard/index.js.map +0 -1
  163. package/dist/trace-attributes.d.ts +0 -52
  164. package/dist/trace-attributes.js +0 -62
  165. package/dist/trace-attributes.js.map +0 -1
  166. package/dist/traces.d.ts +0 -2343
  167. package/dist/traces.js +0 -249
  168. package/dist/traces.js.map +0 -1
  169. package/dist/wire/index.d.ts +0 -1252
  170. package/dist/wire/index.js +0 -81
  171. package/dist/wire/index.js.map +0 -1
@@ -1,974 +0,0 @@
1
- type AgentProfileCellSchemaVersion = 'agent-profile-cell/v1';
2
- type AgentProfileJson = string | number | boolean | null | AgentProfileJson[] | {
3
- [key: string]: AgentProfileJson;
4
- };
5
- type AgentProfileDimensionValue = string | number | boolean | null;
6
- interface AgentProfileSource {
7
- /** Runtime/profile contract being fingerprinted, e.g. `agent-interface-profile`. */
8
- kind: string;
9
- /** sha256 over the canonical source profile object. */
10
- hash: string;
11
- }
12
- interface AgentProfileHarness {
13
- id: string;
14
- version?: string;
15
- hash?: string;
16
- }
17
- interface AgentProfileCell {
18
- schemaVersion: AgentProfileCellSchemaVersion;
19
- cellId: string;
20
- profileId: string;
21
- sourceProfile: AgentProfileSource;
22
- harness?: AgentProfileHarness;
23
- model?: string;
24
- promptHash?: string;
25
- dimensions?: Record<string, AgentProfileDimensionValue>;
26
- }
27
-
28
- type CostChannel = 'agent' | 'judge' | 'verifier' | 'analyst' | 'driver' | (string & {});
29
- interface CostUsage {
30
- inputTokens: number;
31
- /** Includes reasoning tokens when the provider bills them as output. */
32
- outputTokens: number;
33
- /** Reasoning-token subset of outputTokens, when reported. */
34
- reasoningTokens?: number;
35
- /** Prompt tokens served from a provider cache. */
36
- cachedTokens?: number;
37
- /** Prompt tokens written into a provider cache. */
38
- cacheWriteTokens?: number;
39
- }
40
- interface CostCallBase {
41
- callId: string;
42
- channel: CostChannel;
43
- phase: string;
44
- actor: string;
45
- model: string;
46
- maximumCostUsd?: number;
47
- tags?: Record<string, string>;
48
- timestamp: number;
49
- }
50
- interface CostReceipt extends CostCallBase, CostUsage {
51
- status: 'settled';
52
- costUsd: number;
53
- costUnknown: boolean;
54
- usageUnknown?: boolean;
55
- pricing?: {
56
- inputUsdPerThousand: number;
57
- outputUsdPerThousand: number;
58
- };
59
- actualCostUsd?: number;
60
- error?: string;
61
- }
62
- interface CostReceiptInput extends CostUsage {
63
- model: string;
64
- actualCostUsd?: number;
65
- costUnknown?: boolean;
66
- usageUnknown?: boolean;
67
- }
68
- type MaximumCharge = {
69
- externallyEnforcedMaximumUsd: number;
70
- } | ({
71
- model: string;
72
- } & CostUsage);
73
- interface RunPaidCallInput<T> {
74
- callId?: string;
75
- channel: CostChannel;
76
- phase: string;
77
- actor: string;
78
- /** Used before a provider receipt exists and on failures without one. */
79
- model?: string;
80
- tags?: Record<string, string>;
81
- signal?: AbortSignal;
82
- /** Provider-enforced dollar maximum, or maximum priced token usage. Required when capped. */
83
- maximumCharge?: MaximumCharge;
84
- /** `callId` can be forwarded as the provider's idempotency key. */
85
- execute(signal: AbortSignal, callId: string): Promise<T>;
86
- receipt(value: T): CostReceiptInput;
87
- receiptFromError?(error: Error): CostReceiptInput | undefined;
88
- }
89
- type PaidCallResult<T> = {
90
- succeeded: true;
91
- callId: string;
92
- value: T;
93
- receipt: CostReceipt;
94
- } | {
95
- succeeded: false;
96
- callId?: string;
97
- error: Error;
98
- receipt?: CostReceipt;
99
- };
100
- interface ChannelRollup {
101
- channel: CostChannel;
102
- calls: number;
103
- inputTokens: number;
104
- outputTokens: number;
105
- reasoningTokens?: number;
106
- cachedTokens: number;
107
- cacheWriteTokens?: number;
108
- costUsd: number;
109
- unpricedCalls: number;
110
- unknownUsageCalls: number;
111
- }
112
- interface CostLedgerSummary {
113
- totalCalls: number;
114
- pendingCalls: number;
115
- unresolvedCalls: number;
116
- reservedCostUsd: number;
117
- inputTokens: number;
118
- outputTokens: number;
119
- reasoningTokens?: number;
120
- cachedTokens: number;
121
- cacheWriteTokens?: number;
122
- totalCostUsd: number;
123
- byChannel: ChannelRollup[];
124
- unpricedModels: string[];
125
- fullyPriced: boolean;
126
- usageComplete: boolean;
127
- accountingComplete: boolean;
128
- incompleteReasons: string[];
129
- }
130
-
131
- /**
132
- * Paper-grade RunRecord schema + runtime validator.
133
- *
134
- * Every run that participates in a promotion gate, paper table, or
135
- * researcher loop SHOULD be recorded as a `RunRecord`. The mandatory
136
- * fields are exactly those the paper "Two Loops, Three Roles" requires
137
- * for reproducibility: who/what/when/cost/seed/hash, plus the search vs
138
- * holdout split tag and either a `searchScore` or a `holdoutScore`.
139
- *
140
- * This is intentionally NOT a replacement for the rich `Run` /
141
- * `ProposeReviewReport` / `ScenarioResult` types already in the
142
- * package. Those are runtime structures with full provenance. A
143
- * `RunRecord` is the analysis-time projection — the JSON-friendly
144
- * row you'd put in a parquet file or paste into a notebook.
145
- *
146
- * Validate at the boundary:
147
- *
148
- * const rec = validateRunRecord(rawJson) // throws on missing
149
- * const ok = isRunRecord(rawJson) // boolean check
150
- * const rec = parseRunRecordSafe(rawJson) // { ok, value | error }
151
- *
152
- * The validator runs in pure TS — zod is intentionally NOT a
153
- * dependency. Round-trip tested in `tests/run-record.test.ts`.
154
- */
155
-
156
- /** Search/dev/holdout split tag. 'search' is the paper-grade alias for the
157
- * combined train+test pool that the optimizer is allowed to read. */
158
- type RunSplitTag = 'search' | 'dev' | 'holdout';
159
- interface RunTokenUsage {
160
- input: number;
161
- /** All generated tokens charged as output, including reasoning tokens. */
162
- output: number;
163
- /** Reasoning-token subset of `output`, when the provider reports it. */
164
- reasoning?: number;
165
- /** Prompt tokens served from a provider cache. */
166
- cached?: number;
167
- /** Prompt tokens written into a provider cache. */
168
- cacheWrite?: number;
169
- }
170
-
171
- /**
172
- * LLM client with graceful degrade.
173
- *
174
- * OpenAI-compatible `/v1/chat/completions` client with:
175
- * - Exponential-backoff retry on 429 + 5xx gateway errors (502/503/504).
176
- * - Retry on transient network errors (fetch failed, AbortError, ECONNRESET).
177
- * - Graceful json_schema → json_object degrade on 400 with schema-reject body.
178
- * - Fenced-JSON stripping (```json ... ```) for models that wrap structured output.
179
- * - Configurable base URL + api key / bearer, works with LiteLLM proxies, OpenAI
180
- * directly, cli-bridge subscriptions, and any router that speaks the spec.
181
- *
182
- * Usage:
183
- * const { value, result } = await callLlmJson<MyType>(
184
- * { model: 'gpt-4o', messages: [...], jsonSchema: { name: 'x', schema: {...} } },
185
- * { baseUrl: 'https://router.tangle.tools/v1', apiKey: process.env.KEY },
186
- * )
187
- *
188
- * This is THE llm-calling seam for agent-eval primitives that need structured
189
- * output (semantic concept judge, reviewer directives, critic scores). Primitives
190
- * that need free-form text use `callLlm` and parse output themselves.
191
- */
192
-
193
- interface LlmUsage {
194
- promptTokens: number;
195
- completionTokens: number;
196
- totalTokens: number;
197
- /** False when the provider omitted or malformed prompt/completion usage. */
198
- captured?: boolean;
199
- /** Proxies populate this when prompt caching is on. */
200
- cachedPromptTokens?: number;
201
- }
202
- interface LlmCallResult {
203
- /** The text content of the first choice. Empty string if none. */
204
- content: string;
205
- usage: LlmUsage;
206
- /**
207
- * Cost in USD. Pulled from proxy's `_response_cost` field when present;
208
- * `null` when neither the proxy nor the caller can derive it.
209
- */
210
- costUsd: number | null;
211
- /** Model name actually used (echoed from response). */
212
- model: string;
213
- /** Wall-clock duration of the HTTP call (last attempt, if retried). */
214
- durationMs: number;
215
- /**
216
- * `finish_reason` echoed from the first choice (`stop`, `length`,
217
- * `content_filter`, `tool_calls`, ...). `null` when the provider omits it.
218
- * Exposed so a free-form `callLlm` caller CAN detect a truncated answer
219
- * (`length`) instead of treating a cut-off completion as complete. Note:
220
- * `callLlm` does not itself reject on it — acting on this signal is the
221
- * caller's responsibility (in-repo free-form drivers do not yet enforce it).
222
- */
223
- finishReason?: string | null;
224
- /**
225
- * True when `content.trim()` is empty. An empty completion is a silent zero
226
- * for free-form `callLlm` callers; this flag is the signal a caller can
227
- * inspect to fail loud rather than proceed on an empty string. `callLlm`
228
- * surfaces it but does not throw on it.
229
- */
230
- contentEmpty?: boolean;
231
- /** Raw response body. */
232
- raw: Record<string, unknown>;
233
- }
234
- type LlmCallMetadata = Pick<LlmCallResult, 'usage' | 'costUsd' | 'model' | 'durationMs'>;
235
-
236
- /**
237
- * Analyst contract — the missing orchestration layer over agent-eval's
238
- * existing analyzers (analyzeTraces, MultiLayerVerifier, RunCritic,
239
- * SemanticConceptJudge, JudgeFn, ...).
240
- *
241
- * Each existing primitive returns its own output shape. The Analyst
242
- * contract is the single envelope every primitive lifts into, so a
243
- * registry can run N analysts against a run and a single renderer can
244
- * compose findings without knowing which analyzer produced them.
245
- *
246
- * The contract is intentionally domain-agnostic: nothing here knows
247
- * about code, voice, RAG, or any particular agent stack. Analysts
248
- * declare what INPUT KIND they need (a trace store, an artifact dir,
249
- * a RunRecord, a JudgeInput, or `custom`), and the registry routes
250
- * the matching input from `AnalystRunInputs`.
251
- */
252
-
253
- interface EvidenceRef {
254
- /**
255
- * Where the evidence lives. `span` and `event` refer to OTLP trace
256
- * elements; `artifact` to a file inside the run's artifact tree;
257
- * `finding` to another AnalystFinding (cross-analyst chaining);
258
- * `metric` to a named scalar reading the renderer knows how to read.
259
- */
260
- kind: 'span' | 'event' | 'artifact' | 'finding' | 'metric';
261
- uri: string;
262
- excerpt?: string;
263
- }
264
-
265
- type PolicyEditSchemaVersion = 'policy-edit/v1';
266
- declare const POLICY_EDIT_AXES: readonly ["carrier", "representation", "budget", "sampling", "output_contract", "tool_contract", "routing", "memory", "agent_profile", "deployment_target"];
267
- type PolicyEditAxis = (typeof POLICY_EDIT_AXES)[number];
268
- declare const POLICY_EDIT_TARGET_SURFACES: readonly ["prompt", "tool-contract", "runtime-config", "memory", "agent-profile", "code", "deployment"];
269
- type PolicyEditTargetSurface = (typeof POLICY_EDIT_TARGET_SURFACES)[number];
270
- type PolicyEditRisk = 'low' | 'medium' | 'high' | 'unknown';
271
- type PolicyEditGainDirection = 'increase' | 'decrease';
272
- type PolicyEditGainUnit = 'absolute' | 'relative' | 'percent' | 'score';
273
- interface PolicyEditTarget {
274
- surface: PolicyEditTargetSurface;
275
- /** Stable path inside the target surface, for example `system-prompt:tools`
276
- * or `budget.maxTurns`. */
277
- path?: string;
278
- /** Optional canonical deployment identity. Store the existing cell, not a
279
- * local profile shape. */
280
- agentProfileCell?: AgentProfileCell;
281
- /** Human label when the path is not enough for a readable audit trail. */
282
- label?: string;
283
- }
284
- type PolicyEditChange = {
285
- kind: 'text';
286
- mode: 'append' | 'prepend' | 'replace';
287
- value: string;
288
- /** Required when `mode === 'replace'`; exact match only. */
289
- find?: string;
290
- } | {
291
- kind: 'json';
292
- mode: 'set' | 'merge' | 'remove';
293
- path: string;
294
- value?: AgentProfileJson;
295
- };
296
- interface PolicyEditExpectedGain {
297
- /** Metric this edit is expected to move, e.g. `holdout.composite`. */
298
- metric: string;
299
- direction: PolicyEditGainDirection;
300
- /** Positive magnitude in the metric's native units. */
301
- amount: number;
302
- unit?: PolicyEditGainUnit;
303
- rationale?: string;
304
- }
305
- interface PolicyEditSource {
306
- findingIds: string[];
307
- analystIds: string[];
308
- evidenceRefs: EvidenceRef[];
309
- /** Mirrors `AnalystFinding.derived_from_judge`; admission rejects it. */
310
- derivedFromJudge?: boolean;
311
- }
312
- interface PolicyEdit {
313
- schemaVersion: PolicyEditSchemaVersion;
314
- editId: string;
315
- axis: PolicyEditAxis;
316
- target: PolicyEditTarget;
317
- change: PolicyEditChange;
318
- claim: string;
319
- expectedGain: PolicyEditExpectedGain;
320
- confidence: number;
321
- risk: PolicyEditRisk;
322
- source: PolicyEditSource;
323
- rationale?: string;
324
- validationPlan?: string;
325
- metadata?: Record<string, unknown>;
326
- }
327
- declare const POLICY_EDIT_CANDIDATE_RECORD_SCHEMA: "tangle.policy-edit-candidate.v1";
328
- /** JSON-safe attribution carried with a measured candidate and its scores. */
329
- interface PolicyEditCandidateRecord {
330
- schema: typeof POLICY_EDIT_CANDIDATE_RECORD_SCHEMA;
331
- policyEdit: PolicyEdit;
332
- }
333
-
334
- /**
335
- * Pass A substrate types — `runCampaign` is the one primitive every
336
- * eval flow composes from. Three contracts in this file:
337
- *
338
- * - `Scenario` input set
339
- * - `DispatchFn` how to run one scenario → artifact
340
- * - `CampaignResult` defined output schema (the contract downstream tools depend on)
341
- *
342
- * Three more lifted from earlier substrate work (re-exported):
343
- *
344
- * - `JudgeConfig` pluggable dimensional scorer (0.38)
345
- * - `Mutator` optimization-loop surface mutator
346
- * - `Gate` promotion gate (`HeldOutGate` and friends adapt to this)
347
- *
348
- * No new architecture vs 0.38 — Pass A formalizes the shapes so consumers
349
- * can build dashboards / CI gates / regression diffs against a stable schema.
350
- */
351
-
352
- /** Stable identifier + kind tag for any scenario. Consumers
353
- * extend with their per-domain payload (persona, task, requirement, ...). */
354
- interface Scenario {
355
- id: string;
356
- kind: string;
357
- tags?: string[];
358
- }
359
- /** Redacted identity of a complete scenario payload retained in campaign results. */
360
- interface CampaignScenarioIdentity extends Pick<Scenario, 'id' | 'kind'> {
361
- scenarioDigest: `sha256:${string}`;
362
- }
363
- /** Context handed to every dispatch invocation. Scoped — every
364
- * trace/span carries the cellId, every artifact write lands under the cell's
365
- * artifact root, the cost meter accumulates per cell. */
366
- interface DispatchContext {
367
- cellId: string;
368
- rep: number;
369
- generation?: number;
370
- seed: number;
371
- signal: AbortSignal;
372
- trace: CampaignTraceWriter;
373
- artifacts: CampaignArtifactWriter;
374
- cost: CampaignCostMeter;
375
- /** Populated when this run is part of a multi-cycle improvement loop. */
376
- cycleId?: string;
377
- /** Populated when the substrate resumed from a prior cache hit. */
378
- resumedFrom?: string;
379
- /**
380
- * Opaque placement key supplied by `RunCampaignOptions.cellPlacement`.
381
- * The substrate forwards it through unchanged; placement-aware Dispatch
382
- * implementations (e.g. `httpDispatch` from `/adapters/http`) read it to
383
- * route the cell to the right worker / region / sandbox. `undefined`
384
- * when no placement strategy is configured.
385
- */
386
- placement?: string;
387
- }
388
- /** The canonical judge verdict shape — one declaration, shared by campaign
389
- * judges and the multishot judge runner (which re-exports this type).
390
- *
391
- * Scale is PRODUCER-DEFINED: campaign convention is [0,1]; the legacy
392
- * multishot runner emits 0-10. Cross-scale comparison must go through
393
- * `detectScale` (src/campaign/gates/statistical-heldout.ts, used by
394
- * promotion-policy) — never renormalize a producer's values in place, as
395
- * downstream thresholds (`composite >= 5` in multishot/matrix.ts, live-soak
396
- * `>= 7` gates) key on the producer's native scale. */
397
- interface JudgeScore {
398
- dimensions: Record<string, number>;
399
- composite: number;
400
- notes: string;
401
- /** Provider metadata for display and diagnostics; accounting uses CostLedger receipts. */
402
- llmCall?: LlmCallMetadata;
403
- /** Set when the judge itself failed (call error, unparseable output).
404
- * `composite`/`dimensions` carry no signal — aggregators MUST exclude
405
- * failed scores from means instead of folding them into zeros. */
406
- failed?: true;
407
- /** Ensemble extras (populated by `ensembleJudge`): max per-dimension
408
- * spread across surviving judges — the inter-rater signal. */
409
- maxDisagreement?: number;
410
- /** Ensemble extras: judge identities whose verdict failed. */
411
- failedJudges?: string[];
412
- /** Ensemble extras: each surviving judge's per-dimension scores. */
413
- perJudge?: Record<string, Record<string, number>>;
414
- }
415
- /** Five-valued verdict taxonomy (MOSS-paper alignment). */
416
- type GateDecision = 'ship' | 'hold' | 'need_more_work' | 'model_ceiling' | 'arch_ceiling';
417
- interface GateResult {
418
- decision: GateDecision;
419
- reasons: string[];
420
- contributingGates: Array<{
421
- name: string;
422
- passed: boolean;
423
- detail: unknown;
424
- }>;
425
- delta?: number;
426
- }
427
- /** Scoped trace writer handed to each dispatch — every span
428
- * auto-tagged with the cellId so traces filter cleanly. */
429
- interface CampaignTraceWriter {
430
- span(name: string, attributes?: Record<string, unknown>): TraceSpan;
431
- flush(): Promise<void>;
432
- }
433
- interface TraceSpan {
434
- end(attributes?: Record<string, unknown>): void;
435
- setAttribute(key: string, value: unknown): void;
436
- }
437
- /** Scoped artifact writer — `write(path, content)` lands under
438
- * `<runDir>/<cellId>/<path>`. */
439
- interface CampaignArtifactWriter {
440
- write(path: string, content: string | Uint8Array): Promise<string>;
441
- writeJson(path: string, value: unknown): Promise<string>;
442
- }
443
- /** Token usage accumulated for a cell. Aliased to the canonical `RunTokenUsage`
444
- * (run-record.ts, same package) so a cell maps onto a `RunRecord` for the
445
- * backend-integrity guard with ONE source of truth — a field added to
446
- * `RunTokenUsage` is a compile error here, not a silent drift. */
447
- type CampaignTokenUsage = RunTokenUsage;
448
- /** Cell-scoped paid-call entry point. The dispatch places every paid operation
449
- * inside `runPaidCall`; the returned provider result supplies one receipt with
450
- * cost, tokens, and resolved model. Calls made outside this method are not
451
- * admitted or captured. */
452
- interface CampaignCostMeter {
453
- /** The only paid-call path. Returns a typed result; callers must inspect it. */
454
- runPaidCall<T>(input: Omit<RunPaidCallInput<T>, 'channel' | 'phase' | 'tags'> & {
455
- channel?: CostChannel;
456
- }): Promise<PaidCallResult<T>>;
457
- }
458
- interface CampaignCellResult<TArtifact> {
459
- /** Manifest that produced this cell. Resumability refuses to reuse a cell
460
- * whose manifest differs from the current run. */
461
- manifestHash?: string;
462
- cellId: string;
463
- scenarioId: string;
464
- rep: number;
465
- generation?: number;
466
- artifact: TArtifact;
467
- judgeScores: Record<string, JudgeScore>;
468
- costUsd: number;
469
- /** True when at least one priced receipt used the model table instead of a provider bill. */
470
- costEstimated?: boolean;
471
- /** Exact durable receipts required to reuse this cached result. */
472
- costCallIds?: string[];
473
- /** Agent-call token usage committed by `ctx.cost.runPaidCall`.
474
- * `{ input: 0, output: 0 }` when no paid agent call was recorded. */
475
- tokenUsage: CampaignTokenUsage;
476
- /** Concrete model from the latest committed agent receipt. Consumed by
477
- * `buildRunRecord` to pin the model when the declared profile uses a
478
- * runtime-resolved sentinel. */
479
- resolvedModel?: string;
480
- durationMs: number;
481
- seed: number;
482
- cached: boolean;
483
- error?: string;
484
- }
485
- interface JudgeAggregate {
486
- mean: number;
487
- stdev: number;
488
- ci95: [number, number];
489
- n: number;
490
- }
491
- interface ScenarioAggregate {
492
- meanComposite: number;
493
- ci95: [number, number];
494
- n: number;
495
- }
496
- interface GenerationRecord {
497
- generationIndex: number;
498
- candidates: GenerationCandidate[];
499
- promoted: string[];
500
- }
501
- /** One scored candidate surface in a generation. `dimensions` + `scenarios`
502
- * let a reflective proposer ground its next proposal on WHICH
503
- * dimensions the candidate is weakest on and WHICH scenarios it best/worst
504
- * handled — the evidence a blind `Mutator` cannot see. */
505
- interface GenerationCandidate {
506
- surfaceHash: string;
507
- composite: number;
508
- ci95: [number, number];
509
- /** Exact surface this candidate mutated. */
510
- parentSurfaceHash?: string;
511
- /** Measured search-split composite of the exact parent surface. */
512
- parentComposite?: number;
513
- /** Candidate composite minus its parent's composite. Present only when the
514
- * candidate completed the designed denominator. */
515
- observedDeltaFromParent?: number;
516
- /** Whether this candidate had a scorable result for every designed campaign
517
- * cell and was therefore eligible for ranking, promotion, and Pareto
518
- * selection. Older externally-authored records may omit this field; loop
519
- * records always populate it. */
520
- eligibleForPromotion?: boolean;
521
- /** Exact denominator receipt for selection eligibility. Scores stay
522
- * descriptive: an incomplete candidate is retained with its observed score
523
- * and errors instead of receiving an invented penalty. */
524
- coverage?: {
525
- expectedCells: number;
526
- scorableCells: number;
527
- unscorableCells: Array<{
528
- cellId: string;
529
- reason: string;
530
- }>;
531
- };
532
- /** Mean score per judge dimension across all cells (scenarios × reps ×
533
- * judges that reported the dimension). */
534
- dimensions: Record<string, number>;
535
- /** Per-scenario composite (mean over reps + judges), plus the judge's
536
- * free-form `notes` for that scenario — the "why it scored low" evidence a
537
- * reflective proposer grounds its next edit on. Keep `notes` GENERALIZABLE
538
- * (which checks/lines/dimensions failed and how), NOT case-specific ground
539
- * truth: leaking expected answers into the prompt is memorization, and the
540
- * held-out gate would reject it anyway. */
541
- scenarios: Array<{
542
- scenarioId: string;
543
- composite: number;
544
- notes?: string;
545
- }>;
546
- /** Proposer-supplied short label for the change. Present when the proposer
547
- * returned a `ProposedCandidate`; absent for bare-surface mutators. */
548
- label?: string;
549
- /** Proposer-supplied rationale — WHY this candidate was proposed. The
550
- * "because rationale Z" the audit requires to survive to the result.
551
- * Present when the proposer returned a `ProposedCandidate`. */
552
- rationale?: string;
553
- /** Exact structured cause threaded from the proposer, when available. */
554
- candidateRecord?: PolicyEditCandidateRecord;
555
- }
556
- interface CampaignAggregates {
557
- byJudge: Record<string, JudgeAggregate>;
558
- byScenario: Record<string, ScenarioAggregate>;
559
- /** Canonical campaign accounting, including worker and judge calls. */
560
- cost: CostLedgerSummary;
561
- /** Compatibility alias of `cost.totalCostUsd`. */
562
- totalCostUsd: number;
563
- cellsExecuted: number;
564
- cellsSkipped: number;
565
- cellsCached: number;
566
- cellsFailed: number;
567
- }
568
- interface CampaignResult<TArtifact = unknown, TScenario extends Scenario = Scenario> {
569
- /** sha256(scenarios, judges, dispatch source ref, optimizer config, seed). Stable identity for reruns. */
570
- manifestHash: string;
571
- /** Canonical identity of the exact scenario payloads and replicate count. */
572
- splitDigest: `sha256:${string}`;
573
- seed: number;
574
- /** Replicates designed for every scenario in this campaign. */
575
- reps: number;
576
- startedAt: string;
577
- endedAt: string;
578
- durationMs: number;
579
- cells: Array<CampaignCellResult<TArtifact>>;
580
- aggregates: CampaignAggregates;
581
- optimization?: {
582
- generations: GenerationRecord[];
583
- winnerSurfaceHash?: string;
584
- };
585
- gate?: GateResult;
586
- prUrl?: string;
587
- runDir: string;
588
- artifactsByPath: Record<string, string>;
589
- /** Redacted identities that let consumers verify the exact scenario payloads
590
- * without retaining customer task content in the result. */
591
- scenarios: Array<CampaignScenarioIdentity & Pick<TScenario, 'id' | 'kind'>>;
592
- }
593
-
594
- /**
595
- * Shared types for the reference benchmark wrappers under
596
- * `src/benchmarks/`. Each wrapper exports the three functions in
597
- * `BenchmarkAdapter` plus its own typed `DatasetItem` shape.
598
- */
599
-
600
- type BenchmarkTaskKind = 'retrieval' | 'rag-answer' | 'hallucination' | 'kb-improvement' | 'routing' | 'custom';
601
- type BenchmarkFamily = 'beir' | 'mteb-retrieval' | 'msmarco' | 'trec-dl' | 'miracl' | 'lotte' | 'bright' | 'crag' | 'hotpotqa' | 'kilt' | 'ragtruth' | 'faithbench' | 'first-party' | 'custom';
602
- interface BenchmarkDatasetItem<TPayload = unknown> {
603
- /** Stable dataset-local item id (used for split assignment + paper
604
- * references). Unique within a benchmark. */
605
- id: string;
606
- /** Free-form payload. Each benchmark defines its own shape. */
607
- payload: TPayload;
608
- /** Optional precomputed split. When absent, adapters use assignSplit(id). */
609
- split?: RunSplitTag;
610
- /** Benchmark family this row came from, e.g. `beir` or `crag`. */
611
- family?: BenchmarkFamily | string;
612
- /** Benchmark-local task kind, e.g. retrieval vs answer quality. */
613
- taskKind?: BenchmarkTaskKind | string;
614
- /** Slice labels such as language, domain, freshness, multihop, long-tail. */
615
- tags?: string[];
616
- /** Dataset provenance, version, URL, or license notes. */
617
- source?: BenchmarkSource;
618
- metadata?: Record<string, unknown>;
619
- }
620
- interface BenchmarkEvaluation {
621
- /** [0, 1] score for the response on this item. Exact-match
622
- * benchmarks use 0/1; partial-credit benchmarks may return
623
- * fractional values. */
624
- score: number;
625
- /** Optional pass/fail projection. Defaults to `score > 0` when absent. */
626
- passed?: boolean;
627
- /** Numeric sub-metrics. These become report dimensions. */
628
- dimensions?: Record<string, number>;
629
- /** Optional bag of raw scoring signals — e.g. parsed numeric
630
- * answer, regex match, judge sub-scores. */
631
- raw: Record<string, unknown>;
632
- notes?: string;
633
- }
634
- interface BenchmarkSource {
635
- name?: string;
636
- url?: string;
637
- version?: string;
638
- license?: string;
639
- citation?: string;
640
- }
641
- /** Common signature implemented by every adapter under `src/benchmarks/*`. */
642
- interface BenchmarkAdapter<_TItem = unknown, TPayload = unknown, TArtifact = string> {
643
- /** Stable benchmark id such as `beir/nfcorpus` or `crag/smoke`. */
644
- id?: string;
645
- family?: BenchmarkFamily | string;
646
- taskKind?: BenchmarkTaskKind | string;
647
- description?: string;
648
- source?: BenchmarkSource;
649
- defaultMetric?: string;
650
- /** Load the dataset for the given split. May hit the network on
651
- * first call but should be cache-friendly. Adapters that don't
652
- * ship the dataset itself MUST throw a clearly-marked error
653
- * pointing the caller at the loader script. */
654
- loadDataset(split: RunSplitTag): Promise<BenchmarkDatasetItem<TPayload>[]>;
655
- /** Score a single response. Pure with respect to the inputs. */
656
- evaluate(item: BenchmarkDatasetItem<TPayload>, artifact: TArtifact): Promise<BenchmarkEvaluation>;
657
- /** Deterministic split assignment via item id hashing. The
658
- * fraction of items in each split is implementation-defined but
659
- * MUST be stable across processes and platforms. */
660
- assignSplit(itemId: string): RunSplitTag;
661
- }
662
- interface BenchmarkScenario<TPayload = unknown> extends Scenario {
663
- kind: 'benchmark';
664
- benchmarkId: string;
665
- family: BenchmarkFamily | string;
666
- taskKind: BenchmarkTaskKind | string;
667
- splitTag: RunSplitTag;
668
- item: BenchmarkDatasetItem<TPayload>;
669
- }
670
- type BenchmarkResponder<TPayload = unknown, TArtifact = string> = (input: {
671
- scenario: BenchmarkScenario<TPayload>;
672
- item: BenchmarkDatasetItem<TPayload>;
673
- context: DispatchContext;
674
- }) => Promise<TArtifact> | TArtifact;
675
- /** Split-assignment seed shared across all benchmarks. Bumping this
676
- * value reshuffles every split — do NOT do that lightly. */
677
- declare const BENCHMARK_SPLIT_SEED = "agent-eval-v1";
678
- /**
679
- * Assign an item id to one of `'search' | 'dev' | 'holdout'` using a
680
- * stable 32-bit hash of `${seed}::${id}`. Default proportions:
681
- *
682
- * search: 60% (optimization-readable)
683
- * dev: 20% (held-out for tuning, leak-on-purpose during dev)
684
- * holdout:20% (paper-grade held-out, gated reads)
685
- */
686
- declare function deterministicSplit(itemId: string, seed?: string): RunSplitTag;
687
-
688
- interface BenchmarkMetricCalibrationOptions<TPayload = unknown, TArtifact = string> {
689
- adapter: BenchmarkAdapter<BenchmarkDatasetItem<TPayload>, TPayload, TArtifact>;
690
- item: BenchmarkDatasetItem<TPayload>;
691
- weakArtifact: TArtifact;
692
- strongArtifact: TArtifact;
693
- maxWeakScore?: number;
694
- minStrongScore?: number;
695
- minGap?: number;
696
- }
697
- interface BenchmarkMetricCalibrationResult {
698
- passed: boolean;
699
- weak: BenchmarkEvaluation;
700
- strong: BenchmarkEvaluation;
701
- weakScore: number;
702
- strongScore: number;
703
- gap: number;
704
- reasons: string[];
705
- }
706
- declare function calibrateBenchmarkMetric<TPayload = unknown, TArtifact = string>(options: BenchmarkMetricCalibrationOptions<TPayload, TArtifact>): Promise<BenchmarkMetricCalibrationResult>;
707
-
708
- /**
709
- * Synthetic routing dataset. 16 tasks across 4 categories. Used as a
710
- * deterministic, dependency-free benchmark for any router that maps a
711
- * natural-language request to one of a fixed set of route labels.
712
- *
713
- * Format (see `routing/README.md` for prose):
714
- *
715
- * {
716
- * id: stable per-task ID (matches across processes).
717
- * category: one of the four route labels.
718
- * prompt: the user-facing request the router must classify.
719
- * route: the ground-truth route the router should pick.
720
- * synonyms: other strings that count as a correct answer.
721
- * hardNegatives:close-but-wrong route labels — used to detect the
722
- * "always picks the popular route" failure mode.
723
- * }
724
- *
725
- * The four categories are intentionally cross-domain (file ops,
726
- * math, search, conversation) so a router that collapses to one
727
- * category is easy to spot.
728
- */
729
- interface RoutingItem {
730
- id: string;
731
- category: 'file' | 'math' | 'search' | 'chat';
732
- prompt: string;
733
- /** Canonical correct route label. */
734
- route: string;
735
- /** Alternate route labels that also count as correct. */
736
- synonyms: string[];
737
- /** Wrong-but-tempting route labels (for analysis, not grading). */
738
- hardNegatives: string[];
739
- }
740
- declare const ROUTING_DATASET: RoutingItem[];
741
-
742
- /**
743
- * Routing benchmark — synthetic, dependency-free, ships in the
744
- * package. 16 cross-category items in `dataset.ts`. See
745
- * `routing/README.md` for the format.
746
- *
747
- * `evaluate` does case-insensitive exact match against the canonical
748
- * route plus declared synonyms. The first valid route token in the
749
- * response wins; everything else is ignored. Wrong answers also
750
- * report whether they hit a hard negative — useful when triaging
751
- * "always picks the popular route" failure modes.
752
- */
753
-
754
- type RoutingPayload = RoutingItem;
755
- type RoutingDatasetItem = BenchmarkDatasetItem<RoutingPayload>;
756
- declare class RoutingAdapter implements BenchmarkAdapter<RoutingDatasetItem, RoutingPayload> {
757
- readonly id = "first-party/routing";
758
- readonly family = "first-party";
759
- readonly taskKind = "routing";
760
- readonly description = "Synthetic fixed-route classification smoke benchmark";
761
- readonly defaultMetric = "route_exact_match";
762
- loadDataset(split: RunSplitTag): Promise<RoutingDatasetItem[]>;
763
- evaluate(item: RoutingDatasetItem, response: string): Promise<BenchmarkEvaluation>;
764
- assignSplit(itemId: string): RunSplitTag;
765
- }
766
- /**
767
- * Pull route-shaped tokens out of a model response. Routes look like
768
- * `category.action` (`fs.write`, `chat.reply`). Bare alphanumerics
769
- * are not routes, but `category.action` patterns are robust to most
770
- * model wrappers (JSON output, prose explanations, code fences).
771
- */
772
- declare function extractRouteTokens(response: string): string[];
773
- declare const loadDataset: (split: RunSplitTag) => Promise<RoutingDatasetItem[]>;
774
- declare const evaluate: (item: RoutingDatasetItem, response: string) => Promise<BenchmarkEvaluation>;
775
- declare const assignSplit: (itemId: string) => RunSplitTag;
776
-
777
- declare const index_ROUTING_DATASET: typeof ROUTING_DATASET;
778
- type index_RoutingAdapter = RoutingAdapter;
779
- declare const index_RoutingAdapter: typeof RoutingAdapter;
780
- type index_RoutingDatasetItem = RoutingDatasetItem;
781
- type index_RoutingItem = RoutingItem;
782
- type index_RoutingPayload = RoutingPayload;
783
- declare const index_assignSplit: typeof assignSplit;
784
- declare const index_evaluate: typeof evaluate;
785
- declare const index_extractRouteTokens: typeof extractRouteTokens;
786
- declare const index_loadDataset: typeof loadDataset;
787
- declare namespace index {
788
- export { index_ROUTING_DATASET as ROUTING_DATASET, index_RoutingAdapter as RoutingAdapter, type index_RoutingDatasetItem as RoutingDatasetItem, type index_RoutingItem as RoutingItem, type index_RoutingPayload as RoutingPayload, index_assignSplit as assignSplit, index_evaluate as evaluate, index_extractRouteTokens as extractRouteTokens, index_loadDataset as loadDataset };
789
- }
790
-
791
- /**
792
- * `CampaignStorage` — the filesystem seam `runCampaign` writes through
793
- * (run/cell dirs, the resumability cache, per-cell artifacts, trace spans).
794
- *
795
- * The default (`fsCampaignStorage`) is the Node filesystem — identical
796
- * behavior to the inline `node:fs` calls it replaces, so existing CLI
797
- * consumers are unaffected. `inMemoryCampaignStorage` keeps everything in a
798
- * `Map`, so the substrate runs in environments WITHOUT a filesystem
799
- * (Cloudflare Workers, Deno Deploy, other edge runtimes) — the campaign
800
- * still produces its `CampaignResult` (cells + aggregates) in memory;
801
- * artifacts/traces simply aren't persisted to disk.
802
- *
803
- * Paths are opaque keys to the in-memory adapter — it does not parse them,
804
- * so the same `join(...)`-built paths work unchanged across both adapters.
805
- */
806
- interface CampaignStorage {
807
- /** Ensure a directory exists (recursive). No-op for in-memory. */
808
- ensureDir(dir: string): void;
809
- /** Does this path exist (as a written file or an ensured dir)? */
810
- exists(path: string): boolean;
811
- /** Read a UTF-8 file; `undefined` when missing or unreadable. */
812
- read(path: string): string | undefined;
813
- /** Write a file (string or bytes). Parent dir is assumed ensured. */
814
- write(path: string, content: string | Uint8Array): void;
815
- /** Append only when the current UTF-8 byte length matches `expectedBytes`.
816
- * Returns the new length, or undefined when another writer won. */
817
- append?(path: string, content: string, expectedBytes: number): number | undefined;
818
- }
819
-
820
- interface BenchmarkRunOptions<TPayload = unknown, TArtifact = string> {
821
- adapter: BenchmarkAdapter<BenchmarkDatasetItem<TPayload>, TPayload, TArtifact>;
822
- respond: BenchmarkResponder<TPayload, TArtifact>;
823
- splits?: readonly RunSplitTag[];
824
- runDir: string;
825
- repo?: string;
826
- seed?: number;
827
- reps?: number;
828
- resumable?: boolean;
829
- costCeiling?: number;
830
- maxConcurrency?: number;
831
- dispatchTimeoutMs?: number;
832
- expectUsage?: 'assert' | 'warn' | 'off';
833
- storage?: CampaignStorage;
834
- now?: () => Date;
835
- }
836
- interface BenchmarkReport {
837
- benchmarkId: string;
838
- family: BenchmarkFamily | string;
839
- taskKind: BenchmarkTaskKind | string;
840
- source?: BenchmarkAdapter['source'];
841
- runDir: string;
842
- manifestHash: string;
843
- seed: number;
844
- startedAt: string;
845
- endedAt: string;
846
- durationMs: number;
847
- totalItems: number;
848
- totalCells: number;
849
- cellsFailed: number;
850
- cellsCached: number;
851
- totalCostUsd: number;
852
- splits: Record<string, BenchmarkSliceSummary>;
853
- tags: Record<string, BenchmarkSliceSummary>;
854
- dimensions: Record<string, BenchmarkDistribution>;
855
- score: BenchmarkDistribution;
856
- costUsd: BenchmarkDistribution;
857
- latencyMs: BenchmarkDistribution;
858
- }
859
- interface BenchmarkSliceSummary {
860
- n: number;
861
- meanScore: number;
862
- passRate: number;
863
- score: BenchmarkDistribution;
864
- costUsd: BenchmarkDistribution;
865
- latencyMs: BenchmarkDistribution;
866
- }
867
- interface BenchmarkDistribution {
868
- n: number;
869
- min: number;
870
- mean: number;
871
- median: number;
872
- p90: number;
873
- max: number;
874
- }
875
- interface BenchmarkRunResult<TPayload = unknown, TArtifact = string> {
876
- scenarios: Array<BenchmarkScenario<TPayload>>;
877
- campaign: CampaignResult<TArtifact, BenchmarkScenario<TPayload>>;
878
- report: BenchmarkReport;
879
- reportJsonPath: string;
880
- reportMarkdownPath: string;
881
- }
882
- declare function runBenchmarkAdapter<TPayload = unknown, TArtifact = string>(options: BenchmarkRunOptions<TPayload, TArtifact>): Promise<BenchmarkRunResult<TPayload, TArtifact>>;
883
- declare function summarizeBenchmarkCampaign<TPayload, TArtifact>(input: {
884
- adapter: BenchmarkAdapter<BenchmarkDatasetItem<TPayload>, TPayload, TArtifact>;
885
- scenarios: Array<BenchmarkScenario<TPayload>>;
886
- campaign: CampaignResult<TArtifact, BenchmarkScenario<TPayload>>;
887
- }): BenchmarkReport;
888
- declare function renderBenchmarkReportMarkdown(report: BenchmarkReport): string;
889
-
890
- interface StandardRetrievalDocument {
891
- id: string;
892
- title?: string;
893
- text: string;
894
- metadata?: Record<string, unknown>;
895
- }
896
- interface StandardRetrievalQuery {
897
- id: string;
898
- text: string;
899
- metadata?: Record<string, unknown>;
900
- }
901
- interface StandardRetrievalQrel {
902
- queryId: string;
903
- documentId: string;
904
- score: number;
905
- }
906
- interface StandardRetrievalPayload {
907
- queryId: string;
908
- query: string;
909
- expectedDocumentIds: string[];
910
- expectedScores: Record<string, number>;
911
- corpus?: Record<string, StandardRetrievalDocument>;
912
- metadata?: Record<string, unknown>;
913
- }
914
- interface BuildStandardRetrievalItemsOptions {
915
- benchmarkId: string;
916
- family: BenchmarkFamily | string;
917
- queries: readonly StandardRetrievalQuery[];
918
- qrels: readonly StandardRetrievalQrel[];
919
- corpus?: readonly StandardRetrievalDocument[];
920
- includeCorpusInPayload?: boolean;
921
- source?: BenchmarkSource;
922
- tags?: readonly string[];
923
- splitOf?: (queryId: string) => RunSplitTag;
924
- }
925
- interface RetrievalIdAdapterOptions extends BuildStandardRetrievalItemsOptions {
926
- responseIdPattern?: RegExp;
927
- cutoffs?: readonly number[];
928
- primaryMetric?: string;
929
- passMetric?: string;
930
- passThreshold?: number;
931
- }
932
- interface StandardRetrievalResult {
933
- id?: string;
934
- documentId?: string;
935
- docId?: string;
936
- score?: number;
937
- }
938
- type StandardRetrievalArtifact = string | readonly string[] | readonly StandardRetrievalResult[] | {
939
- ids?: readonly string[];
940
- documentIds?: readonly string[];
941
- results?: readonly StandardRetrievalResult[];
942
- };
943
- interface StandardRetrievalEvaluationOptions {
944
- responseIdPattern?: RegExp;
945
- cutoffs?: readonly number[];
946
- primaryMetric?: string;
947
- passMetric?: string;
948
- passThreshold?: number;
949
- }
950
- declare function parseJsonlRows<T = unknown>(text: string): T[];
951
- declare function parseTsvRows(text: string): string[][];
952
- declare function parseQrels(text: string): StandardRetrievalQrel[];
953
- declare function parseBeirCorpusJsonl(text: string): StandardRetrievalDocument[];
954
- declare function parseBeirQueriesJsonl(text: string): StandardRetrievalQuery[];
955
- declare function buildStandardRetrievalItems(options: BuildStandardRetrievalItemsOptions): Array<BenchmarkDatasetItem<StandardRetrievalPayload>>;
956
- declare function createRetrievalIdBenchmarkAdapter(options: RetrievalIdAdapterOptions): BenchmarkAdapter<BenchmarkDatasetItem<StandardRetrievalPayload>, StandardRetrievalPayload, StandardRetrievalArtifact>;
957
- declare function evaluateStandardRetrieval(payload: StandardRetrievalPayload, artifact: StandardRetrievalArtifact, options?: StandardRetrievalEvaluationOptions): {
958
- score: number;
959
- passed: boolean;
960
- dimensions: Record<string, number>;
961
- raw: {
962
- rankedDocumentIds: string[];
963
- expectedDocumentIds: string[];
964
- expectedScores: Record<string, number>;
965
- };
966
- };
967
- declare function normalizeRetrievedDocumentIds(artifact: StandardRetrievalArtifact, responseIdPattern?: RegExp): string[];
968
- declare function retrievalMetricsAtCutoff(input: {
969
- rankedDocumentIds: readonly string[];
970
- expectedScores: Record<string, number>;
971
- cutoff: number;
972
- }): Record<string, number>;
973
-
974
- export { BENCHMARK_SPLIT_SEED, type BenchmarkAdapter, type BenchmarkDatasetItem, type BenchmarkDistribution, type BenchmarkEvaluation, type BenchmarkFamily, type BenchmarkMetricCalibrationOptions, type BenchmarkMetricCalibrationResult, type BenchmarkReport, type BenchmarkResponder, type BenchmarkRunOptions, type BenchmarkRunResult, type BenchmarkScenario, type BenchmarkSliceSummary, type BenchmarkSource, type BenchmarkTaskKind, type BuildStandardRetrievalItemsOptions, type RetrievalIdAdapterOptions, type StandardRetrievalArtifact, type StandardRetrievalDocument, type StandardRetrievalEvaluationOptions, type StandardRetrievalPayload, type StandardRetrievalQrel, type StandardRetrievalQuery, type StandardRetrievalResult, buildStandardRetrievalItems, calibrateBenchmarkMetric, createRetrievalIdBenchmarkAdapter, deterministicSplit, evaluateStandardRetrieval, normalizeRetrievedDocumentIds, parseBeirCorpusJsonl, parseBeirQueriesJsonl, parseJsonlRows, parseQrels, parseTsvRows, renderBenchmarkReportMarkdown, retrievalMetricsAtCutoff, index as routing, runBenchmarkAdapter, summarizeBenchmarkCampaign };