updated skills
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# @suaveplan/api-sandbox-wasm-host-bridge - Host bridge wrapping a @suaveplan/api-sandbox-wasm WasmSandboxHandle as a @suaveplan/api-host PluginModule. Validates the WASM ABI surface (__suaveplan_alloc / free / handle_request / routes / start / dispose + memory) at bridge-init, marshals SerializedRequest bytes into linear memory via __suaveplan_alloc, invokes __suaveplan_handle_request, reads the packed (responsePtr, responseLen) result, JSON-decodes the SerializedResponse, and unmarshals it back to a host Response. Traps surface as SAND_WASM_BRIDGE.HANDLER_TRAPPED with classified trapKind; denied capabilities surface as SAND_PERM.DENIED.
|
||||
# @suaveplan/api-sandbox-wasm-host-bridge - Host bridge wrapping a @suaveplan/api-sandbox-wasm WasmSandboxHandle as a @suaveplan/api-host PluginModule. Validates the WASM ABI surface (__suaveplan_alloc / free / handle_request / routes / start / dispose + memory) at bridge-init, marshals SerializedRequest bytes into linear memory via__suaveplan_alloc, invokes __suaveplan_handle_request, reads the packed (responsePtr, responseLen) result, JSON-decodes the SerializedResponse, and unmarshals it back to a host Response. Traps surface as SAND_WASM_BRIDGE.HANDLER_TRAPPED with classified trapKind; denied capabilities surface as SAND_PERM.DENIED.
|
||||
|
||||
Host-integration layer that wraps a `@suaveplan/api-sandbox-wasm` `WasmSandboxHandle` as a `@suaveplan/api-host` `PluginModule`. Sandboxed-tier plugins compiled to WebAssembly export the `__suaveplan_*` ABI surface (`memory`, `__suaveplan_alloc`, `__suaveplan_free`, `__suaveplan_handle_request`, `__suaveplan_routes`, `__suaveplan_start`, `__suaveplan_dispose`); this bridge validates that surface, discovers the guest's routes once at bridge-init time, and emits per-route closures that marshal `SerializedRequest` records through the guest's linear memory.
|
||||
|
||||
|
||||
@@ -15,18 +15,19 @@ The split from `bridge.ts` is structural rather than mechanical: every
|
||||
direct-variant import (`abi-direct/wasm-abi`, `abi-direct/memory`,
|
||||
`abi-direct/marshal`) is referenced from this file only, so a future
|
||||
removal of the direct variant collapses to deleting `bridge-direct.ts`
|
||||
|
||||
+ `abi-direct/` and trimming the dispatcher.
|
||||
|
||||
## Features
|
||||
|
||||
- `buildDirectInstall(options)` — accepts a `DirectVariantOptions`,
|
||||
+ `buildDirectInstall(options)` — accepts a `DirectVariantOptions`,
|
||||
returns the bridge's `SandboxedWasmPluginInstall`.
|
||||
- Trap classification, capability-gate routing through
|
||||
+ Trap classification, capability-gate routing through
|
||||
`SAND_PERM.DENIED`, idempotent lifecycle — preserved exactly from
|
||||
the shipped contract.
|
||||
- Instrument registry plumbed with `abi_variant: "direct-i32-i64"` on
|
||||
+ Instrument registry plumbed with `abi_variant: "direct-i32-i64"` on
|
||||
every counter and histogram emission.
|
||||
- Route closures are pure functions of the manifest + ABI exports;
|
||||
+ Route closures are pure functions of the manifest + ABI exports;
|
||||
re-instantiating the bridge against the same sandbox produces
|
||||
identical `PipelineRoute[]` records.
|
||||
|
||||
@@ -81,7 +82,7 @@ try {
|
||||
Internal entrypoint called by the dispatcher. Public consumers should
|
||||
use `createSandboxedWasmPluginModule` from the package root.
|
||||
|
||||
- `options: DirectVariantOptions` — `sandbox`, `manifest`, optional
|
||||
+ `options: DirectVariantOptions` — `sandbox`, `manifest`, optional
|
||||
`instruments`.
|
||||
|
||||
Throws `SandboxWasmBridgeError` with code `INVALID_PLUGIN_SURFACE` if
|
||||
@@ -89,14 +90,14 @@ ABI validation fails BEFORE any guest call.
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
- The function never touches the sandbox's `instance` directly past
|
||||
+ The function never touches the sandbox's `instance` directly past
|
||||
the ABI validator — the typed `WasmAbiExports` view is the single
|
||||
hand-off point.
|
||||
- `freeBuffer` is called in a `finally` block so the request pointer
|
||||
+ `freeBuffer` is called in a `finally` block so the request pointer
|
||||
is released even when the response unmarshal throws. The response
|
||||
pointer is released BEFORE unmarshal runs because Zod parsing may
|
||||
allocate additional bytes that would shadow the original buffer.
|
||||
- Capability denials surface through the canonical
|
||||
+ Capability denials surface through the canonical
|
||||
`SAND_PERM.DENIED` code, not the bridge-local `CAPABILITY_DENIED`.
|
||||
Operators see one code for "permission denied" regardless of which
|
||||
bridge raised it.
|
||||
|
||||
Reference in New Issue
Block a user