5.6 KiB
5.6 KiB
Tasks — wire-notification-channels
Every checkbox MUST reflect work actually done in this change. No retroactive ticks.
1. Spec authoring
- 1.1 Read
openspec/archive/2026-05-19-add-api-plugin-notifications/proposal.mdend-to-end - 1.2 Read
openspec/specs/api-plugin-notifications/spec.md(existing canonical spec) - 1.3 Read
openspec/AGENTS.mdSections 6, 13, 14 - 1.4 Draft
proposal.mdfromopenspec/templates/proposal.md - 1.5 Fill in
## Source mappingtable — every requirement cites archived proposal lines or has a "no source line" justification - 1.6 Draft
specs/api-plugin-notifications/spec.mdwith## ADDED Requirements(dispatcher + channels + tracking) and## MODIFIED Requirements(plugin lifecycle, options schema) - 1.7 Every requirement in the spec delta carries a
**Verified by:**line naming concreteit(...)titles
2. Implementation
- 2.1 Add
@suaveplan/notification-channel,@suaveplan/emailer,@suaveplan/delivery-trackingtopackage.jsondependenciesviaworkspace:^ - 2.2 Add new error codes (
DISPATCH_FAILED,DISPATCH_CHANNEL_UNAVAILABLE,DISPATCH_INPUT_INVALID,EMAIL_SERVICE_UNAVAILABLE) tosrc/error-codes/error-codes.ts - 2.3 Add
notificationsDispatchedTotal+notificationsDispatchFailedTotalOTel counters - 2.4 Create
src/channels/apn-channel/module —ApnDeliveryChannelimplementingDeliveryChannel, with sibling.md - 2.5 Create
src/channels/email-channel/module —EmailDeliveryChannelimplementingDeliveryChannel, with sibling.md - 2.6 Create
src/dispatcher/notification-dispatcher/module — wrapsNotificationRouter, emits delivery events, optional idempotency adapter, with sibling.md - 2.7 Create
src/dispatcher/idempotency-adapter/module —DispatcherIdempotencyAdapterinterface +NoopIdempotencyAdapterimpl, with sibling.md - 2.8 Create
src/schemas/dispatch-schemas.ts— ZodDispatchInputSchema+DispatchResultSchema, with sibling.md - 2.9 Extend
src/schemas/options.tswithenableDispatcher,defaultChannel,deliveryfields; existing fields unchanged - 2.10 Extend
src/services/registry-augmentation.tswithnotificationDispatcher,emailServiceslots - 2.11 Extend
src/plugin/plugin.ts—onInitregistersemailService(if injected) +notificationDispatcher(ifenableDispatcher);onCloseclears the dispatcher - 2.12 Extend
src/index.tsto re-export every new public symbol; add per-feature subpath exports inpackage.json
3. Tests
- 3.1
src/channels/apn-channel/apn-channel.test.ts— every behavior (success, per-device failure, missing-token rejection, bulk fan-out viametadata.deviceTokens) - 3.2
src/channels/email-channel/email-channel.test.ts— success, missing subject, transport failure - 3.3
src/dispatcher/notification-dispatcher/notification-dispatcher.test.ts— end-to-end dispatcher: success path, channel-disabled, transport failure, delivery-tracking emission, idempotency dedup, default-channel fallback, OTel emission - 3.4
src/dispatcher/idempotency-adapter/idempotency-adapter.test.ts—NoopIdempotencyAdapterand a fake guard adapter - 3.5
src/schemas/dispatch-schemas.test.ts— Zod boundary tests - 3.6 Extend
src/schemas/options.test.tsto cover the three new fields - 3.7 Extend
src/plugin/plugin.test.tsto cover dispatcher registration + cleanup - 3.8 Extend
src/error-codes/error-codes.test.tsto pin reachability of the four new codes - 3.9 Extend
src/otel/instruments.test.tsto pin the two new counters - 3.10 Extend
src/api-plugin-notifications.spec-conformance.test.tsto pin every new public export - 3.11 Every
it(...)carries{ timeout: 5000 }(or 30000 for genuinely async)
4. Documentation
- 4.1 Sibling
.mdfor every implementation.ts(≥200 words, basic + advanced examples, full API reference) - 4.2 README updated with a
## Dispatchersection linking the new modules
5. Pre-archive verification (the 5-gate triple)
- 5.1
bunx biome check src/— Biome 0 errors from the package folder - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-notifications— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/api-plugin-notifications— 100/100/100/100 istanbul - 5.4
bun scripts/openspec-conformance.ts @suaveplan/api-plugin-notifications— exit 0 - 5.5
bunx turbo build --filter=@suaveplan/api-plugin-notifications— green
6. Pre-archive 9-row checklist (AGENTS.md §13)
- 6.1 Generics threaded;
expectTypeOfassertions on every literal-type claim - 6.2 Zod schemas wired at every declared boundary (DispatchInput, options extension)
- 6.3 Every error code in
error-codes.tsthrown by at least one production path (incl. the four new codes) - 6.4 Strict-mode behaviors tested both on and off where applicable
- 6.5 OTel instruments emitted from production paths and asserted with a real in-memory
MeterProvider - 6.6 Lifecycle dedup tested (idempotency adapter exercised)
- 6.7 No banned patterns — no
vi.mock, noexport *in feature barrels, no// biome-ignore, test files only import from@suaveplan/testing/runner - 6.8 Sibling
.md≥200 words for every implementation file - 6.9 No retroactive tick — every box above reflects work done in this change
7. Archive
- 7.1 Fold
## ADDED+## MODIFIEDRequirements intoopenspec/specs/api-plugin-notifications/spec.md - 7.2 Move
openspec/changes/wire-notification-channels/→openspec/archive/2026-05-19-wire-notification-channels/