You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# ADR-084: ruvllm-wasm — First Functional npm Publish
2
+
3
+
**Status**: Accepted
4
+
**Date**: 2026-03-06
5
+
**Authors**: RuVector Team
6
+
**Deciders**: ruv
7
+
**Related**: ADR-083 (Brain Training Loops), Issue #238 (placeholder deprecation)
8
+
9
+
## 1. Context
10
+
11
+
The `@ruvector/ruvllm-wasm` npm package (v0.1.0) was a placeholder — published without compiled WASM binaries. It was deprecated in PR #239. Meanwhile, the Rust crate `ruvllm-wasm` (v2.0.0) contains substantial working code:
12
+
13
+
| Subsystem | Status | Exports |
14
+
|-----------|--------|---------|
15
+
| KV Cache (two-tier FP32+u8) | Working |`KvCacheWasm`, `KvCacheConfigWasm`|
16
+
| Memory (arena + buffer pool) | Working |`InferenceArenaWasm`, `BufferPoolWasm`|
17
+
| Chat Templates (7 formats) | Working |`ChatTemplateWasm`, `ChatMessageWasm`|
18
+
| HNSW Semantic Router | Working |`HnswRouterWasm`, `PatternWasm`, `RouteResultWasm`|
19
+
| MicroLoRA (rank 1-4) | Working |`MicroLoraWasm`, `AdaptFeedbackWasm`|
20
+
| SONA Instant Learning | Working |`SonaInstantWasm`, `SonaConfigWasm`|
21
+
| Web Workers | Working |`ParallelInference`, feature detection |
| IntelligentLLM (combined) | Commented out | Pending API compatibility |
24
+
25
+
## 2. Decision
26
+
27
+
### 2.1 Fix WASM Build
28
+
29
+
The Rust 1.91 compiler has a codegen bug where release-profile optimizations produce invalid WASM (type mismatch: `expected i32, found f64` in wasm-bindgen post-processing). Debug builds validate fine.
30
+
31
+
**Workaround**: Build with `codegen-units=256` + `lto=off`. This prevents cross-function optimization passes that trigger the bug while still producing optimized output.
32
+
33
+
```bash
34
+
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256 \
35
+
CARGO_PROFILE_RELEASE_LTO=off \
36
+
wasm-pack build crates/ruvllm-wasm --target web --scope ruvector --release
37
+
```
38
+
39
+
Added `wasm-opt = false` to `[package.metadata.wasm-pack.profile.release]` since wasm-opt's validator also rejects the binary.
40
+
41
+
### 2.2 Gate WebGPU Features
42
+
43
+
WebGPU `web-sys` features (`gpu_map_mode`, `GpuSupportedLimits`, 28 GPU types) were compiled unconditionally, inflating binary size. Moved all GPU web-sys features behind the `webgpu` Cargo feature flag.
44
+
45
+
Removed unused `bytemuck` dependency and `gpu_map_mode` / `GpuSupportedLimits` (declared but never referenced in source).
46
+
47
+
### 2.3 Publish as v2.0.0
48
+
49
+
Published `@ruvector/ruvllm-wasm@2.0.0` to npm with:
50
+
- Compiled WASM binary (~435 KB, ~150 KB gzipped)
51
+
- TypeScript definitions (`.d.ts`)
52
+
- ES module JS glue code
53
+
- Accurate README with working API examples
54
+
55
+
### 2.4 README
56
+
57
+
Replaced placeholder README with accurate documentation covering all exported types, working code examples, and browser compatibility table.
0 commit comments