66 lines
2 KiB
TypeScript
66 lines
2 KiB
TypeScript
/** Read-only comparison of retained inputs and existing scalar result summaries. */
|
|
import { z } from 'zod';
|
|
import type { WorkbenchExperimentDetail } from './cost-sensitivity';
|
|
|
|
const experimentId = z
|
|
.string()
|
|
.uuid()
|
|
.transform(id => id.toLowerCase());
|
|
export const experimentComparisonInputSchema = z
|
|
.object({
|
|
leftId: experimentId,
|
|
rightId: experimentId,
|
|
referenceTrialKey: z
|
|
.string()
|
|
.regex(/^[a-f0-9]{64}$/)
|
|
.optional(),
|
|
})
|
|
.strict()
|
|
.refine(input => input.leftId !== input.rightId, {
|
|
message: 'Select two different experiments',
|
|
});
|
|
export type ExperimentComparisonInput = z.infer<typeof experimentComparisonInputSchema>;
|
|
|
|
/** Stable order for mismatch explanations; these are conditions, not performance scores. */
|
|
export const experimentComparisonDimensions = [
|
|
'dataset',
|
|
'window',
|
|
'capital',
|
|
'costs',
|
|
'execution',
|
|
'risk',
|
|
'clock',
|
|
'analytics',
|
|
'seed',
|
|
'build',
|
|
'models',
|
|
] as const;
|
|
export type ExperimentComparisonDimension = (typeof experimentComparisonDimensions)[number];
|
|
export interface ExperimentComparisonRow {
|
|
experimentId: string;
|
|
trialKey: string;
|
|
inputCompatibility: 'match' | 'mismatch';
|
|
differences: ExperimentComparisonDimension[];
|
|
/** Existing compact provenance/shape checks, not full financial reconciliation. */
|
|
summaryAvailable: boolean;
|
|
/** Both saved summaries exist and their input conditions match. */
|
|
ready: boolean;
|
|
}
|
|
export interface ExperimentComparison {
|
|
version: 'experiment-comparison/v1';
|
|
policy: 'retained-input-compatibility/v1';
|
|
selection: Required<ExperimentComparisonInput>;
|
|
reference: {
|
|
experimentId: string;
|
|
trialKey: string;
|
|
index: number;
|
|
runId: string | null;
|
|
summaryAvailable: boolean;
|
|
diagnostic: string | null;
|
|
};
|
|
/** Existing compact result readers; never include full financial/trade/return arrays. */
|
|
experiments: [WorkbenchExperimentDetail, WorkbenchExperimentDetail];
|
|
/** Left then right, in each experiment's immutable candidate order. */
|
|
rows: ExperimentComparisonRow[];
|
|
limitations: string[];
|
|
}
|