3.1 KiB
3.1 KiB
Tasks — Sandbox WASM Host Bridge
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree and no in-flight worktrees with uncommitted work
- 0.2 Account for every worktree under
.claude/worktrees/ - 0.3
MANIFEST.mdpackage count matchesfind packages -maxdepth 3 -name package.json - 0.4 §0a Sync: worktree-isolated agents fast-forward to orchestrator-supplied SHA
1. Dependency check
- 1.1
@suaveplan/api-types/sandbox-bridgesubpath exists (authored by this change ahead of the sibling vm-bridge merge). - 1.2
@suaveplan/api-sandbox-wasmexists withWasmSandboxHandlesurface. - 1.3
@suaveplan/api-host.installPluginaccepts thePluginModuleshape (bridge returnsSandboxedWasmPluginInstallcarrying bothmoduleandroutes).
2. Package scaffold
- 2.1
packages/api-stack/api/api-sandbox-wasm-host-bridge/with package.json, tsconfig, vite, vitest configs. - 2.2 Deps:
@suaveplan/api-sandbox-wasm,@suaveplan/api-host,@suaveplan/api-types,@suaveplan/api-sandbox-permissions,@suaveplan/error,tslib,zod.
3. Implementation
- 3.1
src/bridge/bridge.ts—createSandboxedWasmPluginModule({ sandbox, manifest })factory. - 3.2
src/wasm-abi/abi.ts—__suaveplan_alloc/free/handle_request/routes/start/disposeexport-name constants + signatures. - 3.3
src/wasm-abi/abi-validator.ts— validates the WASM module exports all required functions before bridge init. - 3.4
src/marshal/marshal.ts— JSON-encodeSerializedRequestinto linear memory, decodeSerializedResponseout. - 3.5
src/memory/memory.ts— alloc/free wrappers with trap protection. - 3.6
src/route-discovery/route-discovery.ts— calls__suaveplan_routesat init time. - 3.7
src/lifecycle/lifecycle.ts—__suaveplan_start/__suaveplan_disposeforwarders with idempotency. - 3.8
src/error-codes/error-codes.ts— 7 SAND_WASM_BRIDGE codes + SandboxWasmBridgeError with public constructor. - 3.9
src/instruments/instruments.ts— bridge OTel counters. - 3.10 Paired
.mdper implementation file.
4. Conformance harness
- 4.1
src/testing/wasm-host-bridge-conformance/wasm-host-bridge-conformance.tswith 5 invariants. - 4.2 Sibling .md, .types.ts, .test.ts, index.ts.
5. Tests
- 5.1
tests/fixtures/build-wasm.ts— hand-coded minimal WASM binary that exports the suaveplan ABI (returns canned routes + response). No external compile dep. - 5.2 Real
api-sandbox-wasm+ realapi-hostintegration test intests/integration/full-flow.test.tsagainst the fixture WASM. - 5.3 100% istanbul coverage on touched modules.
- 5.4 Public-constructor lint clean.
- 5.5
bunx --bun turbo lint typecheck test:coverage --filter=@suaveplan/api-sandbox-wasm-host-bridgegreen.
6. Archive
- 6.1 Fold delta into
openspec/specs/api-sandbox-wasm-host-bridge/spec.md. (deferred to merge step) - 6.2 Move folder →
openspec/archive/2026-05-27-api-sandbox-wasm-host-bridge/. (deferred to merge step) - 6.3 Refresh
MANIFEST.md.