Skip to content

Building

Kairos Substrate supports three distribution targets, each with different build profiles and optimization strategies.

The project requires Rust 1.94.0+ with the WASM target:

rust-toolchain.toml
[toolchain]
channel = "1.94.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]

Two release profiles serve different optimization goals:

[profile.release]
opt-level = "z" # Optimize for binary size
lto = true
codegen-units = 1
strip = true
[profile.release-native]
inherits = "release"
opt-level = 3 # Optimize for speed
strip = true
Profileopt-levelUse case
dev0Development and debugging
releasez (size)WASM targets only
release-native3 (speed)CLI, native library, Python bindings

The default --release profile uses opt-level = "z" for minimum binary size, which is correct for WASM but significantly underperforms for CPU-bound workloads. Always use --profile release-native for native builds.

Terminal window
cargo build -p kairos-cli --profile release-native

With TUI dashboard support:

Terminal window
cargo build -p kairos-cli --features tui --profile release-native

Output: target/release-native/kairos

Terminal window
# Core engine only
cargo build -p kairos-ffi --profile release-native
# With fly-by-wire session support
cargo build -p kairos-ffi --profile release-native --features fly-by-wire
# With research-mode constructors
cargo build -p kairos-ffi --profile release-native --features fly-by-wire,dynamic-config

Outputs:

  • Linux: target/release-native/libkairos_engine.so
  • macOS: target/release-native/libkairos_engine.dylib
  • Windows: target/release-native/kairos_engine.dll
  • Header: crates/kairos-ffi/kairos_engine.h
Terminal window
cd crates/kairos-pylib
maturin build --release
pip install target/wheels/kairos_engine-*.whl

Requires pip install maturin. Python 3.9+.

Terminal window
# Default (WasmEngine only)
wasm-pack build crates/kairos-wasm --target web
# With fly-by-wire
wasm-pack build crates/kairos-wasm --target web --features fly-by-wire
# For Node.js
wasm-pack build crates/kairos-wasm --target nodejs --features fly-by-wire

Output: npm package in crates/kairos-wasm/pkg/

Use cross for cross-platform builds:

Terminal window
cargo install cross
Terminal window
# Linux x86_64
cross build -p kairos-ffi --profile release-native --target x86_64-unknown-linux-gnu
# Linux ARM64
cross build -p kairos-ffi --profile release-native --target aarch64-unknown-linux-gnu
# Windows x86_64
cross build -p kairos-ffi --profile release-native --target x86_64-pc-windows-gnu
PlatformArchitectureTarget tripleNotes
Linuxx86_64x86_64-unknown-linux-gnuGLIBC 2.17+ (CentOS 7+)
LinuxARM64aarch64-unknown-linux-gnu
macOSx86_64x86_64-apple-darwin
macOSARM64aarch64-apple-darwinApple Silicon native
Windowsx86_64x86_64-pc-windows-gnuMinGW toolchain
Browser/NodeWASMwasm32-unknown-unknownVia wasm-pack

Feature flags control which capabilities are compiled in. See Feature Flags for the full matrix.

Key build-time choices:

FeatureEffect
tuiEnables kairos observe TUI dashboard (CLI only)
fly-by-wireEnables Substrate session and HITL protocol
slmEnables Sentinel SLM backend (SmolLM2 inference)
licenseEnables cryptographic policy/license verification
dynamic-configEnables research-mode constructors with file paths

The scripts/ci-check.sh script runs the standard verification pipeline:

Terminal window
./scripts/ci-check.sh # Full check
./scripts/ci-check.sh --quick # Lib tests only (faster)

Steps:

  1. cargo clippy --workspace -- -D warnings — lint with warnings-as-errors
  2. cargo test --workspace — full test suite (or --lib in quick mode)
  3. wasm-pack build — WASM build verification