Expand description
Drop classifier (seine): entropy + magic-byte heuristics.
Labels each drop’s plaintext with a class so the deepening stage can pick a class-appropriate codec. Pure-functional, stateless, deterministic — same input always yields the same class.
§Classes
Text— UTF-8 printable, mostly ASCIICode— executable container (ELF, Mach-O, PE)Compressed— already-compressed bytes (gzip, zstd, xz, bz2)Media— image / audio / video container (JPEG, PNG, GIF, MP3, MP4)Sparse— dominated by zero bytesBinary— fallback when no other class fitsIncompressible— high entropy, no magic: random/encrypted; skip codec
§Algorithm
- If the first bytes match a known magic, return that class immediately. Magic detection is the highest-confidence signal.
- Otherwise, compute Shannon entropy over a sample (first 4 KiB):
- < 0.5 →
Sparseif zero-byte ratio is also high, elseText - 0.5–6.5 →
Textif mostly printable, elseBinary - 6.5–7.5 →
Incompressible(likely random/encrypted; skip codec) - ≥ 7.5 →
Incompressible(very high entropy, no magic: same)
- < 0.5 →
- Fall back to
Binary.
Note: Compressed is only ever returned by the magic-byte path
(gzip/zstd/xz streams). High-entropy data without a recognised
magic is Incompressible, not Compressed — the previous label
was a misnomer that caused the writer to attempt (and fail)
compression on random/encrypted input.
Structs§
- Classifier
- A stateless classifier. Holding it in a struct (rather than a free function) leaves room for future configuration without changing the call sites (OCP).
Enums§
- Class
- One of the content classes the seine classifier emits. Each chunk gets exactly one class; the writer’s drop-packing layer routes classes to codecs.
Constants§
- CLASSIFIER_
SAMPLE_ SIZE - Number of bytes at the drop’s start used for classification. The full drop can be megabytes; the first 4 KiB is enough signal.