/** * Parent-selection strategies (v0.10.0) — GEPA `candidate_selection_strategy` * parity for the online evolution loop. * * Upstream GEPA exposes three strategies for picking WHICH candidate to * mutate next: sample from the Pareto frontier (default), always take the * current best, or epsilon-greedy explore/exploit. Darwin's online loop * historically always reflected from the currently-ACTIVE prompt (plus the * opt-in v0.7 coverage selection). This module adds the missing strategies as * a pure, injectable-RNG helper: * * - `"active"` — loop default, reflect from the active prompt * (handled by the caller; this helper returns null). * - `"best"` — GEPA `current_best`: highest scalarised composite * over the version history. * - `"pareto"` — GEPA default: uniform sample from the non-dominated * front of the version history. * - `"epsilon-greedy"`— with probability ε pick a uniformly-random version * (explore), otherwise the best (exploit). * * Why it matters: always mutating the active prompt is a hill-climb that can * get stuck on a local optimum. Sampling parents from the Pareto front keeps * lineages alive that win on DIFFERENT objectives, and epsilon-greedy buys * cheap exploration — both directly per the GEPA paper's selection ablation. * * Purity: no I/O, no LLM calls, deterministic given the same `rng`. The RNG * is injected (default `Math.random`) so tests pin outcomes exactly — same * pattern as `sampleByCoverage` (v0.7.0). */ import { type ParetoObjective } from "./pareto.js"; /** * Strategy for choosing the prompt version the next challenger is derived * from. `"active"` is the historical default (reflect from the active * prompt); the other three operate on the agent's scored version history. */ export type CandidateSelectionStrategy = "active" | "best" | "pareto" | "epsilon-greedy"; /** Minimal shape this module needs — `ScoredVariant` satisfies it. */ export interface SelectableVariant { /** Averaged objective vector for one prompt version. */ metrics: Record; } /** Options for {@link selectParentVariant}. */ export interface ParentSelectionOptions { /** * Exploration probability for `"epsilon-greedy"` (default * {@link DEFAULT_EXPLORATION_EPSILON}). Clamped to [0, 1]; non-finite * values fall back to the default (NaN never bypasses the clamp). */ epsilon?: number; /** * Random source in [0, 1) — injected for deterministic tests * (default `Math.random`). Consulted by `"pareto"` (front sampling) and * `"epsilon-greedy"` (explore coin-flip + explore pick). */ rng?: () => number; /** * Objectives for dominance/scalarisation (default * {@link DARWIN_DEFAULT_OBJECTIVES}). Same scale-sensitivity caveat as * `paretoSelect` applies to the scalarised `"best"` pick. */ objectives?: ReadonlyArray>>; } export declare const DEFAULT_EXPLORATION_EPSILON = 0.1; /** * Pick the parent variant the next challenger should be derived from. * * Returns `null` when the strategy is `"active"` (caller keeps the active * prompt — the historical default path) or when `variants` is empty. A * single-element list short-circuits to that element for every non-active * strategy. */ export declare function selectParentVariant(variants: ReadonlyArray, strategy: CandidateSelectionStrategy, options?: ParentSelectionOptions): V | null; //# sourceMappingURL=selection.d.ts.map