@tangle-network/agent-eval 1.0.5 → 1.0.7

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 (56) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/analyst/index.d.ts.map +1 -1
  3. package/dist/analyst/index.js +1 -1
  4. package/dist/{analyze-runs-Da7P_Mc5.js → analyze-runs-dGYmYNtb.js} +4 -24
  5. package/dist/analyze-runs-dGYmYNtb.js.map +1 -0
  6. package/dist/{benchmark-command-C3mZhNh7.js → benchmark-command-BO-YeQaH.js} +4 -2
  7. package/dist/benchmark-command-BO-YeQaH.js.map +1 -0
  8. package/dist/builder-eval/index.d.ts +1 -1
  9. package/dist/builder-eval/index.js +1 -1
  10. package/dist/campaign/index.d.ts +1 -1
  11. package/dist/campaign/index.js +1 -1
  12. package/dist/cli.js +1 -1
  13. package/dist/contract/index.js +2 -2
  14. package/dist/{define-agent-eval-gXgVUX1h.js → define-agent-eval-DyzJ0wOo.js} +2 -2
  15. package/dist/{define-agent-eval-gXgVUX1h.js.map → define-agent-eval-DyzJ0wOo.js.map} +1 -1
  16. package/dist/diagnosis/index.js +1 -1
  17. package/dist/{eval-campaign-DVqiBoXR.js → eval-campaign-B-dQl_lA.js} +2 -2
  18. package/dist/{eval-campaign-DVqiBoXR.js.map → eval-campaign-B-dQl_lA.js.map} +1 -1
  19. package/dist/experiment/index.js +1 -1
  20. package/dist/index.d.ts +28 -42
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +95 -7
  23. package/dist/index.js.map +1 -1
  24. package/dist/{judge-gate-C9sLLJ-v.js → judge-gate-DMlX38B7.js} +3 -9
  25. package/dist/judge-gate-DMlX38B7.js.map +1 -0
  26. package/dist/meta-eval/index.js +1 -1
  27. package/dist/openapi.json +1 -1
  28. package/dist/paired-arms-C0Vd9bGG.js.map +1 -1
  29. package/dist/pipelines/index.d.ts +1 -1
  30. package/dist/{promotion-gate-CixshGI8.d.ts → promotion-gate-DOkgJcLW.d.ts} +2 -6
  31. package/dist/promotion-gate-DOkgJcLW.d.ts.map +1 -0
  32. package/dist/reporting.d.ts +10 -2
  33. package/dist/reporting.d.ts.map +1 -0
  34. package/dist/reporting.js +15 -2
  35. package/dist/reporting.js.map +1 -0
  36. package/dist/rl.js +1 -1
  37. package/dist/{sandbox-harness-BzAUasgY.js → sandbox-harness-CzRlzJ5y.js} +22 -3
  38. package/dist/sandbox-harness-CzRlzJ5y.js.map +1 -0
  39. package/dist/{sandbox-harness-BS6c6UZV.d.ts → sandbox-harness-K3LuyORm.d.ts} +3 -1
  40. package/dist/sandbox-harness-K3LuyORm.d.ts.map +1 -0
  41. package/dist/summary-report-0La5vejY.d.ts.map +1 -1
  42. package/dist/{summary-report-BstMpOfy.js → summary-report-B4BLQb88.js} +45 -115
  43. package/dist/summary-report-B4BLQb88.js.map +1 -0
  44. package/dist/{tool-waste-BFG1vwTV.d.ts → tool-waste-CUASoTtk.d.ts} +3 -17
  45. package/dist/tool-waste-CUASoTtk.d.ts.map +1 -0
  46. package/dist/wire/index.d.ts +2 -2
  47. package/docs/concepts.md +4 -0
  48. package/package.json +1 -1
  49. package/dist/analyze-runs-Da7P_Mc5.js.map +0 -1
  50. package/dist/benchmark-command-C3mZhNh7.js.map +0 -1
  51. package/dist/judge-gate-C9sLLJ-v.js.map +0 -1
  52. package/dist/promotion-gate-CixshGI8.d.ts.map +0 -1
  53. package/dist/sandbox-harness-BS6c6UZV.d.ts.map +0 -1
  54. package/dist/sandbox-harness-BzAUasgY.js.map +0 -1
  55. package/dist/summary-report-BstMpOfy.js.map +0 -1
  56. package/dist/tool-waste-BFG1vwTV.d.ts.map +0 -1
package/dist/reporting.js CHANGED
@@ -1,8 +1,21 @@
1
- import { i as summaryTable, l as RESEARCH_REPORT_HARD_PAIR_FLOOR, n as gainHistogram, t as researchReport } from "./summary-report-BstMpOfy.js";
1
+ import { i as summaryTable, l as RESEARCH_REPORT_HARD_PAIR_FLOOR, n as gainHistogram, t as researchReport } from "./summary-report-B4BLQb88.js";
2
2
  import { a as wilcoxonSignedRank } from "./paired-arms-C0Vd9bGG.js";
3
3
  import { t as benjaminiHochberg } from "./multiplicity-DAd4xaDC.js";
4
4
  import { r as pairedBootstrap } from "./paired-tests-kASEKpc-.js";
5
5
  import { n as pairedEvalueSequence, t as evaluateInterimReleaseConfidence } from "./sequential-Bjs5roiK.js";
6
6
  import { n as bootstrapCi, r as judgeReplayGate, t as evaluateReleaseConfidence } from "./release-confidence--1iP-d3x.js";
7
7
  import { t as rubricPredictiveValidity } from "./rubric-predictive-validity-BdxXDN6h.js";
8
- export { RESEARCH_REPORT_HARD_PAIR_FLOOR, benjaminiHochberg, bootstrapCi, evaluateInterimReleaseConfidence, evaluateReleaseConfidence, gainHistogram, judgeReplayGate, pairedBootstrap, pairedEvalueSequence, researchReport, rubricPredictiveValidity, summaryTable, wilcoxonSignedRank };
8
+ // src/reporting.ts
9
+ /** Render already-formatted measurements without changing values or missing-data labels. */
10
+ function formatReportTable(columns, rows) {
11
+ const table = [columns.map((column) => column.header), ...rows];
12
+ const widths = columns.map((_, index) => Math.max(...table.map((row) => (row[index] ?? "").length)));
13
+ return table.map((row) => columns.map((column, index) => {
14
+ const value = row[index] ?? "";
15
+ if (column.align === "none") return value;
16
+ return column.align === "right" ? value.padStart(widths[index]) : value.padEnd(widths[index]);
17
+ }).join(" ")).join("\n");
18
+ }
19
+ export { RESEARCH_REPORT_HARD_PAIR_FLOOR, benjaminiHochberg, bootstrapCi, evaluateInterimReleaseConfidence, evaluateReleaseConfidence, formatReportTable, gainHistogram, judgeReplayGate, pairedBootstrap, pairedEvalueSequence, researchReport, rubricPredictiveValidity, summaryTable, wilcoxonSignedRank };
20
+
21
+ //# sourceMappingURL=reporting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporting.js","names":[],"sources":["../src/reporting.ts"],"sourcesContent":["export type {\n RubricOutcomePair,\n RubricPredictiveValidityInput,\n RubricPredictiveValidityReport,\n RubricRanking,\n} from './meta-eval/rubric-predictive-validity'\nexport { rubricPredictiveValidity } from './meta-eval/rubric-predictive-validity'\nexport type {\n BootstrapOptions,\n BootstrapResult,\n JudgeReplayGateArgs,\n Verdict,\n} from './promotion-gate'\nexport {\n bootstrapCi,\n judgeReplayGate,\n} from './promotion-gate'\nexport type {\n ReleaseConfidenceAxis,\n ReleaseConfidenceAxisName,\n ReleaseConfidenceInput,\n ReleaseConfidenceIssue,\n ReleaseConfidenceMetrics,\n ReleaseConfidenceScorecard,\n ReleaseConfidenceStatus,\n ReleaseConfidenceThresholds,\n ReleaseTraceEvidence,\n} from './release-confidence'\nexport { evaluateReleaseConfidence } from './release-confidence'\nexport type {\n InterimReleaseConfidence,\n InterimReleaseConfidenceInput,\n PairedEvalueOptions,\n PairedEvalueSequence,\n PairedEvalueStep,\n SequentialDecision,\n} from './sequential'\nexport {\n evaluateInterimReleaseConfidence,\n pairedEvalueSequence,\n} from './sequential'\nexport type {\n PairedBootstrapOptions,\n PairedBootstrapResult,\n} from './statistics'\nexport {\n benjaminiHochberg,\n pairedBootstrap,\n wilcoxonSignedRank,\n} from './statistics'\nexport type {\n GainDistributionBin,\n GainDistributionFigureSpec,\n GainDistributionOptions,\n ParetoFigureSpec,\n ParetoPoint,\n ResearchReport,\n ResearchReportCandidate,\n ResearchReportDecision,\n ResearchReportMethodology,\n ResearchReportOptions,\n ResearchReportRecommendation,\n SummaryTable,\n SummaryTableOptions,\n SummaryTableRow,\n} from './summary-report'\nexport {\n gainHistogram,\n RESEARCH_REPORT_HARD_PAIR_FLOOR,\n researchReport,\n summaryTable,\n} from './summary-report'\n\n/** A text report column; `none` leaves the cell unpadded. */\nexport interface ReportTableColumn {\n header: string\n align?: 'left' | 'right' | 'none'\n}\n\n/** Render already-formatted measurements without changing values or missing-data labels. */\nexport function formatReportTable(\n columns: readonly ReportTableColumn[],\n rows: readonly (readonly string[])[],\n): string {\n const table = [columns.map((column) => column.header), ...rows]\n const widths = columns.map((_, index) =>\n Math.max(...table.map((row) => (row[index] ?? '').length)),\n )\n return table\n .map((row) =>\n columns\n .map((column, index) => {\n const value = row[index] ?? ''\n if (column.align === 'none') return value\n return column.align === 'right'\n ? value.padStart(widths[index]!)\n : value.padEnd(widths[index]!)\n })\n .join(' '),\n )\n .join('\\n')\n}\n"],"mappings":";;;;;;;;;AAgFA,SAAgB,kBACd,SACA,MACQ;CACR,MAAM,QAAQ,CAAC,QAAQ,KAAK,WAAW,OAAO,MAAM,GAAG,GAAG,IAAI;CAC9D,MAAM,SAAS,QAAQ,KAAK,GAAG,UAC7B,KAAK,IAAI,GAAG,MAAM,KAAK,SAAS,IAAI,UAAU,GAAA,CAAI,MAAM,CAAC,CAC3D;CACA,OAAO,MACJ,KAAK,QACJ,QACG,KAAK,QAAQ,UAAU;EACtB,MAAM,QAAQ,IAAI,UAAU;EAC5B,IAAI,OAAO,UAAU,QAAQ,OAAO;EACpC,OAAO,OAAO,UAAU,UACpB,MAAM,SAAS,OAAO,MAAO,IAC7B,MAAM,OAAO,OAAO,MAAO;CACjC,CAAC,CAAC,CACD,KAAK,IAAI,CACd,CAAC,CACA,KAAK,IAAI;AACd"}
package/dist/rl.js CHANGED
@@ -7,7 +7,7 @@ import { r as pairedBootstrap } from "./paired-tests-kASEKpc-.js";
7
7
  import { t as decidePairedPromotion } from "./paired-promotion-decision-5Pl_qJLX.js";
8
8
  import { n as campaignCellToRunRecord } from "./run-record-B-G2Tu11.js";
9
9
  import { n as extractVerifiableReward, r as extractVerifiableRewardsFromRecords, t as detectRewardHacking } from "./reward-hacking-D-Vi9-fE.js";
10
- import { t as runEvalCampaign } from "./eval-campaign-DVqiBoXR.js";
10
+ import { t as runEvalCampaign } from "./eval-campaign-B-dQl_lA.js";
11
11
  import { s as assertRewardGate } from "./schema-YUIXT8iW.js";
12
12
  import { n as isTrainingLineEligible, o as toSftRows, t as isSplitEligible } from "./exporters-ByLcILYU.js";
13
13
  import { t as mintRolloutRows } from "./mint-D9ZysYtY.js";
@@ -101,6 +101,8 @@ async function runSandboxScenario(spec, options = {}) {
101
101
  assertions: [],
102
102
  timings: []
103
103
  };
104
+ const skipped = Symbol("scenario skipped");
105
+ let retiring = false;
104
106
  let measurementFailures = 0;
105
107
  const retirements = [];
106
108
  const scope = {
@@ -112,6 +114,20 @@ async function runSandboxScenario(spec, options = {}) {
112
114
  status: value[1] ? "pass" : "fail"
113
115
  });
114
116
  },
117
+ skip(name, message, metadata) {
118
+ if (retiring) throw new Error("Retirement cannot be skipped");
119
+ report.skipped = true;
120
+ report.metadata = {
121
+ skipReason: message,
122
+ ...metadata
123
+ };
124
+ scope.check({
125
+ name,
126
+ status: "skip",
127
+ message
128
+ });
129
+ throw skipped;
130
+ },
115
131
  defer: (retire) => retirements.push(retire),
116
132
  async measure(name, run) {
117
133
  const start = performance.now();
@@ -128,6 +144,7 @@ async function runSandboxScenario(spec, options = {}) {
128
144
  measured.durationMs = Math.round(performance.now() - start);
129
145
  }
130
146
  } catch (error) {
147
+ if (error === skipped) throw error;
131
148
  measured = {
132
149
  name,
133
150
  durationMs: Math.round(performance.now() - start),
@@ -135,6 +152,7 @@ async function runSandboxScenario(spec, options = {}) {
135
152
  error: error instanceof Error ? error.message : String(error)
136
153
  };
137
154
  }
155
+ if (report.skipped && !retiring) throw skipped;
138
156
  if (!measured.success) measurementFailures++;
139
157
  report.timings.push(measured);
140
158
  return measured;
@@ -179,8 +197,9 @@ async function runSandboxScenario(spec, options = {}) {
179
197
  scope.check(...spec.expectations?.(state) ?? []);
180
198
  report.metadata = spec.metadata?.(state);
181
199
  } catch (error) {
182
- report.error = error instanceof Error ? error.message : String(error);
200
+ if (error !== skipped) report.error = error instanceof Error ? error.message : String(error);
183
201
  } finally {
202
+ retiring = true;
184
203
  for (const retire of retirements.reverse()) {
185
204
  const measured = await scope.measure("cleanup", retire);
186
205
  if (!measured.success) scope.check({
@@ -190,9 +209,9 @@ async function runSandboxScenario(spec, options = {}) {
190
209
  });
191
210
  }
192
211
  }
193
- report.pass = !report.error && measurementFailures === 0 && report.assertions.every((a) => a.soft || a.status === "pass");
212
+ report.pass = !report.error && measurementFailures === 0 && report.assertions.every((a) => a.soft || a.status === "pass" || report.skipped && a.status === "skip");
194
213
  return report;
195
214
  }
196
215
  export { runSandboxScenario as n, SandboxHarness as t };
197
216
 
198
- //# sourceMappingURL=sandbox-harness-BzAUasgY.js.map
217
+ //# sourceMappingURL=sandbox-harness-CzRlzJ5y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-harness-CzRlzJ5y.js","names":["delay"],"sources":["../src/sandbox-harness.ts"],"sourcesContent":["import { setTimeout as delay } from 'node:timers/promises'\nimport { runBoundedProcess } from './bounded-process'\n\nimport type { TraceEmitter } from './trace/emitter'\nimport type { SandboxSpan } from './trace/schema'\n\nexport interface HarnessConfig {\n /** Setup command (e.g. \"pnpm install\"). Non-zero exit fails the run. */\n setupCommand?: string\n /** Run command (e.g. \"pnpm build\"). */\n runCommand?: string\n /** Test command (e.g. \"pnpm test --run\"). Drives the test count + pass count. */\n testCommand?: string\n cwd?: string\n /** Max wall-clock per phase in ms. Default 10 minutes. */\n timeoutMs?: number\n /** Captured stdout + stderr cap, default 16 MiB; excess is dropped. */\n maxOutputBytes?: number\n image?: string\n env?: Record<string, string>\n /** Parser for the test output — maps stdout/stderr/exit code → pass count. */\n testParser?: TestOutputParser\n}\n\nexport interface TestOutputParser {\n id: string\n parse(\n stdout: string,\n stderr: string,\n exitCode: number,\n ): { testsTotal: number; testsPassed: number } | undefined\n}\n\nexport interface SandboxResult {\n phase: 'setup' | 'run' | 'test'\n exitCode: number\n stdout: string\n stderr: string\n wallMs: number\n testsTotal?: number\n testsPassed?: number\n /** A timed-out phase always fails, even with exitCode 0. Absent/false means natural exit. */\n killedByTimeout?: boolean\n /** Captured output exceeded maxOutputBytes. */\n outputTruncated?: boolean\n}\n\nexport interface SandboxDriver {\n id: string\n exec(\n phase: SandboxResult['phase'],\n command: string,\n config: HarnessConfig,\n ): Promise<SandboxResult>\n}\n\ninterface SubprocessSandboxDriverOptions {\n cwd?: string\n env?: Record<string, string>\n}\n\nexport class SubprocessSandboxDriver implements SandboxDriver {\n id = 'subprocess'\n constructor(private options: SubprocessSandboxDriverOptions = {}) {}\n\n async exec(\n phase: SandboxResult['phase'],\n command: string,\n config: HarnessConfig,\n ): Promise<SandboxResult> {\n const result = await runBoundedProcess({\n command,\n shell: true,\n cwd: config.cwd ?? this.options.cwd,\n env: { ...process.env, ...this.options.env, ...config.env },\n envMode: 'replace',\n timeoutMs: config.timeoutMs ?? 10 * 60_000,\n maxOutputBytes: config.maxOutputBytes ?? 16 * 1024 * 1024,\n })\n // A timed-out phase never reaches the parser: the output of a killed\n // process is a fragment, and a fragment that happens to parse would\n // report a pass for a run that never finished.\n const parsed =\n !result.killedByTimeout && phase === 'test' && config.testParser\n ? config.testParser.parse(result.stdout, result.stderr, result.exitCode)\n : undefined\n return {\n phase,\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.runnerError ? result.stderr + result.runnerError : result.stderr,\n wallMs: result.wallMs,\n testsTotal: parsed?.testsTotal,\n testsPassed: parsed?.testsPassed,\n killedByTimeout: result.killedByTimeout || undefined,\n outputTruncated: result.outputTruncated || undefined,\n }\n }\n}\n\n// ── Harness orchestration ────────────────────────────────────────────\n\nexport interface SandboxHarnessResult {\n passed: boolean\n setup?: SandboxResult\n run?: SandboxResult\n test?: SandboxResult\n totalWallMs: number\n /** Final score — 0 when no tests; otherwise testsPassed/testsTotal. */\n score: number\n}\n\nexport class SandboxHarness {\n constructor(private driver: SandboxDriver = new SubprocessSandboxDriver()) {}\n\n async run(config: HarnessConfig, emitter: TraceEmitter): Promise<SandboxHarnessResult> {\n const handle = await emitter.sandbox({\n name: `sandbox(${this.driver.id})`,\n image: config.image,\n command: [config.setupCommand, config.runCommand, config.testCommand]\n .filter(Boolean)\n .join(' && '),\n })\n const result: SandboxHarnessResult = { passed: false, totalWallMs: 0, score: 0 }\n try {\n for (const phase of ['setup', 'run', 'test'] as const) {\n const command = config[`${phase}Command`]\n if (!command) continue\n const measured = await this.driver.exec(phase, command, config)\n result[phase] = measured\n result.totalWallMs += measured.wallMs\n const passed = !measured.killedByTimeout && measured.exitCode === 0\n if (phase !== 'test' && !passed) {\n await handle.fail(\n measured.killedByTimeout\n ? `${phase} timed out after ${measured.wallMs}ms`\n : `${phase} failed (exit ${measured.exitCode})`,\n {\n exitCode: measured.exitCode,\n wallMs: result.totalWallMs,\n } as Partial<SandboxSpan>,\n )\n return result\n }\n }\n const test = result.test\n result.passed = !test || (!test.killedByTimeout && test.exitCode === 0)\n result.score =\n test?.testsTotal !== undefined && test.testsTotal > 0\n ? (test.testsPassed ?? 0) / test.testsTotal\n : result.passed\n ? 1\n : 0\n await handle.end({\n exitCode: test?.exitCode,\n testsTotal: test?.testsTotal,\n testsPassed: test?.testsPassed,\n status: result.passed ? 'ok' : 'error',\n wallMs: result.totalWallMs,\n } as Partial<SandboxSpan>)\n } catch (err) {\n await handle.fail(err instanceof Error ? err : String(err))\n throw err\n }\n return result\n }\n}\n\n/** Portable integration report; products may retain extra timing and assertion fields. */\nexport interface HarnessAssertion {\n name: string\n status: 'pass' | 'fail' | 'skip'\n expected?: string\n actual?: string\n message?: string\n soft?: boolean\n}\nexport type HarnessExpectation =\n | HarnessAssertion\n | readonly [name: string, passed: boolean, details?: Omit<HarnessAssertion, 'name' | 'status'>]\nexport interface HarnessTiming {\n name: string\n durationMs: number\n success: boolean\n error?: string\n}\nexport interface HarnessReport {\n pass: boolean\n skipped?: boolean\n assertions: HarnessAssertion[]\n timings: HarnessTiming[]\n error?: string\n metadata?: Record<string, unknown>\n}\nexport interface HarnessResource<T> {\n name: string\n create(signal: AbortSignal): Promise<T>\n retire(resource: T): Promise<unknown>\n ready?: (resource: T, signal: AbortSignal) => Promise<unknown>\n onCreate?: (resource: T) => void\n}\nexport interface HarnessScope {\n signal: AbortSignal\n resource<T>(input: HarnessResource<T>): Promise<{ resource?: T; timing: HarnessTiming }>\n check(...assertions: HarnessExpectation[]): void\n skip(name: string, message: string, metadata?: Record<string, unknown>): never\n measure(name: string, run: () => Promise<unknown>): Promise<HarnessTiming>\n /** Register retirement immediately after allocation; cleanup ignores workload cancellation. */\n defer(retire: () => Promise<unknown>): void\n poll<T>(\n read: () => Promise<T>,\n ready: (value: T) => boolean,\n budget: { timeoutMs: number; intervalMs: number },\n ): Promise<T | undefined>\n}\nexport interface HarnessScenario<T> {\n setup(scope: HarnessScope): Promise<T>\n steps?: ReadonlyArray<{\n name: string\n /** Diagnostic measurements retain failures without gating the scenario. */\n advisory?: boolean\n when?: (state: T) => boolean\n run(state: T, scope: HarnessScope): Promise<unknown>\n expect?: (state: T, timing: HarnessTiming) => HarnessExpectation[]\n }>\n expectations?: (state: T) => HarnessExpectation[]\n metadata?: (state: T) => Record<string, unknown>\n /** Includes setup and steps. Transports must honor scope.signal. */\n budgetMs: number\n}\n\n/** Campaigns own whole-scenario retries; polling only repeats the declared read. */\nexport async function runSandboxScenario<T>(\n spec: HarnessScenario<T>,\n options: {\n signal?: AbortSignal\n measure?: HarnessScope['measure']\n } = {},\n): Promise<HarnessReport> {\n if (!(spec.budgetMs > 0 && Number.isSafeInteger(spec.budgetMs)))\n throw new Error('Scenario budgetMs must be positive and finite')\n const signal = AbortSignal.any([\n AbortSignal.timeout(spec.budgetMs),\n ...(options.signal ? [options.signal] : []),\n ])\n const report: HarnessReport = { pass: false, assertions: [], timings: [] }\n const skipped = Symbol('scenario skipped')\n let retiring = false\n let measurementFailures = 0\n const retirements: Array<() => Promise<unknown>> = []\n const scope: HarnessScope = {\n signal,\n check(...assertions) {\n for (const value of assertions)\n report.assertions.push(\n 'status' in value\n ? value\n : {\n ...value[2],\n name: value[0],\n status: value[1] ? 'pass' : 'fail',\n },\n )\n },\n skip(name, message, metadata) {\n if (retiring) throw new Error('Retirement cannot be skipped')\n report.skipped = true\n report.metadata = { skipReason: message, ...metadata }\n scope.check({ name, status: 'skip', message })\n throw skipped\n },\n defer: (retire) => retirements.push(retire),\n async measure(name, run) {\n const start = performance.now()\n let measured: HarnessTiming = { name, durationMs: 0, success: true }\n try {\n if (options.measure) measured = await options.measure(name, run)\n else {\n const result = (await run()) as { success?: boolean; error?: string } | undefined\n if (result?.success === false)\n throw new Error(result.error ?? 'measured operation returned success=false')\n measured.durationMs = Math.round(performance.now() - start)\n }\n } catch (error) {\n if (error === skipped) throw error\n measured = {\n name,\n durationMs: Math.round(performance.now() - start),\n success: false,\n error: error instanceof Error ? error.message : String(error),\n }\n }\n if (report.skipped && !retiring) throw skipped\n if (!measured.success) measurementFailures++\n report.timings.push(measured)\n return measured\n },\n async resource<T>(input: HarnessResource<T>) {\n let resource: T | undefined\n const timing = await scope.measure(input.name, async () => {\n const owned = await input.create(signal)\n resource = owned\n scope.defer(() => input.retire(owned))\n input.onCreate?.(owned)\n await input.ready?.(owned, signal)\n })\n return { resource, timing }\n },\n async poll(read, ready, budget) {\n if (!(budget.timeoutMs > 0 && budget.intervalMs > 0))\n throw new Error('Polling timeout and interval must be positive')\n const deadline = performance.now() + budget.timeoutMs\n while (performance.now() < deadline) {\n signal.throwIfAborted()\n const value = await read()\n if (ready(value)) return value\n await delay(\n Math.min(budget.intervalMs, Math.max(0, deadline - performance.now())),\n undefined,\n { signal },\n )\n }\n return undefined\n },\n }\n try {\n signal.throwIfAborted()\n const state = await spec.setup(scope)\n for (const step of spec.steps ?? []) {\n signal.throwIfAborted()\n if (step.when && !step.when(state)) continue\n const failuresBefore = measurementFailures\n const timing = await scope.measure(step.name, () => step.run(state, scope))\n if (step.advisory) measurementFailures = failuresBefore\n scope.check(...(step.expect?.(state, timing) ?? []))\n }\n signal.throwIfAborted()\n scope.check(...(spec.expectations?.(state) ?? []))\n report.metadata = spec.metadata?.(state)\n } catch (error) {\n if (error !== skipped) report.error = error instanceof Error ? error.message : String(error)\n } finally {\n retiring = true\n for (const retire of retirements.reverse()) {\n const measured = await scope.measure('cleanup', retire)\n if (!measured.success)\n scope.check({ name: 'cleanup', status: 'fail', message: measured.error })\n }\n }\n report.pass =\n !report.error &&\n measurementFailures === 0 &&\n report.assertions.every(\n (a) => a.soft || a.status === 'pass' || (report.skipped && a.status === 'skip'),\n )\n return report\n}\n"],"mappings":";;;AA6DA,IAAa,0BAAb,MAA8D;CAExC;CADpB,KAAK;CACL,YAAY,UAAkD,CAAC,GAAG;EAA9C,KAAA,UAAA;CAA+C;CAEnE,MAAM,KACJ,OACA,SACA,QACwB;EACxB,MAAM,SAAS,MAAM,kBAAkB;GACrC;GACA,OAAO;GACP,KAAK,OAAO,OAAO,KAAK,QAAQ;GAChC,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,KAAK,QAAQ;IAAK,GAAG,OAAO;GAAI;GAC1D,SAAS;GACT,WAAW,OAAO,aAAa;GAC/B,gBAAgB,OAAO,kBAAkB;EAC3C,CAAC;EAID,MAAM,SACJ,CAAC,OAAO,mBAAmB,UAAU,UAAU,OAAO,aAClD,OAAO,WAAW,MAAM,OAAO,QAAQ,OAAO,QAAQ,OAAO,QAAQ,IACrE,KAAA;EACN,OAAO;GACL;GACA,UAAU,OAAO;GACjB,QAAQ,OAAO;GACf,QAAQ,OAAO,cAAc,OAAO,SAAS,OAAO,cAAc,OAAO;GACzE,QAAQ,OAAO;GACf,YAAY,QAAQ;GACpB,aAAa,QAAQ;GACrB,iBAAiB,OAAO,mBAAmB,KAAA;GAC3C,iBAAiB,OAAO,mBAAmB,KAAA;EAC7C;CACF;AACF;AAcA,IAAa,iBAAb,MAA4B;CACN;CAApB,YAAY,SAAgC,IAAI,wBAAwB,GAAG;EAAvD,KAAA,SAAA;CAAwD;CAE5E,MAAM,IAAI,QAAuB,SAAsD;EACrF,MAAM,SAAS,MAAM,QAAQ,QAAQ;GACnC,MAAM,WAAW,KAAK,OAAO,GAAG;GAChC,OAAO,OAAO;GACd,SAAS;IAAC,OAAO;IAAc,OAAO;IAAY,OAAO;GAAW,CAAC,CAClE,OAAO,OAAO,CAAC,CACf,KA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,KAAK,CAAC,CAAE;EACrD;EACA,OAAO,eAAe;EACtB,MAAM,MAAM,GAAI,KAAK,eAAe,KAAK,KAAK,CAAC,CAAE;EACjD,OAAO,WAAW,KAAK,WAAW,KAAK;CACzC,SAAS,OAAO;EACd,IAAI,UAAU,SAAS,OAAO,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC7F,UAAU;EACR,WAAW;EACX,KAAK,MAAM,UAAU,YAAY,QAAQ,GAAG;GAC1C,MAAM,WAAW,MAAM,MAAM,QAAQ,WAAW,MAAM;GACtD,IAAI,CAAC,SAAS,SACZ,MAAM,MAAM;IAAE,MAAM;IAAW,QAAQ;IAAQ,SAAS,SAAS;GAAM,CAAC;EAC5E;CACF;CACA,OAAO,OACL,CAAC,OAAO,SACR,wBAAwB,KACxB,OAAO,WAAW,OACf,MAAM,EAAE,QAAQ,EAAE,WAAW,UAAW,OAAO,WAAW,EAAE,WAAW,MAC1E;CACF,OAAO;AACT"}
@@ -66,6 +66,7 @@ interface HarnessTiming {
66
66
  }
67
67
  interface HarnessReport {
68
68
  pass: boolean;
69
+ skipped?: boolean;
69
70
  assertions: HarnessAssertion[];
70
71
  timings: HarnessTiming[];
71
72
  error?: string;
@@ -85,6 +86,7 @@ interface HarnessScope {
85
86
  timing: HarnessTiming;
86
87
  }>;
87
88
  check(...assertions: HarnessExpectation[]): void;
89
+ skip(name: string, message: string, metadata?: Record<string, unknown>): never;
88
90
  measure(name: string, run: () => Promise<unknown>): Promise<HarnessTiming>;
89
91
  /** Register retirement immediately after allocation; cleanup ignores workload cancellation. */
90
92
  defer(retire: () => Promise<unknown>): void;
@@ -114,4 +116,4 @@ declare function runSandboxScenario<T>(spec: HarnessScenario<T>, options?: {
114
116
  measure?: HarnessScope['measure'];
115
117
  }): Promise<HarnessReport>;
116
118
  export { HarnessScenario as a, SandboxDriver as c, HarnessReport as i, SandboxHarnessResult as l, HarnessConfig as n, HarnessScope as o, HarnessExpectation as r, HarnessTiming as s, HarnessAssertion as t, runSandboxScenario as u };
117
- //# sourceMappingURL=sandbox-harness-BS6c6UZV.d.ts.map
119
+ //# sourceMappingURL=sandbox-harness-K3LuyORm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-harness-K3LuyORm.d.ts","names":[],"sources":["../src/sandbox-harness.ts"],"mappings":"A,UAMiB;;EAEf;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;EACA,MAAM;;EAEN,aAAa;;UAGE;EACf;EACA,MACE,gBACA,gBACA;IACG;IAAoB;;;UAGV;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA,KACE,OAAO,wBACP,iBACA,QAAQ,gBACP,QAAQ;;UAiDI;EACf;EACA,QAAQ;EACR,MAAM;EACN,OAAO;EACP;;EAEA;;;UA4De;EACf;EACA;EACA;EACA;EACA;EACA;;KAEU,qBACR,6BACU,cAAc,iBAAiB,UAAU,KAAK;UAC3C;EACf;EACA;EACA;EACA;;UAEe;EACf;EACA;EACA,YAAY;EACZ,SAAS;EACT;EACA,WAAW;;UAEI,gBAAgB;EAC/B;EACA,OAAO,QAAQ,cAAc,QAAQ;EACrC,OAAO,UAAU,IAAI;EACrB,SAAS,UAAU,GAAG,QAAQ,gBAAgB;EAC9C,YAAY,UAAU;;UAEP;EACf,QAAQ;EACR,SAAS,GAAG,OAAO,gBAAgB,KAAK;IAAU,WAAW;IAAG,QAAQ;;EACxE,SAAS,YAAY;EACrB,KAAK,cAAc,iBAAiB,WAAW;EAC/C,QAAQ,cAAc,WAAW,mBAAmB,QAAQ;;EAE5D,MAAM,cAAc;EACpB,KAAK,GACH,YAAY,QAAQ,IACpB,QAAQ,OAAO,eACf;IAAU;IAAmB;MAC5B,QAAQ;;UAEI,gBAAgB;EAC/B,MAAM,OAAO,eAAe,QAAQ;EACpC,QAAQ;IACN;;IAEA;IACA,QAAQ,OAAO;IACf,IAAI,OAAO,GAAG,OAAO,eAAe;IACpC,UAAU,OAAO,GAAG,QAAQ,kBAAkB;;EAEhD,gBAAgB,OAAO,MAAM;EAC7B,YAAY,OAAO,MAAM;;EAEzB;;;iBAIoB,mBAAmB,GACvC,MAAM,gBAAgB,IACtB;EACE,SAAS;EACT,UAAU;IAEX,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"summary-report-0La5vejY.d.ts","names":[],"sources":["../src/held-out-gate.ts","../src/summary-report-figures.ts","../src/research-report-analysis.ts","../src/research-report.ts"],"mappings":";;;;KAuIY;;;;;;;;UAiBK;;EAEf;;;EAGA;;;;EAIA;;EAEA;;EAEA;;;EAGA;;UAGe;;;;EAIf;;;;;EAKA;;;;;;;;;;;EAWA;;;;EAIA;;;EAGA;;EAEA;;EAEA;;;;EAIA;;;;;;;;;;;;;;;;;EAiBA;;;;;;;;;;;;;;EAcA;;;;KAKG,iBAAiB;UAEL;;EAEf;;EAEA;;EAEA;;;;;;;;EAQA,iBAAiB;;;;;EAKjB,gBAAgB;;;;;EAKhB;;;;;;;;;EASA,gBAAgB;;;EAGhB;;;EAGA;IAAY;IAAa;;;;EAGzB;;;;;;;EAOA;IAAW;IAAW;IAAW;IAAqB;;;;;;EAKtD;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;EAGA;;;;;;;EAOA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA,eAAe;;;;;;;cAQJ;mBACM;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEL,YAAA,QAAQ;;;;EAoCpB,SAAS,WAAW,aAAa,UAAU,cAAc;;;UAiCjD;;;;;;UAoEA;;;UAiCA;;;UAkEA;;;;;;;UAqDA;;UCvnBO;;;EAGf;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf,MAAM;EACN;EACA;;EAEA;;;;;;;iBAQc,aAAa,MAAM,aAAa,OAAM,sBAA2B;UAkHhE;EACf;;EAEA;;EAEA;;EAEA;;;EAGA;;;EAGA;;UAGe;EACf;EACA;EACA,QAAQ;EACR;IAAQ;IAAc;;;UAoEP;;EAEf;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;EACA,MAAM;EACN;EACA;IAAM;IAAa;;;UAGJ;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;iBAQc,cACd,MAAM,aACN,qBACA,oBACA,OAAM,0BACL;;;;;;cCrSU;KCWD;UAOK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;EASA;;;;;;;EAOA;IAAS;IAAa;;;;;;EAKtB;;;;;EAKA;;EAEA,gBAAgB,eAAe;;EAE/B,kBAAkB;;EAElB;;EAEA;;EAEA;;;;;;EAMA;;UAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAa;;;;;;;EAMvB;EACA;;;;;;;EAOA;EACA;EACA,OAAO;EACP,UAAU;EACV;;UAGe;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;EACA;IAAQ;IAAa;;EACrB;EACA,gBAAgB;EAChB,YAAY;EACZ,SAAS;EACT;IACE,QAAQ;IACR,OAAO;;EAET,aAAa;EACb,kBAAkB;EAClB;EACA;;;;;;;;;;;;;;;;;;;;;iBAsBoB,eACpB,MAAM,aACN,OAAM,wBACL,QAAQ"}
1
+ {"version":3,"file":"summary-report-0La5vejY.d.ts","names":[],"sources":["../src/held-out-gate.ts","../src/summary-report-figures.ts","../src/research-report-analysis.ts","../src/research-report.ts"],"mappings":";;;;KAuIY;;;;;;;;UAiBK;;EAEf;;;EAGA;;;;EAIA;;EAEA;;EAEA;;;EAGA;;UAGe;;;;EAIf;;;;;EAKA;;;;;;;;;;;EAW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IAAa;;;;;;EAKtB;;;;;EAKA;;EAEA,gBAAgB,eAAe;;EAE/B,kBAAkB;;EAElB;;EAEA;;EAEA;;;;;;EAMA;;UAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAU;IAAa;;;;;;;EAMvB;EACA;;;;;;;EAOA;EACA;EACA,OAAO;EACP,UAAU;EACV;;UAGe;;;;;EAKf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;EAMA;EACA;EACA;IAAQ;IAAa;;EACrB;EACA,gBAAgB;EAChB,YAAY;EACZ,SAAS;EACT;IACE,QAAQ;IACR,OAAO;;EAET,aAAa;EACb,kBAAkB;EAClB;EACA;;;;;;;;;;;;;;;;;;;;;iBAsBoB,eACpB,MAAM,aACN,OAAM,wBACL,QAAQ"}
@@ -288,22 +288,8 @@ function decisionWeight(decision) {
288
288
  return 1;
289
289
  }
290
290
  // src/statistics/effect-sizes.ts
291
- /**
292
- * Standardized effect sizes: Cohen's d family and Cliff's delta, with the
293
- * shared degenerate-input contract (null where the effect is undefined).
294
- */
295
- /**
296
- * Cohen's d — standardized effect size for two independent groups.
297
- * Positive d means group b has higher mean than group a.
298
- * Rule of thumb: |d| < 0.2 negligible, 0.2–0.5 small, 0.5–0.8 medium, > 0.8 large.
299
- *
300
- * Returns null where the standardized effect is undefined: fewer than two
301
- * observations in either group, or a zero pooled standard deviation with
302
- * unequal means. Null is NOT "no effect" — zero within-group spread across a
303
- * real mean gap is an unbounded effect, the opposite of negligible. Equal
304
- * means with zero spread is a genuine 0. Same contract as
305
- * {@link pairedCohensDz}.
306
- */
291
+ /** Standardized effect sizes; undefined effects remain null. */
292
+ /** Independent Cohen's d, oriented b − a; null below two samples or for an unbounded effect. */
307
293
  function cohensD(a, b) {
308
294
  if (a.length < 2 || b.length < 2) return null;
309
295
  const meanA = a.reduce((x, y) => x + y, 0) / a.length;
@@ -314,14 +300,7 @@ function cohensD(a, b) {
314
300
  if (pooled === 0) return meanB === meanA ? 0 : null;
315
301
  return (meanB - meanA) / pooled;
316
302
  }
317
- /**
318
- * Cohen's dz for paired observations: mean(after - before) divided by the
319
- * sample standard deviation of those within-pair deltas.
320
- *
321
- * Returns null when fewer than two pairs exist or a non-zero constant delta
322
- * has zero observed variance. In that case the standardized effect is
323
- * undefined, not an arbitrarily large finite number.
324
- */
303
+ /** Paired Cohen's dz; constant nonzero deltas have no finite standardized effect. */
325
304
  function pairedCohensDz(before, after) {
326
305
  if (before.length !== after.length) throw new ValidationError(`pairedCohensDz: unequal sample sizes (${before.length} vs ${after.length})`);
327
306
  if (before.length < 2) return null;
@@ -334,16 +313,7 @@ function pairedCohensDz(before, after) {
334
313
  if (standardDeviation <= Number.EPSILON * scale) return meanDelta === 0 ? 0 : null;
335
314
  return meanDelta / standardDeviation;
336
315
  }
337
- /**
338
- * Cliff's delta — a non-parametric effect size for two independent samples.
339
- * `δ = (#(after > before) − #(after < before)) / (n_before · n_after)`,
340
- * ranging [-1, 1]. Positive ⇒ `after` tends to exceed `before` (improvement).
341
- *
342
- * Distribution-free counterpart to Cohen's d: no normality assumption, robust
343
- * to the bounded/skewed score distributions judges produce. Pairs with
344
- * `pairedBootstrap` / `wilcoxonSignedRank` for the non-parametric reporting
345
- * path. Returns 0 when either sample is empty.
346
- */
316
+ /** Cliff's delta, oriented after − before; empty samples return zero. */
347
317
  function cliffsDelta(before, after) {
348
318
  const n = before.length * after.length;
349
319
  if (n === 0) return 0;
@@ -352,11 +322,7 @@ function cliffsDelta(before, after) {
352
322
  else if (a < b) dominance -= 1;
353
323
  return dominance / n;
354
324
  }
355
- /**
356
- * Map a Cliff's delta to a qualitative magnitude using the standard
357
- * Romano et al. thresholds (|δ|): <0.147 negligible, <0.33 small,
358
- * <0.474 medium, else large.
359
- */
325
+ /** Romano magnitude thresholds for the absolute Cliff's delta. */
360
326
  function interpretCliffs(delta) {
361
327
  const d = Math.abs(delta);
362
328
  if (d < .147) return "negligible";
@@ -479,55 +445,33 @@ function summaryTable(runs, opts = {}) {
479
445
  bucket.scores.push(v);
480
446
  byCandidate.set(r.candidateId, bucket);
481
447
  }
482
- const candidateIds = [...byCandidate.keys()].sort();
483
448
  const compRuns = comparator ? byCandidate.get(comparator) : void 0;
484
- const tentative = [];
485
- for (const id of candidateIds) {
449
+ const rows = [...byCandidate.keys()].sort().map((id) => {
486
450
  const bucket = byCandidate.get(id);
487
451
  const ci = confidenceInterval(bucket.scores, confidence);
488
- let rawP = null;
489
- let d = null;
490
- let pairedN = null;
491
- let unpairedCandidateN = null;
492
- let unpairedComparatorN = null;
493
- if (comparator && compRuns && id !== comparator) {
494
- const paired = pairScoresByKey(bucket.runs, compRuns.runs, split);
495
- pairedN = paired.before.length;
496
- unpairedCandidateN = paired.unpairedCandidateN;
497
- unpairedComparatorN = paired.unpairedComparatorN;
498
- if (paired.before.length >= 6) rawP = wilcoxonSignedRank(paired.before, paired.after).p;
499
- d = pairedCohensDz(paired.before, paired.after);
500
- }
501
- tentative.push({
452
+ const paired = comparator && compRuns && id !== comparator ? pairScoresByKey(bucket.runs, compRuns.runs, split) : null;
453
+ return {
502
454
  candidateId: id,
503
455
  n: bucket.scores.length,
504
456
  mean: ci.mean,
505
457
  ciLow: ci.lower,
506
458
  ciHigh: ci.upper,
507
- qValue: rawP,
508
- cohensD: d,
509
- pairedN,
510
- unpairedCandidateN,
511
- unpairedComparatorN,
512
- rawP
513
- });
514
- }
459
+ qValue: paired && paired.before.length >= 6 ? wilcoxonSignedRank(paired.before, paired.after).p : null,
460
+ cohensD: paired ? pairedCohensDz(paired.before, paired.after) : null,
461
+ pairedN: paired?.before.length ?? null,
462
+ unpairedCandidateN: paired?.unpairedCandidateN ?? null,
463
+ unpairedComparatorN: paired?.unpairedComparatorN ?? null
464
+ };
465
+ });
515
466
  if (comparator) {
516
- const idxs = [];
517
- const ps = [];
518
- for (let i = 0; i < tentative.length; i++) {
519
- const r = tentative[i];
520
- if (r.candidateId === comparator) continue;
521
- if (r.rawP === null || !Number.isFinite(r.rawP)) continue;
522
- idxs.push(i);
523
- ps.push(r.rawP);
524
- }
525
- if (ps.length > 0) {
526
- const { qValues } = benjaminiHochberg(ps, fdr);
527
- for (let k = 0; k < idxs.length; k++) tentative[idxs[k]].qValue = qValues[k];
467
+ const comparisons = rows.filter((row) => row.candidateId !== comparator && row.qValue !== null && Number.isFinite(row.qValue));
468
+ if (comparisons.length > 0) {
469
+ const { qValues } = benjaminiHochberg(comparisons.map((row) => row.qValue), fdr);
470
+ comparisons.forEach((row, index) => {
471
+ row.qValue = qValues[index];
472
+ });
528
473
  }
529
474
  }
530
- const rows = tentative.map(({ rawP: _rawP, ...rest }) => rest);
531
475
  return {
532
476
  rows,
533
477
  comparator,
@@ -536,21 +480,22 @@ function summaryTable(runs, opts = {}) {
536
480
  };
537
481
  }
538
482
  function renderSummaryTableMarkdown(rows, comparator, split) {
539
- const lines = [];
540
- const cmpLabel = comparator ? ` (vs ${comparator})` : "";
541
- lines.push(`Summary Table — ${split} split${cmpLabel}`);
542
- lines.push("");
543
- lines.push("| Candidate | N | Pairs | Unpaired | Mean | 95% CI | q (BH) | Cohen's dz |");
544
- lines.push("|---|---:|---:|---:|---:|---|---:|---:|");
545
- for (const r of rows) {
546
- const ci = `[${fmt(r.ciLow)}, ${fmt(r.ciHigh)}]`;
547
- const q = r.qValue !== null ? r.qValue.toFixed(4) : "—";
548
- const d = r.cohensD !== null ? r.cohensD.toFixed(3) : "—";
549
- const paired = r.pairedN ?? "—";
550
- const unpaired = r.unpairedCandidateN === null || r.unpairedComparatorN === null ? "—" : `${r.unpairedCandidateN}/${r.unpairedComparatorN}`;
551
- lines.push(`| ${r.candidateId} | ${r.n} | ${paired} | ${unpaired} | ${fmt(r.mean)} | ${ci} | ${q} | ${d} |`);
552
- }
553
- return lines.join("\n");
483
+ return [
484
+ `Summary Table — ${split} split${comparator ? ` (vs ${comparator})` : ""}`,
485
+ "",
486
+ "| Candidate | N | Pairs | Unpaired | Mean | 95% CI | q (BH) | Cohen's dz |",
487
+ "|---|---:|---:|---:|---:|---|---:|---:|",
488
+ ...rows.map((r) => `| ${[
489
+ r.candidateId,
490
+ r.n,
491
+ r.pairedN ?? "—",
492
+ r.unpairedCandidateN === null || r.unpairedComparatorN === null ? "—" : `${r.unpairedCandidateN}/${r.unpairedComparatorN}`,
493
+ fmt(r.mean),
494
+ `[${fmt(r.ciLow)}, ${fmt(r.ciHigh)}]`,
495
+ r.qValue?.toFixed(4) ?? "—",
496
+ r.cohensD?.toFixed(3) ?? "—"
497
+ ].join(" | ")} |`)
498
+ ].join("\n");
554
499
  }
555
500
  /**
556
501
  * Cost vs quality scatter spec. `gateDecisions` is keyed by
@@ -573,15 +518,14 @@ function paretoChart(runs, opts = {}) {
573
518
  bucket.quality.push(v);
574
519
  buckets.set(r.candidateId, bucket);
575
520
  }
576
- const points = [];
577
- for (const [candidateId, bucket] of buckets.entries()) points.push({
521
+ const points = [...buckets].map(([candidateId, bucket]) => ({
578
522
  candidateId,
579
523
  cost: mean(bucket.cost),
580
524
  quality: mean(bucket.quality),
581
525
  n: bucket.cost.length,
582
526
  onFrontier: false,
583
527
  gate: opts.gateDecisions?.[candidateId] ? gateLabel(opts.gateDecisions[candidateId]) : void 0
584
- });
528
+ }));
585
529
  for (const p of points) p.onFrontier = !points.some((q) => q !== p && dominates(q, p));
586
530
  return {
587
531
  kind: "pareto-cost-quality",
@@ -610,28 +554,14 @@ function gainHistogram(runs, candidateId, comparator, opts = {}) {
610
554
  if (binCount < 1) throw new Error("gainHistogram: bins must be ≥ 1");
611
555
  const { before, after, unpairedCandidateN, unpairedComparatorN } = pairScoresByKey(runs.filter((r) => r.candidateId === candidateId && r.splitTag === split), runs.filter((r) => r.candidateId === comparator && r.splitTag === split), split);
612
556
  const n = before.length;
613
- if (n === 0) return {
614
- kind: "gain-distribution",
615
- candidateId,
616
- comparator,
617
- split,
618
- n: 0,
619
- unpairedCandidateN,
620
- unpairedComparatorN,
621
- bins: [],
622
- median: null,
623
- ci: null
624
- };
625
557
  const deltas = before.map((b, i) => after[i] - b);
626
558
  const sortedDeltas = [...deltas].sort((a, b) => a - b);
627
- const median = interpolatedQuantile(sortedDeltas, .5);
628
- const min = sortedDeltas[0];
629
- const max = sortedDeltas[sortedDeltas.length - 1];
630
- const bound = Math.max(Math.abs(min), Math.abs(max), 1e-6);
559
+ const median = n === 0 ? null : interpolatedQuantile(sortedDeltas, .5);
560
+ const bound = Math.max(Math.abs(sortedDeltas[0]), Math.abs(sortedDeltas[sortedDeltas.length - 1]), 1e-6);
631
561
  const lo = -bound;
632
562
  const width = (bound - lo) / binCount;
633
563
  const bins = [];
634
- for (let i = 0; i < binCount; i++) bins.push({
564
+ for (let i = 0; n > 0 && i < binCount; i++) bins.push({
635
565
  lo: lo + i * width,
636
566
  hi: lo + (i + 1) * width,
637
567
  count: 0
@@ -642,7 +572,7 @@ function gainHistogram(runs, candidateId, comparator, opts = {}) {
642
572
  if (idx >= binCount) idx = binCount - 1;
643
573
  bins[idx].count += 1;
644
574
  }
645
- const ci = pairedBootstrap(before, after, {
575
+ const ci = n === 0 ? null : pairedBootstrap(before, after, {
646
576
  confidence: opts.confidence ?? .95,
647
577
  resamples: opts.resamples ?? 2e3,
648
578
  statistic: "median",
@@ -658,7 +588,7 @@ function gainHistogram(runs, candidateId, comparator, opts = {}) {
658
588
  unpairedComparatorN,
659
589
  bins,
660
590
  median,
661
- ci: {
591
+ ci: ci === null ? null : {
662
592
  low: ci.low,
663
593
  high: ci.high
664
594
  }
@@ -840,4 +770,4 @@ async function researchReport(runs, opts = {}) {
840
770
  }
841
771
  export { cliffsDelta as a, pairedCohensDz as c, summaryTable as i, RESEARCH_REPORT_HARD_PAIR_FLOOR as l, gainHistogram as n, cohensD as o, paretoChart as r, interpretCliffs as s, researchReport as t };
842
772
 
843
- //# sourceMappingURL=summary-report-BstMpOfy.js.map
773
+ //# sourceMappingURL=summary-report-B4BLQb88.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary-report-B4BLQb88.js","names":["avg"],"sources":["../src/research-report-render.ts","../src/research-report-analysis.ts","../src/statistics/effect-sizes.ts","../src/summary-report-evidence.ts","../src/summary-report-figures.ts","../src/research-report.ts"],"sourcesContent":["/** Markdown research reports and their shared numeric text formatting. */\n\nimport type { FailureClusterReport } from './pipelines/failure-cluster'\nimport type {\n ResearchReportCandidate,\n ResearchReportMethodology,\n ResearchReportRecommendation,\n} from './research-report'\nimport type {\n GainDistributionFigureSpec,\n ParetoFigureSpec,\n SummaryTable,\n} from './summary-report-figures'\n\nexport function renderResearchMarkdown(report: {\n title: string\n generatedAt: string\n split: 'search' | 'holdout'\n comparator: string | null\n executiveSummary: string[]\n recommendation: ResearchReportRecommendation\n candidates: ResearchReportCandidate[]\n summary: SummaryTable\n pareto: ParetoFigureSpec\n gains: GainDistributionFigureSpec[]\n rope: { low: number; high: number } | null\n runFingerprint: string\n preregistrationHash: string | null\n methodology: ResearchReportMethodology\n failureClusters?: FailureClusterReport\n}): string {\n const lines: string[] = []\n lines.push(`# ${report.title}`)\n lines.push('')\n lines.push(`**Generated:** ${report.generatedAt}`)\n lines.push(`**Primary split:** ${report.split}`)\n lines.push(`**Comparator:** ${report.comparator ?? 'not configured'}`)\n lines.push(`**ROPE:** ${report.rope ? formatRope(report.rope) : 'not configured'}`)\n lines.push(`**Run fingerprint:** \\`${report.runFingerprint}\\``)\n lines.push(\n `**Preregistration:** ${report.preregistrationHash ? `\\`${report.preregistrationHash}\\`` : 'none'}`,\n )\n lines.push('')\n lines.push('## Executive Summary')\n lines.push('')\n for (const item of report.executiveSummary) lines.push(`- ${item}`)\n lines.push('')\n lines.push('## Recommendation')\n lines.push('')\n lines.push(`**Decision:** ${report.recommendation.decision}`)\n lines.push(`**Candidate:** ${report.recommendation.candidateId ?? 'N/A'}`)\n lines.push('')\n lines.push('### Rationale')\n lines.push('')\n for (const item of report.recommendation.rationale) lines.push(`- ${item}`)\n lines.push('')\n lines.push('### Risks')\n lines.push('')\n for (const item of report.recommendation.risks.length\n ? report.recommendation.risks\n : ['No material report-level risks detected.']) {\n lines.push(`- ${item}`)\n }\n lines.push('')\n lines.push('### Next Actions')\n lines.push('')\n for (const item of report.recommendation.nextActions) lines.push(`- ${item}`)\n lines.push('')\n lines.push('## Candidate Decision Table')\n lines.push('')\n lines.push(\n '| Candidate | Decision | Mean | Δ̄ | Pr(Δ>0) | q | dz | Paired N | Median Gain CI | MDE | Pareto | Gate |',\n )\n lines.push('|---|---|---:|---:|---:|---:|---:|---:|---|---:|---|---|')\n for (const c of report.candidates) {\n const delta = c.meanDeltaVsComparator === null ? '-' : signed(c.meanDeltaVsComparator)\n const prGt = c.prGreaterThanZero === null ? '-' : c.prGreaterThanZero.toFixed(3)\n const q = c.qValue !== null ? c.qValue.toFixed(4) : '-'\n const d = c.cohensD !== null ? c.cohensD.toFixed(3) : '-'\n const gain = c.gainCi ? `[${fmt(c.gainCi.low)}, ${fmt(c.gainCi.high)}]` : '-'\n const mde = c.mde === null || !Number.isFinite(c.mde) ? '-' : fmt(c.mde)\n lines.push(\n `| ${c.candidateId} | ${c.decision} | ${fmt(c.mean)} | ${delta} | ${prGt} | ${q} | ${d} | ${c.pairedN} | ${gain} | ${mde} | ${c.onParetoFrontier ? 'yes' : 'no'} | ${c.gate ?? '-'} |`,\n )\n }\n lines.push('')\n lines.push('## Statistical Summary')\n lines.push('')\n lines.push(report.summary.markdown)\n lines.push('')\n lines.push('## Methodology')\n lines.push('')\n lines.push('### Assumptions')\n lines.push('')\n for (const item of report.methodology.assumptions) lines.push(`- ${item}`)\n lines.push('')\n lines.push('### Methods')\n lines.push('')\n for (const item of report.methodology.methods) lines.push(`- ${item}`)\n lines.push('')\n lines.push('### Alternatives Considered')\n lines.push('')\n for (const item of report.methodology.alternatives) lines.push(`- ${item}`)\n lines.push('')\n lines.push('### When NOT To Apply')\n lines.push('')\n for (const item of report.methodology.whenNotToApply) lines.push(`- ${item}`)\n lines.push('')\n lines.push('### Citations')\n lines.push('')\n for (const item of report.methodology.citations) lines.push(`- ${item}`)\n lines.push('')\n lines.push('## Chart Specs')\n lines.push('')\n lines.push(\n 'The report carries JSON chart specs for Pareto cost/quality and paired gain histograms.',\n )\n lines.push('')\n lines.push('```json')\n lines.push(JSON.stringify({ pareto: report.pareto, gains: report.gains }, null, 2))\n lines.push('```')\n if (report.failureClusters) {\n lines.push('')\n lines.push('## Failure Clusters')\n lines.push('')\n lines.push('| Failure Class | Runs | Scenarios | Tool | Example |')\n lines.push('|---|---:|---:|---|---|')\n for (const c of report.failureClusters.clusters.slice(0, 10)) {\n lines.push(\n `| ${c.failureClass} | ${c.runCount} | ${c.scenarioIds.length} | ${c.toolName ?? '-'} | ${escapePipes(c.exampleError ?? c.exampleRunId)} |`,\n )\n }\n }\n return lines.join('\\n')\n}\n\nfunction escapePipes(s: string): string {\n return s.replace(/\\|/g, '\\\\|')\n}\n\nfunction signed(x: number): string {\n return `${x >= 0 ? '+' : ''}${fmt(x)}`\n}\n\nexport function formatRope(rope: { low: number; high: number }): string {\n return `[${fmt(rope.low)}, ${fmt(rope.high)}]`\n}\n\nexport function fmt(x: number): string {\n if (!Number.isFinite(x)) return String(x)\n return x.toFixed(4)\n}\n","/** Evidence-based report verdicts, recommendations, and methodology. */\n\nimport type { HeldOutGateDecision } from './held-out-gate'\nimport type { FailureClusterReport } from './pipelines/failure-cluster'\nimport type {\n ResearchReportCandidate,\n ResearchReportDecision,\n ResearchReportMethodology,\n ResearchReportRecommendation,\n} from './research-report'\nimport { fmt, formatRope } from './research-report-render'\nimport type { pairedPosterior } from './summary-report-evidence'\nimport type { ParetoPoint, SummaryTableRow } from './summary-report-figures'\n\n/**\n * Hard floor below which a paired comparison is treated as uninformative\n * regardless of `minPairs`. Mirrors the lower limit on Wilcoxon signed-rank\n * exact tables; below this the test has no power to separate effect sizes.\n */\nexport const RESEARCH_REPORT_HARD_PAIR_FLOOR = 6\n\nexport function buildMethodology(ctx: {\n split: 'search' | 'holdout'\n comparator: string | null\n fdr: number\n minPairs: number\n rope: { low: number; high: number } | null\n confidence: number\n mdePower: number\n mdeAlpha: number\n}): ResearchReportMethodology {\n const assumptions: string[] = [\n 'Pairs are matched by (experimentId, scenarioId, seed); input order does not affect the comparison.',\n 'Paired deltas are exchangeable conditional on the matched scenario — no mid-run distribution shift.',\n `Decisions are pre-specified at fdr=${ctx.fdr}, minPairs=${ctx.minPairs}, confidence=${ctx.confidence}; deviating from these post-hoc invalidates the false-discovery control.`,\n ]\n if (ctx.rope) {\n assumptions.push(\n `The Region of Practical Equivalence ${formatRope(ctx.rope)} is supplied by the domain owner; equivalent verdicts are only meaningful if that range is treated as the standing definition of \"no material difference.\"`,\n )\n }\n if (ctx.comparator === null) {\n assumptions.push('No comparator was configured; this run is descriptive, not causal.')\n }\n const methods: string[] = [\n \"Marginal scores summarised with BH-FDR-adjusted Wilcoxon signed-rank q-values and paired Cohen's dz via summaryTable.\",\n 'Paired evidence summarised with a frequentist bootstrap CI on the median delta and a Dirichlet-weight Bayesian bootstrap for Pr(Δ>0) and Pr(Δ∈ROPE) on the mean delta.',\n `Minimum detectable effect reported per candidate at α=${ctx.mdeAlpha} (two-sided), power=${ctx.mdePower}, standardised by the observed paired-delta SD.`,\n 'Pareto frontier flagged as a separate axis (cost vs quality); a candidate can be on-frontier without winning the paired test.',\n 'Held-out gate decisions, when supplied, override the statistical verdict in the reject direction.',\n ]\n const alternatives: string[] = [\n 'Paired t-test rejected: not robust to the heavy-tailed score distributions common in agent benchmarks.',\n 'Unpaired Mann–Whitney rejected: matched scenarios make pairing free; unpaired throws away that variance reduction.',\n 'Sequential / always-valid inference (e-values, mSPRT) is the right tool for iterative sweeps and is out of scope for this single-look report — preregister and run once, or wrap this report in an alpha-spending schedule.',\n 'Hierarchical Bayesian shrinkage across many candidates is future work; the current ranking uses raw paired statistics.',\n ]\n const whenNotToApply: string[] = [\n `Paired N below ${RESEARCH_REPORT_HARD_PAIR_FLOOR} on any candidate — the bootstrap CI is degenerate.`,\n 'Comparator chosen post-hoc by inspecting the same data; q-values are no longer false-discovery-controlled.',\n 'Scenarios not drawn under a stable preregistered protocol; the report can describe the data but cannot anchor a launch decision.',\n 'Score distributions with mid-run shift (judge model swap, rubric change, infra outage) — pair exchangeability is violated.',\n ]\n const citations: string[] = [\n 'Benjamini, Y. & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. JRSS B, 57(1), 289–300.',\n 'Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin, 1(6), 80–83.',\n 'Efron, B. (1979). Bootstrap methods: another look at the jackknife. Annals of Statistics, 7(1), 1–26.',\n 'Rubin, D. B. (1981). The Bayesian bootstrap. Annals of Statistics, 9(1), 130–134.',\n 'Kruschke, J. K. (2018). Rejecting or accepting parameter values in Bayesian estimation. Advances in Methods and Practices in Psychological Science, 1(2), 270–280. (ROPE.)',\n ]\n return { assumptions, methods, alternatives, whenNotToApply, citations }\n}\n\nexport function classifyCandidate(\n row: SummaryTableRow,\n ctx: {\n comparator: string | null\n posterior: ReturnType<typeof pairedPosterior> | null\n point?: ParetoPoint\n gateDecision?: HeldOutGateDecision\n split: 'search' | 'holdout'\n fdr: number\n minPairs: number\n rope: { low: number; high: number } | null\n },\n): { decision: ResearchReportDecision; reason: string } {\n if (ctx.comparator && row.candidateId === ctx.comparator) {\n return { decision: 'hold', reason: 'Comparator baseline.' }\n }\n if (ctx.gateDecision && !ctx.gateDecision.promote) {\n const code = ctx.gateDecision.rejectionCode ?? 'rejected'\n return {\n decision: 'reject',\n reason: `Held-out gate returned ${code}: ${ctx.gateDecision.reason}`,\n }\n }\n if (!ctx.comparator) {\n return {\n decision: ctx.point?.onFrontier ? 'hold' : 'needs_more_data',\n reason:\n 'No comparator configured; report ranks candidates but cannot anchor a promotion call.',\n }\n }\n if (!ctx.posterior || ctx.posterior.n < RESEARCH_REPORT_HARD_PAIR_FLOOR) {\n return {\n decision: 'needs_more_data',\n reason: `Only ${ctx.posterior?.n ?? 0} paired observations; below hard floor of ${RESEARCH_REPORT_HARD_PAIR_FLOOR} for any paired inference.`,\n }\n }\n const ci = ctx.posterior.ci\n if (ctx.split === 'search') {\n return {\n decision: 'hold',\n reason:\n 'Search-split evidence is descriptive; release decisions require matched holdout runs.',\n }\n }\n // A ZERO-WIDTH interval cannot support any directional or equivalence claim:\n // every resample was identical, so it says nothing about how far the estimate\n // could be wrong. It is the shape that sits fully inside any ROPE containing\n // it (a fake \"practically equivalent\") and clears any threshold below it (a\n // fake \"promote\"). Both are an absence of evidence, so it is disqualified from\n // each claim rather than short-circuiting the whole classifier — the\n // sample-size and MDE diagnostics below are still the more useful answer when\n // they apply.\n const degenerate = !Number.isFinite(ci.low) || !Number.isFinite(ci.high) || ci.low === ci.high\n if (!degenerate && ctx.rope && ci.low >= ctx.rope.low && ci.high <= ctx.rope.high) {\n return {\n decision: 'equivalent',\n reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] is fully inside ROPE ${formatRope(ctx.rope)}; candidate is practically equivalent to comparator.`,\n }\n }\n const gainPositive = !degenerate && ci.low > 0\n const gainNegative = !degenerate && ci.high < 0\n if (gainNegative) {\n return {\n decision: 'reject',\n reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] lies entirely below zero.`,\n }\n }\n if (ctx.posterior.n < ctx.minPairs) {\n return {\n decision: 'needs_more_data',\n reason: `Only ${ctx.posterior.n} paired observations; minimum detectable effect at this N is ${fmt(ctx.posterior.mde)} score units (need ≥ ${ctx.minPairs} pairs to issue a directional verdict).`,\n }\n }\n if (degenerate) {\n return {\n decision: 'needs_more_data',\n reason: `Paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] has zero width — every resample was identical, so the interval carries no information about how far the estimate could be wrong and cannot support a promote or equivalence call.`,\n }\n }\n if (row.qValue !== null && row.qValue <= ctx.fdr && gainPositive) {\n return {\n decision: 'promote',\n reason: `BH-adjusted q=${fmt(row.qValue)} ≤ ${ctx.fdr} and paired-delta CI [${fmt(ci.low)}, ${fmt(ci.high)}] excludes zero; Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)}.`,\n }\n }\n return {\n decision: 'hold',\n reason: `Pr(Δ>0)=${fmt(ctx.posterior.prGreaterThanZero)} but CI [${fmt(ci.low)}, ${fmt(ci.high)}] crosses zero; effect not decisive at fdr=${ctx.fdr}.`,\n }\n}\n\nexport function buildRecommendation(\n candidates: ResearchReportCandidate[],\n ctx: {\n comparator: string | null\n failureClusters?: FailureClusterReport\n rope: { low: number; high: number } | null\n minPairs: number\n preregistrationHash: string | null\n },\n): ResearchReportRecommendation {\n const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator)\n const bestPromote = nonComparator.find((c) => c.decision === 'promote')\n const bestEquivalent = nonComparator.find((c) => c.decision === 'equivalent')\n const chosen = bestPromote ?? bestEquivalent ?? nonComparator[0] ?? null\n const decision: ResearchReportDecision = bestPromote\n ? 'promote'\n : nonComparator.some((c) => c.decision === 'needs_more_data')\n ? 'needs_more_data'\n : bestEquivalent\n ? 'equivalent'\n : nonComparator.some((c) => c.decision === 'hold')\n ? 'hold'\n : 'reject'\n\n const rationale: string[] = []\n const risks: string[] = []\n const nextActions: string[] = []\n\n if (chosen) {\n rationale.push(`${chosen.candidateId}: ${chosen.decisionReason}`)\n if (chosen.gainCi) {\n const probSummary =\n chosen.prGreaterThanZero !== null ? `, Pr(Δ>0)=${fmt(chosen.prGreaterThanZero)}` : ''\n rationale.push(\n `Median paired gain CI: [${fmt(chosen.gainCi.low)}, ${fmt(chosen.gainCi.high)}]${probSummary}.`,\n )\n }\n if (chosen.mde !== null && Number.isFinite(chosen.mde)) {\n rationale.push(`MDE at current paired N=${chosen.pairedN}: ${fmt(chosen.mde)} score units.`)\n }\n }\n if (!ctx.comparator) {\n risks.push('No comparator was configured; verdict is descriptive, not causal.')\n nextActions.push('Re-run with a stable comparator candidate for paired inference.')\n }\n if (!ctx.preregistrationHash) {\n risks.push(\n 'No preregistration hash supplied; readers cannot verify the analysis was specified before data inspection.',\n )\n nextActions.push(\n 'Sign a HypothesisManifest before the next sweep and pass `preregistrationHash` so the report cites it.',\n )\n }\n if (ctx.rope === null && nonComparator.length > 0) {\n risks.push(\n 'No ROPE configured; the report cannot distinguish \"equivalent\" from \"inconclusive\".',\n )\n nextActions.push(\n 'Define a domain-specific Region of Practical Equivalence and pass it to lock in the equivalence threshold.',\n )\n }\n const inconclusive = nonComparator.filter((c) => c.decision === 'needs_more_data')\n if (inconclusive.length > 0) {\n const worst = inconclusive.reduce((a, b) => (b.pairedN < a.pairedN ? b : a))\n risks.push(\n `${inconclusive.length} candidate(s) below soft floor (${ctx.minPairs} pairs); thinnest is ${worst.candidateId} with ${worst.pairedN}.`,\n )\n nextActions.push(\n `Collect at least ${ctx.minPairs - worst.pairedN} more matched holdout runs for ${worst.candidateId}.`,\n )\n }\n const rejected = nonComparator.filter((c) => c.decision === 'reject')\n if (rejected.length > 0) {\n risks.push(\n `${rejected.length} candidate(s) failed the paired test or held-out gate; do not ship those variants.`,\n )\n }\n if (ctx.failureClusters && ctx.failureClusters.clusters.length > 0) {\n const top = ctx.failureClusters.clusters[0]!\n risks.push(`Top failure cluster: ${top.failureClass} across ${top.runCount} run(s).`)\n nextActions.push('Prioritize the largest failure cluster before broad rollout.')\n }\n if (decision === 'promote') {\n nextActions.push('Ship behind the existing promotion gate and monitor canaries.')\n } else if (decision === 'hold') {\n nextActions.push('Keep current production candidate while expanding holdout evidence.')\n } else if (decision === 'equivalent') {\n nextActions.push(\n 'Either keep the comparator (no quality regression) or promote on cost/latency grounds — equivalence does not justify either; the choice is a product decision, not a stats one.',\n )\n } else if (decision === 'reject') {\n nextActions.push(\n 'Do not promote this sweep; inspect failures and generate a revised candidate.',\n )\n }\n\n return {\n decision,\n candidateId: chosen?.candidateId ?? null,\n rationale,\n risks,\n nextActions,\n }\n}\n\nexport function buildExecutiveSummary(\n candidates: ResearchReportCandidate[],\n recommendation: ResearchReportRecommendation,\n ctx: {\n comparator: string | null\n split: 'search' | 'holdout'\n failureClusters?: FailureClusterReport\n preregistrationHash: string | null\n },\n): string[] {\n const lines: string[] = []\n const nonComparator = candidates.filter((c) => c.candidateId !== ctx.comparator)\n lines.push(\n `Evaluated ${nonComparator.length} candidate(s) on the ${ctx.split} split${ctx.comparator ? ` against ${ctx.comparator}` : ''}.`,\n )\n lines.push(\n `Recommendation: ${recommendation.decision}${recommendation.candidateId ? ` ${recommendation.candidateId}` : ''}.`,\n )\n const promoted = nonComparator.filter((c) => c.decision === 'promote').length\n const held = nonComparator.filter((c) => c.decision === 'hold').length\n const equivalent = nonComparator.filter((c) => c.decision === 'equivalent').length\n const rejected = nonComparator.filter((c) => c.decision === 'reject').length\n const more = nonComparator.filter((c) => c.decision === 'needs_more_data').length\n lines.push(\n `Decision mix: ${promoted} promote, ${equivalent} equivalent, ${held} hold, ${rejected} reject, ${more} need more data.`,\n )\n const frontier = nonComparator.filter((c) => c.onParetoFrontier).map((c) => c.candidateId)\n if (frontier.length > 0) lines.push(`Pareto-frontier candidates: ${frontier.join(', ')}.`)\n if (ctx.failureClusters) {\n lines.push(\n `Failure clustering found ${ctx.failureClusters.totalFailures}/${ctx.failureClusters.totalRuns} failed runs across ${ctx.failureClusters.clusters.length} reportable cluster(s).`,\n )\n }\n lines.push(\n ctx.preregistrationHash\n ? `Preregistered analysis: ${ctx.preregistrationHash.slice(0, 12)}…`\n : 'Analysis is post-hoc — no preregistration hash supplied.',\n )\n return lines\n}\n\nexport function decisionWeight(decision: ResearchReportDecision): number {\n if (decision === 'promote') return 5\n if (decision === 'equivalent') return 4\n if (decision === 'hold') return 3\n if (decision === 'needs_more_data') return 2\n return 1\n}\n","/** Standardized effect sizes; undefined effects remain null. */\n\nimport { ValidationError } from '../errors'\n\n/** Independent Cohen's d, oriented b − a; null below two samples or for an unbounded effect. */\nexport function cohensD(a: number[], b: number[]): number | null {\n if (a.length < 2 || b.length < 2) return null\n const meanA = a.reduce((x, y) => x + y, 0) / a.length\n const meanB = b.reduce((x, y) => x + y, 0) / b.length\n const varA = a.reduce((acc, x) => acc + (x - meanA) ** 2, 0) / (a.length - 1)\n const varB = b.reduce((acc, x) => acc + (x - meanB) ** 2, 0) / (b.length - 1)\n const pooled = Math.sqrt(\n ((a.length - 1) * varA + (b.length - 1) * varB) / (a.length + b.length - 2),\n )\n if (pooled === 0) return meanB === meanA ? 0 : null\n return (meanB - meanA) / pooled\n}\n\n/** Paired Cohen's dz; constant nonzero deltas have no finite standardized effect. */\nexport function pairedCohensDz(before: number[], after: number[]): number | null {\n if (before.length !== after.length) {\n throw new ValidationError(\n `pairedCohensDz: unequal sample sizes (${before.length} vs ${after.length})`,\n )\n }\n if (before.length < 2) return null\n const deltas = before.map((value, index) => after[index]! - value)\n if (deltas.some((value) => !Number.isFinite(value))) {\n throw new ValidationError('pairedCohensDz: all paired values must be finite')\n }\n const meanDelta = deltas.reduce((sum, value) => sum + value, 0) / deltas.length\n const variance =\n deltas.reduce((sum, value) => sum + (value - meanDelta) ** 2, 0) / (deltas.length - 1)\n const standardDeviation = Math.sqrt(variance)\n const scale = Math.max(1, Math.abs(meanDelta), ...deltas.map(Math.abs))\n if (standardDeviation <= Number.EPSILON * scale) return meanDelta === 0 ? 0 : null\n return meanDelta / standardDeviation\n}\n\nexport type CliffsMagnitude = 'negligible' | 'small' | 'medium' | 'large'\n\n/** Cliff's delta, oriented after − before; empty samples return zero. */\nexport function cliffsDelta(before: number[], after: number[]): number {\n const n = before.length * after.length\n if (n === 0) return 0\n let dominance = 0\n for (const a of after) {\n for (const b of before) {\n if (a > b) dominance += 1\n else if (a < b) dominance -= 1\n }\n }\n return dominance / n\n}\n\n/** Romano magnitude thresholds for the absolute Cliff's delta. */\nexport function interpretCliffs(delta: number): CliffsMagnitude {\n const d = Math.abs(delta)\n if (d < 0.147) return 'negligible'\n if (d < 0.33) return 'small'\n if (d < 0.474) return 'medium'\n return 'large'\n}\n","/** Matched split scores and paired statistical evidence for report consumers. */\n\nimport { interpolatedQuantile } from './math/quantile'\nimport { pairRunRecords } from './paired-arms'\nimport { observedSplitScore, type ScorePreference } from './rollout/reward'\nimport type { RunRecord } from './run-record'\nimport { pairedBootstrap, pairedMde } from './statistics'\nimport { makeRng } from './statistics/internal'\n\nexport function pairScoresByKey(\n candidate: RunRecord[],\n baseline: RunRecord[],\n split: ScorePreference,\n): {\n before: number[]\n after: number[]\n unpairedCandidateN: number\n unpairedComparatorN: number\n} {\n // RAW, split-exact reads through `observedSplitScore` — the single allowed\n // spelling of the split-score derivation (see rollout/score-derivation-guard).\n const scoreOf = (run: RunRecord): number | undefined => {\n const v = observedSplitScore(run, split)\n return typeof v === 'number' && Number.isFinite(v) ? v : undefined\n }\n const scoredCandidate = candidate.filter((run) => scoreOf(run) !== undefined)\n const scoredBaseline = baseline.filter((run) => scoreOf(run) !== undefined)\n const pairing = pairRunRecords(scoredBaseline, scoredCandidate)\n return {\n before: pairing.pairs.map((pair) => scoreOf(pair.baseline) as number),\n after: pairing.pairs.map((pair) => scoreOf(pair.treatment) as number),\n unpairedCandidateN: pairing.unpairedTreatment.length,\n unpairedComparatorN: pairing.unpairedBaseline.length,\n }\n}\n\n/**\n * Internal: paired posterior summary on (candidate − comparator) deltas.\n *\n * Returns the bootstrap CI on the median (matching `gainHistogram`) plus\n * Bayesian-bootstrap posterior summaries Pr(Δ>0) and Pr(Δ∈ROPE) computed\n * from Dirichlet(1, ..., 1) weights on the observed paired deltas\n * (Rubin 1981), and the\n * minimum detectable paired effect at the configured power and α.\n *\n * `null` is returned when no paired observations exist; callers must\n * gate on `n` before consuming the bootstrap statistics.\n */\nexport function pairedPosterior(\n runs: RunRecord[],\n candidateId: string,\n comparator: string,\n opts: {\n split: 'search' | 'holdout'\n confidence: number\n seed?: number\n rope: { low: number; high: number } | null\n mdePower: number\n mdeAlpha: number\n },\n): {\n n: number\n meanDelta: number\n medianDelta: number\n sdDelta: number\n ci: { low: number; high: number }\n prGreaterThanZero: number\n prInRope: number | null\n mde: number\n} | null {\n const candidate = runs.filter((r) => r.candidateId === candidateId && r.splitTag === opts.split)\n const baseline = runs.filter((r) => r.candidateId === comparator && r.splitTag === opts.split)\n const { before, after } = pairScoresByKey(candidate, baseline, opts.split)\n const n = before.length\n if (n === 0) return null\n\n const deltas = before.map((b, i) => after[i]! - b)\n const meanDelta = deltas.reduce((s, x) => s + x, 0) / n\n const sortedDeltas = [...deltas].sort((a, b) => a - b)\n const medianDelta = interpolatedQuantile(sortedDeltas, 0.5)\n const sdDelta = stdev(deltas, meanDelta)\n\n const ci = pairedBootstrap(before, after, {\n confidence: opts.confidence,\n resamples: 2000,\n statistic: 'median',\n seed: opts.seed,\n })\n\n const meanSamples = bayesianBootstrapMeanSamples(deltas, 2000, opts.seed)\n const prGreaterThanZero =\n meanSamples.length === 0 ? 0 : meanSamples.filter((s) => s > 0).length / meanSamples.length\n const prInRope =\n opts.rope === null || meanSamples.length === 0\n ? null\n : meanSamples.filter((s) => s >= opts.rope!.low && s <= opts.rope!.high).length /\n meanSamples.length\n\n const dStandardised = pairedMde({ nPaired: n, alpha: opts.mdeAlpha, power: opts.mdePower })\n const mde = sdDelta === 0 ? 0 : dStandardised * sdDelta\n\n return {\n n,\n meanDelta,\n medianDelta,\n sdDelta,\n ci: { low: ci.low, high: ci.high },\n prGreaterThanZero,\n prInRope,\n mde,\n }\n}\n\nfunction bayesianBootstrapMeanSamples(\n deltas: number[],\n resamples: number,\n seed?: number,\n): number[] {\n const n = deltas.length\n if (n === 0) return []\n if (n === 1) return new Array<number>(resamples).fill(deltas[0]!)\n const rng = makeRng(seed, deltas)\n const samples = new Array<number>(resamples)\n for (let b = 0; b < resamples; b++) {\n let weightedSum = 0\n let weightSum = 0\n for (let k = 0; k < n; k++) {\n const weight = -Math.log(Math.max(Number.MIN_VALUE, rng()))\n weightedSum += deltas[k]! * weight\n weightSum += weight\n }\n samples[b] = weightedSum / weightSum\n }\n return samples\n}\n\nfunction stdev(xs: number[], mean: number): number {\n if (xs.length < 2) return 0\n let sse = 0\n for (const x of xs) sse += (x - mean) ** 2\n return Math.sqrt(sse / (xs.length - 1))\n}\n","/** Tables and library-independent chart specifications from scored runs. */\n\nimport type { HeldOutGateDecision } from './held-out-gate'\nimport { interpolatedQuantile } from './math/quantile'\nimport { fmt } from './research-report-render'\nimport { observedSplitScore } from './rollout/reward'\nimport type { RunRecord } from './run-record'\nimport {\n benjaminiHochberg,\n confidenceInterval,\n pairedBootstrap,\n pairedCohensDz,\n wilcoxonSignedRank,\n} from './statistics'\nimport { mean as avg } from './statistics/mean'\nimport { pairScoresByKey } from './summary-report-evidence'\n\n// ── summaryTable ───────────────────────────────────────────────────────\n\nexport interface SummaryTableOptions {\n /** Comparator candidate id. Wilcoxon + paired Cohen's dz are computed\n * versus this candidate. Required for paired stats columns. */\n comparator?: string\n /** Which split to read scores from. Default 'holdout'. */\n split?: 'search' | 'holdout'\n /** Confidence level for the bootstrap CI on the mean. Default 0.95. */\n confidence?: number\n /** FDR for BH adjustment of the comparison p-values. Default 0.05. */\n fdr?: number\n}\n\nexport interface SummaryTableRow {\n candidateId: string\n n: number\n mean: number\n ciLow: number\n ciHigh: number\n /** BH-adjusted q-value vs comparator, or null when unavailable. */\n qValue: number | null\n /** Paired Cohen's dz vs comparator, or null when the paired variance is zero. */\n cohensD: number | null\n /** Matched observations used for paired comparison, or null on the comparator row. */\n pairedN: number | null\n /** Candidate observations without a comparator match. */\n unpairedCandidateN: number | null\n /** Comparator observations without a candidate match. */\n unpairedComparatorN: number | null\n}\n\nexport interface SummaryTable {\n rows: SummaryTableRow[]\n comparator: string | null\n split: 'search' | 'holdout'\n /** Pre-rendered markdown — drop into a paper or PR. */\n markdown: string\n}\n\n/**\n * Table 1 helper. Buckets runs by `candidateId`, computes mean +\n * bootstrap CI on the chosen split, and (when a comparator is given)\n * BH-adjusted Wilcoxon p + paired Cohen's dz versus that comparator.\n */\nexport function summaryTable(runs: RunRecord[], opts: SummaryTableOptions = {}): SummaryTable {\n const split = opts.split ?? 'holdout'\n const confidence = opts.confidence ?? 0.95\n const fdr = opts.fdr ?? 0.05\n const comparator = opts.comparator ?? null\n\n const byCandidate = new Map<string, { runs: RunRecord[]; scores: number[] }>()\n for (const r of runs) {\n if (r.splitTag !== split) continue\n // Report raw, exact-split scores so gaming remains visible.\n const v = observedSplitScore(r, split)\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n const bucket = byCandidate.get(r.candidateId) ?? { runs: [], scores: [] }\n bucket.runs.push(r)\n bucket.scores.push(v)\n byCandidate.set(r.candidateId, bucket)\n }\n\n const compRuns = comparator ? byCandidate.get(comparator) : undefined\n\n const rows: SummaryTableRow[] = [...byCandidate.keys()].sort().map((id) => {\n const bucket = byCandidate.get(id)!\n const ci = confidenceInterval(bucket.scores, confidence)\n const paired =\n comparator && compRuns && id !== comparator\n ? pairScoresByKey(bucket.runs, compRuns.runs, split)\n : null\n return {\n candidateId: id,\n n: bucket.scores.length,\n mean: ci.mean,\n ciLow: ci.lower,\n ciHigh: ci.upper,\n qValue:\n paired && paired.before.length >= 6\n ? wilcoxonSignedRank(paired.before, paired.after).p\n : null,\n cohensD: paired ? pairedCohensDz(paired.before, paired.after) : null,\n pairedN: paired?.before.length ?? null,\n unpairedCandidateN: paired?.unpairedCandidateN ?? null,\n unpairedComparatorN: paired?.unpairedComparatorN ?? null,\n }\n })\n if (comparator) {\n const comparisons = rows.filter(\n (row) => row.candidateId !== comparator && row.qValue !== null && Number.isFinite(row.qValue),\n )\n if (comparisons.length > 0) {\n const { qValues } = benjaminiHochberg(\n comparisons.map((row) => row.qValue!),\n fdr,\n )\n comparisons.forEach((row, index) => {\n row.qValue = qValues[index]!\n })\n }\n }\n\n const markdown = renderSummaryTableMarkdown(rows, comparator, split)\n return { rows, comparator, split, markdown }\n}\n\nfunction renderSummaryTableMarkdown(\n rows: SummaryTableRow[],\n comparator: string | null,\n split: 'search' | 'holdout',\n): string {\n return [\n `Summary Table — ${split} split${comparator ? ` (vs ${comparator})` : ''}`,\n '',\n \"| Candidate | N | Pairs | Unpaired | Mean | 95% CI | q (BH) | Cohen's dz |\",\n '|---|---:|---:|---:|---:|---|---:|---:|',\n ...rows.map(\n (r) =>\n `| ${[\n r.candidateId,\n r.n,\n r.pairedN ?? '—',\n r.unpairedCandidateN === null || r.unpairedComparatorN === null\n ? '—'\n : `${r.unpairedCandidateN}/${r.unpairedComparatorN}`,\n fmt(r.mean),\n `[${fmt(r.ciLow)}, ${fmt(r.ciHigh)}]`,\n r.qValue?.toFixed(4) ?? '—',\n r.cohensD?.toFixed(3) ?? '—',\n ].join(' | ')} |`,\n ),\n ].join('\\n')\n}\n\n// ── paretoChart ─────────────────────────────────────────────────────\n\nexport interface ParetoPoint {\n candidateId: string\n /** Mean USD cost per run on the chosen split. */\n cost: number\n /** Mean score on the chosen split. */\n quality: number\n /** Number of runs that informed this point. */\n n: number\n /** Whether this candidate is on the Pareto frontier — high\n * quality, low cost, no dominator. */\n onFrontier: boolean\n /** Optional gate verdict for this candidate, if a `HeldOutGateDecision`\n * for it was passed in. */\n gate?: 'promote' | 'reject'\n}\n\nexport interface ParetoFigureSpec {\n kind: 'pareto-cost-quality'\n split: 'search' | 'holdout'\n points: ParetoPoint[]\n axes: { x: 'costUsd'; y: 'score' }\n}\n\n/**\n * Cost vs quality scatter spec. `gateDecisions` is keyed by\n * candidate id; if present, every point picks up the gate verdict\n * for overlay.\n */\nexport function paretoChart(\n runs: RunRecord[],\n opts: {\n split?: 'search' | 'holdout'\n gateDecisions?: Record<string, HeldOutGateDecision>\n } = {},\n): ParetoFigureSpec {\n const split = opts.split ?? 'holdout'\n\n const buckets = new Map<string, { cost: number[]; quality: number[] }>()\n for (const r of runs) {\n if (r.splitTag !== split) continue\n const v = observedSplitScore(r, split)\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n if (r.costUsd === null) continue\n const bucket = buckets.get(r.candidateId) ?? { cost: [], quality: [] }\n bucket.cost.push(r.costUsd)\n bucket.quality.push(v)\n buckets.set(r.candidateId, bucket)\n }\n\n const points: ParetoPoint[] = [...buckets].map(([candidateId, bucket]) => ({\n candidateId,\n cost: avg(bucket.cost),\n quality: avg(bucket.quality),\n n: bucket.cost.length,\n onFrontier: false,\n gate: opts.gateDecisions?.[candidateId]\n ? gateLabel(opts.gateDecisions[candidateId]!)\n : undefined,\n }))\n\n // Pareto: minimize cost, maximize quality. A point is dominated if\n // some other point has lower-or-equal cost AND higher-or-equal\n // quality with strict inequality somewhere.\n for (const p of points) {\n p.onFrontier = !points.some((q) => q !== p && dominates(q, p))\n }\n\n return {\n kind: 'pareto-cost-quality',\n split,\n axes: { x: 'costUsd', y: 'score' },\n points,\n }\n}\n\nfunction dominates(a: ParetoPoint, b: ParetoPoint): boolean {\n return a.cost <= b.cost && a.quality >= b.quality && (a.cost < b.cost || a.quality > b.quality)\n}\n\nexport function gateLabel(d: HeldOutGateDecision): ParetoPoint['gate'] {\n return d.promote ? 'promote' : 'reject'\n}\n\n// ── gainHistogram ───────────────────────────────────────────\n\nexport interface GainDistributionBin {\n /** Inclusive lower edge. */\n lo: number\n /** Exclusive upper edge (or inclusive if it's the last bin). */\n hi: number\n /** Number of pairs whose delta lands in this bin. */\n count: number\n}\n\nexport interface GainDistributionFigureSpec {\n kind: 'gain-distribution'\n candidateId: string\n comparator: string\n split: 'search' | 'holdout'\n /** Number of pairs used. */\n n: number\n /** Candidate rows without a comparator match. */\n unpairedCandidateN: number\n /** Comparator rows without a candidate match. */\n unpairedComparatorN: number\n bins: GainDistributionBin[]\n median: number | null\n ci: { low: number; high: number } | null\n}\n\nexport interface GainDistributionOptions {\n /** Number of histogram bins. Default 11 (so the centre is exact at 0). */\n bins?: number\n /** Which split to use. Default 'holdout'. */\n split?: 'search' | 'holdout'\n /** Confidence level for the CI. Default 0.95. */\n confidence?: number\n /** Bootstrap resamples. Default 2000. */\n resamples?: number\n /** Deterministic seed. */\n seed?: number\n}\n\n/**\n * Held-out improvement distribution: per-pair delta (candidate −\n * comparator), histogrammed. Includes the bootstrap CI on the median\n * delta — same primitive the promotion gate uses.\n */\nexport function gainHistogram(\n runs: RunRecord[],\n candidateId: string,\n comparator: string,\n opts: GainDistributionOptions = {},\n): GainDistributionFigureSpec {\n const split = opts.split ?? 'holdout'\n const binCount = opts.bins ?? 11\n if (binCount < 1) throw new Error('gainHistogram: bins must be ≥ 1')\n\n const candidate = runs.filter((r) => r.candidateId === candidateId && r.splitTag === split)\n const baseline = runs.filter((r) => r.candidateId === comparator && r.splitTag === split)\n // pairScoresByKey returns before=baseline-score, after=candidate-score\n // for each canonical work-identity pair where both sides recorded a\n // valid score on this split. delta = after - before = candidate - baseline.\n const { before, after, unpairedCandidateN, unpairedComparatorN } = pairScoresByKey(\n candidate,\n baseline,\n split,\n )\n const n = before.length\n\n const deltas = before.map((b, i) => after[i]! - b)\n const sortedDeltas = [...deltas].sort((a, b) => a - b)\n const median = n === 0 ? null : interpolatedQuantile(sortedDeltas, 0.5)\n\n // Symmetric bins around the wider of (|min|, |max|) so the chart\n // visually centres on zero without dropping outliers.\n const bound = Math.max(\n Math.abs(sortedDeltas[0]!),\n Math.abs(sortedDeltas[sortedDeltas.length - 1]!),\n 1e-6,\n )\n const lo = -bound\n const width = (bound - lo) / binCount\n const bins: GainDistributionBin[] = []\n for (let i = 0; n > 0 && i < binCount; i++) {\n bins.push({ lo: lo + i * width, hi: lo + (i + 1) * width, count: 0 })\n }\n for (const d of deltas) {\n let idx = Math.floor((d - lo) / width)\n if (idx < 0) idx = 0\n if (idx >= binCount) idx = binCount - 1\n bins[idx]!.count += 1\n }\n\n const ci =\n n === 0\n ? null\n : pairedBootstrap(before, after, {\n confidence: opts.confidence ?? 0.95,\n resamples: opts.resamples ?? 2000,\n statistic: 'median',\n seed: opts.seed,\n })\n\n return {\n kind: 'gain-distribution',\n candidateId,\n comparator,\n split,\n n,\n unpairedCandidateN,\n unpairedComparatorN,\n bins,\n median,\n ci: ci === null ? null : { low: ci.low, high: ci.high },\n }\n}\n","/** Assemble research report evidence, guidance, figures, and rendered documents. */\n\nimport type { HeldOutGateDecision } from './held-out-gate'\nimport type { FailureClusterReport } from './pipelines/failure-cluster'\nimport { hashJson } from './pre-registration'\nimport { renderResearchHtml } from './reporting-html'\nimport {\n buildExecutiveSummary,\n buildMethodology,\n buildRecommendation,\n classifyCandidate,\n decisionWeight,\n RESEARCH_REPORT_HARD_PAIR_FLOOR,\n} from './research-report-analysis'\nimport { renderResearchMarkdown } from './research-report-render'\nimport type { RunRecord } from './run-record'\nimport { pairedPosterior } from './summary-report-evidence'\nimport {\n type GainDistributionFigureSpec,\n gainHistogram,\n gateLabel,\n type ParetoFigureSpec,\n type ParetoPoint,\n paretoChart,\n type SummaryTable,\n summaryTable,\n} from './summary-report-figures'\n\nexport { RESEARCH_REPORT_HARD_PAIR_FLOOR } from './research-report-analysis'\n\nexport type ResearchReportDecision =\n | 'promote'\n | 'hold'\n | 'reject'\n | 'equivalent'\n | 'needs_more_data'\n\nexport interface ResearchReportOptions {\n /** Human-readable report title. */\n title?: string\n /** Comparator candidate id. Required for statistical decision guidance. */\n comparator?: string\n /** Which split to use for the primary decision. Default 'holdout'. */\n split?: 'search' | 'holdout'\n /** Confidence level used by lower-level report helpers. Default 0.95. */\n confidence?: number\n /** FDR threshold for q-values. Default 0.05. */\n fdr?: number\n /**\n * Soft floor on paired observations before issuing a directional\n * promote / reject. Below this we report `needs_more_data` and surface the\n * minimum detectable effect at the current N. Default 20 — chosen so the\n * Wilcoxon signed-rank approximation is reasonable and so the paired\n * bootstrap CI has non-degenerate coverage. Hard floor is enforced at\n * `RESEARCH_REPORT_HARD_PAIR_FLOOR` (6) regardless of this value.\n */\n minPairs?: number\n /**\n * Region of Practical Equivalence on the paired delta. When a candidate's\n * paired-delta CI is fully contained in `[low, high]`, the decision is\n * `equivalent` rather than `hold`. Sourced from the domain owner — there is\n * no statistically-defensible default.\n */\n rope?: { low: number; high: number }\n /**\n * Power for the minimum detectable effect (MDE) reported on each candidate.\n * Default 0.8.\n */\n mdePower?: number\n /**\n * Two-sided alpha for the MDE. Default matches `fdr` so the reported MDE\n * lines up with the test the report actually runs.\n */\n mdeAlpha?: number\n /** Optional held-out gate decisions keyed by candidate id. */\n gateDecisions?: Record<string, HeldOutGateDecision>\n /** Optional failure clusters from failureClusterView. */\n failureClusters?: FailureClusterReport\n /** Build gain histograms for these candidates. Defaults to all non-comparator candidates. */\n candidateIds?: string[]\n /** Deterministic bootstrap seed passed to gainHistogram and the posterior helper. */\n seed?: number\n /** Report timestamp. Defaults to current time. */\n generatedAt?: string\n /**\n * Hash of a preregistered protocol (e.g. `signManifest({...}).contentHash`).\n * Embedded verbatim in the report so the analysis can be cited as the\n * preregistered one rather than a post-hoc fishing expedition.\n */\n preregistrationHash?: string\n}\n\nexport interface ResearchReportRecommendation {\n decision: ResearchReportDecision\n candidateId: string | null\n rationale: string[]\n risks: string[]\n nextActions: string[]\n}\n\nexport interface ResearchReportCandidate {\n candidateId: string\n n: number\n mean: number\n ciLow: number\n ciHigh: number\n qValue: number | null\n cohensD: number | null\n meanDeltaVsComparator: number | null\n pairedN: number\n medianGain: number | null\n meanGain: number | null\n gainCi: { low: number; high: number } | null\n /**\n * Bayesian-bootstrap posterior summaries on the paired mean delta.\n * Dirichlet(1, ..., 1) weights represent uncertainty over the empirical\n * distribution of matched deltas.\n */\n prGreaterThanZero: number | null\n prInRope: number | null\n /**\n * Minimum detectable effect (in score units) at the candidate's paired N,\n * the configured power, and the configured alpha. Standardised by the\n * observed paired-delta SD and inverted via `requiredSampleSize`. Reported\n * for every candidate so a `needs_more_data` verdict is actionable.\n */\n mde: number | null\n onParetoFrontier: boolean\n gate?: ParetoPoint['gate']\n decision: ResearchReportDecision\n decisionReason: string\n}\n\nexport interface ResearchReportMethodology {\n /**\n * Plain-language assumptions the report depends on. Read these first when\n * deciding whether the verdict is load-bearing for a launch decision.\n */\n assumptions: string[]\n /** Tests and estimators the verdict was computed from. */\n methods: string[]\n /** Alternatives the author considered and why this report didn't take them. */\n alternatives: string[]\n /** Failure modes — when this report should NOT drive a decision. */\n whenNotToApply: string[]\n /** Citations for the methodological choices above. */\n citations: string[]\n}\n\nexport interface ResearchReport {\n kind: 'agent-eval-research-report'\n title: string\n generatedAt: string\n split: 'search' | 'holdout'\n comparator: string | null\n /**\n * SHA-256 over the canonicalised set of `(runId, candidateId, split)` triples\n * the report was computed from, plus the comparator and split. Stable across\n * key insertion order; recomputable by the reader to verify provenance.\n */\n runFingerprint: string\n preregistrationHash: string | null\n rope: { low: number; high: number } | null\n executiveSummary: string[]\n recommendation: ResearchReportRecommendation\n candidates: ResearchReportCandidate[]\n summary: SummaryTable\n charts: {\n pareto: ParetoFigureSpec\n gains: GainDistributionFigureSpec[]\n }\n methodology: ResearchReportMethodology\n failureClusters?: FailureClusterReport\n markdown: string\n html: string\n}\n\n/**\n * Executive research report for CPO / AI-lead / launch-review consumption.\n *\n * Composes:\n * - `summaryTable` marginal stats with BH-FDR-adjusted q-values\n * - `paretoChart` cost-vs-quality frontier with gate overlay\n * - `gainHistogram` per-candidate paired-delta distribution\n * - paired posterior (this file): bootstrap CI on median, Bayesian-bootstrap Pr(Δ>0),\n * Pr(Δ∈ROPE), MDE at the configured power\n *\n * Decisions are made on paired evidence — never on marginal means alone —\n * and respect any held-out gate decision the caller passes through. The\n * report embeds a SHA-256 fingerprint of the input run set and, optionally,\n * the hash of a preregistered protocol so a downstream reader can verify\n * provenance and that the analysis was the preregistered one.\n *\n * Async because the fingerprint uses Web Crypto via `hashJson`; deterministic\n * for any fixed `runs`, `seed`, and ROPE.\n */\nexport async function researchReport(\n runs: RunRecord[],\n opts: ResearchReportOptions = {},\n): Promise<ResearchReport> {\n const split = opts.split ?? 'holdout'\n const comparator = opts.comparator ?? null\n const confidence = opts.confidence ?? 0.95\n const fdr = opts.fdr ?? 0.05\n const minPairs = Math.max(opts.minPairs ?? 20, RESEARCH_REPORT_HARD_PAIR_FLOOR)\n const rope = opts.rope ?? null\n const mdePower = opts.mdePower ?? 0.8\n const mdeAlpha = opts.mdeAlpha ?? fdr\n const title = opts.title ?? 'Agent Evaluation Research Report'\n const generatedAt = opts.generatedAt ?? new Date().toISOString()\n const preregistrationHash = opts.preregistrationHash ?? null\n\n if (rope && !(Number.isFinite(rope.low) && Number.isFinite(rope.high) && rope.low <= rope.high)) {\n throw new Error(\n `researchReport: rope must satisfy low ≤ high with finite bounds, got ${JSON.stringify(rope)}`,\n )\n }\n\n const summary = summaryTable(runs, {\n comparator: comparator ?? undefined,\n split,\n confidence,\n fdr,\n })\n const pareto = paretoChart(runs, { split, gateDecisions: opts.gateDecisions })\n const candidateIds =\n opts.candidateIds ?? summary.rows.map((r) => r.candidateId).filter((id) => id !== comparator)\n const gains = comparator\n ? candidateIds.map((id) =>\n gainHistogram(runs, id, comparator, {\n split,\n confidence,\n seed: opts.seed,\n }),\n )\n : []\n\n const gainByCandidate = new Map(gains.map((g) => [g.candidateId, g]))\n const paretoByCandidate = new Map(pareto.points.map((p) => [p.candidateId, p]))\n const posteriorByCandidate = new Map<string, ReturnType<typeof pairedPosterior>>()\n if (comparator) {\n for (const id of candidateIds) {\n posteriorByCandidate.set(\n id,\n pairedPosterior(runs, id, comparator, {\n split,\n confidence,\n seed: opts.seed,\n rope,\n mdePower,\n mdeAlpha,\n }),\n )\n }\n }\n\n const candidates = summary.rows\n .map((row) => {\n const gain = gainByCandidate.get(row.candidateId)\n const point = paretoByCandidate.get(row.candidateId)\n const posterior = posteriorByCandidate.get(row.candidateId) ?? null\n const gateDecision = opts.gateDecisions?.[row.candidateId]\n const classified = classifyCandidate(row, {\n comparator,\n posterior,\n point,\n gateDecision,\n split,\n fdr,\n minPairs,\n rope,\n })\n return {\n candidateId: row.candidateId,\n n: row.n,\n mean: row.mean,\n ciLow: row.ciLow,\n ciHigh: row.ciHigh,\n qValue: row.qValue,\n cohensD: row.cohensD,\n meanDeltaVsComparator: posterior ? posterior.meanDelta : null,\n pairedN: posterior?.n ?? gain?.n ?? 0,\n medianGain: posterior ? posterior.medianDelta : gain ? gain.median : null,\n meanGain: posterior ? posterior.meanDelta : null,\n gainCi: posterior ? posterior.ci : gain ? gain.ci : null,\n prGreaterThanZero: posterior ? posterior.prGreaterThanZero : null,\n prInRope: posterior ? posterior.prInRope : null,\n mde: posterior ? posterior.mde : null,\n onParetoFrontier: point?.onFrontier ?? false,\n gate: gateDecision ? gateLabel(gateDecision) : undefined,\n decision: classified.decision,\n decisionReason: classified.reason,\n } satisfies ResearchReportCandidate\n })\n .sort((a, b) => {\n const decisionRank = decisionWeight(b.decision) - decisionWeight(a.decision)\n if (decisionRank !== 0) return decisionRank\n return b.mean - a.mean\n })\n\n const recommendation = buildRecommendation(candidates, {\n comparator,\n failureClusters: opts.failureClusters,\n rope,\n minPairs,\n preregistrationHash,\n })\n const executiveSummary = buildExecutiveSummary(candidates, recommendation, {\n comparator,\n split,\n failureClusters: opts.failureClusters,\n preregistrationHash,\n })\n const methodology = buildMethodology({\n split,\n comparator,\n fdr,\n minPairs,\n rope,\n confidence,\n mdePower,\n mdeAlpha,\n })\n\n const runFingerprint = await hashJson({\n triples: runs\n .filter((r) => r.splitTag === split)\n .map((r) => ({ runId: r.runId, candidateId: r.candidateId, splitTag: r.splitTag }))\n .sort((a, b) => a.runId.localeCompare(b.runId)),\n comparator,\n split,\n })\n\n const markdown = renderResearchMarkdown({\n title,\n generatedAt,\n split,\n comparator,\n rope,\n runFingerprint,\n preregistrationHash,\n executiveSummary,\n recommendation,\n candidates,\n summary,\n pareto,\n gains,\n methodology,\n failureClusters: opts.failureClusters,\n })\n const html = renderResearchHtml(markdown, title)\n\n return {\n kind: 'agent-eval-research-report',\n title,\n generatedAt,\n split,\n comparator,\n runFingerprint,\n preregistrationHash,\n rope,\n executiveSummary,\n recommendation,\n candidates,\n summary,\n charts: { pareto, gains },\n methodology,\n failureClusters: opts.failureClusters,\n markdown,\n html,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,uBAAuB,QAgB5B;CACT,MAAM,QA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