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

3.6 KiB

Tasks — Add @suaveplan/api-plugin-tenant

Every checkbox MUST reflect work actually done in this change.

1. Spec authoring

  • 1.1 Read ../suaveplan/enterprise/api-plugin-tenant.md end-to-end
  • 1.2 Read @suaveplan/api-tenant README + index.ts (wrapped library)
  • 1.3 Read openspec/AGENTS.md Sections 13 and 14
  • 1.4 Draft proposal.md from openspec/templates/proposal.md
  • 1.5 Fill in ## Source mapping table
  • 1.6 Draft specs/api-plugin-tenant/spec.md from openspec/templates/spec-delta.md
  • 1.7 Every requirement carries a **Verified by:** line

2. Implementation

  • 2.1 src/error-codes/error-codes.ts — 7 TENANT_PLUGIN_* codes via defineCodes
  • 2.2 src/types/types.ts — TenantPluginOptions, TenantPluginConfig, TenantStrategySpec
  • 2.3 src/store/store.ts — TenantStore interface (canonical contract)
  • 2.4 src/store/memory.ts — MemoryTenantStore default in-memory implementation
  • 2.5 src/schemas/options.ts — Zod schemas for TenantPluginOptions
  • 2.6 src/schemas/routes.ts — Zod request/response schemas for CRUD routes
  • 2.7 src/services/tenant-service.ts — TenantService interface + factory
  • 2.8 src/services/registry-augmentation.ts — module augmentation for tenantService
  • 2.9 src/middleware/tenant.ts — middleware install wrapping @suaveplan/api-tenant
  • 2.10 src/routes/routes.ts — buildTenantRoutes() returning PluginRouteEntry[]
  • 2.11 src/plugin/plugin.ts — createTenantPlugin factory + 6-step onInit
  • 2.12 src/otel/instruments.ts — counters + histogram via real MeterProvider
  • 2.13 src/index.ts — explicit named re-exports
  • 2.14 Sibling .md for every implementation file

3. Tests

  • 3.1 Unit tests per feature module — every code path covered
  • 3.2 src/api-plugin-tenant.spec-conformance.test.ts — type / observability / augmentation
  • 3.3 tests/integration/full-boot.test.ts — end-to-end resolver chain + CRUD
  • 3.4 Every it(...) carries { timeout: 5000 } (or higher for integration)

4. Documentation

  • 4.1 Sibling .md for every implementation .ts (≥200 words, basic + advanced examples)
  • 4.2 README links every co-located .md under ## Modules
  • 4.3 No CLAUDE.md update needed (CLAUDE.md does not enumerate api-plugin-* packages individually)

5. Pre-archive verification

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

6. Pre-archive 9-row checklist

  • 6.1 Generics threaded; expectTypeOf where literal-type claims are made
  • 6.2 Zod schemas wired at every declared boundary (options + every CRUD body)
  • 6.3 Every error code in error-codes.ts thrown by at least one production path
  • 6.4 Strict-mode behaviours tested on and off (required: true/false)
  • 6.5 OTel instruments emitted from production paths, asserted with real MeterProvider
  • 6.6 Cache hit/miss tested via TenantCache
  • 6.7 No retroactive ticking
  • 6.8 No export * in feature-module barrels
  • 6.9 No direct vitest / bun:test imports

7. Archive

  • 7.1 Fold spec delta into openspec/specs/api-plugin-tenant/spec.md
  • 7.2 Move change folder to openspec/archive/2026-05-19-add-api-plugin-tenant/