pub struct Confidence {
pub recognition: f32,
pub rule: f32,
pub region: Option<f32>,
pub runner_up_ratio: Option<f32>,
pub features: Vec<FeatureContribution>,
}Expand description
Multi-axis confidence attached to every FixProposal.
Fields:
recognition— posterior from theRecognizerthat surfaced this candidate (0.0–1.0).rule— confidence the emitting rule has in its own fix (0.0–1.0). Strict-path rules report 1.0 when the invariant is unambiguous.region— optional region-level confidence (a page-context prior, for example).runner_up_ratio— optional ratio of top candidate to runner-up posterior. Decoder-sourced fixes carry this; strict-path fixes leave itNonebecause the strict grammar has no runner-up by construction.features— the concrete evidence features that contributed torecognition. Used by the corpus-accuracy harness to break down where posterior mass came from.
Construction happens via Confidence::strict (for rules that
bypass the decoder) or the decoder’s scoring path (Phase 4 / task
T061).
Fields§
§recognition: f32Recognizer posterior in [0.0, 1.0].
rule: f32Rule-level confidence in [0.0, 1.0].
region: Option<f32>Region / page-context confidence, when a rule computes one.
runner_up_ratio: Option<f32>Posterior ratio between top candidate and runner-up
(None for strict-path fixes; set by decoder-sourced fixes).
features: Vec<FeatureContribution>Per-feature contributions to recognition.
Implementations§
Source§impl Confidence
impl Confidence
Sourcepub fn strict(rule_confidence: f32) -> Self
pub fn strict(rule_confidence: f32) -> Self
Confidence record for a strict-path fix where recognition was unambiguous.
rule_confidence is the rule’s own confidence in its proposed
fix (typically 1.0 for migrations, lower for heuristics). The
recognition axis is pinned at 1.0 because the strict grammar
has one unambiguous match by definition, and no feature
contributions are recorded — strict-path fixes do not traverse
the decoder’s feature graph.
Sourcepub fn combined(&self) -> f32
pub fn combined(&self) -> f32
Product of recognition and rule. The engine’s
confidence-threshold gate compares this combined score against
the configured threshold (FR-016).
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate every axis of this Confidence record.
Returns Err(message) naming the first invalid axis. Checks:
recognitionandrulein[0.0, 1.0]and not NaN.region, whenSome, in[0.0, 1.0]and not NaN.runner_up_ratio, whenSome, finite and not NaN. No range constraint — a well-behaved decoder returns≥ 1.0(top / runner-up) but infinity (runner-up posterior = 0) and values< 1.0are legal for debugging / inspection code.- Every
features[i].deltafinite and not NaN.deltacarries signed log-posterior contributions so any finite value is legal;NaN/ infinity would poison downstream audit-sum invariants silently.
The zero-axis edge case (recognition = 0 or rule = 0) is valid
— combined() = 0.0 is a legitimate below-threshold result,
not an invariant violation.
Trait Implementations§
Source§impl Clone for Confidence
impl Clone for Confidence
Source§fn clone(&self) -> Confidence
fn clone(&self) -> Confidence
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more