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

3.5 KiB

Capability Spec Delta: mime (spec-conformance)

Package: @suaveplan/mime Status: PROPOSED

This delta annotates each existing requirement in openspec/specs/mime/spec.md with a **Verified by:** line and rectifies two pieces of implementation drift (MIME-07 and MIME-12 / MIME-16 schema invocation). No requirement semantics change.

MODIFIED Requirements

(See openspec/specs/mime/spec.md for the full requirement bodies.)

Requirement Verified by
MIME-01 Magic-byte detection via compiled trie src/detection/detection.magic.test.ts
MIME-02 All-matches magic-byte detection src/detection/detection.magic.test.ts
MIME-03 RFC 7231 Content-Type parsing src/content-type/content-type.test.ts
MIME-04 Content-Type round-trip serialisation src/content-type/content-type.test.ts (incl. property-based)
MIME-05 Content-Type equality and matching src/content-type/content-type.test.ts
MIME-06 Curated IANA-sourced registry src/db/db.test.ts
MIME-07 Runtime registry extension src/db/db.test.ts AND src/db/db.spec-conformance.test.ts
MIME-08 Reverse lookups src/reverse/reverse.test.ts
MIME-09 BOM charset sniffing src/charset/charset.test.ts
MIME-10 HTML meta charset sniffing src/charset/charset.test.ts
MIME-11 XML declaration charset sniffing src/charset/charset.test.ts
MIME-12 Unified detect() src/detection/detection.extension-contenttype.test.ts AND src/db/db.spec-conformance.test.ts
MIME-13 detectFromStream() interim shim src/detection/stream.test.ts
MIME-14 Signature registry extension src/detection/from-magic-bytes/registry.test.ts AND signature-pack tests
MIME-15 Structured errors src/error-codes.test.ts AND src/errors/errors.test.ts
MIME-16 Zod schemas src/schemas/mime.schemas.test.ts AND src/db/db.spec-conformance.test.ts
MIME-17 OTel instrumentation src/telemetry/meters.test.ts
MIME-18 Legacy shim src/legacy/legacy.test.ts
MIME-19 Property-based tests src/content-type/content-type.test.ts (round-trip property) AND src/detection/detection.magic.test.ts::"always returns MagicBytesResult or undefined — never throws" AND src/db/db.test.ts::"every registered entry is retrievable by mime"
MIME-20 Benchmarks src/db/db.spec-conformance.test.ts::"src/__benchmarks__/ exists with the documented bench suites"
MIME-21 sideEffects: false + 100% coverage tests/tree-shake.test.ts AND tests/no-disallowed.test.ts AND coverage gate

Newly added tests in this change

  • src/db/db.spec-conformance.test.ts — pins registerMimeEntry ParseError on invalid shape (MIME-07), detect ParseError on invalid input field types (MIME-12 / MIME-16), and __benchmarks__/mime.bench.ts existence (MIME-20).

Drift fixed inline

  • src/db/registry.ts::registerMimeEntry now invokes MimeEntrySchema.safeParse and throws ParseError on failure.
  • src/detection/detect.ts::detect now invokes DetectInputSchema.safeParse and throws ParseError on field-type mismatches; the at-least-one-source refinement is treated as non-fatal so the documented detect({}) → application/octet-stream default is preserved.
  • SignatureSchema, MagicBytesResultSchema, ExtensionDetectionResultSchema, ContentTypeDetectionResultSchema, StreamDetectionResultSchema, and DetectResultSchema carry // schema: boundary-only markers — they describe cross-process serialisation shapes, not runtime arguments.