Files
suaveplan/openspec/changes/complete-rng-unification/specs/mime/spec.md
2026-05-27 23:29:53 +01:00

2.0 KiB

Capability Spec Delta: mime (mime)

Package: @suaveplan/mime Status: PROPOSED

Every requirement below carries a **Verified by:** line at authoring time. No exceptions.

MODIFIED Requirements

Requirement: Stream byte source uses a distinct name

The file-scope helper type at src/detection/from-stream.ts (currently type ByteSource = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>) SHALL be renamed to StreamByteSource. The rename removes a cross-package name collision with @suaveplan/crypto-core's and @suaveplan/crypto-utils's ByteSource callable type, which is a distinct concept ((n: number) => Uint8Array). The local StreamByteSource remains file-scope only (not exported from src/detection/from-stream.ts); this change has zero external-consumer impact.

@suaveplan/mime SHALL NOT declare a top-level Rng-shaped type — it has no need for a random-number source and does not appear in the unification audit's "structurally compatible / incompatible" categorisation.

Verified by: packages/data/mime/src/detection/from-stream.ts (declaration type StreamByteSource = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> and parameter source: StreamByteSource) AND packages/data/mime/src/detection/from-stream.test.ts (test names unchanged; runtime unaffected) AND bunx turbo typecheck test --filter=@suaveplan/mime (green with zero assertion edits) AND repo-internal grep grep -rn "ByteSource" packages/data/mime/src/ --include="*.ts" returns only StreamByteSource matches.

Scenario: rename is internal-only

  • WHEN a consumer imports anything from @suaveplan/mime
  • THEN no breaking change is observable — StreamByteSource was never exported

Scenario: detectFromStream signature unchanged at the public boundary

  • WHEN a consumer calls detectFromStream(readableStream)
  • THEN the call typechecks and behaviour is unchanged (the parameter is structurally identical to before — only the local alias name changed)