Files
suaveplan/openspec/archive/2026-05-19-add-api-plugin-notifications/tasks.md
2026-05-27 23:29:53 +01:00

75 lines
4.6 KiB
Markdown

# Tasks — add-api-plugin-notifications
## 1. Spec authoring
- [x] 1.1 Read `../suaveplan/enterprise/api-plugin-notifications.md` end-to-end
- [x] 1.2 Confirm `openspec/specs/api-plugin-notifications/` does not pre-exist
- [x] 1.3 Read `openspec/AGENTS.md` Sections 0a, 2a, 6a, 7, 12, 13, 14
- [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md`
- [x] 1.5 Fill `## Source mapping` table
- [x] 1.6 Draft `specs/api-plugin-notifications/spec.md` from `openspec/templates/spec-delta.md`
- [x] 1.7 Every requirement in the spec delta carries a `**Verified by:**` line
## 2. Implementation
- [x] 2.1 `src/error-codes/error-codes.ts` — `defineCodes("NOTIFICATIONS_PLUGIN", [...])` with 18 codes
- [x] 2.2 `src/schemas/notification-schemas.ts` — notification entity + wire schemas
- [x] 2.3 `src/schemas/push-schemas.ts` — device-token + push wire schemas
- [x] 2.4 `src/schemas/options.ts` — `NotificationsPluginOptionsSchema`, `ApnConfigSchema`
- [x] 2.5 `src/otel/instruments.ts` — `NotificationsInstruments`, lazy memoised factory
- [x] 2.6 `src/services/registry-augmentation.ts` — declare repo + APN slots
- [x] 2.7 `src/repositories/notification-repository/notification-repository.ts` — full repository over positional SurQL
- [x] 2.8 `src/repositories/device-token-repository/device-token-repository.ts` — full repository over positional SurQL
- [x] 2.9 `src/transport/apn-transport/apn-transport.ts` — `MemoryApnTransport` + factory + interface
- [x] 2.10 `src/services/apn-service/apn-service.ts` — `ApnService` with pluggable transport
- [x] 2.11 `src/routes/notifications-routes/notifications-routes.ts` — 11 endpoints with OTel + event-bus emission
- [x] 2.12 `src/routes/push-routes/push-routes.ts` — 5 endpoints
- [x] 2.13 `src/plugin/plugin.ts` — factory + onInit / onReady / onClose
- [x] 2.14 `src/types/types.ts` — public types
- [x] 2.15 `src/index.ts` — explicit named re-exports
- [x] 2.16 `surql/tables/notification.surql` + `surql/tables/device_token.surql`
## 3. Tests
- [x] 3.1 `src/error-codes/error-codes.test.ts` — every code referenced from a real throw site
- [x] 3.2 `src/schemas/*.test.ts` — Zod boundary positive + negative cases
- [x] 3.3 `src/otel/instruments.test.ts` — real `MeterProvider`, asserts emission
- [x] 3.4 `src/repositories/notification-repository/notification-repository.test.ts` — full CRUD
- [x] 3.5 `src/repositories/device-token-repository/device-token-repository.test.ts` — full CRUD
- [x] 3.6 `src/transport/apn-transport/apn-transport.test.ts` — `MemoryApnTransport` paths
- [x] 3.7 `src/services/apn-service/apn-service.test.ts` — every error branch
- [x] 3.8 `src/routes/notifications-routes/notifications-routes.test.ts` — every route + status code + auth + ownership
- [x] 3.9 `src/routes/push-routes/push-routes.test.ts` — every route + status code
- [x] 3.10 `src/plugin/plugin.test.ts` — lifecycle, double-mount, missing dep
- [x] 3.11 `src/api-plugin-notifications.spec-conformance.test.ts` — pins public surface
- [x] 3.12 `tests/integration/full-boot.test.ts` — real SurrealDB, boots plugin + CRUD roundtrip
- [x] 3.13 Every `it(...)` carries `{ timeout: 5000 }` (or 30000+ for genuinely async)
## 4. Documentation
- [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples)
- [x] 4.2 `README.md` links every co-located `.md` under `## Modules`
## 5. Pre-archive verification (the 5-gate triple)
- [x] 5.1 `bun run check` — green
- [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-notifications` — green
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-notifications` — 100/100/100/100
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/api-plugin-notifications` — 0 errors
- [x] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-notifications` — green
## 6. Pre-archive 7-row checklist (AGENTS.md §13)
- [x] 6.1 Generics threaded; `expectTypeOf` assertions where literal-type claims exist
- [x] 6.2 Zod schemas wired at every declared boundary
- [x] 6.3 Every code in `NOTIFICATIONS_PLUGIN_CODES` thrown by ≥1 production path
- [x] 6.4 OTel instruments emitted from production paths and asserted with real `MeterProvider`
- [x] 6.5 Lifecycle dedup tested (double-mount guard, `onClose` clears state)
- [x] 6.6 No retroactive tick — every box reflects work done in this change
- [x] 6.7 Test files import only from `@suaveplan/testing/runner` (rule 11)
## 7. Archive
- [x] 7.1 Fold spec delta into `openspec/specs/api-plugin-notifications/spec.md`
- [x] 7.2 Move `openspec/changes/add-api-plugin-notifications/` → `openspec/archive/2026-05-19-add-api-plugin-notifications/`