#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CoverageError {
UnclassifiedCategory {
op_id: String,
},
EmptySignature {
op_id: String,
},
EmptyLawSet {
op_id: String,
},
MissingDocsPath {
op_id: String,
},
FutureSinceVersion {
op_id: String,
declared: String,
},
MissingCategoryCHardware {
op_id: String,
},
DuplicateOpId {
op_id: String,
},
LawListDrift {
op_id: String,
},
ZeroWitnesses {
op_id: String,
law: String,
},
InvalidOracle {
op_id: String,
message: String,
},
InvalidSpecRow {
op_id: String,
row: usize,
message: String,
},
InvalidSource {
op_id: String,
message: String,
},
InvalidDocsPath {
op_id: String,
},
MissingDocsFile {
op_id: String,
path: String,
},
EmptyArchetypeSet {
op_id: String,
},
UnknownArchetype {
op_id: String,
archetype: String,
},
}
impl core::fmt::Display for CoverageError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::UnclassifiedCategory { op_id } => write!(
f,
"{op_id}: Category::unclassified() marker is not allowed. \
Fix: declare Category::A {{ composition_of: vec![...] }} \
or Category::C {{ hardware, backend_availability }}."
),
Self::EmptySignature { op_id } => write!(
f,
"{op_id}: signature.inputs is empty. Fix: every op consumes at \
least one value."
),
Self::EmptyLawSet { op_id } => write!(
f,
"{op_id}: declares no algebraic laws. Fix: run inference on the \
reference_fn — if no laws hold, document the reason in the \
op's module doc comment."
),
Self::MissingDocsPath { op_id } => write!(
f,
"{op_id}: docs_path is empty. Fix: point it at the op's \
documentation page, e.g. \"docs/ops/primitive/add.md\"."
),
Self::FutureSinceVersion { op_id, declared } => write!(
f,
"{op_id}: since_version {declared} is ahead of CURRENT_VERSION. \
Fix: set since_version to CURRENT_VERSION, or ship a version \
bump first."
),
Self::MissingCategoryCHardware { op_id } => write!(
f,
"{op_id}: Category::C declared without a hardware intrinsic identifier. \
Fix: add hardware: \"...\" and backend_availability."
),
Self::DuplicateOpId { op_id } => write!(
f,
"{op_id}: duplicate op id in the registry. Fix: every op id \
must be unique."
),
Self::LawListDrift { op_id } => write!(
f,
"{op_id}: laws and declared_laws disagree. Fix: make the two law lists exactly match."
),
Self::ZeroWitnesses { op_id, law } => write!(
f,
"{op_id}: law {law} uses zero WitnessedU32 witnesses. Fix: set count > 0."
),
Self::InvalidOracle { op_id, message } => {
write!(f, "{op_id}: invalid oracle override: {message}")
}
Self::InvalidSpecRow {
op_id,
row,
message,
} => write!(f, "{op_id}: invalid spec row {row}: {message}"),
Self::InvalidSource { op_id, message } => {
write!(f, "{op_id}: invalid source provenance: {message}")
}
Self::InvalidDocsPath { op_id } => write!(
f,
"{op_id}: docs_path must point under docs/ops/. Fix: use a repository-relative operation docs path."
),
Self::MissingDocsFile { op_id, path } => write!(
f,
"{op_id}: docs_path file missing at '{path}'. Fix: create the documentation file or correct the path."
),
Self::EmptyArchetypeSet { op_id } => write!(
f,
"{op_id}: archetypes list is empty. Fix: declare at least one archetype id from the locked vocabulary."
),
Self::UnknownArchetype { op_id, archetype } => write!(
f,
"{op_id}: unknown archetype '{archetype}'. Fix: use an id from the global ARCHETYPES registry."
),
}
}
}
impl core::error::Error for CoverageError {}