Files
2026-05-27 23:29:53 +01:00

4.0 KiB

Tasks — @suaveplan/api-sandbox-vm

Every checkbox MUST reflect work actually done in this change.

0. Pre-flight (non-negotiable)

  • 0.1 Confirm clean working tree (git status reports nothing) and no in-flight worktrees with uncommitted work (git worktree list then git status in 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.md matches find packages -maxdepth 3 -name package.json count. Drift here means a prior change archived without regenerating the manifest.

1. Spec authoring

  • 1.1 Read design doc (§2.2, §5.2b)
  • 1.2 Read openspec/AGENTS.md Sections 13 and 14
  • 1.3 Draft proposal.md
  • 1.4 Draft specs/api-sandbox-vm/spec.md
  • 1.5 Every requirement carries **Verified by:** line

2. Implementation

  • 2.1 Scaffold packages/api-stack/api/api-sandbox-vm/
  • 2.2 src/sandbox/ — createVmSandbox, VmSandboxHandle, frozen-globals construction
  • 2.3 src/globals/frozen-globals/ — curated allowlist
  • 2.4 src/proxies/fs-proxy/ — host-proxied fs
  • 2.5 src/proxies/fetch-proxy/ — host-proxied fetch
  • 2.6 src/proxies/install-capability-proxies/ — wire proxy receiver into sandbox
  • 2.7 src/error-codes/error-codes.ts via defineCodes (subfolder layout per §"Package Structure")
  • 2.8 src/testing/run-vm-conformance.ts
  • 2.9 src/index.ts — explicit named re-exports
  • 2.10 package.json exports — ./testing subpath

3. Tests

  • 3.1 src/sandbox/sandbox.test.ts — 19 cases including all SAND_VM.* codes
  • 3.2 src/sandbox/sandbox.spec-conformance.test.ts — denial metric + dispose idempotency
  • 3.3 src/proxies/fs-proxy/fs-proxy.test.ts, src/proxies/fetch-proxy/fetch-proxy.test.ts
  • 3.4 src/testing/run-vm-conformance.test.ts — in-package fixture passes the harness
  • 3.5 tests/dep-graph.test.ts
  • 3.6 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 Sibling .md per implementation .ts
  • 4.2 README.md ## Modules
  • 4.3 Update CLAUDE.md package listing

5. Pre-archive verification (the 5-gate triple)

  • 5.1 bun run check — package-local biome clean
  • 5.2 bunx turbo lint typecheck test:coverage --filter=@suaveplan/api-sandbox-vm — green
  • 5.3 Coverage 100/100/100/100 (statements/branches/functions/lines)
  • 5.4 bun scripts/openspec-conformance.ts packages/api-stack/api/api-sandbox-vm — exit 0 (0 error, 0 warn)
  • 5.5 bunx turbo build --filter=@suaveplan/api-sandbox-vm — green

6. Pre-archive 7-row checklist

  • 6.1 Generics threaded: VmSandboxHandle<Caps> parameter flows through createVmSandbox<Caps>
  • 6.2 Zod-equivalent schema gating: PermissionsManifest typed boundary (api-types) drives createPermissionChecker; capability decisions checked synchronously before host call
  • 6.3 Every SAND_VM.* code thrown by at least one production path (eval/Function trap, linker refuse, SourceTextModule resolver, dispose, permission denials)
  • 6.4 Strict-mode behaviours: dynamic-code constructors rejected via Proxy-guarded globalThis traps + per-property eval/Function overrides + codeGeneration:{strings:false,wasm:false} defence-in-depth
  • 6.5 OTel instruments asserted with real in-memory MeterProvider (CUMULATIVE), metrics.disable() between cases for clean re-binding
  • 6.6 Lifecycle dedup: dispose() second/third call is a no-op (test covers triple-dispose)
  • 6.7 No retroactive ticks

7. Archive

  • 7.1 Fold spec delta into openspec/specs/api-sandbox-vm/spec.md
  • 7.2 Move to openspec/archive/2026-05-26-api-sandbox-vm/
  • 7.3 Tick 8.2 in umbrella tasks
  • 7.4 Refresh MANIFEST.md