Skip to main content

datasynth_eval/calibration/
mod.rs

1//! C3 (#158) — adversarial calibration loop.
2//!
3//! Closed-loop calibration that drives the synthetic engine's tunable
4//! knobs so a chosen gap metric (versus a reference corpus, or
5//! versus a target value) converges. Builds on
6//! [`crate::enhancement::AutoTuner`] for patch proposals and
7//! [`crate::behavioral_fidelity::compute_report`] for the loss
8//! signal. The "adversarial" framing matches a GAN-style dynamic
9//! (generator config θ vs discriminator gap-metric L) but with a
10//! fixed analytic discriminator instead of a co-trained model,
11//! making the loop trivial to reason about + debug.
12//!
13//! See `docs/design/2026-05-27-c3-adversarial-calibration-design.md`
14//! for the broader plan and the validation strategy.
15//!
16//! This module ships Piece 1 of the C3 plan:
17//! - [`CalibrationObjective`] — what we're minimising.
18//! - [`CalibrationKnob`] + [`KnobBounds`] — the parameter space.
19//!
20//! Pieces 2 (iteration controller), 3 (history persistence), 4
21//! (`datasynth-data calibrate` CLI), 5 (safety rails) land in
22//! follow-up commits.
23
24mod history;
25mod knob;
26mod loop_runner;
27mod objective;
28mod proposer;
29mod safety;
30
31pub use history::{CalibrationHistory, HistoryError, HISTORY_SCHEMA_VERSION};
32pub use knob::{CalibrationKnob, KnobBounds, KnobClipResult, KnobValue};
33pub use loop_runner::{
34    CalibrationConfig, CalibrationLoop, Evaluator, EvaluatorError, ProposedPatch, Proposer,
35    RollbackPolicy, StepOutcome, StepReport,
36};
37pub use objective::{CalibrationObjective, ObjectiveMetric};
38pub use proposer::{GreedyKnobProposer, RoundRobinProposer};
39pub use safety::{ClipCounts, KnobClipDiagnostics, OscillationDetector, WallClockBudget};