pub fn check_claims(
root: &Path,
summary: &EconomicsSummary,
) -> (usize, Vec<EconomicsFinding>)Expand description
Check the claims matrix against the methodology’s bindings and summary, and return how
many bindings the methodology declares with every finding.
A binding whose claim docs/CLAIMS.yaml does not have is a finding. A claim that is not
guaranteed promises nothing and is left alone. A guaranteed claim stands only while its
metric does — verified with a publishable verdict, or measured (or better) — and
while every suite behind the metric is current. A guaranteed claim whose sentence says
tokens, context or cost go down and that no binding names is claim_unbound, whether or
not a methodology is declared; a claim id used twice is claim_duplicate. Declarations
that cannot be read are declarations_unreadable, one finding per error, and a claims
matrix that cannot be parsed is claims_unreadable: the check fails closed.
use majordomus_cli::economics::{claims::check_claims, summarize};
let dir = tempfile::tempdir().unwrap();
let summary = summarize(dir.path(), &Default::default());
let (checked, findings) = check_claims(dir.path(), &summary);
assert_eq!(checked, 0, "no methodology, no bindings");
assert!(findings.is_empty());
// with no methodology, a guaranteed savings claim has nothing to stand on
std::fs::create_dir(dir.path().join("docs")).unwrap();
let claims = "claims:\n - id: cheap\n claim: Majordomus reduces token spend\n status: guaranteed\n";
std::fs::write(dir.path().join("docs/CLAIMS.yaml"), claims).unwrap();
let (_, findings) = check_claims(dir.path(), &summary);
assert_eq!((findings[0].kind.as_str(), findings[0].line), ("claim_unbound", Some(2)));