# Tasks — Add @suaveplan/api-plugin-import > Every checkbox MUST reflect work actually done in this change. No retroactive ticking. ## 1. Spec authoring - [x] 1.1 Read `/mnt/s/web/suaveplan/enterprise/api-plugin-import.md` end-to-end - [x] 1.2 Confirm no prior `openspec/specs/api-plugin-import/spec.md` exists - [x] 1.3 Read `openspec/AGENTS.md` §§ 2a, 6a, 7, 12, 13, 14 - [x] 1.4 Draft `proposal.md` with `## Source mapping` table + `### Excluded from this migration` - [x] 1.5 Source-mapping table cites every requirement to upstream `enterprise/.md` lines OR the "no source line" justification table - [x] 1.6 Draft `specs/api-plugin-import/spec.md` - [x] 1.7 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles ## 2. Implementation - [ ] 2.1 `src/error-codes/error-codes.ts` — `defineCodes("IMPORT", […])` (9 codes) + `ImportError extends SuaveplanError` - [ ] 2.2 `src/types/types.ts` — shared types (ImportFormat, ImportStatus, ColumnMapping, RowError, ImportJobRecord, ImportEventMap, …) - [ ] 2.3 `src/parsers/csv.ts` — `parseCsv`, `parseCsvLine`, `detectColumns`, `streamParseCsv`, `detectHeaders`, `parseStreamLine`, `applyColumnMappings` - [ ] 2.4 `src/parsers/json.ts` — `parseJson` - [ ] 2.5 `src/parsers/xlsx.ts` — `parseXlsx` (TSV-style) - [ ] 2.6 `src/transform/pipeline.ts` — `coerceType`, `validateField`, `transformRow`, `transformRows`, `validateRow`, `validateUnique` - [ ] 2.7 `src/progress/tracker.ts` — `ImportProgressTracker` - [ ] 2.8 `src/store/memory.ts` — `ImportStoreAdapter` interface + `MemoryImportStore` - [ ] 2.9 `src/otel/instruments.ts` — `getImportInstruments`, `resetImportInstruments`, `ImportInstruments` - [ ] 2.10 `src/schemas/options.ts` — `ImportPluginOptionsSchema`, `ImportPluginConfig` - [ ] 2.11 `src/schemas/schemas.ts` — public Zod surface (CreateImportJob, Preview, ImportJobResponse, …) - [ ] 2.12 `src/services/registry-augmentation.ts` — `ServiceRegistry` augmentation for `importService` - [ ] 2.13 `src/service/service.ts` — canonical `ImportService` (EventEmitter, OTel-emit, owner-scoped) - [ ] 2.14 `src/routes/problem-json.ts` — RFC 7807 helper - [ ] 2.15 `src/routes/build-routes.ts` — 5 routes with `requireAuth()` + owner scoping - [ ] 2.16 `src/plugin/plugin.ts` — `createImportPlugin` via `definePlugin` - [ ] 2.17 `src/index.ts` — barrel with explicit named re-exports ## 3. Tests - [ ] 3.1 `src/error-codes/error-codes.test.ts` - [ ] 3.2 `src/parsers/csv.test.ts`, `json.test.ts`, `xlsx.test.ts` - [ ] 3.3 `src/transform/pipeline.test.ts` - [ ] 3.4 `src/progress/tracker.test.ts` - [ ] 3.5 `src/store/memory.test.ts` - [ ] 3.6 `src/otel/instruments.test.ts` - [ ] 3.7 `src/service/service.test.ts` - [ ] 3.8 `src/routes/problem-json.test.ts`, `build-routes.test.ts` - [ ] 3.9 `src/plugin/plugin.test.ts`, `plugin.spec-conformance.test.ts` - [ ] 3.10 Every `it(...)` carries `{ timeout: 5000 }` - [ ] 3.11 Every test imports from `@suaveplan/testing/runner` ## 4. Documentation - [ ] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, full API reference) - [ ] 4.2 `README.md` at package root linking every `.md` under `## Modules` ## 5. Pre-archive 5-gate triple - [ ] 5.1 `bun run check` - [ ] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-import --force` - [ ] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-import` → 100/100/100/100 istanbul - [ ] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-plugin-import` → 0 errors - [ ] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-import --force` ## 6. Pre-archive 9-row checklist (skill §7) - [ ] 6.1 Generics threaded; `expectTypeOf` claims pinned - [ ] 6.2 Zod boundary on every public option bundle - [ ] 6.3 Every IMPORT.* code thrown by ≥1 production path - [ ] 6.4 Strict-mode behaviours tested both on and off where applicable (dry-run vs real, skipDuplicates on/off, onRow filter on/off) - [ ] 6.5 OTel emitted from production paths, asserted via real in-memory `MeterProvider` - [ ] 6.6 Lifecycle dedup tested (route prefix collision, double init) - [ ] 6.7 No retroactive tick - [ ] 6.8 No `export *` in feature barrels - [ ] 6.9 No direct `vitest` / `bun:test` imports in test files ## 7. Archive - [ ] 7.1 Fold spec delta into `openspec/specs/api-plugin-import/spec.md` - [ ] 7.2 Move `openspec/changes/add-api-plugin-import/` → `openspec/archive/2026-05-19-add-api-plugin-import/`