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

4.7 KiB

Tasks — Add @suaveplan/api-plugin-event-bus

Every checkbox MUST reflect work actually done in this change.

1. Spec authoring

  • 1.1 Confirm package is genesis-native (no upstream enterprise/api-plugin-event-bus.md); enterprise/api-plugin-events.md is a DIFFERENT package deferred to a later wave
  • 1.2 Read openspec/AGENTS.md §§13, 14, 14a
  • 1.3 Read @suaveplan/events source (bus, queue, idempotent, interceptor)
  • 1.4 Read @suaveplan/api-plugin-auth reference implementation
  • 1.5 Draft proposal.md from openspec/templates/proposal.md
  • 1.6 Fill ## Source mapping — every requirement listed in the "no source line" justification table with the canonical genesis-native reason
  • 1.7 Draft specs/api-plugin-event-bus/spec.md with ## ADDED Requirements only; every requirement carries **Verified by:**

2. Package scaffolding

  • 2.1 Create packages/api/api-plugin-event-bus/ with package.json, vite.config.ts, vitest.config.ts, tsconfig.json, tsconfig.lib.json, README.md
  • 2.2 Per-feature src/<feature>/{<feature>.ts, <feature>.md, <feature>.test.ts, index.ts} layout
  • 2.3 tests/setup/polyfills.ts installs in-memory MeterProvider
  • 2.4 Subpath exports map matches the proposal verbatim

3. Implementation

  • 3.1 error-codes/error-codes.ts — 8 EVENT_BUS_* codes + EventBusError
  • 3.2 topic/topic.ts — EVENT_TOPIC_PATTERN, scopeTopic, unscopeTopic, assertValidTopic
  • 3.3 schemas/options.ts — EventBusPluginOptionsSchema (Zod strict)
  • 3.4 schemas/routes.ts — PublishBodySchema, PublishResultSchema, SubscriptionRecordSchema, SubscriptionListSchema, UnsubscribeParamsSchema, UnsubscribeResultSchema
  • 3.5 services/event-bus-service.ts — EventBusService, backpressure wiring, idempotency wiring, tenant scoping
  • 3.6 services/registry-augmentation.ts — declare eventBusService slot
  • 3.7 middleware/request-bus.ts — installs c.set("eventBus", ...) per-request handle
  • 3.8 middleware/context-augmentation.ts — Hono ContextVariableMap.eventBus
  • 3.9 routes/build-routes.ts — 3 OpenAPI routes with requireAuth gate
  • 3.10 otel/instruments.ts — 5 instruments + singleton + reset helper
  • 3.11 plugin/plugin.ts — createEventBusPlugin 6-step onInit
  • 3.12 types/types.ts — public option / config / handle interfaces
  • 3.13 index.ts — explicit named re-exports

4. Tests

  • 4.1 Unit tests per feature module (real @suaveplan/events, no vi.mock)
  • 4.2 src/api-plugin-event-bus.spec-conformance.test.ts — every error code reachable; subpath exports match
  • 4.3 Integration: tests/integration/tenant-isolation.test.ts — A publish does not reach B subscriber; ownership enforced
  • 4.4 Integration: tests/integration/http-routes.test.ts — publish / list / delete end-to-end with auth + tenant middleware
  • 4.5 Every it() carries { timeout: 5000 } (30000 for genuinely async)

5. Documentation

  • 5.1 Sibling .md for every implementation .ts (≥200 words, basic + advanced examples, full API reference)
  • 5.2 README links every co-located .md under ## Modules

6. Pre-archive gates

  • 6.1 cd packages/api/api-plugin-event-bus && bun run check — Biome clean
  • 6.2 bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-event-bus --force — green
  • 6.3 bunx turbo test:coverage --filter=@suaveplan/api-plugin-event-bus — 100/100/100/100
  • 6.4 bun scripts/openspec-conformance.ts @suaveplan/api-plugin-event-bus — exit 0
  • 6.5 bunx turbo build --filter=@suaveplan/api-plugin-event-bus --force — green
  • 6.6 bun scripts/lint/check-test-runner-imports.ts — zero direct vitest/bun:test imports

7. Pre-archive 9-row checklist

  • 7.1 Generics threaded; expectTypeOf assertions on every literal-type claim
  • 7.2 Zod schemas wired at every declared boundary
  • 7.3 Every error code in error-codes.ts thrown by at least one production path
  • 7.4 Strict-mode behaviors tested both on and off where applicable
  • 7.5 OTel instruments emitted from production paths and asserted with a real in-memory MeterProvider
  • 7.6 No vi.mock / no bun:test direct imports / no vitest direct imports
  • 7.7 No export * in feature barrels
  • 7.8 No biome-ignore in src/
  • 7.9 No retroactive tick — every box reflects work done in this change

8. Archive

  • 8.1 Fold specs/api-plugin-event-bus/spec.md into openspec/specs/api-plugin-event-bus/spec.md
  • 8.2 Move openspec/changes/add-api-plugin-event-bus/ → openspec/archive/2026-05-19-add-api-plugin-event-bus/