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

audit health evidence does not match its evaluation

Error message

audit health evidence does not match its evaluation

What it means

If an audit entry references an evaluation_id, the store cross-checks that the referenced harness_evaluations row has identical health fields (health_evidence_json, health_evidence_sha256, asserted_health, health_check_status, legacy_unverifiable=false) to the audit entry. A mismatch breaks cross-table consistency.

Source

Thrown at ecc2/src/session/store.rs:5635

        if !event_consistent {
            anyhow::bail!("harness health evidence is inconsistent with audit outcome");
        }
        if let Some(evaluation_id) = entry.evaluation_id {
            let evaluation: (Option<String>, Option<String>, Option<bool>, Option<String>, bool) = self.conn.query_row(
                "SELECT health_evidence_json, health_evidence_sha256, asserted_health, health_check_status, legacy_unverifiable FROM harness_evaluations WHERE id = ?1",
                [evaluation_id],
                |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?, row.get(4)?)),
            )?;
            if evaluation
                != (
                    Some(json.clone()),
                    Some(digest.clone()),
                    Some(asserted),
                    Some(status.clone()),
                    false,
                )
            {
                anyhow::bail!("audit health evidence does not match its evaluation");
            }
        }
        Ok(())
    }

    #[cfg(test)]
    fn connection_for_test(&self) -> &Connection {
        &self.conn
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use chrono::{Duration as ChronoDuration, Utc};
    use std::fs;

    struct TestDir {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Always insert the harness_evaluations row and its harness_eval_audit row in the same transaction with identical health values.
  2. If repairing, update both rows to the same authoritative values in one transaction.
  3. Add a trigger or application-layer invariant so an evaluation and its audit cannot diverge.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before verifying, confirm the referenced evaluation matches the audit row.
if let Some(eid) = entry.evaluation_id {
    let eval: (Option<String>, Option<String>, Option<bool>, Option<String>, bool) = conn.query_row(
        "SELECT health_evidence_json, health_evidence_sha256, asserted_health, health_check_status, legacy_unverifiable
         FROM harness_evaluations WHERE id = ?1", [eid],
        |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?, r.get(4)?)))?;
    let want = (entry.health_evidence_json.clone(), entry.health_evidence_sha256.clone(),
                entry.asserted_health, entry.health_check_status.clone(), false);
    if eval != want {
        return Err(anyhow::anyhow!("audit row {eid} diverges from its evaluation"));
    }
}

Type guard

fn audit_matches_evaluation(audit: &AuditFields, eval: &EvalFields) -> bool {
    audit.health_evidence_json == eval.health_evidence_json
        && audit.health_evidence_sha256 == eval.health_evidence_sha256
        && audit.asserted_health == eval.asserted_health
        && audit.health_check_status == eval.health_check_status
        && !eval.legacy_unverifiable
}

Try / catch

match verify_audit_entry(&store, &entry) {
    Ok(()) => { /* ok */ }
    Err(e) if e.to_string().contains("audit health evidence does not match its evaluation") => {
        // reconcile both rows to the same authoritative values in one transaction
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: An audit row with evaluation_id pointing at a harness_evaluations row whose health columns differ from the audit's, or whose legacy_unverifiable is not false.

Common situations: An evaluation was updated without updating its audit row (or vice versa); a partial migration; a code path that wrote the evaluation and its audit in separate transactions, one of which partially failed.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/ad62133ba536a657. Report an issue: GitHub.