4.8 KiB
4.8 KiB
OpenSpec Change: testing-spec-conformance
- Change ID: testing-spec-conformance
- Package:
@suaveplan/testing - Status: PROPOSED
- Date: 2026-04-26
Summary
Close five drift items uncovered by bun scripts/openspec-conformance.ts @suaveplan/testing:
**Verified by:**lines on every requirement inopenspec/specs/testing/spec.md(15 reqs, all owned by this package).- Thread a
<TBody = unknown>generic throughRequestBuilder,ResponseBuilder,TestRequest,TestResponse, and the corresponding*BuilderStatetypes so consumers can pin the body type at the call site instead of the public d.ts leaking five: unknownpositions. - Add a
tests/spec-conformance.spec-conformance.test.tspinning the new generic threading viaexpectTypeOf, the dual-runner / sideEffects / subpath-export package-shape assertions, the schemas-leaf-isolation check, and the module-scope determinism scan (Math.random/Date.now/performance.nowallow-list). - Replace the wall-clock fallback in
measureTimeandwithObservabilitywith the existing injectableClocksubstrate (defaultClockby default,FakeClockwhen injected). Removes the last two non-deterministic call sites insrc/outside the allow list. - Tighten
scripts/openspec-conformance.ts: stop matching change folders by token-substring on the folder name (which over-matched 226 reqs acrossenterprise-testing-dom,enterprise-testing-e2e,enterprise-ab-testing,enterprise-network-testing, etc.). Match only via**Package**: @suaveplan/<pkg>inproposal.mdfrontmatter, and only pull active-changespecs/<cap>/spec.mddeltas from changes whose proposal explicitly names this package.
After this change, bun scripts/openspec-conformance.ts @suaveplan/testing exits 0.
Current state
@suaveplan/testing is structurally solid (Layer 0, zero @suaveplan/* workspace deps, 295 passing tests, structured TestingError hierarchy with stable TESTING.<DOMAIN>.<REASON> codes, dual-runner subpath exports, sideEffects: false, fast-check property tests, mitata bench harness). Conformance gaps are documentary plus two real drift items:
- 35/35 requirements lacked
**Verified by:**lines (down from 226 once the conformance script's over-matching was fixed). - 5 public d.ts positions resolved to
: unknown(request-builder.types.d.ts,response-builder.types.d.ts,http.types.d.tsx2,fixture-manager-internals.d.ts). - 2 wall-clock fallback sites (
measureTime,withObservability) bypassed theClocksubstrate documented by the spec's "Module-scope non-determinism absent" scenario. - The conformance script over-matched on folder-name tokens, pulling in unrelated
testing-*change folders.
What changes
- Add
**Verified by:**lines under every### Requirement:block inopenspec/specs/testing/spec.md. Citations name realit(...)test titles insrc/**/*.test.tsandtests/*.test.ts. - Thread
<TBody = unknown>throughRequestBuilder,ResponseBuilder,RequestBuilderState,ResponseBuilderState,TestRequest, andTestResponse. Default generic preserves the existingunknownsurface for zero-config callers. - Add
tests/spec-conformance.spec-conformance.test.ts:expectTypeOfassertions overRequestBuilder<UserPayload>/ResponseBuilder<UserPayload>so the generic threading regresses loudly.package.jsonshape:sideEffects === false, every public surface has a subpath export.- Module-scope determinism: scan
src/forMath.random(/Date.now(/performance.now(outside the allow list (context,fake-clock,memory-store). - Schema-bundle isolation:
*.schemas.tsfiles do not import their sibling implementation file.
measureTime(fn, { clock })andwithObservability({ ..., clock })now route every wall-clock read throughdefaultClock(default) or a caller-suppliedClock. Behaviour identical for zero-config callers.scripts/openspec-conformance.tsswaps the folder-name token regex for a frontmatter check and only pulls active-changespecs/<cap>/spec.mddeltas from changes explicitly tagged**Package**: @suaveplan/<pkg>.
Impact
- Public API: additive —
RequestBuilder,ResponseBuilder,TestRequest,TestResponsegain an optional<TBody>generic withunknowndefault.measureTimeandwithObservabilitygain an optionalclockoption. - Tests: 7 new
itblocks undertests/spec-conformance.spec-conformance.test.ts. Existing 295 tests unchanged. - Spec: 15
**Verified by:**lines folded intoopenspec/specs/testing/spec.md. Two stalepackages/universal/testing/path references corrected topackages/dev/testing/. - Tooling:
scripts/openspec-conformance.tsmatching tightened. Affects every package's audit but downward-only (fewer false-positive folders).