Files
suaveplan/openspec/archive/2026-05-25-api-router/tasks.md
2026-05-27 23:29:53 +01:00

3.8 KiB

Tasks — @suaveplan/api-router

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 §6 (per-request pipeline), §7 (OpenAPI / route options), §8.1 (blue-green slots), §10.7 (GraphQL coexistence)
  • 1.2 Read openspec/specs/api-router/spec.md (does not exist yet)
  • 1.3 Read openspec/AGENTS.md Sections 13 and 14
  • 1.4 Draft proposal.md
  • 1.5 Source-mapping table — every requirement cites design-doc section
  • 1.6 Draft specs/api-router/spec.md
  • 1.7 Every requirement has a **Verified by:** line

2. Implementation

  • 2.1 Scaffold packages/api/api-router/ ("version": "0.1.0", "sideEffects": false, deps: @suaveplan/api-types, @suaveplan/error, @suaveplan/types, zod)
  • 2.2 src/router/ — abstract Router interface + ambient defaults
  • 2.3 src/request/ — host-side Request type
  • 2.4 src/response/ — host-side Response builder shape + constructor
  • 2.5 src/route-options/ — Zod schema (import z from "zod"); inferred type matches api-types
  • 2.6 src/middleware/ — Middleware type + composeMiddleware + insertion-point guard
  • 2.7 src/route-match/ — RouteMatch type
  • 2.8 src/slot/ — RouterSlot + BlueGreenSlot interfaces (no concrete impl)
  • 2.9 src/error-codes/ — ROUTER_CODES: ROUTE_COLLISION, INVALID_PREFIX, MIDDLEWARE_INSERTION_DENIED, SLOT_FLIP_FAILED, SLOT_DISPOSE_TIMEOUT
  • 2.10 src/testing/ — runRouterConformance(factory) harness
  • 2.11 src/index.ts — explicit named re-exports
  • 2.12 package.json exports — one subpath per category

3. Tests

  • 3.1 Unit tests per feature
  • 3.2 Spec-conformance tests (type-level + Zod inference)
  • 3.3 Property test on composeMiddleware (chain order is preserved)
  • 3.4 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 Sibling .md for every implementation .ts (≥200 words)
  • 4.2 README.md linking every .md under ## Modules
  • 4.3 No CLAUDE.md update (umbrella covers)

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

  • 5.1 bun run check — Biome 0/0/0
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/api-router — green
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/api-router — 100/100/100/100
  • 5.4 bun scripts/openspec-conformance.ts @suaveplan/api-router — exit 0
  • 5.5 bunx turbo build --filter=@suaveplan/api-router — green

6. Pre-archive 7-row checklist

  • 6.1 Generics on Router<Caps> and Middleware<Caps>; expectTypeOf assertions
  • 6.2 Zod wired at RouteOptions boundary
  • 6.3 Every ROUTER_CODES entry thrown by a production path
  • 6.4 runtimeValidation: true vs false behaviors tested
  • 6.5 OTel — N/A (instruments emitted by adapters, not the contract)
  • 6.6 Lifecycle dedup — N/A
  • 6.7 No retroactive tick

7. Archive

  • 7.1 Fold into openspec/specs/api-router/spec.md
  • 7.2 Move folder to openspec/archive/<yyyy-mm-dd>-api-router/
  • 7.3 Tick 1.3 in umbrella tasks
  • 7.4 Refresh MANIFEST.md