affaan-m/ECC · error · anyhow::Error

score must be finite and between 0 and 1

Error message

score must be finite and between 0 and 1

What it means

RecordedEvaluator::evaluate looks up the pre-recorded score for the (candidate_id, seed) pair and validates it is a finite number in [0,1]. The error fires for stored scores that are NaN, infinite, or outside the valid range — a corruption guard on recorded evidence, not on live evaluation.

Source

Thrown at ecc2/src/harness_eval.rs:436

    #[cfg(test)]
    pub fn calls(&self) -> &[(String, u64)] {
        &self.calls
    }
}

impl Evaluator for RecordedEvaluator {
    fn name(&self) -> &str {
        &self.name
    }

    fn evaluate(&mut self, candidate_id: &str, seed: u64) -> Result<f64> {
        self.calls.push((candidate_id.to_string(), seed));
        let score = *self
            .scores
            .get(&(candidate_id.to_string(), seed))
            .with_context(|| format!("missing recorded score for {candidate_id} seed {seed}"))?;
        if !score.is_finite() || !(0.0..=1.0).contains(&score) {
            bail!("score must be finite and between 0 and 1");
        }
        Ok(score)
    }

    fn health_check(&mut self, candidate_id: &str) -> Result<bool> {
        if self
            .health_candidate
            .as_deref()
            .is_some_and(|expected| expected != candidate_id)
        {
            bail!("health evidence does not match promoted candidate");
        }
        Ok(self.health_ok)
    }
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PairedSample {

View on GitHub (pinned to 06c5e118c4)

Solutions

  1. Clamp or normalize the score into the [0, 1] range before recording it.
  2. Guard against NaN/Infinity from division by zero in the scoring computation.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at ecc2/src/harness_eval.rs:436 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@06c5e118c4 (2026-08-18). Data as JSON: /api/errors/75f571fc880e8513. Report an issue: GitHub.