vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use vyre_conform::{
    certify, Category, CertificateStrength, DataType, DispatchConfig, OpOutcome, OpSignature,
    OpSpec, Strictness, VyreBackend,
};

fn cpu(_: &[u8]) -> Vec<u8> {
    0_u32.to_le_bytes().to_vec()
}

fn underspecified_wgsl() -> String {
    "fn vyre_op(index: u32, input_len: u32) -> u32 { return 0u; }".to_string()
}

fn spec() -> OpSpec {
    OpSpec::builder("primitive.tensor.matmul")
        .signature(OpSignature {
            inputs: vec![DataType::Tensor, DataType::Tensor],
            output: DataType::Tensor,
        })
        .cpu_fn(cpu)
        .wgsl_fn(underspecified_wgsl)
        .category(Category::A {
            composition_of: vec![],
        })
        .laws(vec![])
        .strictness(Strictness::Strict)
        .version(1)
        .build()
        .expect("registry invariant violated")
}

struct Backend;

impl VyreBackend for Backend {
    fn name(&self) -> &str {
        "float-b6-mock"
    }

    fn dispatch(
        &self,
        _wgsl: &str,
        input: &[u8],
        _output_size: usize,
        _config: DispatchConfig,
    ) -> Result<Vec<u8>, String> {
        Ok(input.get(0..4).unwrap_or(&[0, 0, 0, 0]).to_vec())
    }
}

#[test]
fn certify_trips_b6_missing_accumulator_gate() {
    let cert = certify(&Backend, &[spec()], CertificateStrength::FastCheck).unwrap();
    assert_eq!(cert.ops()[0].outcome(), OpOutcome::Failed);
    assert!(cert.ops()[0].parity_failures()[0]
        .message
        .contains("SPEC.md:334"));
}