Files
2026-05-27 23:29:53 +01:00

1.4 KiB

Tasks: validation-spec-conformance

1. Implementation drift fixes

  • 1.1 Add withHooks(hooks) method to BaseSchema returning an immutable clone with merged _hooks.
  • 1.2 Invoke beforeValidate / afterValidate / onError from parse (sync) and parseAsync (awaited) at every terminal branch.
  • 1.3 Carry _hooks through _clone() so chained builders preserve hook state.
  • 1.4 Wire recordParseSuccess / recordParseFailure and the duration histogram in parse / parseAsync, tagged with schema.type = this.constructor.name.
  • 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.
  • 1.6 Update src/core/schema/schema.md Features and API Reference to document withHooks and OTel emission.

2. New tests

  • 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

  • 3.1 Add **Verified by:** line under every ### VL-NN requirement in openspec/specs/validation/spec.md (all 12 requirements).

4. Verify

  • 4.1 bunx turbo lint typecheck test --filter=@suaveplan/validation green.
  • 4.2 bunx turbo test:coverage --filter=@suaveplan/validation 100/100/100/100.
  • 4.3 bun scripts/openspec-conformance.ts @suaveplan/validation exits 0.