mirror of
https://github.com/ruvnet/RuView.git
synced 2026-10-23 07:02:44 -05:00
CI fixes (both failures on PR #2062 were in this branch): - harness/ruview: remove `2.11.0` literals from training remedies; the ADR-265 D3 version-literal gate rejects them. - ruview-kernel workflow: install wasm32 for the toolchain pinned by v2/rust-toolchain (the action only added it to `stable`); build.mjs now fails fast with the exact `rustup target add` remedy. Kernel optimization (ADR-368 amendment): - New `analyze_flat` / `session_push_flat` ops via `call_f64`: WASM `rvk_call_f64` (alignment-agnostic bytes) and napi `callF64(Float64Array)`. `analyze()`/`session.push()` pack uniform frames automatically; irregular input keeps the JSON path and its per-frame errors. `analyzeFlat()` is the zero-copy entry. Shared `Session::step` makes both paths byte-identical on identical f64 inputs (Rust test), and the binary path avoids serde_json's non-correctly-rounded float parsing. - MEASURED (`ruview-kernel bench --seconds 120`, one Linux x64 host): 2.82x (wasm) and 2.45x (napi) faster than the JSON transport. - Profiled remaining cost (examples/profile_stages.rs): heart-rate ACF in wifi-densepose-vitals dominates; left for a separate, output-reviewed change. Rejected WASM +simd128 and opt-level=s after three measured runs (bench/wasm-variants.mjs). Device e2e (ADR-373 amendment): - test/e2e/devices.e2e.mjs + `npm run test:e2e:devices` + new workflow ruview-device-e2e.yml: pty-emulated MR60BHA2 and RPLIDAR through real pyserial, a UDP ESP32 node, and the real iPhone relay, via the CLI. - mmWave auto-detect keeps probe frames and reads only the remainder; iPhone LiDAR gains max_frames and returns immediately when refused. Suite wall time 19.6 s -> 5.6 s (MEASURED, dev container). Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_015H55jmprfz4oHWXSFbX5rf
35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
//! napi-rs transport for `ruview-kernel` (ADR-368).
|
|
//!
|
|
//! Deliberately exposes only the kernel's single string ABI so the native
|
|
//! and WASM backends of `@ruvnet/ruview-kernel` stay behaviourally identical.
|
|
#![deny(clippy::all)]
|
|
|
|
use napi::bindgen_prelude::Float64Array;
|
|
use napi_derive::napi;
|
|
|
|
/// JSON ABI version; must equal the WASM module's `rvk_abi_version()`.
|
|
#[napi]
|
|
pub fn abi_version() -> u32 {
|
|
ruview_kernel::ABI_VERSION
|
|
}
|
|
|
|
/// Run one kernel operation: operation name + JSON request → JSON envelope.
|
|
/// A Rust panic is converted into an `internal` error envelope.
|
|
#[napi]
|
|
pub fn call(op: String, input: String) -> String {
|
|
std::panic::catch_unwind(|| ruview_kernel::call(&op, &input)).unwrap_or_else(|_| {
|
|
r#"{"ok":false,"error":{"code":"internal","message":"kernel panicked"}}"#.to_string()
|
|
})
|
|
}
|
|
|
|
/// Binary fast path: frame data as a `Float64Array` (`analyze_flat`,
|
|
/// `session_push_flat`), same envelope as [`call`].
|
|
#[napi]
|
|
pub fn call_f64(op: String, input: String, data: Float64Array) -> String {
|
|
// The kernel only reads the slice, so observing it after a panic is sound.
|
|
let values = std::panic::AssertUnwindSafe(&data[..]);
|
|
std::panic::catch_unwind(move || ruview_kernel::call_f64(&op, &input, *values)).unwrap_or_else(
|
|
|_| r#"{"ok":false,"error":{"code":"internal","message":"kernel panicked"}}"#.to_string(),
|
|
)
|
|
}
|