The selection engine utilizes a two-stage hierarchical process designed to balance structural exploration across categories with statistical exploitation of proven snippet edits:

  1. Stage 1: Diversity Sampling — The engine first calculates an inverse-frequency freshness score for each category within the six-tier Rank Factor Class taxonomy (Alignment, Substance, Architecture, Style, Framing, Proof, and Other). It probabilistically samples a class using a freshness formula adjusted by a configurable diversity weight, preventing the optimizer from prematurely over-focusing on a single mechanism.
  2. Stage 2: Hypothesis Selection — Once a class is chosen, the engine evaluates the specific hypotheses within that group using a Bayesian acquisition policy. It supports three distinct algorithms depending on the exploration strategy:
  3. Thompson Sampling: Draws random samples from each hypothesis's Beta distribution parameters \(\text{Beta}(\alpha, \beta)\) and picks the highest value.
  4. Upper Confidence Bound (UCB): Computes a deterministic score combining the posterior mean with an exploration bonus derived from total test counts.
  5. Epsilon-Greedy: Selects the hypothesis with the highest empirical mean with probability \(1-\epsilon\), and chooses a random hypothesis with probability \(\epsilon\).

When diversity weighting is disabled or all hypotheses belong to a single class, Stage 1 is bypassed and the selected Bayesian policy evaluates the entire pool directly.