cordance-cortex 0.1.0

Cordance Cortex adapter. Emits candidate receipts; never writes to the cortex repo or runtime.
Documentation
//! Cortex adapter. Emits `cordance-cortex-receipt-v1-candidate` JSON only.
//!
//! ADR 0005: Cordance never writes to the cortex repo or runtime. It produces
//! a receipt; the operator hands the receipt to Cortex via Cortex's own
//! acceptance flow.

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

use cordance_core::pack::CordancePack;
use cordance_core::receipt::{AuthorityBoundary, CortexReceiptV1Candidate};

pub mod builder;
pub mod validator;

#[derive(Debug, thiserror::Error)]
pub enum CortexError {
    #[error("receipt validation error: {0}")]
    Validation(String),
    #[error("serialisation error: {0}")]
    Serde(#[from] serde_json::Error),
}

/// Build a candidate receipt from a compiled pack.
///
/// # Errors
/// Returns `CortexError::Validation` if the assembled receipt fails structural
/// validation.
#[allow(clippy::missing_errors_doc)]
pub fn build_receipt(pack: &CordancePack) -> Result<CortexReceiptV1Candidate, CortexError> {
    builder::build_receipt(pack)
}

/// Quick check: a fresh `AuthorityBoundary::candidate_only()` is always safe.
#[must_use]
pub const fn safe_boundary() -> AuthorityBoundary {
    AuthorityBoundary::candidate_only()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn safe_boundary_grants_nothing() {
        let b = safe_boundary();
        assert!(b.candidate_only);
        assert!(!b.cortex_truth_allowed);
    }
}