# Tasks — Add @suaveplan/api-plugin-export > Every checkbox MUST reflect work actually done in this change. ## 1. Spec authoring - [x] 1.1 Read `../suaveplan/enterprise/api-plugin-export.md` end-to-end - [x] 1.2 Read upstream `../suaveplan/packages/server/api-plugin-export/src/` end-to-end - [x] 1.3 Read `openspec/AGENTS.md` §§ 2a, 6a, 7, 12, 13, 14 - [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md` - [x] 1.5 Fill `## Source mapping` table — every requirement cites a line range - [x] 1.6 Draft `specs/api-plugin-export/spec.md` with `## ADDED Requirements` - [x] 1.7 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles ## 2. Implementation - [x] 2.1 `src/error-codes/error-codes.ts` — `EXPORT_CODES` (5 codes) + `ExportError` extending `SuaveplanError` - [x] 2.2 `src/types/types.ts` — `ExportFormat`, `ExportStatus`, `ExportOptions`, `ExportResult`, `Exporter`, `DataProvider` - [x] 2.3 `src/schemas/schemas.ts` — `ExportFormatSchema`, `ExportStatusSchema`, `ColumnDefinitionSchema`, `CreateExportJobSchema`, `ExportJobSchema`, `ExportJobListQuerySchema`, `ExportPluginConfigSchema` - [x] 2.4 `src/otel/instruments.ts` — `getExportInstruments()` + `resetExportInstruments()` - [x] 2.5 `src/exporters/csv/csv.ts` — `escapeCsvField`, `formatCellValue`, `convertToCsv`, `CsvExporter` - [x] 2.6 `src/exporters/json/json.ts` — `projectRow`, `convertToJson`, `JsonExporter` - [x] 2.7 `src/exporters/xlsx/xlsx.ts` — `escapeXml`, `columnIndexToLetter`, `formatXlsxCell`, `buildSpreadsheetXml`, `XlsxExporter` - [x] 2.8 `src/services/export-service.ts` — `getExporter`, `inferColumns`, `runExport`, `DEFAULT_EXPORT_CONFIG`, `ExportServiceConfig` - [x] 2.9 `src/routes/exports.ts` — `createExportRoutes(deps)` mounting GET / POST / GET /:id / DELETE /:id - [x] 2.10 `src/plugin/plugin.ts` — `createExportPlugin`, `registerDataProvider` - [x] 2.11 `src/services/registry-augmentation.ts` — augment `ServiceRegistry` with `exportProviders`/`exportJobs`/`app` - [x] 2.12 `src/events/event-augmentation.ts` — augment `EventBusLike` event topics (`export:initialized`, etc.) - [x] 2.13 `src/index.ts` — explicit named re-exports of the full surface; subpath exports in package.json ## 3. Tests - [x] 3.1 `src/exporters/csv/csv.test.ts` - [x] 3.2 `src/exporters/json/json.test.ts` - [x] 3.3 `src/exporters/xlsx/xlsx.test.ts` - [x] 3.4 `src/services/export-service.test.ts` - [x] 3.5 `src/routes/exports.test.ts` — full Hono route exercise via `app.request` - [x] 3.6 `src/plugin/plugin.test.ts` — lifecycle + service registration + event emission against a real `PluginContext` built from `createPluginContext` - [x] 3.7 `src/error-codes/error-codes.test.ts` — every code thrown from a real production path - [x] 3.8 `src/otel/instruments.test.ts` — real in-memory `MeterProvider`, assert counter + histogram emission - [x] 3.9 `src/api-plugin-export.spec-conformance.test.ts` — `expectTypeOf` on public surface - [x] 3.10 `src/schemas/schemas.test.ts` — Zod-boundary assertions - [x] 3.11 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for async) ## 4. Documentation - [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, API reference) - [x] 4.2 README links every co-located `.md` under `## Modules` ## 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-plugin-export` — green - [ ] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-export` — 100/100/100/100 - [ ] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-plugin-export` — exit 0 - [ ] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-export` — green ## 6. Pre-archive 9-row checklist - [ ] 6.1 Generics threaded; `expectTypeOf` assertions on every literal-type claim - [ ] 6.2 Zod schemas wired at every declared boundary - [ ] 6.3 Every error code in `error-codes.ts` thrown by at least one production path - [ ] 6.4 Strict-mode behaviors tested - [ ] 6.5 OTel instruments emitted from production paths and asserted with real in-memory `MeterProvider` - [ ] 6.6 Lifecycle dedup tested - [ ] 6.7 No retroactive tick — every box above reflects work done in this change - [ ] 6.8 No `export *` in any feature-module barrel - [ ] 6.9 No direct `vitest`/`bun:test` imports in test files (all via `@suaveplan/testing/runner`) ## 7. Archive - [ ] 7.1 Fold spec delta into `openspec/specs/api-plugin-export/spec.md` - [ ] 7.2 Move `openspec/changes/add-api-plugin-export/` → `openspec/archive/2026-05-18-add-api-plugin-export/`