@tangle-network/agent-eval 0.33.0 → 0.34.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 (58) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/benchmarks/index.d.ts +2 -2
  3. package/dist/chunk-DCZXFOQN.js +489 -0
  4. package/dist/chunk-DCZXFOQN.js.map +1 -0
  5. package/dist/{chunk-B73G44OH.js → chunk-FT3IAMQR.js} +5 -5
  6. package/dist/chunk-FT3IAMQR.js.map +1 -0
  7. package/dist/{chunk-GVQT44CS.js → chunk-KE7TDJUO.js} +2 -2
  8. package/dist/{chunk-4L3WJXQJ.js → chunk-KHZRNY3F.js} +163 -2
  9. package/dist/{chunk-4L3WJXQJ.js.map → chunk-KHZRNY3F.js.map} +1 -1
  10. package/dist/{chunk-WGXZAQLR.js → chunk-LGAPK7NA.js} +2 -2
  11. package/dist/{chunk-DTEJNZYK.js → chunk-SQYRO3BT.js} +47 -4
  12. package/dist/chunk-SQYRO3BT.js.map +1 -0
  13. package/dist/{chunk-CXJOVDJR.js → chunk-TQL7BAOY.js} +5 -175
  14. package/dist/chunk-TQL7BAOY.js.map +1 -0
  15. package/dist/{chunk-M6RZ5LJN.js → chunk-VXNVVBZO.js} +34 -5
  16. package/dist/chunk-VXNVVBZO.js.map +1 -0
  17. package/dist/{chunk-S4Y5VXMS.js → chunk-WRGHMGWT.js} +2 -2
  18. package/dist/{chunk-SMSGXM74.js → chunk-YU3G6I7F.js} +2 -2
  19. package/dist/cli.js +2 -2
  20. package/dist/{control-p2ns7elI.d.ts → control-C3k02SCP.d.ts} +1 -1
  21. package/dist/control.d.ts +2 -2
  22. package/dist/control.js +3 -2
  23. package/dist/governance/index.d.ts +2 -1
  24. package/dist/{index-DPILdKbP.d.ts → index-CN2agEaO.d.ts} +2 -142
  25. package/dist/{index-BTqhGHJT.d.ts → index-ClMxVqe_.d.ts} +1 -1
  26. package/dist/index.d.ts +278 -486
  27. package/dist/index.js +522 -134
  28. package/dist/index.js.map +1 -1
  29. package/dist/judge-calibration-DilmB3Ml.d.ts +142 -0
  30. package/dist/meta-eval/index.d.ts +2 -2
  31. package/dist/openapi.json +1 -1
  32. package/dist/optimization.d.ts +3 -3
  33. package/dist/optimization.js +6 -6
  34. package/dist/pipelines/index.js +2 -2
  35. package/dist/release-report-ChfmCmLi.d.ts +713 -0
  36. package/dist/reporting.d.ts +6 -4
  37. package/dist/reporting.js +10 -9
  38. package/dist/{researcher-BRHa5Jxo.d.ts → researcher-CfnL3HEb.d.ts} +34 -3
  39. package/dist/rl.d.ts +5 -5
  40. package/dist/rl.js +6 -6
  41. package/dist/rl.js.map +1 -1
  42. package/dist/{rubric-predictive-validity-CMHypZ_M.d.ts → rubric-predictive-validity-BvaNwfBE.d.ts} +1 -1
  43. package/dist/{run-record-BfX5y68A.d.ts → run-record-YinVdFwu.d.ts} +78 -2
  44. package/dist/{summary-report-D7AQS7eB.d.ts → summary-report-BPJVzIeW.d.ts} +2 -2
  45. package/dist/wire/index.js +2 -2
  46. package/docs/product-eval-adoption.md +18 -0
  47. package/package.json +12 -22
  48. package/dist/chunk-B73G44OH.js.map +0 -1
  49. package/dist/chunk-CXJOVDJR.js.map +0 -1
  50. package/dist/chunk-DTEJNZYK.js.map +0 -1
  51. package/dist/chunk-M6RZ5LJN.js.map +0 -1
  52. package/dist/chunk-ZN2CMQIW.js +0 -208
  53. package/dist/chunk-ZN2CMQIW.js.map +0 -1
  54. package/dist/release-report-DLWbBPtH.d.ts +0 -292
  55. /package/dist/{chunk-GVQT44CS.js.map → chunk-KE7TDJUO.js.map} +0 -0
  56. /package/dist/{chunk-WGXZAQLR.js.map → chunk-LGAPK7NA.js.map} +0 -0
  57. /package/dist/{chunk-S4Y5VXMS.js.map → chunk-WRGHMGWT.js.map} +0 -0
  58. /package/dist/{chunk-SMSGXM74.js.map → chunk-YU3G6I7F.js.map} +0 -0
@@ -0,0 +1,713 @@
1
+ import { C as ContinuousAgreementOptions, a as ContinuousAgreement } from './judge-calibration-DilmB3Ml.js';
2
+ import { TCloud } from '@tangle-network/tcloud';
3
+ import { D as DatasetSplit, b as DatasetManifest, a as DatasetScenario } from './dataset-ueRVTUoY.js';
4
+ import { a3 as GateDecision, A as ActionableSideInfo, m as MultiShotTrialResult } from './summary-report-BPJVzIeW.js';
5
+ import { R as RunRecord, a as RunSplitTag } from './run-record-YinVdFwu.js';
6
+
7
+ interface Scenario {
8
+ id: string;
9
+ persona: string;
10
+ label: string;
11
+ thesis: string;
12
+ dimensions: string[];
13
+ turns: Turn[];
14
+ artifactChecks: ArtifactCheck[];
15
+ systemPromptAppend?: string;
16
+ }
17
+ interface Turn {
18
+ user: string;
19
+ expectedBehaviors: string[];
20
+ adversarial?: boolean;
21
+ feedbackType?: 'correction' | 'rejection' | 'vague' | 'contradictory' | 'escalation';
22
+ }
23
+ interface ArtifactCheck {
24
+ type: 'vault_file_exists' | 'vault_file_contains' | 'block_extracted' | 'code_valid' | 'generation_produced' | 'tool_created' | string;
25
+ target: string;
26
+ contains?: string;
27
+ minCount?: number;
28
+ description: string;
29
+ }
30
+ interface JudgeConfig {
31
+ model: string;
32
+ temperature: number;
33
+ rubric: JudgeRubric;
34
+ }
35
+ interface JudgeRubric {
36
+ name: string;
37
+ description: string;
38
+ dimensions: RubricDimension[];
39
+ }
40
+ interface RubricDimension {
41
+ name: string;
42
+ description: string;
43
+ anchor_low: string;
44
+ anchor_high: string;
45
+ weight: number;
46
+ }
47
+ interface ScenarioResult {
48
+ scenarioId: string;
49
+ persona: string;
50
+ turns: TurnResult[];
51
+ artifactResults: ArtifactResult[];
52
+ judgeScores: JudgeScore[];
53
+ judgeErrors: number;
54
+ overallScore: number;
55
+ totalDurationMs: number;
56
+ artifacts: CollectedArtifacts;
57
+ }
58
+ interface TurnResult {
59
+ turnIndex: number;
60
+ userMessage: string;
61
+ agentResponse: string;
62
+ durationMs: number;
63
+ blocksExtracted: {
64
+ type: string;
65
+ title: string;
66
+ }[];
67
+ containsCode: boolean;
68
+ containsToolCall: boolean;
69
+ }
70
+ interface ArtifactResult {
71
+ check: ArtifactCheck;
72
+ passed: boolean;
73
+ detail?: string;
74
+ }
75
+ interface JudgeScore {
76
+ judgeName: string;
77
+ dimension: string;
78
+ score: number;
79
+ reasoning: string;
80
+ evidence?: string;
81
+ }
82
+ interface CollectedArtifacts {
83
+ vaultFiles: {
84
+ path: string;
85
+ content: string;
86
+ }[];
87
+ blocksExtracted: {
88
+ type: string;
89
+ fields: Record<string, string>;
90
+ }[];
91
+ codeBlocks: {
92
+ language: string;
93
+ code: string;
94
+ }[];
95
+ toolCalls: string[];
96
+ }
97
+ interface BenchmarkReport {
98
+ timestamp: string;
99
+ generation: number;
100
+ promptVersion: string;
101
+ scenarioCount: number;
102
+ results: ScenarioResult[];
103
+ summary: {
104
+ overallAvg: number;
105
+ byPersona: Record<string, {
106
+ avg: number;
107
+ passed: number;
108
+ total: number;
109
+ }>;
110
+ byDimension: Record<string, {
111
+ avg: number;
112
+ scores: number[];
113
+ }>;
114
+ weakest: {
115
+ scenario: string;
116
+ score: number;
117
+ reason: string;
118
+ }[];
119
+ strongest: {
120
+ scenario: string;
121
+ score: number;
122
+ reason: string;
123
+ }[];
124
+ };
125
+ }
126
+ interface RouteMap {
127
+ signup?: string;
128
+ login?: string;
129
+ workspaces?: string;
130
+ threads?: string;
131
+ chat?: string;
132
+ tasks?: string;
133
+ events?: string;
134
+ approvals?: string;
135
+ vault?: string;
136
+ generations?: string;
137
+ [key: string]: string | undefined;
138
+ }
139
+ interface ProductClientConfig {
140
+ baseUrl: string;
141
+ routes: RouteMap;
142
+ }
143
+ interface ScenarioFile {
144
+ id: string;
145
+ category: string;
146
+ persona: string;
147
+ label: string;
148
+ thesis: string;
149
+ isControl?: boolean;
150
+ rubric?: {
151
+ dimensions: {
152
+ name: string;
153
+ description: string;
154
+ weight: number;
155
+ }[];
156
+ };
157
+ turns: Turn[];
158
+ artifactChecks: ArtifactCheck[];
159
+ }
160
+ interface CompletionCriterion {
161
+ name: string;
162
+ check: (state: DriverState) => boolean;
163
+ progress?: (state: DriverState) => number;
164
+ }
165
+ interface FeedbackPattern {
166
+ trigger: string;
167
+ response: string;
168
+ }
169
+ /**
170
+ * How hard the simulated user pushes back. The driver LLM scales its tone
171
+ * and follow-up aggression to this:
172
+ * cooperative — forgiving early adopter; accepts reasonable answers.
173
+ * demanding — experienced professional; rejects vague or hedged answers.
174
+ * relentless — senior partner reviewing for a client who will litigate;
175
+ * interrogates every claim, accepts nothing undefended.
176
+ */
177
+ type PersonaRigor = 'cooperative' | 'demanding' | 'relentless';
178
+ interface PersonaConfig {
179
+ id: string;
180
+ role: string;
181
+ goal: string;
182
+ completionCriteria: CompletionCriterion[];
183
+ feedbackPatterns?: FeedbackPattern[];
184
+ maxTurns: number;
185
+ driverModel?: string;
186
+ /** How adversarial the simulated user is. Defaults to 'demanding'. */
187
+ rigor?: PersonaRigor;
188
+ /**
189
+ * Domain expertise the simulated user holds — quoted into the driver
190
+ * prompt so it challenges the agent with authority instead of vague
191
+ * dissatisfaction. e.g. "a 15-year M&A partner who knows GAAP
192
+ * working-capital mechanics cold".
193
+ */
194
+ expertise?: string;
195
+ /**
196
+ * Substantive issues a senior professional in this role would
197
+ * interrogate — traps the scenario hides, claims that must be defended.
198
+ * The driver probes these without revealing them verbatim; the agent
199
+ * must surface them on its own.
200
+ */
201
+ pressurePoints?: string[];
202
+ /**
203
+ * Curveballs the driver may inject once the agent is coasting — changed
204
+ * facts, a hostile counterparty position, a new constraint. Forces the
205
+ * agent to re-derive rather than recite.
206
+ */
207
+ curveballs?: string[];
208
+ }
209
+ interface DriverState {
210
+ tasks: number;
211
+ events: number;
212
+ proposals: {
213
+ pending: number;
214
+ approved: number;
215
+ rejected: number;
216
+ };
217
+ vaultFiles: string[];
218
+ codeBlocks: number;
219
+ generations: number;
220
+ }
221
+ interface TurnMetrics {
222
+ turn: number;
223
+ timestamp: string;
224
+ tasks: number;
225
+ events: number;
226
+ proposals: {
227
+ pending: number;
228
+ approved: number;
229
+ rejected: number;
230
+ };
231
+ vaultFiles: number;
232
+ responseLatencyMs: number;
233
+ responseChars: number;
234
+ codeBlocksProduced: number;
235
+ blocksExtracted: number;
236
+ qualityScore?: number;
237
+ inputTokens: number;
238
+ outputTokens: number;
239
+ estimatedCostUsd: number;
240
+ totalCostUsd: number;
241
+ completionPercent: number;
242
+ }
243
+ interface DriverResult {
244
+ personaId: string;
245
+ /** True when the simulated user professionally signed off (driver said DONE). */
246
+ completed: boolean;
247
+ /** Turn at which the simulated user signed off, or null if it never did. */
248
+ turnsToCompletion: number | null;
249
+ /**
250
+ * Turn at which nominal completionCriteria were first all met, or null.
251
+ * Distinct from turnsToCompletion: criteria can be met while the
252
+ * simulated professional is still unsatisfied with the work's rigor.
253
+ */
254
+ criteriaMetAtTurn: number | null;
255
+ totalTurns: number;
256
+ metrics: TurnMetrics[];
257
+ finalState: DriverState;
258
+ convergenceCurve: number[];
259
+ totalCostUsd: number;
260
+ finalQualityScore: number | null;
261
+ }
262
+ interface BenchmarkRunnerConfig {
263
+ scenarios: Scenario[];
264
+ judges: JudgeFn[];
265
+ systemPrompt: string;
266
+ model?: string;
267
+ judgeModel?: string;
268
+ passThreshold?: number;
269
+ generation?: number;
270
+ promptVersion?: string;
271
+ }
272
+ interface JudgeInput {
273
+ scenario: Scenario;
274
+ turns: TurnResult[];
275
+ artifacts: CollectedArtifacts;
276
+ }
277
+ type JudgeFn = (tc: TCloud, input: JudgeInput) => Promise<JudgeScore[]>;
278
+
279
+ interface TestResult {
280
+ name: string;
281
+ passed: boolean;
282
+ duration: number;
283
+ detail?: string;
284
+ checks: CheckResult[];
285
+ }
286
+ interface CheckResult {
287
+ name: string;
288
+ passed: boolean;
289
+ expected: string;
290
+ actual: string;
291
+ }
292
+ interface EvalResult {
293
+ scenario: string;
294
+ status: 'pass' | 'fail' | 'skip';
295
+ duration: number;
296
+ detail?: string;
297
+ artifact?: string;
298
+ }
299
+
300
+ /**
301
+ * Release confidence gate.
302
+ *
303
+ * This is the production-facing composition layer over the lower-level
304
+ * primitives:
305
+ * - Dataset manifests prove corpus/version coverage.
306
+ * - RunRecord rows prove reproducible search/holdout outcomes.
307
+ * - Multi-shot trace evidence carries turn counts and ASI diagnostics.
308
+ * - HeldOutGate decisions remain the paired promotion authority.
309
+ *
310
+ * The gate is intentionally pure and conservative. Missing declared evidence
311
+ * fails closed instead of being treated as a neutral zero.
312
+ */
313
+
314
+ type ReleaseConfidenceStatus = 'pass' | 'warn' | 'fail';
315
+ type ReleaseConfidenceAxisName = 'corpus' | 'quality' | 'generalization' | 'diagnostics' | 'efficiency';
316
+ interface ReleaseTraceEvidence {
317
+ scenarioId: string;
318
+ candidateId?: string;
319
+ split?: RunSplitTag;
320
+ score?: number;
321
+ ok?: boolean;
322
+ turnCount?: number;
323
+ costUsd?: number;
324
+ durationMs?: number;
325
+ failureMode?: string;
326
+ asi?: ActionableSideInfo[];
327
+ metadata?: Record<string, unknown>;
328
+ }
329
+ interface ReleaseConfidenceThresholds {
330
+ /** Require a Dataset manifest or explicit scenarios. Default true. */
331
+ requireCorpus?: boolean;
332
+ minScenarioCount?: number;
333
+ minSearchRuns?: number;
334
+ minHoldoutRuns?: number;
335
+ /** Require at least one holdout scenario/run. Default true. */
336
+ requireHoldout?: boolean;
337
+ minPassRate?: number;
338
+ minMeanScore?: number;
339
+ /** Search mean may exceed holdout mean by at most this much. */
340
+ maxOverfitGap?: number;
341
+ maxMeanCostUsd?: number;
342
+ maxP95WallMs?: number;
343
+ /** Low-score/failed rows must carry ASI. Default true. */
344
+ requireAsiForFailures?: boolean;
345
+ /** Score below this is considered a failure for ASI coverage. Default 0.5. */
346
+ failureScoreThreshold?: number;
347
+ }
348
+ interface ReleaseConfidenceInput {
349
+ target: string;
350
+ candidateId?: string;
351
+ baselineId?: string;
352
+ dataset?: DatasetManifest;
353
+ scenarios?: readonly DatasetScenario[];
354
+ runs?: readonly RunRecord[];
355
+ traces?: readonly ReleaseTraceEvidence[];
356
+ gateDecision?: GateDecision | null;
357
+ thresholds?: ReleaseConfidenceThresholds;
358
+ }
359
+ interface ReleaseConfidenceAxis {
360
+ name: ReleaseConfidenceAxisName;
361
+ status: ReleaseConfidenceStatus;
362
+ score: number;
363
+ detail: string;
364
+ }
365
+ interface ReleaseConfidenceIssue {
366
+ axis: ReleaseConfidenceAxisName;
367
+ severity: 'critical' | 'warning';
368
+ code: string;
369
+ detail: string;
370
+ }
371
+ interface ReleaseConfidenceMetrics {
372
+ scenarioCount: number;
373
+ searchRuns: number;
374
+ holdoutRuns: number;
375
+ passRate: number;
376
+ meanScore: number;
377
+ searchMeanScore: number;
378
+ holdoutMeanScore: number;
379
+ overfitGap: number;
380
+ meanCostUsd: number;
381
+ p95WallMs: number;
382
+ failedRows: number;
383
+ failuresWithAsi: number;
384
+ singleShotTraces: number;
385
+ multiShotTraces: number;
386
+ splitCounts: Record<DatasetSplit, number>;
387
+ domainCounts: Record<string, number>;
388
+ failureModeCounts: Record<string, number>;
389
+ responsibleSurfaceCounts: Record<string, number>;
390
+ }
391
+ interface ReleaseConfidenceScorecard {
392
+ target: string;
393
+ candidateId: string | null;
394
+ baselineId: string | null;
395
+ status: ReleaseConfidenceStatus;
396
+ promote: boolean;
397
+ axes: ReleaseConfidenceAxis[];
398
+ issues: ReleaseConfidenceIssue[];
399
+ metrics: ReleaseConfidenceMetrics;
400
+ dataset: DatasetManifest | null;
401
+ gateDecision: GateDecision | null;
402
+ summary: string;
403
+ }
404
+ declare function releaseTraceEvidenceFromMultiShotTrials(trials: readonly MultiShotTrialResult[]): ReleaseTraceEvidence[];
405
+ declare function evaluateReleaseConfidence(input: ReleaseConfidenceInput): ReleaseConfidenceScorecard;
406
+ declare function assertReleaseConfidence(input: ReleaseConfidenceInput): ReleaseConfidenceScorecard;
407
+
408
+ /**
409
+ * Normalize scores so all dimensions follow "higher = better".
410
+ * Inverted dimensions (hallucination, false_confidence, worst_failure)
411
+ * already use inverted scoring in the prompt (10 = no hallucination),
412
+ * but this function ensures consistency if raw scores leak through.
413
+ */
414
+ declare function normalizeScores(scores: JudgeScore[]): JudgeScore[];
415
+ /** Weighted mean — falls back to uniform weights when omitted */
416
+ declare function weightedMean(scores: {
417
+ score: number;
418
+ weight?: number;
419
+ }[]): number;
420
+ /** Bootstrap confidence interval */
421
+ declare function confidenceInterval(scores: number[], confidence?: number): {
422
+ mean: number;
423
+ lower: number;
424
+ upper: number;
425
+ };
426
+ /**
427
+ * Inter-rater reliability — simplified Krippendorff's alpha.
428
+ *
429
+ * Each inner array is one judge's scores for all items.
430
+ * All arrays must have the same length (same items scored).
431
+ */
432
+ declare function interRaterReliability(judgeScores: JudgeScore[][]): number;
433
+ /**
434
+ * Mann-Whitney U test for comparing two independent groups.
435
+ * Returns U statistic and approximate p-value (normal approximation).
436
+ */
437
+ declare function mannWhitneyU(a: number[], b: number[]): {
438
+ u: number;
439
+ p: number;
440
+ };
441
+ /** Partial credit: returns 0-1 ratio of current toward target */
442
+ declare function partialCredit(current: number, target: number): number;
443
+ /**
444
+ * Paired t-test — before/after measurements on the SAME items.
445
+ * Pairing removes inter-item variance, giving tighter significance than
446
+ * an unpaired test when comparing prompt v1 vs prompt v2 on identical
447
+ * scenarios.
448
+ */
449
+ declare function pairedTTest(before: number[], after: number[]): {
450
+ t: number;
451
+ df: number;
452
+ p: number;
453
+ };
454
+ /**
455
+ * Wilcoxon signed-rank test — paired non-parametric alternative.
456
+ * Use when the differences aren't normally distributed.
457
+ */
458
+ declare function wilcoxonSignedRank(before: number[], after: number[]): {
459
+ w: number;
460
+ p: number;
461
+ };
462
+ /**
463
+ * Cohen's d — standardized effect size for two independent groups.
464
+ * Positive d means group b has higher mean than group a.
465
+ * Rule of thumb: |d| < 0.2 negligible, 0.2–0.5 small, 0.5–0.8 medium, > 0.8 large.
466
+ */
467
+ declare function cohensD(a: number[], b: number[]): number;
468
+ interface CorpusScoreRecord {
469
+ /** Stable identifier for the rated item (scenario, span, turn, …). */
470
+ itemId: string;
471
+ /** Identifier for the judge that produced this score. */
472
+ judgeName: string;
473
+ /** Dimension name (matches `JudgeScore.dimension`). */
474
+ dimension: string;
475
+ /** Numeric score; must be finite. */
476
+ score: number;
477
+ }
478
+ interface CorpusAgreementPerDimension extends ContinuousAgreement {
479
+ dimension: string;
480
+ /** Item IDs that contributed to this dimension's matrix (every judge scored them). */
481
+ itemIds: string[];
482
+ /** Judge IDs that contributed to this dimension's matrix. */
483
+ judgeIds: string[];
484
+ }
485
+ interface CorpusAgreementReport {
486
+ /** Per-dimension ICC(2,1) + κ_w + Pearson + Spearman + bootstrap CIs. */
487
+ perDimension: CorpusAgreementPerDimension[];
488
+ /** Mean ICC across dimensions (NaN if no dimension yielded a finite ICC). */
489
+ overallIcc: number;
490
+ /** Mean weighted κ across dimensions (NaN if none finite). */
491
+ overallWeightedKappa: number;
492
+ /** Dimensions evaluated (sorted). */
493
+ dimensions: string[];
494
+ /** Judges seen across the corpus (sorted). */
495
+ judgeIds: string[];
496
+ }
497
+ interface CorpusAgreementOptions extends ContinuousAgreementOptions {
498
+ /**
499
+ * Restrict the audit to these dimensions. Default = every dimension
500
+ * that appears in the input. A dimension named here but absent from
501
+ * the input throws — silent omission would corrupt the overall metric.
502
+ */
503
+ dimensions?: string[];
504
+ /**
505
+ * Restrict the audit to these judges. Default = every judge that
506
+ * appears in the input. A judge named here but absent from a
507
+ * dimension throws (see "fail loud" below).
508
+ */
509
+ judges?: string[];
510
+ }
511
+ /**
512
+ * Corpus-wide inter-rater agreement across N items × M judges × D dimensions.
513
+ *
514
+ * For each dimension, builds the [n_items][n_judges] matrix of scores
515
+ * (keeping only items every judge rated on that dimension), then runs
516
+ * `continuousAgreement` to get ICC(2,1), κ_w, Pearson, Spearman, and
517
+ * bootstrap CIs. Reports a pooled mean across dimensions as a single
518
+ * "is this judge panel reliable on this corpus?" number.
519
+ *
520
+ * Fail-loud contract:
521
+ * - Empty input throws.
522
+ * - Fewer than 2 judges or fewer than 2 items per dimension throws.
523
+ * - A judge present in some dimensions but with zero scored items on
524
+ * another dimension throws (would silently shrink the matrix).
525
+ * - Duplicate (itemId, judgeName, dimension) records throw.
526
+ */
527
+ declare function corpusInterRaterAgreement(records: CorpusScoreRecord[], opts?: CorpusAgreementOptions): CorpusAgreementReport;
528
+ /**
529
+ * Convenience adapter for `JudgeScore[]` data keyed externally by item.
530
+ *
531
+ * Use when you have per-item arrays of `JudgeScore[]` (e.g. one
532
+ * `ScenarioResult.judgeScores` per scenario) and want corpus-wide
533
+ * agreement without manually flattening. `itemId` must be unique per
534
+ * row of `itemsScores`.
535
+ */
536
+ declare function corpusInterRaterAgreementFromJudgeScores(itemsScores: Array<{
537
+ itemId: string;
538
+ scores: JudgeScore[];
539
+ }>, opts?: CorpusAgreementOptions): CorpusAgreementReport;
540
+ /**
541
+ * Required N per arm for a two-sample comparison at target effect size,
542
+ * alpha, and power. Normal-approximation formula:
543
+ * n = 2 * ( (z_{1-α/2} + z_{1-β}) / d )^2
544
+ * where d is Cohen's d. Returns Infinity for effect ≤ 0.
545
+ */
546
+ declare function requiredSampleSize(opts: {
547
+ effect: number;
548
+ alpha?: number;
549
+ power?: number;
550
+ twoSided?: boolean;
551
+ }): number;
552
+ /**
553
+ * Minimum detectable paired effect (standardised units) for a target paired
554
+ * sample size: d_min = (z_{1-α/2} + z_β) / sqrt(n_paired). Multiply by
555
+ * sd(deltas) for score units; treat as a lower bound — Wilcoxon and bootstrap
556
+ * have asymptotic relative efficiency below 1 vs the t-test on heavy tails.
557
+ */
558
+ declare function pairedMde(opts: {
559
+ nPaired: number;
560
+ alpha?: number;
561
+ power?: number;
562
+ twoSided?: boolean;
563
+ }): number;
564
+ /** Bonferroni adjustment: multiply every p-value by the test count, clamp at 1. */
565
+ declare function bonferroni(pValues: number[], alpha?: number): {
566
+ adjusted: number[];
567
+ significant: boolean[];
568
+ };
569
+ /**
570
+ * Benjamini–Hochberg false discovery rate. Returns adjusted q-values and
571
+ * significance at the target FDR; handles ties and preserves q monotonicity.
572
+ */
573
+ declare function benjaminiHochberg(pValues: number[], fdr?: number): {
574
+ qValues: number[];
575
+ significant: boolean[];
576
+ };
577
+ interface PairedBootstrapResult {
578
+ /** Number of paired observations. */
579
+ n: number;
580
+ /** Median of paired deltas (after − before). */
581
+ median: number;
582
+ /** Mean of paired deltas. */
583
+ mean: number;
584
+ /** Lower bound of the bootstrap CI on the chosen statistic. */
585
+ low: number;
586
+ /** Upper bound of the bootstrap CI on the chosen statistic. */
587
+ high: number;
588
+ /** Confidence level used (e.g. 0.95). */
589
+ confidence: number;
590
+ /** Number of bootstrap resamples used. */
591
+ resamples: number;
592
+ }
593
+ interface PairedBootstrapOptions {
594
+ /** Confidence level. Default 0.95. */
595
+ confidence?: number;
596
+ /** Bootstrap resample count. Default 2000. */
597
+ resamples?: number;
598
+ /** Statistic to bootstrap. Default 'median'. */
599
+ statistic?: 'median' | 'mean';
600
+ /** Deterministic seed. If omitted, uses Math.random(). */
601
+ seed?: number;
602
+ }
603
+ /**
604
+ * Paired bootstrap on (after − before) deltas. Returns a CI on the chosen
605
+ * statistic (median by default); pairs are resampled with replacement. The
606
+ * lower bound is what the promotion gate checks — `low > threshold` means the
607
+ * gain is real at the confidence level. Throws on unequal sample sizes.
608
+ */
609
+ declare function pairedBootstrap(before: number[], after: number[], opts?: PairedBootstrapOptions): PairedBootstrapResult;
610
+
611
+ /**
612
+ * Bootstrap-CI promotion gate.
613
+ *
614
+ * In any iterative-improvement loop (GEPA, prompt evolution, dataset
615
+ * curation), the question is "did this generation actually improve, or are
616
+ * we celebrating noise?". With small N and noisy outcomes, point-estimate
617
+ * deltas lie. Bootstrap confidence intervals tell the operator whether the
618
+ * delta is real before code or prompts get promoted.
619
+ *
620
+ * This module is pure functions — no I/O, no model calls. Easy to unit-test
621
+ * and to compose into any verdict gate.
622
+ *
623
+ * Default gate:
624
+ * - Bootstrap mean baseline vs candidate (1k resamples).
625
+ * - Compute the delta distribution; pass if the lower CI bound > 0.
626
+ * - Tunable confidence (default 95%) and resample count.
627
+ *
628
+ * Verdict semantics intentionally match the existing `experiments.jsonl`
629
+ * vocabulary:
630
+ * - ADVANCE: candidate's CI lower bound > baseline mean (real win)
631
+ * - KEEP: overlap, but candidate point estimate >= baseline (neutral)
632
+ * - REVERT: candidate's CI upper bound < baseline mean (real regression)
633
+ * - INCONCLUSIVE: not enough samples or CI straddles zero with no signal
634
+ */
635
+ type Verdict = 'ADVANCE' | 'KEEP' | 'REVERT' | 'INCONCLUSIVE';
636
+ interface BootstrapResult {
637
+ baselineMean: number;
638
+ candidateMean: number;
639
+ /** candidateMean - baselineMean, point estimate. */
640
+ delta: number;
641
+ /** Lower bound of the (1 - alpha) CI on the delta. */
642
+ ciLower: number;
643
+ /** Upper bound of the (1 - alpha) CI on the delta. */
644
+ ciUpper: number;
645
+ /** Number of bootstrap resamples used. */
646
+ iterations: number;
647
+ alpha: number;
648
+ verdict: Verdict;
649
+ }
650
+ interface BootstrapOptions {
651
+ /** Confidence level alpha (default 0.05 → 95% CI). */
652
+ alpha?: number;
653
+ /** Number of resamples (default 1000). */
654
+ iterations?: number;
655
+ /**
656
+ * Minimum total samples (baseline + candidate) below which we always
657
+ * return INCONCLUSIVE — bootstrap with too few samples is meaningless.
658
+ * Default 6 (combined).
659
+ */
660
+ minTotalSamples?: number;
661
+ /** RNG seed for reproducibility. Default: Math.random. */
662
+ seed?: number;
663
+ }
664
+ /**
665
+ * Compute the bootstrap CI on (candidateMean - baselineMean) and a verdict.
666
+ *
667
+ * Uses simple percentile bootstrap on the difference of resampled means.
668
+ * That's the standard non-parametric primitive — no distributional
669
+ * assumptions, robust to skew, easy to reason about.
670
+ */
671
+ declare function bootstrapCi(baseline: number[], candidate: number[], options?: BootstrapOptions): BootstrapResult;
672
+ /**
673
+ * Judge-replay promotion gate.
674
+ *
675
+ * The cheap inner-loop judge that drives an evolution run is by definition
676
+ * fast and noisy. When you're about to promote a winning variant to the
677
+ * canonical default, you want a STRONGER judge (a more expensive model, a
678
+ * human grader, a separately-trained reward model) to confirm the win
679
+ * generalises beyond the inner loop.
680
+ *
681
+ * This helper takes raw winner + baseline outputs, scores both through the
682
+ * stronger judge, and applies `bootstrapCi`. ADVANCE means the stronger
683
+ * judge agrees the winner is real with the configured confidence. Doesn't
684
+ * matter what shape your "output" is — pass a string, an object, anything
685
+ * the judge can read.
686
+ */
687
+ interface JudgeReplayGateArgs<TOutput> {
688
+ baselineOutputs: TOutput[];
689
+ candidateOutputs: TOutput[];
690
+ /** Stronger judge — async to allow LLM calls. Return a 0..N scalar score. */
691
+ judge: (output: TOutput) => Promise<number> | number;
692
+ alpha?: number;
693
+ iterations?: number;
694
+ /** RNG seed for reproducibility. */
695
+ seed?: number;
696
+ /** Maximum concurrent judge calls. Default 4. */
697
+ judgeConcurrency?: number;
698
+ }
699
+ declare function judgeReplayGate<TOutput>(args: JudgeReplayGateArgs<TOutput>): Promise<BootstrapResult & {
700
+ baselineSamples: number;
701
+ candidateSamples: number;
702
+ }>;
703
+
704
+ interface RenderReleaseReportOptions {
705
+ title?: string;
706
+ runs?: readonly RunRecord[];
707
+ comparator?: string;
708
+ traceAnalystFindings?: readonly string[];
709
+ nextActions?: readonly string[];
710
+ }
711
+ declare function renderReleaseReport(scorecard: ReleaseConfidenceScorecard, options?: RenderReleaseReportOptions): string;
712
+
713
+ export { type RouteMap as $, type DriverState as A, type BootstrapOptions as B, type CheckResult as C, type DriverResult as D, type CollectedArtifacts as E, type ScenarioResult as F, type TurnMetrics as G, type ScenarioFile as H, type CompletionCriterion as I, type JudgeReplayGateArgs as J, type ArtifactCheck as K, type ArtifactResult as L, type CorpusAgreementOptions as M, type CorpusAgreementPerDimension as N, type CorpusAgreementReport as O, type PairedBootstrapOptions as P, type CorpusScoreRecord as Q, type ReleaseConfidenceAxis as R, type Scenario as S, type TestResult as T, type EvalResult as U, type Verdict as V, type FeedbackPattern as W, type JudgeConfig as X, type JudgeRubric as Y, type JudgeScore as Z, type PersonaRigor as _, type BootstrapResult as a, type RubricDimension as a0, type Turn as a1, type TurnResult as a2, bonferroni as a3, cohensD as a4, confidenceInterval as a5, corpusInterRaterAgreement as a6, corpusInterRaterAgreementFromJudgeScores as a7, interRaterReliability as a8, mannWhitneyU as a9, normalizeScores as aa, pairedMde as ab, pairedTTest as ac, partialCredit as ad, requiredSampleSize as ae, weightedMean as af, type PairedBootstrapResult as b, type ReleaseConfidenceAxisName as c, type ReleaseConfidenceInput as d, type ReleaseConfidenceIssue as e, type ReleaseConfidenceMetrics as f, type ReleaseConfidenceScorecard as g, type ReleaseConfidenceStatus as h, type ReleaseConfidenceThresholds as i, type ReleaseTraceEvidence as j, type RenderReleaseReportOptions as k, assertReleaseConfidence as l, benjaminiHochberg as m, bootstrapCi as n, evaluateReleaseConfidence as o, judgeReplayGate as p, pairedBootstrap as q, releaseTraceEvidenceFromMultiShotTrials as r, renderReleaseReport as s, type JudgeInput as t, type JudgeFn as u, type BenchmarkRunnerConfig as v, wilcoxonSignedRank as w, type BenchmarkReport as x, type ProductClientConfig as y, type PersonaConfig as z };