/** * Agentic QE v3 - Time Crystal Scheduler * ADR-032: Kuramoto CPG oscillators for self-sustaining scheduling * * The Time Crystal Scheduler uses coupled oscillators (Central Pattern Generator) * to create emergent, self-sustaining test execution schedules without external timing. * * Key features: * - Kuramoto model for phase synchronization * - Winner-take-all phase selection * - Quality-gated phase transitions * - Self-repair on quality failures * - Crystal stability detection * * REAL TEST EXECUTION: * For production use, provide a TestRunner via SchedulerOptions.testRunner: * ```typescript * import { VitestTestRunner } from './test-runner'; * * const scheduler = new TimeCrystalScheduler(phases, config, { * testRunner: new VitestTestRunner({ cwd: '/path/to/project' }) * }); * ``` * * Without a TestRunner, the scheduler uses MOCK MODE with deterministic fake data. */ import { CPGConfig, PhaseTransition, PhaseResult, TestPhase, SchedulerState, SchedulerOptions, CrystalHealth, TimeCrystalEvent } from './types'; import type { TestRunner } from './phase-executor'; /** * Event emitter type for the scheduler */ export type TimeCrystalEventHandler = (event: TimeCrystalEvent) => void; /** * Time Crystal Scheduler - CPG Controller for Test Execution * * Creates a self-sustaining schedule by using coupled oscillators that * naturally cycle through test phases without external timing signals. */ export declare class TimeCrystalScheduler { private readonly phases; private readonly config; private readonly options; private oscillators; private coupling; private currentPhase; private time; private phaseHistory; private running; private paused; private phaseStartTime; private phaseResults; private cycleCount; private lastCycleStartTime; private cycleDurations; private eventHandlers; private qualityFailures; private consecutiveFailures; private readonly testRunner?; private readonly mockMode; /** * Create a new Time Crystal Scheduler * * @param phases - Test execution phases * @param config - CPG configuration (optional, uses DEFAULT_CPG_CONFIG) * @param options - Scheduler options (include testRunner for REAL test execution) */ constructor(phases: TestPhase[], config?: CPGConfig, options?: Partial); /** * Initialize oscillator neurons with evenly distributed phases */ private initializeOscillators; /** * Initialize coupling matrix with ring topology */ private initializeCoupling; /** * Run one integration tick * * @returns PhaseTransition if a transition occurred, null otherwise */ tick(): PhaseTransition | null; /** * Start the crystal oscillation loop * * Runs asynchronously, calling tick() and executing phases on transitions */ start(): Promise; /** * Stop the crystal oscillation */ stop(): void; /** * Pause the crystal (maintains state) */ pause(): void; /** * Resume from pause */ resume(): void; /** * Execute tests for a specific phase * * @param phase - The phase to execute * @returns Phase execution result */ executePhase(phase: TestPhase): Promise; /** * Default phase executor * * Uses real TestRunner if provided, otherwise falls back to MOCK MODE * with deterministic fake data for development/testing. */ private defaultPhaseExecutor; /** * Execute REAL tests using the configured TestRunner */ private executeRealTests; /** * MOCK MODE: Generate deterministic fake test results. * * WARNING: For development/testing only. Does NOT run real tests. * Provides deterministic values based on phase configuration. */ private executeMockTests; /** * Evaluate quality gates for a phase */ private evaluateQualityGates; /** * Repair crystal structure after quality failures * * Re-synchronizes oscillators to restore stable periodic behavior */ repairCrystal(): Promise; /** * Check if crystal is exhibiting stable periodic behavior * * @returns True if the crystal is stable */ isStable(): boolean; /** * Get the current test phase */ getCurrentPhase(): TestPhase; /** * Get the current phase index */ getCurrentPhaseIndex(): number; /** * Get all phases */ getPhases(): readonly TestPhase[]; /** * Get current simulation time */ getTime(): number; /** * Get number of completed cycles */ getCycleCount(): number; /** * Get the complete scheduler state */ getState(): SchedulerState; /** * Get crystal health status */ getHealth(): CrystalHealth; /** * Compute phase coherence from oscillator history */ private computeCoherence; /** * Get phase execution results */ getPhaseResults(phaseId: number): readonly PhaseResult[]; /** * Register an event handler */ on(handler: TimeCrystalEventHandler): void; /** * Remove an event handler */ off(handler: TimeCrystalEventHandler): void; /** * Emit an event to all handlers */ private emitEvent; /** * Get configuration */ getConfig(): CPGConfig; /** * Check if scheduler is in mock mode (no real test execution) * * @returns true if no TestRunner was provided and mock data is being used */ isMockMode(): boolean; /** * Get the configured test runner, if any */ getTestRunner(): TestRunner | undefined; /** * Update coupling strength */ setCouplingStrength(strength: number): void; /** * Get the oscillator order parameter (synchronization measure) */ getOrderParameter(): number; /** * Force a phase transition (for testing/debugging) */ forcePhaseTransition(targetPhase: number): void; /** * Run for a specified number of ticks (for testing) * * @param ticks - Number of ticks to run * @returns Array of phase transitions that occurred */ runTicks(ticks: number): PhaseTransition[]; /** * Sleep helper */ private sleep; /** * Check if scheduler is running */ isRunning(): boolean; /** * Check if scheduler is paused */ isPaused(): boolean; } /** * Create a Time Crystal Scheduler with default test phases */ export declare function createDefaultScheduler(config?: CPGConfig, options?: Partial): TimeCrystalScheduler; //# sourceMappingURL=scheduler.d.ts.map