4.9 KiB
4.9 KiB
Tasks — @suaveplan/api-sandbox-wasm
Every checkbox MUST reflect work actually done in this change.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Spec authoring
- 1.1 Read design doc (§2.2, §5.2b, §14)
- 1.2 Read
openspec/AGENTS.mdSections 13 and 14 - 1.3 Draft
proposal.md - 1.4 Draft
specs/api-sandbox-wasm/spec.md - 1.5 Every requirement carries
**Verified by:**
2. Implementation
- 2.1 Scaffold
packages/api-stack/api/api-sandbox-wasm/ - 2.2
src/sandbox/—createWasmSandbox,WasmSandboxHandle - 2.3
src/preopens/—buildWasiPreopens(policy)+matchPreopen - 2.4
src/outbound/—buildWasiOutboundAllowlist(policy)+gateOutboundConnect - 2.5
src/imports/install-capability-imports/ - 2.6
src/error-codes/error-codes.tsviadefineCodes - 2.7
src/testing/run-wasm-conformance.ts - 2.8 Fixture WASM module builder under
tests/fixtures/build-wasm.ts(hand-encoded validwasi_snapshot_preview1module — nowabtbuild step) - 2.9
src/index.ts— explicit named re-exports - 2.10
package.jsonexports —./testing,./sandbox,./preopens,./outbound,./error-codes,./otelsubpaths - 2.11
src/wasi/wasi.ts—wasi_snapshot_preview1snapshot with policy-gatedpath_open - 2.12
src/policy/policy.ts—PermissionPolicystructural type +resolvePermissionPolicyZod boundary - 2.13
src/otel/otel.ts—plugin.permission_denied_totalcounter wiring
3. Tests
- 3.1
src/sandbox/sandbox.test.ts— 9 cases - 3.2
src/sandbox/sandbox.spec-conformance.test.ts— denial + dispose-idempotent - 3.3
src/preopens/preopens.test.ts— read-only / rw-prefix / dedup / matchPreopen - 3.4
src/outbound/outbound.test.ts— allow / deny / wildcard / port-pinned - 3.5
src/testing/run-wasm-conformance.test.ts— harness self-test passes - 3.6
tests/dep-graph.test.ts— runtime deps pinned to allowlist - 3.7 Every
it(...)carries{ timeout: 5000 }(30000 for WASM instantiation) - 3.8
src/wasi/wasi.test.ts— 13 cases covering every snapshot import path - 3.9
src/otel/otel.test.ts— instrument creation + denial labels - 3.10
src/policy/policy.test.ts— resolve / freeze / type-guard - 3.11
src/error-codes/error-codes.test.ts— registry shape + frozen - 3.12
src/imports/install-capability-imports/install-capability-imports.test.ts— allow / deny / async forwarding - 3.13
tests/fixtures/build-wasm.test.ts— validator + magic-bytes pinning
4. Documentation
- 4.1 Sibling
.mdper implementation.ts(9 files, all ≥200 words) - 4.2
README.md## Modules - 4.3 Update
CLAUDE.mdpackage listing
5. Pre-archive verification (the 5-gate triple)
- 5.1
bun run check—bunx biome check src/returns clean - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/api-sandbox-wasm— green (87 tests pass) - 5.3
bunx turbo test:coverage --filter=@suaveplan/api-sandbox-wasm— 100/100/100/100 across every src file - 5.4
bun scripts/openspec-conformance.ts packages/api-stack/api/api-sandbox-wasm— PASS (0 error / 0 warn / 0 info) - 5.5
bunx turbo build --filter=@suaveplan/api-sandbox-wasm— green
6. Pre-archive 7-row checklist
- 6.1
expectTypeOf<WasmSandboxHandle>properties asserted insandbox.test.ts - 6.2
resolvePermissionPolicyruns the Zod schema at the boundary; an out-of-range cpuPercent surfaces aZodError - 6.3 Every
SAND_WASM_*code thrown by a production path (verified byopenspec-conformancegate) - 6.4 Strict-mode: writable-preopen requires explicit
rw:prefix (preopens.test.ts::"rw prefix enables write") - 6.5 OTel instruments asserted with a real-shape
MeterProvider(otel.test.ts) - 6.6
dispose()idempotent (sandbox.spec-conformance.test.ts::"dispose is idempotent"+ harness pin) - 6.7 No retroactive tick — every checkbox in this file marked at the moment the corresponding work landed
7. Archive
- 7.1 Fold spec delta into
openspec/specs/api-sandbox-wasm/spec.md - 7.2 Move folder to
openspec/archive/2026-05-26-api-sandbox-wasm/ - 7.3 Tick
8.3in umbrella tasks (openspec/changes/api-plugin-foundation/tasks.md) - 7.4 Refresh
MANIFEST.md