vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
//! Enforcement modules for conformance invariants.
//!
//! This module is the immune system of vyre. It exports the gate trait
//! (`Enforcer`), the execution context (`EnforceCtx`), and the aggregated
//! orchestration (`enforce_all`). Every conformance check - from algebraic
//! laws to wire-format equivalence - lives in a submodule and is wired into
//! the auto-generated registry so that adding a new gate requires zero
//! modifications outside the gate's own file.

pub mod ctx;
pub mod enforcer;
pub(crate) mod gates;
pub mod registry;

pub use ctx::{workspace_root, EnforceCtx};
pub use enforcer::{aggregate_finding, finding_result, EnforceGate, Finding, RegisteredEnforcer};
pub use registry::{enforce_all, EnforcementReport, LayerCheck, LayerFinding, LayerStatus};

/// Concrete gate implementations organized by conformance layer.
pub mod enforcers {
    /// Admission gate: mechanical checks for new op specs.
    pub mod admission;
    /// Atomic race detector.
    pub mod atomics;
    /// Barrier placement validator.
    pub mod barrier;
    /// Category A zero-overhead verifier.
    pub mod category_a;
    /// Category B forbidden-pattern tripwire.
    pub mod category_b;
    /// Category C intrinsic verifier.
    pub mod category_c;
    /// Law-set distinctiveness reporter.
    pub mod characterize;
    /// Composition closure theorem checker.
    pub mod composition_closure;
    /// Cost certificate gate.
    pub mod cost_certificate;
    /// Data race detector.
    pub mod data_race;
    /// Decomposition verifier.
    pub mod decomposition;
    /// K-dispatch determinism enforcer.
    pub mod determinism;
    /// Divergence conformance gate.
    pub mod divergence;
    /// GPU-mandatory pattern scanner.
    pub mod enforcer_gpu_mandatory;
    /// Engine composition invariant checker.
    pub mod engine_composition;
    /// Floating-point semantics gate.
    pub mod float_semantics;
    /// Gate 7 coverage requirement.
    pub mod gate_7_coverage;
    /// Layer 1: executable spec validator.
    pub mod layer1_executable_spec;
    /// Layer 2: law inference validator.
    pub mod layer2_law_inference;
    /// Layer 3: reference interpreter oracle.
    pub mod layer3_reference_interp;
    /// Layer 4: mutation gate.
    pub mod layer4_mutation_gate;
    /// Layer 5: adversarial wave.
    pub mod layer5_adversarial;
    /// Layer 6: stability auditor.
    pub mod layer6_stability;
    /// Layer 7: composition proof checker.
    pub mod layer7_composition_proof;
    /// Layer 8: feedback loop.
    pub mod layer8_feedback_loop;
    /// No-silent-wrong-answer meta-gate.
    pub mod no_silent_wrong;
    /// Out-of-bounds contract enforcer.
    pub mod oob_access;
    /// Overflow contract gate.
    pub mod overflow_contract;
    /// Reference trust verifier.
    pub mod reference_trust;
    /// Self-audit gate.
    pub mod self_audit;
    /// Signature match checker.
    pub mod signature_match;
    /// Structural rules gate.
    pub mod structural_rules;
    /// Wire-format equivalence enforcer.
    pub mod wire_format_eq;
    /// Zero-stubs scanner.
    pub mod zero_stubs;
}

pub use crate::spec::{CategoryFinding, FindingLocation};
pub use enforcers::admission;
pub use enforcers::category_a::check_category_a_zero_overhead;
pub use enforcers::category_b::check_category_b_tripwire;
pub use enforcers::category_c::check_category_c_intrinsic;
pub use enforcers::reference_trust;
pub use enforcers::signature_match::enforce_signature;
pub use vyre_spec::{Category, IntrinsicTable};

// Convenience re-exports of enforcer submodules at enforce:: root so
// callers can write `enforce::atomics::…` instead of `enforce::enforcers::atomics::…`.
pub(crate) use enforcers::float_semantics as float;
pub(crate) use enforcers::signature_match as signature;
pub(crate) use enforcers::{atomics, barrier, determinism, float_semantics, wire_format_eq};

/// Convenience re-export of all category enforcement passes.
pub mod category {
    /// Run all category gates (A, B, and C) and return the merged findings.
    pub use crate::enforce::{
        check_category_a_zero_overhead, check_category_b_tripwire, check_category_c_intrinsic,
        Category, CategoryFinding, IntrinsicTable,
    };
    /// Run Category A, B, and C enforcement passes and merge the findings.
    ///
    /// This is the unified entry point for the category gate. It runs the
    /// zero-overhead checker, the intrinsic checker, and the forbidden-pattern
    /// tripwire in that order, appending all findings into a single vector.
    /// A non-empty return means at least one category invariant was violated.
    #[inline]
    pub fn check_all_categories(
        specs: &[crate::OpSpec],
        root: &std::path::Path,
    ) -> Vec<CategoryFinding> {
        let mut findings = check_category_a_zero_overhead(specs);
        findings.extend(check_category_c_intrinsic(specs));
        findings.extend(check_category_b_tripwire(root));
        findings
    }
}

/// Layer-oriented orchestration re-exports.
pub mod layers {
    pub use crate::enforce::enforcers::layer8_feedback_loop;
}