Skip to main content

Confidence

Struct Confidence 

Source
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 the Recognizer that 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 it None because the strict grammar has no runner-up by construction.
  • features — the concrete evidence features that contributed to recognition. 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: f32

Recognizer posterior in [0.0, 1.0].

§rule: f32

Rule-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

Source

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.

Source

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).

Source

pub fn validate(&self) -> Result<(), String>

Validate every axis of this Confidence record.

Returns Err(message) naming the first invalid axis. Checks:

  • recognition and rule in [0.0, 1.0] and not NaN.
  • region, when Some, in [0.0, 1.0] and not NaN.
  • runner_up_ratio, when Some, 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.0 are legal for debugging / inspection code.
  • Every features[i].delta finite and not NaN. delta carries 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

Source§

fn clone(&self) -> Confidence

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Confidence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Confidence

Source§

fn eq(&self, other: &Confidence) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Confidence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.