Skip to main content

Module reliability

Module reliability 

Source
Expand description

Extraction reliability scoring

Computes a 0.0–1.0 reliability score for domain::ExtractionResult outputs so fallback chains can optimize for data quality, not only fetch success. See the module-level docs for the score interpretation table and the selection policy. Extraction reliability scoring

Computes a 0.0–1.0 reliability score for ExtractionResult outputs so fallback chains can optimize for data quality, not only fetch success.

§Score components

The score is the weighted sum of three sub-scores, clamped to [0.0, 1.0]:

Sub-scoreDefault weightSource
schema_completeness0.70successful_regions / total_regions
transformation_success0.301 − transformation_failure_rate
retry_penalty0.10retry_count / max_retries (clamped)

retry_penalty is subtracted from the weighted sum — it represents a quality discount for results that took many retries to produce.

§Interpretation bands

The continuous overall score is bucketed into three discrete bands so callers can branch on a single ReliabilityBand value:

BandScore rangeInterpretation
High0.85..=1.00Production-ready; trust the result.
Medium0.50..0.85Partial; treat as best-effort, retry if needed.
Low0.00..0.50Unreliable; prefer an alternative fallback.

§Selection policy

The ScoreWeightedSelector helper ranks a list of (name, score) candidates and picks the highest-scoring one. Callers can apply a custom ScoringWeights to tune the importance of each sub-score for their target class.

§Example

use stygian_plugin::domain::{ExtractionResult, IdempotencyKey};
use stygian_plugin::reliability::{ReliabilityScorer, ReliabilityBand};

let result = ExtractionResult::new(IdempotencyKey::new());
let score = ReliabilityScorer::new().score_extraction(&result, 0);
assert_eq!(score.band, ReliabilityBand::High); // empty template -> vacuously complete
assert!((score.overall - 1.0).abs() < f32::EPSILON);

Re-exports§

pub use score::ReliabilityBand;
pub use score::ReliabilityScore;
pub use scorer::ReliabilityScorer;
pub use scorer::ScoringWeights;
pub use selector::ScoreWeightedSelector;
pub use selector::ScoredCandidate;

Modules§

score
ReliabilityScore value type and its discrete interpretation band.
scorer
Reliability scorer: turns an ExtractionResult into a ReliabilityScore.
selector
Score-weighted selection over a list of (name, score) candidates.