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

5.3 KiB

Tasks — add-api-plugin-events

1. Spec authoring

  • 1.1 Read ../suaveplan/enterprise/api-plugin-events.md end-to-end
  • 1.2 Confirm openspec/specs/api-plugin-events/ does not pre-exist
  • 1.3 Read openspec/AGENTS.md Sections 0a, 2a, 6a, 7, 12, 13, 14
  • 1.4 Draft proposal.md from openspec/templates/proposal.md
  • 1.5 Fill in ## Source mapping table — every requirement cites a line range OR appears in the "no source line" table with justification
  • 1.6 Draft specs/api-plugin-events/spec.md from openspec/templates/spec-delta.md
  • 1.7 Every requirement in the spec delta carries a **Verified by:** line naming concrete it(...) titles

2. Implementation

  • 2.1 src/error-codes/error-codes.ts — defineCodes("EVENTS_PLUGIN", [...]) with 12 codes; EventsPluginError extends SuaveplanError
  • 2.2 src/schemas/event-schemas.ts — EventSchema, CreateEventSchema, UpdateEventSchema, EventQuerySchema, EventIdParamSchema, EventLocationSchema, EventStatusSchema, AttendeeCountSchema, EventListResponseSchema
  • 2.3 src/schemas/rsvp-schemas.ts — RsvpSchema, RsvpStatusSchema, CreateRsvpSchema, RsvpResponseSchema, AttendeeSchema, AttendeeQuerySchema, AttendeeListResponseSchema, InviteUsersSchema, InviteResponseSchema
  • 2.4 src/schemas/options.ts — EventsPluginOptionsSchema, EventsPluginConfig, EventsPluginConfigInput
  • 2.5 src/otel/instruments.ts — EventsInstruments, getEventsInstruments, resetEventsInstruments
  • 2.6 src/services/registry-augmentation.ts — declare eventRepository, rsvpRepository slots
  • 2.7 src/repositories/event-repository/event-repository.ts — EventRepository implementation (positional $p0-style params over genesis DatabaseAdapter)
  • 2.8 src/repositories/rsvp-repository/rsvp-repository.ts — RsvpRepository implementation
  • 2.9 src/routes/events-routes/events-routes.ts — createEventRoutes with 9 endpoints, OTel emission, error mapping
  • 2.10 src/plugin/plugin.ts — createEventsPlugin factory; onInit registers repositories + augments registry; onReady mounts routes via ctx.getService("app"); onClose clears state
  • 2.11 src/types/types.ts — public types (EventsPluginConfig, EventsPluginEvents, EventRoutesConfig)
  • 2.12 src/index.ts — explicit named re-exports of every public symbol
  • 2.13 surql/tables/event.surql — event, event_rsvp, event_update SCHEMAFULL tables + indexes + helper functions

3. Tests

  • 3.1 src/error-codes/error-codes.test.ts — every code is referenced by a real throw site
  • 3.2 src/schemas/event-schemas.test.ts — Zod boundary positive + negative cases
  • 3.3 src/schemas/rsvp-schemas.test.ts — Zod boundary positive + negative cases
  • 3.4 src/schemas/options.test.ts — EventsPluginOptionsSchema parse + defaults + invalid input
  • 3.5 src/otel/instruments.test.ts — real MeterProvider, asserts instrument shape + emission
  • 3.6 src/repositories/event-repository/event-repository.test.ts — full CRUD + edge cases via stub DatabaseAdapter
  • 3.7 src/repositories/rsvp-repository/rsvp-repository.test.ts — full RSVP surface + edge cases
  • 3.8 src/routes/events-routes/events-routes.test.ts — every route + every status code, auth guard, event emission
  • 3.9 src/plugin/plugin.test.ts — lifecycle, double-mount guard, service registration, missing-dep failure
  • 3.10 src/api-plugin-events.spec-conformance.test.ts — pins public surface
  • 3.11 tests/integration/full-boot.test.ts — real SurrealDB, applies the surql migration, then full plugin boot + CRUD roundtrip
  • 3.12 Every it(...) carries { timeout: 5000 } (or 30000+ for genuinely async)

4. Documentation

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

5. Pre-archive verification (the 5-gate triple)

  • 5.1 bunx turbo lint --filter=@suaveplan/api-plugin-events — green
  • 5.2 bunx turbo typecheck --filter=@suaveplan/api-plugin-events — green
  • 5.3 bunx turbo test --filter=@suaveplan/api-plugin-events — green
  • 5.4 bunx turbo test:coverage --filter=@suaveplan/api-plugin-events — 100/100/100/100
  • 5.5 bunx turbo build --filter=@suaveplan/api-plugin-events — green

6. Pre-archive 7-row checklist (AGENTS.md Section 13)

  • 6.1 Generics threaded; expectTypeOf assertions where literal-type claims exist
  • 6.2 Zod schemas wired at every declared boundary (plugin options, route bodies, query / param)
  • 6.3 Every code in EVENTS_PLUGIN_CODES thrown by at least one production path
  • 6.4 OTel instruments emitted from production paths and asserted with a real in-memory MeterProvider
  • 6.5 Lifecycle dedup tested where claimed (double-mount guard, onClose clears state)
  • 6.6 No retroactive tick — every box above reflects work done in this change
  • 6.7 Test files import only from @suaveplan/testing/runner (rule 11)

7. Archive

  • 7.1 Fold spec delta into openspec/specs/api-plugin-events/spec.md
  • 7.2 Move openspec/changes/add-api-plugin-events/ → openspec/archive/2026-05-19-add-api-plugin-events/