Skip to content

Commit 480c7c2

Browse files
committed
Document wasip1 modules, the WASI shim and warmup deadline
1 parent a1d0bde commit 480c7c2

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

Documentation/PluginABI.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# BLE Parser Plugin ABI v1 (normative)
22

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.
66

77
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`.
1010

1111
## Module requirements
1212

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.
1521
- **No JIT / no threads required.** Pure computation only.
1622

1723
## Required exports
@@ -121,8 +127,11 @@ declare. `sha256` is mandatory for user-imported plugins and verified before loa
121127
## Resource limits & failure isolation
122128

123129
- 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).
126135
- A trap, allocation failure, out-of-bounds result, oversized output, or malformed CBOR is a
127136
failure; three consecutive failures quarantine the plugin. Failures never propagate — the UI
128137
falls back to the raw hex view.

0 commit comments

Comments
 (0)