/** * Cross-run comparison for dsh-eval: two persisted run reports become a row * list of metric values and deltas, rendered as a markdown table. * * @module dsh-eval/compare */ import type { EvalRun } from './types.ts'; import { type PairedDelta, type SignTestOutcome } from './stats.ts'; /** One compared metric row. */ export interface CompareRow { /** Metric label. */ metric: string; /** Run A's rendered value. */ a: string; /** Run B's rendered value. */ b: string; /** Signed delta (`b - a`) for numeric rows, or a dash for text rows. */ delta: string; } /** Paired same-case statistics over two runs. */ export interface PairedStats { /** Number of case x trial pairs completed in both runs. */ pairs: number; /** Pairs where run B beat run A on the primary metric. */ wins: number; /** Pairs where run A beat run B on the primary metric. */ losses: number; /** Pairs with equal primary-metric outcomes. */ ties: number; /** The metric used for win/lose/tie classification. */ primaryMetric: 'task success' | 'tool selection accuracy' | 'final answer score'; /** Exact two-sided sign test over the discordant pairs of the primary metric. */ test: SignTestOutcome; /** Paired step delta (`b - a`) with its bootstrap interval, or null when no pair is numeric. */ stepsDelta: PairedDelta | null; /** Paired token delta (`b - a`) with its bootstrap interval, or null when no pair is numeric. */ tokensDelta: PairedDelta | null; /** Paired judge-score delta (`b - a`) with its bootstrap interval, or null without verdicts. */ scoreDelta: PairedDelta | null; } /** * Pair both runs' trials by case id and trial index and compute win/lose/tie * plus mean deltas. Trials are paired as-is; the runs' `seed` is recorded * provenance for the pairing, not a guarantee of identical model output. * @param a - the baseline run. * @param b - the candidate run. * @returns paired statistics, or null when no trial is completed in both runs. */ export declare function pairedCompare(a: EvalRun, b: EvalRun): PairedStats | null; /** * Build the comparison rows between two runs. * @param a - the baseline run. * @param b - the candidate run. * @returns the row list in display order. */ export declare function compareRuns(a: EvalRun, b: EvalRun): CompareRow[]; /** * Render comparison rows as a markdown table. * @param rows - the rows from {@link compareRuns}. * @returns the markdown text. */ export declare function renderCompareMarkdown(rows: readonly CompareRow[]): string;