|
1 | 1 | # BLE Parser Plugin ABI v1 (normative) |
2 | 2 |
|
3 | | -A plugin is a core WebAssembly module (`wasm32-unknown-unknown`, import-free) that decodes a BLE |
4 | | -advertisement field or GATT attribute value into structured fields. The host is |
5 | | -`BluetoothExplorerPluginEngine`, running the module under the WasmKit interpreter. |
| 3 | +A plugin is a WebAssembly module that decodes a BLE advertisement field or GATT attribute value into |
| 4 | +structured fields. The host is `BluetoothExplorerPluginEngine`, running the module under the WasmKit |
| 5 | +interpreter. |
6 | 6 |
|
7 | 7 | This document is normative. The host implementation lives in |
8 | | -`Sources/BluetoothExplorerPluginEngine/PluginABI.swift`; the reference plugin is |
9 | | -`Sources/BluetoothExplorerPluginEngine/Plugins/battery-level.wat`. |
| 8 | +`Sources/BluetoothExplorerPluginEngine/PluginABI.swift`; plugins are authored in Embedded Swift |
| 9 | +against `PluginSDK/BLEPluginSDK`, with a complete example in `PluginSDK/Examples/BatteryLevel`. |
10 | 10 |
|
11 | 11 | ## Module requirements |
12 | 12 |
|
13 | | -- **Import-free.** The module must not import any host function. A module with any import is |
14 | | - rejected at load. |
| 13 | +- **Target.** `wasm32-unknown-wasip1` built as a **reactor** (`-mexec-model=reactor`) — what the |
| 14 | + Embedded Swift SDK emits. Import-free core modules are also accepted. |
| 15 | +- **Imports.** Only `wasi_snapshot_preview1` may be imported; any other import module is rejected at |
| 16 | + load. The host satisfies those imports with a minimal shim rather than a real WASI |
| 17 | + implementation: `random_get` fills guest memory with real random bytes (the Embedded Swift runtime |
| 18 | + requires it), and every other WASI function is stubbed to return success with zeroed results. A |
| 19 | + plugin therefore has no filesystem, network, environment or clock access, and cannot call back |
| 20 | + into the host. |
15 | 21 | - **No JIT / no threads required.** Pure computation only. |
16 | 22 |
|
17 | 23 | ## Required exports |
@@ -121,8 +127,11 @@ declare. `sha256` is mandatory for user-imported plugins and verified before loa |
121 | 127 | ## Resource limits & failure isolation |
122 | 128 |
|
123 | 129 | - Guest linear memory is capped at `maxMemoryPages` (default 16, ceiling 64) × 64 KiB. |
124 | | -- Each call has a wall-clock deadline (default 50 ms). On timeout the plugin is **quarantined** |
125 | | - (WasmKit has no execution interruption; the wedged call is abandoned). |
| 130 | +- Each parse call has a wall-clock deadline (default 50 ms). The one-time cost of parsing, |
| 131 | + instantiating and `_initialize`-ing a module is bounded separately by a generous warmup deadline |
| 132 | + (default 5 s), and WasmKit compiles eagerly, so translation never lands on the per-call deadline. |
| 133 | + On timeout the plugin is **quarantined** (WasmKit has no execution interruption; the wedged call |
| 134 | + is abandoned). |
126 | 135 | - A trap, allocation failure, out-of-bounds result, oversized output, or malformed CBOR is a |
127 | 136 | failure; three consecutive failures quarantine the plugin. Failures never propagate — the UI |
128 | 137 | falls back to the raw hex view. |
0 commit comments