export type StateSwitchPhase = 'boot' | 'replay' | 'settle' | 'stability' | 'serialize' | 'publish'; type Clock = () => number; interface WaypointTiming { screenId: string; replayMs: number | null; settleMs: number | null; stabilityMs: number | null; stabilityTimedOut: boolean; serializeMs: number | null; publishMs: number | null; } /** * Live handle for one walk. Created by beginStateSwitchWalk, fed by the * mark/record hooks inside walkPath, and closed by endStateSwitchWalk. */ export interface StateSwitchWalkTrace { runner: string; pathId: string; /** True when the walk resumed on a parked warm instance (no boot). */ reused: boolean; startedAtEpochMs: number; startedAt: number; markAt: number | null; bootMs: number | null; waypoints: WaypointTiming[]; current: WaypointTiming | null; ended: boolean; } export interface PhaseAggregate { count: number; totalMs: number; maxMs: number; } export interface WalkAggregate { count: number; completed: number; coldBoots: number; warmReuses: number; stabilityTimeouts: number; phases: Record; } export interface WalkRecord { runner: string; pathId: string; reused: boolean; completed: boolean; startedAtEpochMs: number; totalMs: number; bootMs: number | null; /** Per-phase sums across the walk's waypoints, for quick reading. */ totals: { replayMs: number; settleMs: number; stabilityMs: number; serializeMs: number; publishMs: number; }; waypoints: WaypointTiming[]; } /** * One editor's state-switch metrics: the walk aggregates per runner, the * bounded walk history, and the route-preview producer counters, behind the * clock a test can replace. Every runtime owns one; its preview cache and * flow-session runners record into it. */ export declare function createStateSwitchMetrics(): { setStateSwitchMetricsClock: (next: Clock | null) => void; beginStateSwitchWalk: (runner: string, pathId: string, reused: boolean) => StateSwitchWalkTrace; beginStateSwitchWaypoint: (trace: StateSwitchWalkTrace, screenId: string) => void; markStateSwitchPhase: (trace: StateSwitchWalkTrace) => void; recordStateSwitchPhase: (trace: StateSwitchWalkTrace, phase: StateSwitchPhase) => void; endStateSwitchWalk: (trace: StateSwitchWalkTrace, completed: boolean) => void; recordRoutePreviewProducerDecision: (input: { endpointConfigured: boolean; detailActive: boolean; previewIntended: boolean; }) => void; getStateSwitchMetricsSnapshot: () => { walks: { byRunner: { [k: string]: { count: number; completed: number; coldBoots: number; warmReuses: number; stabilityTimeouts: number; phases: Record; }; }; recent: { totals: { replayMs: number; settleMs: number; stabilityMs: number; serializeMs: number; publishMs: number; }; waypoints: { screenId: string; replayMs: number | null; settleMs: number | null; stabilityMs: number | null; stabilityTimedOut: boolean; serializeMs: number | null; publishMs: number | null; }[]; runner: string; pathId: string; reused: boolean; completed: boolean; startedAtEpochMs: number; totalMs: number; bootMs: number | null; }[]; count: number; completed: number; coldBoots: number; warmReuses: number; stabilityTimeouts: number; phases: Record; }; routePreviewProducer: { evaluations: number; allowed: number; suppressed: number; byTrigger: { endpointNotConfigured: number; detailActive: number; previewIntended: number; }; }; }; resetStateSwitchMetrics: () => void; }; export type StateSwitchMetrics = ReturnType; export {};