# Tasks — Add @suaveplan/api-plugin-tenant > Every checkbox MUST reflect work actually done in this change. ## 1. Spec authoring - [x] 1.1 Read `../suaveplan/enterprise/api-plugin-tenant.md` end-to-end - [x] 1.2 Read `@suaveplan/api-tenant` README + `index.ts` (wrapped library) - [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 Fill in `## Source mapping` table - [x] 1.6 Draft `specs/api-plugin-tenant/spec.md` from `openspec/templates/spec-delta.md` - [x] 1.7 Every requirement carries a `**Verified by:**` line ## 2. Implementation - [x] 2.1 `src/error-codes/error-codes.ts` — 7 `TENANT_PLUGIN_*` codes via `defineCodes` - [x] 2.2 `src/types/types.ts` — `TenantPluginOptions`, `TenantPluginConfig`, `TenantStrategySpec` - [x] 2.3 `src/store/store.ts` — `TenantStore` interface (canonical contract) - [x] 2.4 `src/store/memory.ts` — `MemoryTenantStore` default in-memory implementation - [x] 2.5 `src/schemas/options.ts` — Zod schemas for `TenantPluginOptions` - [x] 2.6 `src/schemas/routes.ts` — Zod request/response schemas for CRUD routes - [x] 2.7 `src/services/tenant-service.ts` — `TenantService` interface + factory - [x] 2.8 `src/services/registry-augmentation.ts` — module augmentation for `tenantService` - [x] 2.9 `src/middleware/tenant.ts` — middleware install wrapping `@suaveplan/api-tenant` - [x] 2.10 `src/routes/routes.ts` — `buildTenantRoutes()` returning `PluginRouteEntry[]` - [x] 2.11 `src/plugin/plugin.ts` — `createTenantPlugin` factory + 6-step `onInit` - [x] 2.12 `src/otel/instruments.ts` — counters + histogram via real `MeterProvider` - [x] 2.13 `src/index.ts` — explicit named re-exports - [x] 2.14 Sibling `.md` for every implementation file ## 3. Tests - [x] 3.1 Unit tests per feature module — every code path covered - [x] 3.2 `src/api-plugin-tenant.spec-conformance.test.ts` — type / observability / augmentation - [x] 3.3 `tests/integration/full-boot.test.ts` — end-to-end resolver chain + CRUD - [x] 3.4 Every `it(...)` carries `{ timeout: 5000 }` (or higher for integration) ## 4. Documentation - [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples) - [x] 4.2 README links every co-located `.md` under `## Modules` - [x] 4.3 No CLAUDE.md update needed (CLAUDE.md does not enumerate `api-plugin-*` packages individually) ## 5. Pre-archive verification - [x] 5.1 `bun run check` — Biome clean - [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-tenant` - [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-tenant` — 100/100/100/100 - [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-plugin-tenant` — exit 0 - [x] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-tenant` - [x] 5.6 `bun scripts/lint/check-test-runner-imports.ts` — exit 0 ## 6. Pre-archive 9-row checklist - [x] 6.1 Generics threaded; `expectTypeOf` where literal-type claims are made - [x] 6.2 Zod schemas wired at every declared boundary (options + every CRUD body) - [x] 6.3 Every error code in `error-codes.ts` thrown by at least one production path - [x] 6.4 Strict-mode behaviours tested on and off (`required: true/false`) - [x] 6.5 OTel instruments emitted from production paths, asserted with real `MeterProvider` - [x] 6.6 Cache hit/miss tested via `TenantCache` - [x] 6.7 No retroactive ticking - [x] 6.8 No `export *` in feature-module barrels - [x] 6.9 No direct `vitest` / `bun:test` imports ## 7. Archive - [x] 7.1 Fold spec delta into `openspec/specs/api-plugin-tenant/spec.md` - [x] 7.2 Move change folder to `openspec/archive/2026-05-19-add-api-plugin-tenant/`