- 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> |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
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 tosensor.test_tempstate changesplugin_handle_state_changed— setsbinary_sensor.test_alerttoonwhen temp > 25,offwhen 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.