/** * Code-owned benchmark aggregation and acceptance decisions. `aggregateCells` * reduces validated `CellScore[]` records into per-side means (for reporting) * plus the per-case **paired** differences that the decision is built on * (failed cells drop their pair rather than entering any mean), and * `decideBenchmark` applies the spec §4.5 non-regression rules to produce the * binding `BenchmarkDecision`. Both are pure: no I/O, no LLM, and the decision * never invokes the rollback engine — `autoRollback` is the literal `false` in * every MVP decision. * @module dsh-continual-harness */ import type { BenchmarkDecision, CellScore } from './benchmark.ts'; /** Aggregation and decision knobs with spec §4.5 defaults. */ export interface AggregateOptions { /** Intended by spec §4.5 as a report-only pass line in 0..100; it never gates * acceptance and is currently not emitted in the run output either. */ passThreshold: number; /** How far the candidate may fall below the reference before regressing. */ regressionTolerance: number; /** * @deprecated No longer gates the verdict. A failed cell is missing * measurement, and under the paired comparison it only drops that iteration's * pair; the sample size is reported as `pairs` instead. Kept so existing * configs keep validating; scheduled for removal. */ maxFailedCells: number; } /** Per-case paired comparison: the differences, plus the pairs that dropped out. */ export interface PerCasePair { /** Paired differences (candidate − reference) for iterations scored on both sides. */ diffs: number[]; /** Iterations where at least one side produced no score, so the pair dropped. */ missing: number; } /** Aggregation output over one run's cells. */ export interface AggregateResult { /** Mean over all ok reference cells; `null` when none are usable. */ referenceOverall: number | null; /** Mean over all ok candidate cells; `null` when none are usable. */ candidateOverall: number | null; /** Per-case paired differences keyed by case id (every case seen on either side). */ perCase: Record; /** Total failed cells across both sides. */ failedCells: number; /** Failed reference cells. */ failedReference: number; /** Failed candidate cells. */ failedCandidate: number; /** Count of ok reference cells. */ usableReference: number; /** Count of ok candidate cells. */ usableCandidate: number; /** * Run-to-run noise the candidate must exceed: the half-width of the 95% * t-interval of the paired differences pooled over cases. `null` when fewer * than two paired iterations exist, i.e. when no interval can be formed. */ noiseFloor: number | null; /** Mean paired difference (candidate − reference) over every paired iteration. */ pairedDelta: number | null; /** Iterations scored on both sides — the decision's real sample size. */ pairs: number; } /** Everything `decideBenchmark` needs beyond the cells: run identity and seams. */ export interface BenchmarkDecisionInput { runId: string; refinementId: string; cells: CellScore[]; options?: AggregateOptions; /** Clock seam so decisions are deterministic in tests. */ now?: () => Date; } /** Spec §4.5 defaults: passThreshold 60, regressionTolerance 0, maxFailedCells 0. */ export declare const DEFAULT_AGGREGATE_OPTIONS: AggregateOptions; /** * Aggregate one run's cells: validate every input score first, partition by * side, then compute the overall mean over all ok cells plus the pooled and * per-case **paired differences** the decision is built on (a failed cell drops * its pair instead of entering any mean, and is counted separately per side). An * overall of `null` means that side had no usable (ok) cells. */ export declare function aggregateCells(cells: CellScore[], options?: AggregateOptions): AggregateResult; /** * Decide a benchmark run from its aggregated cells (spec §4.5, tightened). * * The comparison is **paired**: each iteration contributes candidate − reference * for the same case, so case difficulty cancels and a cell that failed drops one * pair instead of unbalancing a mean toward either side. * * REJECTED when the run measured something bad: zero paired iterations across * every case even though both sides produced usable cells, or some case's paired * mean difference falls below both `regressionTolerance` and that case's observed * noise (a drop inside the noise is no more evidence than a gain inside it). * * INCONCLUSIVE when the evidence cannot separate the two sides: a side produced * no usable cells at all (`empty-measurement-side`), fewer than two paired * iterations in some case (the noise is unestimable — `no-noise-estimate` with * no dropouts, `insufficient-paired-observations` with them), a difference that * does not exceed the observed noise, or an improvement that clears the noise * but is not consistent across iterations (`improvement-not-consistent`). * * ACCEPTED only when the paired improvement exceeds the observed spread *and* * survives the sign test — "no regression" alone is never an accept. * * A failed cell is an absence of measurement, never evidence against: an * unparseable executor reply must not veto a refinement as if it had regressed — * not even when every cell on one side fails, which is why that run is * INCONCLUSIVE with `empty-measurement-side` rather than REJECTED. * Collects non-empty cell feedback in input order and always records * `autoRollback: false` — the rollback engine is never invoked. */ export declare function decideBenchmark(input: BenchmarkDecisionInput): BenchmarkDecision; /** * Exact two-sided sign test over the paired differences: ties are dropped and, * under the null, each remaining difference is equally likely to fall either * way. Returns null when every difference is a tie, so there is no direction to * test. * * Why this exists next to the t interval: when every pair differs by the same * amount the sample spread is 0 and the interval collapses to zero width, which * would read a small-n fluke as infinite confidence. Four same-direction pairs * give p = 0.125 here — not significant — so acceptance needs more agreement * than the interval alone demands. */ export declare function signTestPValue(diffs: number[]): number | null; //# sourceMappingURL=score.d.ts.map