knut-bifrost-wasm-guest
A real wasm32-unknown-unknown guest for the WasmTransform host in crates/knut-bifrost/src/wasm.rs. It reads the input Arrow IPC stream, keeps only the rows where _gar_id is even, and writes the result back as an Arrow IPC stream — proving arrow-on-wasm works, and giving users a template for their own polyglot, out-of-line transforms.
This crate is not a knut workspace member: it only ever builds for wasm32-unknown-unknown, so the root Cargo.toml lists it under [workspace] exclude, and the crate carries an empty [workspace] table so it resolves a separate (wasm-only) dependency tree and lockfile.
Guest ABI
The module exports (matching the host):
memory— linear memory (auto-exported for acdylib).alloc(len: i32) -> i32— reservelenbytes, return the offset; the host writes the input IPC stream there. Implemented as aVec-leak.transform(ptr: i32, len: i32) -> i64— read the IPC at[ptr, ptr+len), filter, write an IPC stream to a leaked buffer, return it packed as(out_ptr as i64) << 32 | (out_len as i64).
Build
cargo build -p knut-bifrost-wasm-guest \
--target wasm32-unknown-unknown --release \
--manifest-path crates/knut-bifrost/wasm-guest/Cargo.toml
(or from inside this directory: cargo build --target wasm32-unknown-unknown --release).
The wasm32-unknown-unknown target must be installed (rustup target add wasm32-unknown-unknown). The artifact lands at:
target/wasm32-unknown-unknown/release/knut_bifrost_wasm_guest.wasm
(~1.2 MB; opt-level = "z" + lto + panic = "abort").
arrow-on-wasm
Arrow 58 compiles to wasm32-unknown-unknown out of the box — no patches, no shims, no feature gymnastics. arrow-array, arrow-schema, arrow-buffer, arrow-data, arrow-ipc, arrow-select, plus their transitive deps (flatbuffers, chrono, half, ahash, getrandom 0.2, num-*) all build cleanly for the bare-unknown target. getrandom 0.2 pulls in via ahash but nothing on the IPC/filter path actually calls it at runtime, so the default (no-js, no-custom) build links fine. We pass default-features = false to the arrow crates purely to keep the artifact lean.
Test it against the host
An #[ignore]d integration test in the parent crate loads this artifact and asserts only even-_gar_id rows survive:
# 1. build the guest (above), then:
cargo test -p knut-bifrost --features wasm --test wasm_guest -- --ignored
It is #[ignore]d because it depends on the pre-built .wasm; the normal cargo test run skips it.