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

73 lines
4.9 KiB
Markdown

# Tasks — `@suaveplan/api-router-hono`
> 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
- [x] 1.1 Read design doc `docs/superpowers/specs/2026-05-13-api-plugin-foundation-design.md` (§2.1, §5.2a, §6, §8.1, §13.4, §15 Stage 4)
- [x] 1.2 Read `openspec/changes/api-router/` and `openspec/changes/api-worker-rpc/` for upstream contracts
- [x] 1.3 Read `openspec/AGENTS.md` Sections 13 and 14
- [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md`
- [x] 1.5 Draft `specs/api-router-hono/spec.md` from `openspec/templates/spec-delta.md`
- [x] 1.6 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles
## 2. Implementation
- [ ] 2.1 Scaffold `packages/api/api-router-hono/` with `package.json` (`"version": "0.1.0"`, `"sideEffects": false`, hono as `peerDependencies`)
- [ ] 2.2 `src/options/hono-router-options.ts` — Zod schema for `HonoRouterOptions`
- [ ] 2.3 `src/factory/create-hono-router.ts` — direct-surface `Router` factory backed by Hono
- [ ] 2.4 `src/blue-green/hono-blue-green-slot.ts` — atomic two-instance pointer with health-gated swap
- [ ] 2.5 `src/proxy/create-hono-router-worker-proxy.ts` — `MessagePort`-marshalled proxy via `api-worker-rpc`
- [ ] 2.6 `src/streaming/streaming-bridge.ts` — Hono `ReadableStream` adapter for `streaming: true` routes
- [ ] 2.7 `src/error-codes.ts` — `ROUTER_HONO_*` codes via `defineCodes`
- [ ] 2.8 `src/testing/index.ts` — re-export `runRouterConformance` pre-bound to `createHonoRouter`
- [ ] 2.9 `src/index.ts` — explicit named re-exports (no `export *`)
## 3. Tests
- [ ] 3.1 `src/factory/create-hono-router.test.ts` — direct-surface unit tests
- [ ] 3.2 `src/factory/create-hono-router.spec-conformance.test.ts` — invokes `runRouterConformance` against the direct factory
- [ ] 3.3 `src/proxy/create-hono-router-worker-proxy.test.ts` — proxy-surface unit tests over `MessageChannel`
- [ ] 3.4 `src/proxy/create-hono-router-worker-proxy.spec-conformance.test.ts` — invokes `runRouterConformance` against the proxy factory
- [ ] 3.5 `src/blue-green/hono-blue-green-slot.test.ts` — swap semantics, in-flight completion, rollback on health failure
- [ ] 3.6 `src/streaming/streaming-bridge.test.ts` — stream chunk preservation, abort propagation
- [ ] 3.7 `tests/integration/integration.test.ts` — boot against real `Bun.serve`
- [ ] 3.8 Every `it(...)` carries `{ timeout: 5000 }` (30000 for genuinely async)
## 4. Documentation
- [ ] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, full API reference)
- [ ] 4.2 README links every co-located `.md` under `## Modules`
- [ ] 4.3 Register `@suaveplan/api-router-hono` as the production router adapter in `@suaveplan/api-host`'s adapter table documentation
## 5. Pre-archive verification (the 5-gate triple)
- [ ] 5.1 `bun run check` — Biome 0 errors / 0 warnings / 0 info
- [ ] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/api-router-hono` — green
- [ ] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-router-hono` — 100/100/100/100
- [ ] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-router-hono` — exit 0
- [ ] 5.5 `bunx turbo build --filter=@suaveplan/api-router-hono` — green
## 6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- [ ] 6.1 Generics threaded through every `Router` method signature; `expectTypeOf` assertions on route-handler typing
- [ ] 6.2 Zod schemas wired at the `HonoRouterOptions` boundary
- [ ] 6.3 Every `ROUTER_HONO_*` error code thrown by at least one production path
- [ ] 6.4 Strict-mode behaviors (trustProxy on/off, maxBodyBytes enforcement) tested both on and off
- [ ] 6.5 OTel instruments emitted from production paths (route-match histogram, swap counter) asserted with in-memory `MeterProvider`
- [ ] 6.6 Blue-green swap dedup tested (concurrent `swap()` calls collapse to one)
- [ ] 6.7 No retroactive tick — every box above reflects work done in this change
## 7. Archive
- [ ] 7.1 Fold spec delta into `openspec/specs/api-router-hono/spec.md`
- [ ] 7.2 Move `openspec/changes/api-router-hono/` → `openspec/archive/<yyyy-mm-dd>-api-router-hono/`
- [ ] 7.3 Tick the corresponding Stage 4 box in umbrella `openspec/changes/api-plugin-foundation/tasks.md`
- [ ] 7.4 Refresh `MANIFEST.md`