Skip to main content

Module validation_pipeline

Module validation_pipeline 

Source
Expand description

Expected-cost validation ordering with Bayesian online learning.

This module provides a validation pipeline that orders validators by expected cost, using Beta-posterior failure probabilities and early exit.

§Mathematical Model

Each validator i has:

  • cost c_i: measured execution time (running exponential average)
  • failure probability p_i = α_i / (α_i + β_i): Beta posterior mean

The optimal ordering minimises expected total cost under early-exit (stop on first failure). By the classic optimal search theorem (Blackwell 1953), the minimum-expected-cost ordering sorts validators by decreasing p_i / c_i (highest “bang per buck” first).

E[cost(π)] = Σ_k  c_{π_k} × Π_{j<k} (1 − p_{π_j})

§Online Learning

After each validation run the pipeline updates its Beta posteriors:

  • Failure observed: α_i += 1
  • Success observed: β_i += 1

Cost estimates use an exponential moving average with configurable smoothing factor γ ∈ (0,1].

§Evidence Ledger

Every ordering decision is recorded in an evidence ledger so that the ranking is fully explainable. Each entry contains:

  • validator id, p_i, c_i, score = p_i / c_i, rank

§Failure Modes

ConditionBehaviorRationale
c_i = 0Clamp to c_min (1μs)Division by zero guard
α + β = 0Use prior (1, 1)Uniform prior assumption
All validators passFull cost incurredNo early exit possible
No validatorsReturn success, zero costVacuously valid

§Determinism

Given identical history (same sequence of update calls), the ordering is fully deterministic. Ties are broken by validator index (stable sort).

Structs§

LedgerEntry
A single entry in the evidence ledger recording an ordering decision.
PipelineConfig
Configuration for the validation pipeline.
PipelineResult
Result of running the full pipeline.
PipelineSummary
Diagnostic summary of pipeline state.
ValidationOutcome
Result of running one validation.
ValidationPipeline
Expected-cost validation pipeline with Bayesian ordering.
ValidatorStats
Per-validator statistics tracked by the pipeline.