koala-core 1.0.4

Shared types, invariant evaluator, and primitives for the koala framework.
Documentation
use crate::invariant::{Category, Context, Invariant, Outcome};

pub struct ReadmeExists;

impl Invariant for ReadmeExists {
    fn id(&self) -> &'static str {
        "docs.readme-exists"
    }
    fn category(&self) -> Category {
        Category::Docs
    }
    fn intent(&self) -> &'static str {
        "Repository root contains a non-empty README.md (entry-point doc for humans + agents)."
    }
    fn adr(&self) -> Option<&'static str> {
        Some("ADR-0013")
    }

    fn evaluate(&self, ctx: &Context) -> Outcome {
        let path = ctx.root().join("README.md");
        if !path.exists() {
            return Outcome::fail_repro("README.md missing at repository root", "ls README.md");
        }
        match path.metadata() {
            Ok(m) if m.len() < 64 => Outcome::fail_repro(
                format!(
                    "README.md too small ({} bytes); need at least 64 bytes of content",
                    m.len()
                ),
                "wc -c README.md",
            ),
            Ok(_) => Outcome::pass(),
            Err(e) => Outcome::skip(format!("could not stat README.md: {e}")),
        }
    }
}