cordance-advise 0.1.1

Cordance advisory engine. Deterministic doctrine checks against project state.
Documentation
//! Deterministic doctrine checks. Every finding cites a specific doctrine
//! file path. No prose interpretation; no LLM.
//!
//! Each rule targets a specific doctrine principle
//! (`doctrine/principles/<name>.md`) and includes that path as the
//! `doctrine_anchor` on every finding it emits. Severity is one of
//! `Info` / `Warning` / `Error`, with a concrete `remediation` string.
//!
//! # Golden path
//!
//! ```no_run
//! use cordance_core::advise::AdviseReport;
//! use cordance_core::lock::SourceLock;
//! use cordance_core::pack::{CordancePack, PackTargets, ProjectIdentity};
//! use cordance_core::schema;
//!
//! let pack = CordancePack {
//!     schema: schema::CORDANCE_PACK_V1.into(),
//!     project: ProjectIdentity {
//!         name: "my-project".into(),
//!         repo_root: ".".into(),
//!         kind: "rust-workspace".into(),
//!         host_os: "linux".into(),
//!         axiom_pin: None,
//!     },
//!     sources: vec![],
//!     doctrine_pins: vec![],
//!     targets: PackTargets::all(),
//!     outputs: vec![],
//!     source_lock: SourceLock::empty(),
//!     advise: AdviseReport::empty(),
//!     residual_risk: vec![],
//! };
//!
//! let report = cordance_advise::run_all(&pack).expect("advise");
//! for finding in &report.findings {
//!     println!(
//!         "[{:?}] {} — see {}",
//!         finding.severity, finding.summary, finding.doctrine_anchor,
//!     );
//! }
//! ```

#![forbid(unsafe_code)]
#![deny(clippy::unwrap_used, clippy::expect_used)]

use cordance_core::advise::AdviseReport;
use cordance_core::pack::CordancePack;

pub mod rules;

#[derive(Clone, Debug, thiserror::Error)]
pub enum AdviseError {
    #[error("rule error: {0}")]
    Rule(String),
}

/// Run all deterministic rules over a pack and return the consolidated report.
#[allow(clippy::missing_errors_doc)]
pub fn run_all(pack: &CordancePack) -> Result<AdviseReport, AdviseError> {
    let all = rules::all_rules();
    let mut findings = Vec::new();
    for rule in &all {
        findings.extend(rule.check(pack));
    }
    Ok(AdviseReport {
        schema: cordance_core::schema::CORDANCE_ADVISE_REPORT_V1.into(),
        findings,
    })
}