2.2 KiB
2.2 KiB
OpenSpec Change: error-spec-conformance
- Change ID: error-spec-conformance
- Package:
@suaveplan/error - Status: PROPOSED
- Date: 2026-04-26
Summary
Add **Verified by:** lines to every requirement in openspec/specs/error/spec.md, fill the three missing test scenarios (subclass narrows code union, stack trace contains subclass name, code values are literal-typed), and rectify the retroactively ticked historical hazard so bun scripts/openspec-conformance.ts @suaveplan/error exits 0. No public-API changes.
Current state
@suaveplan/error is structurally solid: SuaveplanError base class, defineCodes registry helper, cycle-safe walkCauses, lossless JSON/binary serialization with markSensitive redaction, toSpanEvent adapter, setMessageResolver i18n hook, fast-check property-based round-trip, 100% coverage. The conformance gaps are documentary plus three unwritten test scenarios:
- 9/9 requirements lack
**Verified by:**lines. - "Subclass narrows code union" — the spec asserts type-level inference but no test pins it.
- "Stack trace preserved" — the existing
captureStackTrace fallbacktest doesn't assert the subclass name appears inerr.stack. - "Code values are literal-typed" — type-level scenario with no test.
tasks.mdof2026-04-19-enterprise-error/carriesretroactively ticked.
What changes
- Add
**Verified by:**line under every### Requirement:block inopenspec/specs/error/spec.md. - Add
src/base/suaveplan-error.spec-conformance.test.tscovering:- "subclass narrows code union" —
expectTypeOfassertion onerr.codeafterinstanceof MySubclassnarrowing. - "stack trace contains subclass name" —
expect(err.stack).toContain("MySubclass")ANDexpect(err.stack).not.toMatch(/^\s*Error\b/).
- "subclass narrows code union" —
- Add
src/codes/define-codes.spec-conformance.test.tscovering:- "code values are literal-typed" —
expectTypeOf<typeof codes.A>().toEqualTypeOf<"PKG.A">().
- "code values are literal-typed" —
- Re-run
bun scripts/openspec-conformance.ts @suaveplan/errorand confirm exit 0.
Impact
- Public API unchanged.
- Two new test files (~60 lines combined).
openspec/specs/error/spec.mdgains 9**Verified by:**lines.