Files
suaveplan/openspec/archive/2026-04-27-validation-spec-conformance/tasks.md
2026-05-27 23:29:53 +01:00

25 lines
1.4 KiB
Markdown

# Tasks: validation-spec-conformance
## 1. Implementation drift fixes
- [x] 1.1 Add `withHooks(hooks)` method to `BaseSchema` returning an immutable clone with merged `_hooks`.
- [x] 1.2 Invoke `beforeValidate` / `afterValidate` / `onError` from `parse` (sync) and `parseAsync` (awaited) at every terminal branch.
- [x] 1.3 Carry `_hooks` through `_clone()` so chained builders preserve hook state.
- [x] 1.4 Wire `recordParseSuccess` / `recordParseFailure` and the duration histogram in `parse` / `parseAsync`, tagged with `schema.type = this.constructor.name`.
- [x] 1.5 Re-implement `safeParse` as a `try { return { success: true, data: this.parse(input) } } catch …` shim so OTel + hooks fire on the safe path too.
- [x] 1.6 Update `src/core/schema/schema.md` Features and API Reference to document `withHooks` and OTel emission.
## 2. New tests
- [x] 2.1 Add `src/core/schema/schema.spec-conformance.test.ts` covering VL-01, VL-02, VL-10, VL-11 (sync + async hook paths, OTel counters + histogram via fake MeterProvider).
## 3. Spec annotations
- [x] 3.1 Add `**Verified by:**` line under every `### VL-NN` requirement in `openspec/specs/validation/spec.md` (all 12 requirements).
## 4. Verify
- [x] 4.1 `bunx turbo lint typecheck test --filter=@suaveplan/validation` green.
- [x] 4.2 `bunx turbo test:coverage --filter=@suaveplan/validation` 100/100/100/100.
- [x] 4.3 `bun scripts/openspec-conformance.ts @suaveplan/validation` exits 0.