pub struct ReliabilityScorer { /* private fields */ }Expand description
Computes a ReliabilityScore for an ExtractionResult.
The scorer is pure and deterministic — it derives every sub-score from the result’s metadata plus an externally-supplied retry count. There is no I/O and no clock dependency.
§Example
use stygian_plugin::domain::{ExtractionResult, IdempotencyKey, RegionStatus};
use stygian_plugin::reliability::ReliabilityScorer;
use std::collections::HashMap;
let mut result = ExtractionResult::new(IdempotencyKey::new());
result.metadata.region_status.insert(
"title".to_string(),
RegionStatus { success: true, matched_count: 1, error: None },
);
let score = ReliabilityScorer::new().score_extraction(&result, 0);
assert!((score.overall - 1.0).abs() < f32::EPSILON);Implementations§
Source§impl ReliabilityScorer
impl ReliabilityScorer
Sourcepub const MAX_RETRIES_FOR_PENALTY: u32 = 5
pub const MAX_RETRIES_FOR_PENALTY: u32 = 5
Maximum retry count the retry_penalty sub-score saturates at.
Beyond this many retries the retry_penalty sub-score is 1.0
regardless of the actual count, so a single retry-bloated call can
never zero out the rest of the score on its own.
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a scorer with the default ScoringWeights.
§Example
use stygian_plugin::reliability::ReliabilityScorer;
let _scorer = ReliabilityScorer::new();Sourcepub fn with_weights(weights: ScoringWeights) -> Result<Self>
pub fn with_weights(weights: ScoringWeights) -> Result<Self>
Build a scorer with custom weights.
§Errors
Returns crate::error::PluginError::TemplateValidationError when
any weight is outside [0.0, 1.0] (see ScoringWeights::validate).
Sourcepub fn score_extraction(
&self,
result: &ExtractionResult,
retry_count: u32,
) -> ReliabilityScore
pub fn score_extraction( &self, result: &ExtractionResult, retry_count: u32, ) -> ReliabilityScore
Score an extraction result. retry_count is the number of retries
the caller had to take to produce this result.
§Example
use stygian_plugin::domain::{ExtractionResult, IdempotencyKey, RegionStatus};
use stygian_plugin::reliability::{ReliabilityScorer, ReliabilityBand};
use std::collections::HashMap;
let mut result = ExtractionResult::new(IdempotencyKey::new());
result.metadata.region_status.insert(
"title".to_string(),
RegionStatus { success: false, matched_count: 0, error: Some("missing".into()) },
);
let score = ReliabilityScorer::new().score_extraction(&result, 0);
assert_eq!(score.band, ReliabilityBand::Low);Sourcepub fn score_metadata(
&self,
metadata: &ExtractionMetadata,
retry_count: u32,
) -> ReliabilityScore
pub fn score_metadata( &self, metadata: &ExtractionMetadata, retry_count: u32, ) -> ReliabilityScore
Score from raw ExtractionMetadata without needing the full result.
Useful when the metadata has been serialized over the wire (e.g.
into a MCP debug payload) and the caller only has the metadata.
Trait Implementations§
Source§impl Clone for ReliabilityScorer
impl Clone for ReliabilityScorer
Source§fn clone(&self) -> ReliabilityScorer
fn clone(&self) -> ReliabilityScorer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more