clm-kernel 0.0.23

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
//! Stage 1.4 native runtime dispatch.
//!
//! Provides a single `petri_run_net` entry point dispatching directly to the
//! native CPN-VM executor (`cpn::vm`).

/// Run a Petri net topology, dispatching to the native CPN-VM executor.
pub fn petri_run_net(topo_file: &str, clm_root: &str) -> Result<String, String> {
    crate::cpn::vm::petri_run_net(topo_file, clm_root)
}

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

    #[test]
    fn test_dispatch_native_backend() {
        // Verify the dispatcher delegates to the native backend. The native
        // backend will fail to parse an intentionally invalid YAML, which is
        // expected and proves the native code path is reached.
        let dir = std::env::temp_dir().join("clm_runtime_dispatch_native_test");
        std::fs::create_dir_all(&dir).unwrap();
        let path = dir.join("net.yaml");
        {
            let mut f = std::fs::File::create(&path).unwrap();
            f.write_all(b"not a valid topology\n").unwrap();
        }
        let result = petri_run_net(path.to_str().unwrap(), "/tmp/clm_root");
        assert!(result.is_err());
    }
}