# clm-kernel (`0.0.21`, Rust crate `clm_rust_core`)
`clm-kernel` (library target `clm_rust_core`) is the Rust 2024 microkernel for the Cubical Logic Model (CLM). It implements content-addressed `MCard` storage, `BLAKE3` `g_time` provenance, bitset `PlaceTypeLattice` inference, Colored Petri Net execution, Cellular Sheaf Cohomology, and PyO3 acceleration bindings.
## Cargo features
`Cargo.toml` defines composable feature flags so downstream crates and WebAssembly targets compile only the layers they need:
- **`core`**: Minimal zero-network, zero-database core (`BLAKE3` hashing, `MCard`/`PCard`/`VCard`, `TypeLattice`, `PlaceTypeLattice`, `ColoredPetriVM`, Open Petri Pullback, Sheaf Cohomology, and bialgebraic bisimulation). Compiles cleanly for `wasm32-unknown-unknown` with `--no-default-features --features core`.
- **`fiber`**: Cordis `Fiber` context isolation, `DisposableList`, and `SavepointGuard`.
- **`crdt`**: Vector clocks, G-Set handle history, and `SyncContract v1` state convergence.
- **`db`**: Dual-pool SQLite storage (`rusqlite` WAL mode, statement cache, and `SqlSavepointPool`).
- **`bundled-sqlite`**: Compiles SQLite from source alongside `db`.
- **`async`**: Tokio asynchronous task runtime.
- **`net`**: QUIC (`quinn`) and mDNS (`mdns-sd`) Satori mesh transport.
- **`native`** *(default)*: Enables `core`, `crdt`, `fiber`, `db`, `async`, and `net`.
- **`full`**: Alias for the complete `native` profile.
- **`python`**: PyO3 extension bindings (`clm_rust_core` native module for `clm_py_core`).
## Usage
Add `clm-kernel` `0.0.21` to `Cargo.toml` (the library crate name is `clm_rust_core`):
```toml
[dependencies]
clm-kernel = { version = "0.0.21", default-features = false, features = ["core", "fiber"] }
```
For `wasm32-unknown-unknown` builds, enable only `core`:
```bash
cargo check --target wasm32-unknown-unknown --no-default-features --features core
```
### Quick start
```rust
use clm_rust_core::prelude::*;
fn main() -> Result<()> {
let hash = raw_hash_bytes(b"hello clm 0.0.21");
println!("BLAKE3 digest: {}", hash);
let did = AgentDid::parse("did:pkc:node-1")?;
println!("Agent DID: {}", did.as_str());
Ok(())
}
```
### Contract parameters
`clm_rust_core::layer0::parameter_context::ParameterContext` holds the contract's typed parameters, generated from the CLM runtime contract alongside the `layer0::vocabulary*` constant modules. `from_mapping` resolves CLI (contract keys) over environment (`CLM_*` names) over the contract default and returns `ParameterBoundaryError` for a value outside its refinement:
```rust
use std::collections::BTreeMap;
use clm_rust_core::layer0::parameter_context::ParameterContext;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let env = BTreeMap::from([("CLM_SQLITE_BUSY_TIMEOUT_MS".to_string(), "8000".to_string())]);
let context = ParameterContext::from_mapping(&env, &BTreeMap::new())?;
assert_eq!(context.sqlite_busy_timeout_ms, 8000);
Ok(())
}
```
Production dispatch matches canonical catalog ids (`evaluator::dispatch::catalog_ids::OP_*`, resolved from module paths and operation names by `op_id_for`); an id with no handler is `DispatchError::Unbound`, raised before any receipt or store write.
## CLI binaries
Building with default (`native`) features produces two binaries:
- `clm_rust_core`: Full `clmEval` CLI evaluator, conformance runner, and formal oracle dispatcher.
- `clm_version_cli`: Zero-framework fast version binary dispatched by `./clmEval version`.
```bash
cargo run --release --bin clm_rust_core -- version --json
```
## License
MIT License. Source code, formal proofs, and Python and TypeScript kernels live in the [CLM repository](https://github.com/xlp0/CLM).