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

5.4 KiB

Tasks — Add @suaveplan/api-plugin-cms

Every checkbox MUST reflect work actually done in this change. Do not retroactively tick boxes for work that was already in main when this change opened. Do not tick a box for a test that doesn't exist or doesn't pin the requirement it claims to verify. Retroactive ticking is the failure mode this template guards against.

1. Spec authoring

  • 1.1 Read ../suaveplan/enterprise/api-plugin-cms.md end-to-end
  • 1.2 Read openspec/specs/ for prior art (api-plugin-database, api-plugin-audit) — no existing api-plugin-cms/spec.md
  • 1.3 Read openspec/AGENTS.md Sections 13 and 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-cms/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/types/cms.types.ts — verbatim port of upstream content-model types, slug + validator utilities, status transitions, event map (adapted to EventBus<EventMap> single-payload style)
  • 2.2 src/error-codes/error-codes.ts — defineCodes("CMS", [...]) + CmsError extends SuaveplanError<CmsErrorCode> + six factory helpers
  • 2.3 src/engine/cms-engine.ts — port CmsEngine (model CRUD, content CRUD, query, transitions, versions); compose with EventBus<CmsEventMap>; inject Clock + IdGenerator; emit OTel counters
  • 2.4 src/routes/problem-json.ts — local ProblemDetails + formatProblemJson + respondProblemJson with full CMS_CODES → HTTP status table
  • 2.5 src/schemas/options.ts — Zod CmsPluginOptionsSchema with Clock / IdGenerator accepted as opaque unknown (genesis convention from audit plugin)
  • 2.6 src/otel/instruments.ts — CmsInstruments bundle with counters for the seven engine events + validation failures
  • 2.7 src/services/registry-augmentation.ts — declare module "@suaveplan/api-plugin/service-registry" adding the cms: CmsEngine slot
  • 2.8 src/plugin/plugin.ts — createCmsPlugin(options) factory returning a PluginDescriptor; onInit constructs CmsEngine, registers it; onClose drops the reference
  • 2.9 src/index.ts — barrel with explicit named re-exports + side-effect imports of code registry and registry augmentation

3. Tests

  • 3.1 src/types/cms.types.test.ts — generateSlug, validateContentData, VALID_STATUS_TRANSITIONS
  • 3.2 src/error-codes/error-codes.test.ts — every factory raises expected code; cause chain; instanceof narrowing
  • 3.3 src/engine/cms-engine.test.ts — model + content CRUD, query, transitions, versions, events
  • 3.4 src/engine/cms-engine.spec-conformance.test.ts — determinism with injected Clock/IdGenerator; full code enumeration
  • 3.5 src/routes/problem-json.test.ts — CmsError mapping, generic SuaveplanError, non-error throwables
  • 3.6 src/schemas/options.test.ts — Zod boundary
  • 3.7 src/plugin/plugin.test.ts — descriptor shape, onInit/onClose
  • 3.8 src/otel/instruments.test.ts — counter emission asserted with in-memory MeterProvider
  • 3.9 src/api-plugin-cms.spec-conformance.test.ts — every code thrown from production source, side-effect barrel imports
  • 3.10 tests/dep-graph.test.ts — pins runtime dep set
  • 3.11 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 Sibling .md for every implementation .ts (≥200 words, basic + advanced examples, full API reference)
  • 4.2 README at package root linking every co-located .md
  • 4.3 CLAUDE.md package listing — covered by the api-plugin family entry already present (no edit needed for additive plugin)

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

  • 5.1 bun run check — Biome 0/0/0
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-cms — green
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/api-plugin-cms — 100/100/100/100
  • 5.4 bun scripts/openspec-conformance.ts @suaveplan/api-plugin-cms — exit 0, no error findings
  • 5.5 bunx turbo build --filter=@suaveplan/api-plugin-cms — green

6. Pre-archive 9-row checklist (skill §7)

  • 6.1 Generics threaded; expectTypeOf on every literal-type claim (event-map keys)
  • 6.2 Zod schemas wired at every declared boundary (createCmsPlugin)
  • 6.3 Every error code in error-codes.ts thrown by ≥1 production path
  • 6.4 Strict-mode behaviors tested both on and off — N/A; no strict-mode flag in this package
  • 6.5 OTel instruments emitted from production paths and asserted with real MeterProvider
  • 6.6 Lifecycle dedup tested where claimed — N/A; engine state is per-instance, no in-flight Promise dedup
  • 6.7 No retroactive tick — every box reflects work done in this change
  • 6.8 No export * in any feature-module barrel (no feature-module barrels; flat module per dir)
  • 6.9 No direct vitest / bun:test imports — every test imports @suaveplan/testing/runner

7. Archive

  • 7.1 Fold spec delta into openspec/specs/api-plugin-cms/spec.md
  • 7.2 Move openspec/changes/add-api-plugin-cms/ → openspec/archive/2026-05-19-add-api-plugin-cms/
  • 7.3 Refresh MANIFEST.md — skipped per session protocol (concurrent sessions own MANIFEST.md)