Initial Commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# 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 fallback` test doesn't assert the subclass name appears in `err.stack`.
|
||||
- "Code values are literal-typed" — type-level scenario with no test.
|
||||
- `tasks.md` of `2026-04-19-enterprise-error/` carries `retroactively ticked`.
|
||||
|
||||
## What changes
|
||||
|
||||
1. Add `**Verified by:**` line under every `### Requirement:` block in `openspec/specs/error/spec.md`.
|
||||
2. Add `src/base/suaveplan-error.spec-conformance.test.ts` covering:
|
||||
- "subclass narrows code union" — `expectTypeOf` assertion on `err.code` after `instanceof MySubclass` narrowing.
|
||||
- "stack trace contains subclass name" — `expect(err.stack).toContain("MySubclass")` AND `expect(err.stack).not.toMatch(/^\s*Error\b/)`.
|
||||
3. Add `src/codes/define-codes.spec-conformance.test.ts` covering:
|
||||
- "code values are literal-typed" — `expectTypeOf<typeof codes.A>().toEqualTypeOf<"PKG.A">()`.
|
||||
4. Re-run `bun scripts/openspec-conformance.ts @suaveplan/error` and confirm exit 0.
|
||||
|
||||
## Impact
|
||||
|
||||
- Public API unchanged.
|
||||
- Two new test files (~60 lines combined).
|
||||
- `openspec/specs/error/spec.md` gains 9 `**Verified by:**` lines.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Capability Spec Delta: error (spec-conformance)
|
||||
|
||||
**Package**: `@suaveplan/error`
|
||||
**Status**: PROPOSED
|
||||
|
||||
This delta annotates each existing requirement in `openspec/specs/error/spec.md` with a `**Verified by:**` line. No requirement semantics change.
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
(See `openspec/specs/error/spec.md` for the full requirement bodies; this delta only records the verification mapping.)
|
||||
|
||||
| Requirement | Verified by |
|
||||
|---|---|
|
||||
| Zero workspace and runtime dependencies | `tests/dep-graph.test.ts` AND `tests/no-disallowed.test.ts` |
|
||||
| SuaveplanError base class | `src/base/suaveplan-error.spec-conformance.test.ts` AND `src/base/suaveplan-error.test.ts` |
|
||||
| Stable error-code registry helper | `src/codes/define-codes.test.ts` AND `src/codes/define-codes.spec-conformance.test.ts` |
|
||||
| Cause-chain traversal is cycle-safe and depth-bounded | `src/causes/walk-causes.test.ts` |
|
||||
| Lossless wire serialization | `src/serialize/serialize.test.ts` |
|
||||
| Redaction at the serialization boundary | `src/serialize/serialize.test.ts` AND `src/redact/sensitive.test.ts` |
|
||||
| OTel span event adapter | `src/otel/to-span-event.test.ts` |
|
||||
| i18n-ready messages | `src/i18n/resolver.test.ts` AND `src/base/suaveplan-error.test.ts` |
|
||||
| Test coverage at 100% | `src/serialize/serialize.test.ts` (property-based) + coverage gate |
|
||||
|
||||
## Newly added tests in this change
|
||||
|
||||
- `src/base/suaveplan-error.spec-conformance.test.ts` — pins type-level "subclass narrows code union" and runtime "stack contains subclass name".
|
||||
- `src/codes/define-codes.spec-conformance.test.ts` — pins "code values are literal-typed" type-level scenario.
|
||||
16
openspec/archive/2026-05-02-error-spec-conformance/tasks.md
Normal file
16
openspec/archive/2026-05-02-error-spec-conformance/tasks.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Tasks: error-spec-conformance
|
||||
|
||||
## 1. New tests
|
||||
|
||||
- [x] 1.1 Add `src/base/suaveplan-error.spec-conformance.test.ts` with two cases: subclass code narrowing (type-level via `expectTypeOf`); stack trace contains subclass name (runtime).
|
||||
- [x] 1.2 Add `src/codes/define-codes.spec-conformance.test.ts` with one case: code values are literal-typed (type-level via `expectTypeOf`).
|
||||
|
||||
## 2. Spec annotations
|
||||
|
||||
- [x] 2.1 Add `**Verified by:**` line under every `### Requirement:` block in `openspec/specs/error/spec.md`.
|
||||
|
||||
## 3. Verify
|
||||
|
||||
- [x] 3.1 `bunx turbo lint typecheck test --filter=@suaveplan/error` green.
|
||||
- [x] 3.2 `bunx turbo test:coverage --filter=@suaveplan/error` 100/100/100/100.
|
||||
- [x] 3.3 `bun scripts/openspec-conformance.ts @suaveplan/error` exits 0.
|
||||
Reference in New Issue
Block a user