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

71 lines
4.0 KiB
Markdown

# Tasks — `@suaveplan/api-sandbox-vm`
> Every checkbox MUST reflect work actually done in this change.
## 0. Pre-flight (non-negotiable)
- [x] 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)
- [x] 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.
- [x] 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
- [x] 1.1 Read design doc (§2.2, §5.2b)
- [x] 1.2 Read `openspec/AGENTS.md` Sections 13 and 14
- [x] 1.3 Draft `proposal.md`
- [x] 1.4 Draft `specs/api-sandbox-vm/spec.md`
- [x] 1.5 Every requirement carries `**Verified by:**` line
## 2. Implementation
- [x] 2.1 Scaffold `packages/api-stack/api/api-sandbox-vm/`
- [x] 2.2 `src/sandbox/` — `createVmSandbox`, `VmSandboxHandle`, frozen-globals construction
- [x] 2.3 `src/globals/frozen-globals/` — curated allowlist
- [x] 2.4 `src/proxies/fs-proxy/` — host-proxied fs
- [x] 2.5 `src/proxies/fetch-proxy/` — host-proxied fetch
- [x] 2.6 `src/proxies/install-capability-proxies/` — wire proxy receiver into sandbox
- [x] 2.7 `src/error-codes/error-codes.ts` via `defineCodes` (subfolder layout per §"Package Structure")
- [x] 2.8 `src/testing/run-vm-conformance.ts`
- [x] 2.9 `src/index.ts` — explicit named re-exports
- [x] 2.10 `package.json` exports — `./testing` subpath
## 3. Tests
- [x] 3.1 `src/sandbox/sandbox.test.ts` — 19 cases including all SAND_VM.* codes
- [x] 3.2 `src/sandbox/sandbox.spec-conformance.test.ts` — denial metric + dispose idempotency
- [x] 3.3 `src/proxies/fs-proxy/fs-proxy.test.ts`, `src/proxies/fetch-proxy/fetch-proxy.test.ts`
- [x] 3.4 `src/testing/run-vm-conformance.test.ts` — in-package fixture passes the harness
- [x] 3.5 `tests/dep-graph.test.ts`
- [x] 3.6 Every `it(...)` carries `{ timeout: 5000 }`
## 4. Documentation
- [x] 4.1 Sibling `.md` per implementation `.ts`
- [x] 4.2 `README.md` `## Modules`
- [x] 4.3 Update `CLAUDE.md` package listing
## 5. Pre-archive verification (the 5-gate triple)
- [x] 5.1 `bun run check` — package-local biome clean
- [x] 5.2 `bunx turbo lint typecheck test:coverage --filter=@suaveplan/api-sandbox-vm` — green
- [x] 5.3 Coverage 100/100/100/100 (statements/branches/functions/lines)
- [x] 5.4 `bun scripts/openspec-conformance.ts packages/api-stack/api/api-sandbox-vm` — exit 0 (0 error, 0 warn)
- [x] 5.5 `bunx turbo build --filter=@suaveplan/api-sandbox-vm` — green
## 6. Pre-archive 7-row checklist
- [x] 6.1 Generics threaded: `VmSandboxHandle<Caps>` parameter flows through `createVmSandbox<Caps>`
- [x] 6.2 Zod-equivalent schema gating: `PermissionsManifest` typed boundary (api-types) drives `createPermissionChecker`; capability decisions checked synchronously before host call
- [x] 6.3 Every `SAND_VM.*` code thrown by at least one production path (eval/Function trap, linker refuse, SourceTextModule resolver, dispose, permission denials)
- [x] 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
- [x] 6.5 OTel instruments asserted with real in-memory `MeterProvider` (CUMULATIVE), `metrics.disable()` between cases for clean re-binding
- [x] 6.6 Lifecycle dedup: `dispose()` second/third call is a no-op (test covers triple-dispose)
- [x] 6.7 No retroactive ticks
## 7. Archive
- [x] 7.1 Fold spec delta into `openspec/specs/api-sandbox-vm/spec.md`
- [x] 7.2 Move to `openspec/archive/2026-05-26-api-sandbox-vm/`
- [x] 7.3 Tick `8.2` in umbrella tasks
- [x] 7.4 Refresh `MANIFEST.md`