use koala_core::invariant::Context;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Severity {
Hard,
Advisory,
}
impl Severity {
pub fn label(&self) -> &'static str {
match self {
Self::Hard => "✗",
Self::Advisory => "⚠",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FindingKind {
AcceptanceTestRefMissing,
AdrRefDangling,
AdrRefSuperseded { superseder: Option<String> },
AdrDormant,
AdrIdGap { missing: u32 },
Tier1Tampered { expected: String, actual: String },
TemplatePlaceholderUnfilled,
}
impl FindingKind {
pub fn short(&self) -> &'static str {
match self {
Self::AcceptanceTestRefMissing => "acceptance test ref missing",
Self::AdrRefDangling => "ADR reference does not resolve",
Self::AdrRefSuperseded { .. } => "ADR reference is superseded",
Self::AdrDormant => "ADR has no inbound references",
Self::AdrIdGap { .. } => "ADR id is missing — file was deleted",
Self::Tier1Tampered { .. } => "Tier 1 file body edited by hand",
Self::TemplatePlaceholderUnfilled => "scaffolded placeholder never filled in",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Finding {
pub check_id: &'static str,
pub file: PathBuf,
pub line: usize,
pub claim: String,
pub kind: FindingKind,
pub severity: Severity,
pub fix_hint: Option<String>,
}
pub trait Check: Send + Sync {
fn id(&self) -> &'static str;
fn intent(&self) -> &'static str;
fn run(&self, ctx: &Context) -> Vec<Finding>;
}