wifi-densepose/v2/crates/homecore-plugin-example
ruv 424721fa16 feat(homecore-plugins/p2): Wasmtime runtime + example WASM plugin (resolves ADR-128 Q2)
- Implements WasmtimeRuntime in v2/crates/homecore-plugins/src/wasmtime_runtime.rs
  with a Wasmtime 25 Cranelift JIT engine. Registers 4 host imports via Linker:
  hc_state_get, hc_state_set, hc_state_subscribe, hc_log. Each plugin gets an
  isolated Store<PluginStoreData> holding a HomeCore handle + subscription list.

- Adds host_abi.rs documenting the JSON-over-linear-memory wire format (public
  ABI spec for plugin authors). Max buffer 64 KiB. ConfigEntryJson and
  StateChangedEventJson are the canonical wire types.

- Creates v2/crates/homecore-plugin-example/ (wasm32-unknown-unknown, excluded
  from workspace per wifi-densepose-wasm-edge pattern). The plugin monitors
  sensor.test_temp and sets binary_sensor.test_alert on/off at 25/20 thresholds.

- Adds tests/integration.rs with 3 tests: compiled .wasm end-to-end round-trip,
  WAT-based fallback (always runs), and linker smoke test. All 15 tests pass
  (12 unit + 3 integration) under --features wasmtime.

- ADR-128 Q2 resolved: Wasmtime is the chosen runtime for P2. WASM3 stays as
  future fallback under --features wasm3 for constrained hardware (ADR-128 §8).

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-25 19:04:31 -04:00
..
src feat(homecore-plugins/p2): Wasmtime runtime + example WASM plugin (resolves ADR-128 Q2) 2026-05-25 19:04:31 -04:00
Cargo.lock feat(homecore-plugins/p2): Wasmtime runtime + example WASM plugin (resolves ADR-128 Q2) 2026-05-25 19:04:31 -04:00
Cargo.toml feat(homecore-plugins/p2): Wasmtime runtime + example WASM plugin (resolves ADR-128 Q2) 2026-05-25 19:04:31 -04:00
README.md feat(homecore-plugins/p2): Wasmtime runtime + example WASM plugin (resolves ADR-128 Q2) 2026-05-25 19:04:31 -04:00

README.md

homecore-plugin-example

Example WASM plugin for the HOMECORE plugin system (ADR-128 P2).

Demonstrates the complete ADR-128 host ABI round-trip:

  • plugin_setup — subscribes to sensor.test_temp state changes
  • plugin_handle_state_changed — sets binary_sensor.test_alert to on when temp > 25, off when temp < 20

Build

# Ensure the wasm32 target is installed (once)
rustup target add wasm32-unknown-unknown

# Build the example plugin (from this directory)
cargo build --target wasm32-unknown-unknown --release -p homecore-plugin-example

Output: target/wasm32-unknown-unknown/release/homecore_plugin_example.wasm

Run the integration test

# From v2/
cargo test -p homecore-plugins --features wasmtime

ABI

See homecore-plugins/src/host_abi.rs for the authoritative host ABI spec.