# Tasks — Add `@suaveplan/api-plugin-banking` ## 1. Spec authoring - [x] 1.1 Read `../suaveplan/enterprise/api-plugin-banking.md` end-to-end - [x] 1.2 Verify no prior `openspec/specs/api-plugin-banking/spec.md` exists - [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 `## Source mapping` with line references to upstream - [x] 1.6 Draft `specs/api-plugin-banking/spec.md` from `openspec/templates/spec-delta.md` - [x] 1.7 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles ## 2. Implementation - [x] 2.1 `error-codes/error-codes.ts` — 14 `BANKING.*` codes + `BankingError` class - [x] 2.2 `otel/instruments.ts` — meter + 6 instruments (counters + histograms) - [x] 2.3 `schemas/schemas.ts` — 11 Zod schemas - [x] 2.4 `schemas/options.ts` — `BankingPluginOptionsSchema` factory-options schema - [x] 2.5 `repositories/base-repository.ts` — shared scaffold + field whitelist + RecordId flattening - [x] 2.6 `repositories/bank-repository.ts` — full upstream bank surface retyped - [x] 2.7 `repositories/account-repository.ts` — full upstream account surface retyped - [x] 2.8 `service/service.ts` — `BankingService` coordinator with policy enforcement - [x] 2.9 `routes/build-routes.ts` — 19 OpenAPIHono routes with uniform error mapping - [x] 2.10 `plugin/plugin.ts` — `createBankingPlugin` factory + `decommissionBankingTenant` helper - [x] 2.11 `services/registry-augmentation.ts` — `bankingService` / `app` / `db` slots - [x] 2.12 `types/types.ts` — record aliases, result wrappers, lifecycle event payloads, `BankingEventMap` - [x] 2.13 `index.ts` — explicit named barrel + side-effect imports for error-codes + registry augmentation - [x] 2.14 `surql/001-bank-and-account.surql` — schema migration carried over verbatim ## 3. Tests - [ ] 3.1 Unit tests per feature module (in-memory `FakeDatabaseAdapter` for fast feedback) - [ ] 3.2 `api-plugin-banking.spec-conformance.test.ts` — type-level + barrel pins - [ ] 3.3 Integration test against real SurrealDB testcontainer covering create / transfer / soft-delete / tenant-purge - [ ] 3.4 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for testcontainer-bound cases) ## 4. Documentation - [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, full API reference) - [ ] 4.2 README links every co-located `.md` - [ ] 4.3 STATUS.md row updated post-archival (other-session-owned; skipped per guidance) ## 5. Pre-archive verification (the 5-gate triple) - [ ] 5.1 `bun run check` — Biome 0/0/0 - [ ] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-banking` - [ ] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-banking` - [ ] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-plugin-banking` - [ ] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-banking` ## 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 behaviours tested both on and off (overdraft toggle) - [ ] 6.5 OTel instruments emitted from production paths and asserted with a real in-memory `MeterProvider` - [ ] 6.6 Lifecycle dedup tested where claimed (idempotent default-bank bootstrap) - [ ] 6.7 No retroactive tick - [ ] 6.8 No `export *` in any feature barrel - [ ] 6.9 No direct `vitest` / `bun:test` imports in any test file ## 7. Archive - [ ] 7.1 Fold spec delta into `openspec/specs/api-plugin-banking/spec.md` - [ ] 7.2 Move `openspec/changes/add-api-plugin-banking/` → `openspec/archive/2026-05-19-add-api-plugin-banking/`