import type { Frame, Page } from 'playwright'; /** Page side, idempotent. Counts animation frames and records the gaps between them. Installed as an init script and, as a fallback, evaluated into the World frame. */ export declare const FRAME_CLOCK_SOURCE = "(() => {\n const G = globalThis;\n if (G.__vqaClock) return true;\n const C = { n: 0, last: performance.now(), startedAt: performance.now(), maxGapMs: 0, gaps: [], stalls: [], hist: [0, 0, 0, 0, 0, 0] };\n const edges = [20, 34, 50, 100, 250];\n const tick = (ts) => {\n const now = typeof ts === 'number' ? ts : performance.now();\n const gap = now - C.last;\n C.last = now;\n C.n += 1;\n if (C.n > 1) {\n C.maxGapMs = Math.max(C.maxGapMs, gap);\n let b = edges.findIndex((e) => gap < e); if (b < 0) b = edges.length;\n C.hist[b] += 1;\n if (C.gaps.length < 4000) C.gaps.push(Math.round(gap * 10) / 10);\n if (gap >= 250 && C.stalls.length < 40) C.stalls.push({ atMs: Math.round(now - C.startedAt), ms: Math.round(gap), frame: C.n });\n }\n G.requestAnimationFrame(tick);\n };\n C.read = () => ({ n: C.n, now: performance.now(), sinceLastFrameMs: performance.now() - C.last });\n G.__vqaClock = C;\n G.requestAnimationFrame(tick);\n return true;\n})()"; /** * HELIX_VQA_FAULT_FRAME_STALL=:[:] (debug proof of the settle waits; never set on a hosted worker): every * period the page's animation frames stop for stallMs, as the hosted GPU runner's do under contention. Deterministic: the stall * windows are fixed fractions of the page's life, shifted by the seed, so a run can be repeated exactly. */ export declare function frameStallFaultSource(spec: string): string; export interface FrameRead { n: number; now: number; sinceLastFrameMs: number; } export declare function readClock(frame: Frame): Promise; export declare function ensureClock(frame: Frame): Promise; export interface SettleOptions { /** Rendered frames that must pass AFTER the predicate first holds (the engine applies state in its frame loop). Default 4. */ minFrames?: number; /** Wall-clock cap for the whole wait. It only bounds a run that never recovers. Default 8000 ms. */ capMs?: number; /** Poll interval. Default 50 ms. */ pollMs?: number; } export interface SettleResult { ok: boolean; value: T | null; frames: number; ms: number; reason: 'ok' | 'timeout' | 'no-clock'; } /** * Wait until `ok(value)` holds AND `minFrames` animation frames have rendered since it first did. When the page has no frame * clock (a unit fixture) it degrades to the predicate plus a short sleep, never to a longer one. */ export declare function waitForState(frame: Frame, read: () => Promise, ok: (v: T) => boolean, o?: SettleOptions): Promise>; /** Wait for `n` rendered frames (a settle that does not depend on any state). */ export declare function waitFrames(frame: Frame, n: number, capMs?: number): Promise<{ ok: boolean; frames: number; ms: number; }>; export interface PressOptions extends SettleOptions { /** Rendered frames that may pass with the state unchanged before the press is judged lost and made again. Default 24. */ lostAfterFrames?: number; /** Extra presses allowed after the first. Default 2. */ repress?: number; } export interface PressResult { ok: boolean; presses: number; frames: number; ms: number; } /** * Press a key and wait until its EFFECT shows (`changed` is true), repeating the press only when many rendered frames have * passed with nothing changed (a lost key), never merely because the clock ran. The effect is read as a CHANGE from the state * before the press, so a toggle that already landed is never toggled back. */ export declare function pressUntilChanged(page: Page, frame: Frame, key: string, read: () => Promise, changed: (before: T, now: T) => boolean, o?: PressOptions): Promise; export interface FramePacing { frames: number; wallMs: number; medianGapMs: number | null; p99GapMs: number | null; maxGapMs: number; stalls: Array<{ atMs: number; ms: number; frame: number; }>; histogram: Record; fault: unknown; } /** The World frame's frame pacing for the whole run so far: what the hosted GPU actually delivered. Recorded in `facts.framePacing`. */ export declare function readFramePacing(frame: Frame): Promise;