use crate::spec::types::OracleKind;
use crate::OpSpec;
use vyre_spec::Category;
use super::error::CoverageError;
pub(super) fn check_oracle(spec: &OpSpec, errors: &mut Vec<CoverageError>) {
match spec.oracle_override {
Some(OracleKind::SpecTable) if spec.spec_table.is_empty() => {
errors.push(CoverageError::InvalidOracle {
op_id: spec.id.to_string(),
message: "SpecTable requires at least one SpecRow. Fix: add rows or choose another oracle."
.to_string(),
});
}
Some(OracleKind::Law) if spec.laws.is_empty() => {
errors.push(CoverageError::InvalidOracle {
op_id: spec.id.to_string(),
message:
"Law oracle requires declared laws. Fix: declare laws or choose another oracle."
.to_string(),
})
}
Some(OracleKind::Composition) if !matches!(spec.category, Category::A { .. }) => {
errors.push(CoverageError::InvalidOracle {
op_id: spec.id.to_string(),
message:
"Composition oracle requires Category A. Fix: change the oracle or category."
.to_string(),
});
}
Some(OracleKind::External)
if spec
.external_oracle_url
.map(|s| s.trim().is_empty())
.unwrap_or(true) =>
{
errors.push(CoverageError::InvalidOracle {
op_id: spec.id.to_string(),
message:
"External oracle requires external_oracle_url. Fix: set the URL or choose another oracle."
.to_string(),
});
}
Some(OracleKind::Property) if spec.property_invariants.is_empty() => {
errors.push(CoverageError::InvalidOracle {
op_id: spec.id.to_string(),
message:
"Property oracle requires non-empty property_invariants. Fix: declare invariants or choose another oracle."
.to_string(),
});
}
_ => {}
}
}