# Tasks — add-api-plugin-events ## 1. Spec authoring - [x] 1.1 Read `../suaveplan/enterprise/api-plugin-events.md` end-to-end - [x] 1.2 Confirm `openspec/specs/api-plugin-events/` 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 in `## Source mapping` table — every requirement cites a line range OR appears in the "no source line" table with justification - [x] 1.6 Draft `specs/api-plugin-events/spec.md` from `openspec/templates/spec-delta.md` - [x] 1.7 Every requirement in the spec delta carries a `**Verified by:**` line naming concrete `it(...)` titles ## 2. Implementation - [x] 2.1 `src/error-codes/error-codes.ts` — `defineCodes("EVENTS_PLUGIN", [...])` with 12 codes; `EventsPluginError extends SuaveplanError` - [x] 2.2 `src/schemas/event-schemas.ts` — `EventSchema`, `CreateEventSchema`, `UpdateEventSchema`, `EventQuerySchema`, `EventIdParamSchema`, `EventLocationSchema`, `EventStatusSchema`, `AttendeeCountSchema`, `EventListResponseSchema` - [x] 2.3 `src/schemas/rsvp-schemas.ts` — `RsvpSchema`, `RsvpStatusSchema`, `CreateRsvpSchema`, `RsvpResponseSchema`, `AttendeeSchema`, `AttendeeQuerySchema`, `AttendeeListResponseSchema`, `InviteUsersSchema`, `InviteResponseSchema` - [x] 2.4 `src/schemas/options.ts` — `EventsPluginOptionsSchema`, `EventsPluginConfig`, `EventsPluginConfigInput` - [x] 2.5 `src/otel/instruments.ts` — `EventsInstruments`, `getEventsInstruments`, `resetEventsInstruments` - [x] 2.6 `src/services/registry-augmentation.ts` — declare `eventRepository`, `rsvpRepository` slots - [x] 2.7 `src/repositories/event-repository/event-repository.ts` — `EventRepository` implementation (positional `$p0`-style params over genesis `DatabaseAdapter`) - [x] 2.8 `src/repositories/rsvp-repository/rsvp-repository.ts` — `RsvpRepository` implementation - [x] 2.9 `src/routes/events-routes/events-routes.ts` — `createEventRoutes` with 9 endpoints, OTel emission, error mapping - [x] 2.10 `src/plugin/plugin.ts` — `createEventsPlugin` factory; `onInit` registers repositories + augments registry; `onReady` mounts routes via `ctx.getService("app")`; `onClose` clears state - [x] 2.11 `src/types/types.ts` — public types (`EventsPluginConfig`, `EventsPluginEvents`, `EventRoutesConfig`) - [x] 2.12 `src/index.ts` — explicit named re-exports of every public symbol - [x] 2.13 `surql/tables/event.surql` — `event`, `event_rsvp`, `event_update` SCHEMAFULL tables + indexes + helper functions ## 3. Tests - [x] 3.1 `src/error-codes/error-codes.test.ts` — every code is referenced by a real `throw` site - [x] 3.2 `src/schemas/event-schemas.test.ts` — Zod boundary positive + negative cases - [x] 3.3 `src/schemas/rsvp-schemas.test.ts` — Zod boundary positive + negative cases - [x] 3.4 `src/schemas/options.test.ts` — `EventsPluginOptionsSchema` parse + defaults + invalid input - [x] 3.5 `src/otel/instruments.test.ts` — real `MeterProvider`, asserts instrument shape + emission - [x] 3.6 `src/repositories/event-repository/event-repository.test.ts` — full CRUD + edge cases via stub `DatabaseAdapter` - [x] 3.7 `src/repositories/rsvp-repository/rsvp-repository.test.ts` — full RSVP surface + edge cases - [x] 3.8 `src/routes/events-routes/events-routes.test.ts` — every route + every status code, auth guard, event emission - [x] 3.9 `src/plugin/plugin.test.ts` — lifecycle, double-mount guard, service registration, missing-dep failure - [x] 3.10 `src/api-plugin-events.spec-conformance.test.ts` — pins public surface - [x] 3.11 `tests/integration/full-boot.test.ts` — real SurrealDB, applies the surql migration, then full plugin boot + CRUD roundtrip - [x] 3.12 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, full API reference) - [x] 4.2 `README.md` links every co-located `.md` under `## Modules` ## 5. Pre-archive verification (the 5-gate triple) - [x] 5.1 `bunx turbo lint --filter=@suaveplan/api-plugin-events` — green - [x] 5.2 `bunx turbo typecheck --filter=@suaveplan/api-plugin-events` — green - [x] 5.3 `bunx turbo test --filter=@suaveplan/api-plugin-events` — green - [x] 5.4 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-events` — 100/100/100/100 - [x] 5.5 `bunx turbo build --filter=@suaveplan/api-plugin-events` — green ## 6. Pre-archive 7-row checklist (AGENTS.md Section 13) - [x] 6.1 Generics threaded; `expectTypeOf` assertions where literal-type claims exist - [x] 6.2 Zod schemas wired at every declared boundary (plugin options, route bodies, query / param) - [x] 6.3 Every code in `EVENTS_PLUGIN_CODES` thrown by at least one production path - [x] 6.4 OTel instruments emitted from production paths and asserted with a real in-memory `MeterProvider` - [x] 6.5 Lifecycle dedup tested where claimed (double-mount guard, `onClose` clears state) - [x] 6.6 No retroactive tick — every box above 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-events/spec.md` - [x] 7.2 Move `openspec/changes/add-api-plugin-events/` → `openspec/archive/2026-05-19-add-api-plugin-events/`