Goal: Run deterministic work (parse, aggregate, scoring) in WASM so it does not consume LLM tokens.
Scope: The WASM adapter calls pre-compiled .wasm/.wat module exports. It does not compile AINL graphs to WASM. See STATUS.yaml marketing_claims_boundary for the distinction.
pip install 'ainativelang[wasm]'
# or
pip install wasmtimeainl doctor reports wasmtime availability when the package is installed.
adapters/openclaw_integration.py registers WasmAdapter when wasmtime is available and demo modules exist under demo/wasm/ (metrics, health — .wasm or .wat).
Custom deployments: extend the same pattern — map logical names to absolute paths via env or code, then call R wasm.CALL ... from AINL (see runtime WasmAdapter contract).
{
"enable": ["wasm"],
"wasm": {
"modules": {
"metrics": "/path/to/metrics.wasm",
"health": "/path/to/health.wasm"
}
}
}{
"adapters": {
"wasm": {
"modules": {
"metrics": "/opt/ainl/wasm/metrics.wasm"
}
}
}
}# Compact syntax
result = wasm.CALL "metrics.add" 2 3
# Opcode syntax
R wasm.CALL metrics.add 2 3 ->result
The first argument to CALL is <module>.<export>. Additional arguments are positional and passed to the WASM function.
examples/wasm/wasm_add_minimal.ainl— minimal add callexamples/wasm/wasm_lead_score.ainl— scoring with branchexamples/wasm/wasm_health_check.ainl— health check with branch
All registered in tooling/artifact_profiles.json under strict-valid.
- Module allowlist:
WasmAdapter(modules=..., allowed_modules=...)restricts which modules can be invoked. - WASI imports are not supported (sandboxed compute only).
- See
docs/SECURITY_REVIEW.mdanddocs/operations/SANDBOX_EXECUTION_PROFILE.mdfor the broader security model.
- Identify a hot path that is pure/deterministic (same inputs → same outputs).
- Add or reuse a small module; unit-test the WASM boundary.
- Route one label or monitor to WASM; keep the Python fallback until parity is proven.
- Expand only after benchmarks show real savings.
This is not a substitute for gateway caps or embedding retrieval — it removes LLM calls only where logic is already non-LLM.
- Not whole-graph WASM compilation (no
ainl emit --target wasm) - Not browser-targeted WASM (no DOM/web API access)
- Not on-chain smart contract execution
These are explicitly listed as never_shipped or never in STATUS.yaml.