# Tasks: templates-spec-conformance ## 1. Inline drift fixes - [x] 1.1 Add `@opentelemetry/api` runtime dep (`catalog:observability`) to `packages/primitives/templates/package.json`. - [x] 1.2 Create `src/otel/templates-otel.ts` with `recordRender`, `recordPluginCall`, `startRenderTimer`, `_resetInstruments` + sibling `.md`. - [x] 1.3 Wire `recordRender` (success / error) and `recordPluginCall` (success / skip / error) into `TemplateEngine` and `applyPlugin` / `applyPluginAsync`. - [x] 1.4 Validate `TemplateEngineOptions` via `TemplateEngineOptionsSchema.safeParse` in the constructor, throwing `TemplateError(TEMPLATE.PARSE_ERROR)` on failure. - [x] 1.5 Validate `ParseOptions` via `ParseOptionsSchema.safeParse` in `parse` / `parseAsync` when callers pass options. - [x] 1.6 Mark `PluginPrioritySchema` as `// schema: boundary-only`. - [x] 1.7 Add `src/otel/templates-otel.ts` to the `tests/no-disallowed.test.ts` `APPROVED` set so the OTel timing helper can use `Date.now`. ## 2. Spec rewrite (folded) - [x] 2.1 Rewrite `openspec/specs/templates/spec.md` to fourteen `### TPL-NN — name` requirement blocks. - [x] 2.2 Add `**Verified by:**` lines under each requirement naming the test files / cases that pin it. ## 3. Conformance tests - [x] 3.1 `src/__tests__/package-shape.spec-conformance.test.ts` — TPL-01 / TPL-02. - [x] 3.2 `src/__tests__/types.spec-conformance.test.ts` — TPL-04 (PluginPriority enum, SKIP_PLUGIN symbol, generic threading). - [x] 3.3 `src/engine/ParseState.spec-conformance.test.ts` — TPL-05. - [x] 3.4 `src/engine/TemplateEngine.spec-conformance.test.ts` — TPL-06 / TPL-07 / TPL-09. - [x] 3.5 `src/engine/apply-plugin.spec-conformance.test.ts` — TPL-08. - [x] 3.6 `src/errors/template-error.spec-conformance.test.ts` — TPL-03. - [x] 3.7 `src/otel/templates-otel.spec-conformance.test.ts` — TPL-13. - [x] 3.8 `src/plugins/plugins.spec-conformance.test.ts` — TPL-10. - [x] 3.9 `src/presets/presets.spec-conformance.test.ts` — TPL-11. ## 4. Archive hygiene - [x] 4.1 Replace the bulk-archive marker line in `openspec/archive/2026-04-19-enterprise-templates/tasks.md` with a pointer to this change folder. ## 5. Verification - [x] 5.1 `bun scripts/openspec-conformance.ts @suaveplan/templates` — green (no errors; warnings for boundary-only schemas tolerated). - [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/templates` — green. - [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/templates` — 100/100/100/100.