3.3 KiB
3.3 KiB
Tasks: serialize-spec-conformance
1. New tests pinning implicit scenarios
- 1.1 Add
src/codec/json/json-encode.spec-conformance.test.tscovering SZ-02 typed-array round-trip (Int8Array/Int16Array/Int32Array/Uint16Array/Uint32Array/Float32Array/Float64Array) and SZ-03 envelope-shape contract forDate. - 1.2 Add
src/codec/msgpack/msgpack-encode.spec-conformance.test.tscovering SZ-06 byte-identical output for the same structured input across two encode calls.
2. Spec annotations
- 2.1 Add
**Verified by:**line under every### SZ-NN —block inopenspec/specs/serialization/spec.md(12 requirements).
3. Close in scope: SZ-10 wire-format + options validation
- 3.1 Add
src/codec/wire/wire.schemas.tswithWireNodeSchema,TaggedEnvelopeSchema, andvalidateWireNodecovering tagged-envelope and recursive plain-record shapes. Include strict envelope rejection (extra keys, non-string__t). - 3.2 Tighten
src/codec/json/json.schemas.tsto.strict()and addsignalfield validation (duck-typedAbortSignal). - 3.3 Wire
SerializeOptionsSchema/DeserializeOptionsSchema.safeParseinto the publicserialize/deserialize/encodeBinary/decodeBinaryentry points; on rejection throwInvalidOptionsError(new codeSERIALIZE.OPTIONS.INVALID). - 3.4 Wire
validateWireNodeinto the publicdeserializeanddecodeBinaryentry points; on rejection throwMalformedWireError(new codeSERIALIZE.CODEC.MALFORMED_WIRE). Preserve__proto__round-trip by re-using the original parsed value when validation passes. - 3.5 Add
MalformedWireErrorandInvalidOptionsErrortosrc/errors/serialize-error.ts; register codes viadefineCodes; export fromsrc/index.ts. - 3.6 Add
src/codec/wire/wire.schemas.test.tspinning rejection of malformed JSON / msgpack inputs, invalid options, and the schema acceptance set. Add__proto__regression coverage.
4. Close in scope: SZ-11 OTel instrumentation
- 4.1 Add
src/observability/metrics.tsexportinggetSerializeMetrics()andresetSerializeMetrics()with the lazymetrics.getMeter('suaveplan.serialize')singleton pattern from@suaveplan/i18n/@suaveplan/logger. - 4.2 Wire histograms (
serialize.encode.bytes,serialize.decode.bytes,serialize.payload_bytes,serialize.encode.duration_ms,serialize.decode.duration_ms) and counter (serialize.error.totalwithcode+formatlabels) into all four public entry points. - 4.3 Add
src/observability/metrics.test.tsusing a real in-memoryMeterProviderimplementation (conforming class hierarchy, notvi.mock) that records all instrument creation + measurement calls.
5. Close in scope: generic threading on public deserialize entry points
- 5.1 Thread
<T = unknown>throughdeserialize,decodeBinary,legacyDeserialize, anddeserializeEvalSafe. Type-only change; runtime unchanged. - 5.2 Add
expectTypeOfassertions towire.schemas.test.ts,legacy.test.ts, andeval-safe.test.ts.
6. Verify
- 6.1
bunx turbo lint typecheck test --filter=@suaveplan/serializegreen. - 6.2
bunx turbo test:coverage --filter=@suaveplan/serialize100/100/100/100. - 6.3
bun scripts/openspec-conformance.ts @suaveplan/serializeexits 0.