Mostly Quantized

Issue 01 · Data Format Architecture · 56 min · 5 Exhibits · 5 Drills

Data formats:
what bytes promise and cost.

Every data format is a bundle of bets: what the writer guarantees, what the reader may skip, and how failure surfaces. Read the coordinates, and you can judge a format you have never seen.

Teams mistake the format in front of them for the whole design space, copying its accidents as laws. Before arguing over tools, separate the independent choices every format makes—and price each one against the workload.

ONE RECORD · FOUR COORDINATES 2 AXES · 4 PRICES ▲ SELF-DESCRIBING · NAMES OR TAGS IN BYTES JSON · 45 B names in every record legible · 3.2× bytes PNG · chunked 4-byte type per block extensible · opaque CSV · 23 B delimited columns lean · delimiter traps Protobuf · 17 B numbered wire tags dense · needs .proto ▼ SCHEMA-BOUND · READER KNOWS LAYOUT ← TEXT (human-legible) BINARY (machine-dense) →
PLATE 00 · DESIGN COORDINATES MOVE A DOT · PAY A DIFFERENT PRICE
§ 01 · 10 MIN READ

A format is a set of promises, not a file extension

Start with a cheque. Along its bottom edge runs a line of digits printed in magnetic ink: a routing number, an account number, and a cheque number. Nothing in that line explains itself. It works because the clearing system extracted four promises and wrote them down: one nine-digit group is the routing number and passes a check-digit test; another identifies the account; a third names the cheque; and a reader that finds fewer than three groups may reject the item. The digits are not the format. The promises are.

Consider a boarding pass next. The printed slip carries a passenger name in capitals, a route, a seat, and a two-dimensional barcode whose fields sit at fixed offsets: a fixed character count for the name, a filler character for unused space, and a check digit over the document number. The gate scanner does not trust the printer to behave; it trusts the arithmetic embedded in the barcode. Once again, the contract—not the ink—is doing the work.

A data format is the same kind of object. Every format makes four promises, whether or not its specification states them aloud. First, admissible bytes: which byte sequences may appear, in what order, and with what lengths. Second, structural invariants: what a reader may assume without checking—that a length is truthful, that text is well-formed, that a checksum matches, or that a field is present.

Third comes failure behaviour: what happens when a promise breaks—reject the entire input, skip the damaged record, substitute a default, or leave behaviour undefined. Fourth come growth rules: how the admissible set may expand over time, which additions stay legal, which are detectable, and which quietly corrupt older readers. A file extension promises none of these, and neither does a brand name; those are labels for families of contracts whose members frequently disagree.

To see the difference in raw bytes, encode a single purchase order in two ways. The first is a fixed-width record, exactly 23 bytes long:

WIDGET04 00001220261130

The first nine bytes hold the SKU, space-padded to width; the next six hold a zero-padded quantity; the final eight hold the date as YYYYMMDD. This contract is positional: byte 0 always starts the SKU, byte 9 the quantity, and byte 15 the date. A SKU may not contain a space because spaces mean padding, and appending a new column means rewriting the stride of every record ever stored. What the reader buys in return is immediate frame validation—any record shorter than 23 bytes fails before a single field is inspected—though the reader still has to verify that the characters inside each slot are legal digits or SKU bytes.

Now write the same order as a delimited line—also 23 bytes once you include its terminating newline:

WIDGET04,12,2026-11-30

Here the contract is separational: commas divide fields, a newline ends the record, and any field containing a comma or embedded newline must be quoted. Nothing in the framing layer constrains how many bytes a field or a record occupies. That buys painless extensibility: a writer can append a fourth column, and an older reader simply ignores it.

The cost surfaces the instant a wire drops bytes. Slice the last four bytes off the fixed-width record and you hold 19 bytes instead of 23; the reader rejects the frame before touching a field. Slice the last four bytes off WIDGET04,12,2026-11-30 before the newline arrives and you get WIDGET04,12,2026-1: both commas remain intact, all three columns are present, and the delimiter parser succeeds without raising a framing error.

Now reorder those same three columns so the numeric quantity sits in the final slot—WIDGET04,2026-11-30,120000 followed by a newline—and drop the last four bytes (000\n). What reaches the reader is WIDGET04,2026-11-30,120. Both commas survive, every field holds a syntactically legal value, and even a schema-aware type check silently ingests a quantity off by a factor of a thousand. Because total record length was never part of the contract, comma-counting cannot detect truncation inside the trailing field.

Even in twenty-three bytes, those two lines have already settled deep architectural questions: positional against separational, fixed against variable, schema-bound against self-describing. In practice, both contracts are everywhere. The fixed-width layout is the direct ancestor of mainframe record files and packed binary structs; the delimited line is CSV.

Encode the same order in JSON—45 bytes—and the contract shifts a third time. Field names travel alongside their values, strings are escaped rather than comma-quoted, and a grammatical envelope replaces both fixed length and bare delimiters. Drop the last few bytes off a JSON object and you leave an unclosed quote or brace, forcing the parser to fail loudly instead of parsing short—even though the application must still verify types, ranges, and required keys on its own.

The productive question is never which format is better in the abstract. It is which promises your reader actually relies on, and which promises your writer is prepared to keep.

EXHIBIT 01 · FORENSIC BYTE SPECIMEN

Three Encodings of One Order — and What a 4-Byte Wire Drop Does to Each

Same purchase order (WIDGET04, qty 12, date 2026-11-30), three different contracts.

Forensic byte ruler and 4-byte wire-cut stress test across Fixed-width, CSV, and JSON Band A aligns Fixed-width (23 B), CSV (23 B), and JSON (45 B) on a single 0 to 45 byte ruler. Band B drops 4 bytes at EOF: Fixed-width rejects at byte 0 (19 vs 23 B), CSV with quantity last suffers silent 1000x corruption (120000 becomes 120), and JSON fails loudly with a syntax error. A · CLEAN WIRE LAYOUT (1 CELL = 1 BYTE) RULER: 0..45 B 051015202530354045 B FIXED-WIDTH · 23 B space pad (0x20) W I D G E T 0 4 0 0 0 0 1 2 2 0 2 6 1 1 3 0 091523 SKU (9 B) Qty 6 B Date (8 B) positional length=23 is the contract CSV · 23 B , delimiter ↵ newline (\n) W I D G E T 0 4 , 1 2 , 2 0 2 6 - 1 1 - 3 0 ↵ separational commas divide, length unpromised JSON · 45 B 25 B keys/syntax 20 B values grammatical · field names travel (+22 B) { " s k u " : " W I D G E T 0 4 " , " q t y " : 1 2 , " o n " : " 2 0 2 6 - 1 1 - 3 0 " } +22 B beyond 23 B (key & syntax chrome) B · WIRE-CUT STRESS TEST (4 BYTES DROPPED IN TRANSIT) WIRE CUT −4 B FIXED-WIDTH · 19 B ≠ 23 B REJECTED AT BYTE 0 19 B received vs 23 B promised. Framing fails before field parsing. W I D G E T 0 4 0 0 0 0 1 2 2 0 2 6 1 1 3 0 CSV (QTY LAST) · 27 B → 23 B SILENT 1000× CORRUPTION 120000 → 120 (3 fields survive) Both commas intact; parser returns OK. W I D G E T 0 4 , 2 0 2 6 - 1 1 - 3 0 , 1 2 0 0 0 0 ↵ JSON · 45 B → 41 B FAILS LOUDLY (SYNTAX) { " s k u " : " W I D G E T 0 4 " , " q t y " : 1 2 , " o n " : " 2 0 2 6 - 1 1 - 3 0 " } Unclosed string & missing closing brace — parser aborts before returning a record.

IN-PAYLOAD COLLISIONS Space inside SKU breaks Fixed-width padding · Unquoted comma inside SKU shifts CSV columns · JSON escapes both inside quotes.

THE FOUR PROMISES — DELEGATION OF TRUST
Promise
Writer / spec guarantees
Reader stops checking
01Admissible bytes
Writer bounds legal byte alphabet, order, and widths
Reader rejects illegal tokens at the door.
02Structural invariants
Writer guarantees lengths, UTF-8 validity, check digits, or CRCs
Reader skips defensive re-parsing.
03Failure behaviour
Spec pins reject, skip-record, or default on broken input
Readers stop inventing divergent guesses.
04Growth rules
Spec declares legal additions and unknown-field handling
Older readers survive schema evolution without flag-days.
INVARIANT SPECIMEN · ABA MICR CHECK-DIGIT ARITHMETIC (0 2 1 0 0 0 0 2 1)
Weight371371371
Routing021000021
d × w01410000141
3(0+0+0) + 7(2+0+2) + 1(1+0+1) = 30
30 mod 10 = 0 VALID
FIG. 01 · CONTRACT SPECIMEN A file extension (.csv, .json, .bin) promises none of these — only the contract does.
Principle · Insight

A format is the set of assumptions a reader is allowed to skip checking. The more it promises, the heavier the writer's obligation; the less it promises, the more each reader invents its own dialect.

§ 02 · 11 MIN READ

Four axes describe any format you will meet

Take a library's shelf list. For decades it lived on catalogue cards with fixed zones—author, title, date, call number—each starting at a known position on the card. A clerk could locate the publication year without reading the title because position carried the meaning. Compare that with a laboratory notebook: entries run in prose, dates appear wherever the researcher wrote them, and you must parse the language to extract a single fact. Both are records; they simply occupy different points on the same design axes.

The first axis is text against binary. Text buys human legibility, clean diffs, and universal command-line tooling; it pays in byte count and parsing ambiguity. Binary buys compact density and unambiguous field widths; it pays in opacity and the requirement to ship a decoder everywhere the bytes are read.

The second axis is fixed against variable. Fixed-width fields buy constant-time indexing—field k starts at a computable byte offset—along with cheap validation by length. They pay in wasted padding bytes and brittle schema evolution. Variable-length fields reclaim that space, paying instead in length prefixes, delimiters, and the scanning work both imply.

The third axis is delimited against framed. A delimiter reserves a byte pattern that cannot appear raw in the payload without escaping; framing attaches an explicit length or type header that announces where each record ends. Delimited formats are easy to author by hand and treacherous to parse cleanly. Framed formats are effortless for machines to skip and parse, yet awkward to edit raw.

The fourth axis is schema-bound against self-describing. In a schema-bound format, the bytes carry only values and the reader must already know the layout out of band. In a self-describing format, names or type tags ride inside the bytes so an unfamiliar reader can still make sense of them. Schema-bound layouts buy density and strict validation; self-describing layouts buy reach.

The decisive property of these four axes is that they are independent. Binary does not imply schema-bound: PNG chunks, CBOR, and MessagePack are all binary formats that embed type tags or field names directly in the payload. Conversely, text does not imply self-describing: a fixed-width text line or a headerless CSV carries zero field names and is every bit as schema-bound as a C struct. A format is a coordinate, not a camp.

Read together, those four coordinates predict almost everything that will hurt later. Fixed and positional means inserting a column breaks every existing reader. Delimited means payload bytes can collide with separators unless escaped. Schema-bound means the schema never disappears—it simply migrates out of the file and into every reader's build.

Self-describing carries a subtler price governed by amortisation granularity: tagging one multi-megabyte compressed block once costs four bytes total, whereas repeating field names on every single row across ten million records burns hundreds of megabytes.

Familiar formats occupy all four corners of this plane. On the text side, CSV sits at text, variable, delimited, and weakly self-describing (only when an optional header row is present), holding our purchase order in 23 bytes at the cost of delimiter fragility. JSON sits at text, variable, delimited by grammar, and self-describing: every 45-byte record repeats "sku", "qty", and "on" in ASCII so any language can inspect it without an external schema. CSV and JSON are nearest neighbours—sharing three of four axes—and diverge most sharply on whether layout metadata travels with every row.

On the binary side, PNG occupies the self-describing corner: binary, variable, framed, and self-describing by chunk type. Each block announces its byte length and a four-letter name such as IHDR or IDAT, amortising a four-byte label across kilobytes or megabytes of pixel data so an older decoder can safely skip chunks it does not understand.

Protocol Buffers sits across from PNG in the schema-bound binary corner: binary, variable, framed, and schema-bound. None of the ASCII field names ("sku", "qty", "on") ever touch the wire. Instead, each value is prefixed only by a compact integer field number and a wire type, telling the decoder whether a varint or a length-prefixed byte slice follows so unknown field numbers can be skipped cleanly.

That coordinate shrinks our 45-byte JSON order to 17 bytes (0A 08 "WIDGET04" | 10 0C | 18 8A D2 D4 09), compared with 22 bytes for a generic tag-length-value record or 14 bytes for a raw packed binary struct. The space saving is real, and so is the trade: without the external .proto schema mapping field 1 to SKU, field 2 to quantity, and field 3 to date, those 17 bytes are three anonymous numbered values. Moving from JSON to Protocol Buffers never erases schemas—it relocates them from the wire into every producer and consumer. Each corner solves a coherent constraint, and becomes the wrong answer the moment that constraint moves.

EXHIBIT 02 · COORDINATE BLUEPRINT & BYTE ANATOMY

Four Independent Axes — and Where the 310 MB Actually Went

Binary does not imply schema-bound; text does not imply self-describing. Every move relocates complexity.

▲ SELF-DESCRIBING (names or chunk types travel in bytes) ← give up grep · gain density → ▼ names leave the wire → enter every reader’s build JSON 45 B/row text · variable grammar-delimited · self-describing repeats keys on every row PNG chunked binary · variable framed · self-describing amortises 4 B type over MB of pixels CSV 23 B/row text · variable comma-delimited · schema-bound positional columns; optional header Protobuf 17 B/row binary · variable framed · schema-bound field # tags only; needs .proto Packed struct 14 B fixed · framed · schema-bound ▼ SCHEMA-BOUND (layout lives in external code) ← TEXT (legible, greppable, escaping required) BINARY (dense, fixed widths, decoder required) →
PROPORTIONAL BYTE ANATOMY · SAME ORDER (WIDGET04, 12, 2026-11-30) DRAWN TO EXACT SCALE 10 px = 1 B Payload values Framing / tags / delimiters Repeated field names & JSON syntax FORMAT 0 B 10 B 20 B 30 B 40 B 45 B 10M ROWS REL. Packed binary fixed struct 14 B pure payload 8 B sku + 2 B u16 + 4 B u32 · 0 B overhead 140 MB 1.00× 14 B/row Protobuf varint + tags 13 B payload 4 B tags 0A 08 · 10 · 18 + varints 170 MB 1.21× 17 B/row TLV binary tag-len-value 14 B payload 8 B tags skip unknown tags via length 220 MB 1.57× 22 B/row CSV delimited text 20 B ASCII values 3B delimiters ( , , \n ) · ASCII text 230 MB 1.64× 23 B/row JSON self-describing 20 B ASCII values 25 B repeated keys & JSON syntax 450 MB 3.21× 45 B/row 310 MB SAVED AT 10M ROWS schema moved out of the wire and into every reader’s build
REAL WIRE BYTES · PACKED STRUCT VS. PROTOCOL BUFFERS
Packed binary 14 B · 0 B framing
57 49 44 47 45 54 30 34 sku (8 B ASCII) 0C 00 qty (u16 LE = 12) 0A 29 35 01 date (u32 LE = 20261130)
Protocol Buffers 17 B · 4 B tags / 13 B
0A 08 57 49 44 47 45 54 30 34 field #1 len-delim (sku) 10 0C field #2 varint 12 18 8A D2 D4 09 field #3 varint 20261130

Amortisation granularity: Tagging a single 4 MB PNG IDAT chunk once costs 4 bytes total (0.0001%). Repeating "sku", "qty", and "on" across 10,000,000 JSON rows costs 250 MB (55.6% of the file). Self-description is cheap per large block and punishing per tiny row.

FIG. 02 · FOUR-AXIS TOPOLOGY & SCALE Packing saved 310 MB by moving schema knowledge out of the bytes and into code.
Principle · Insight

Because these four axes are independent, 'binary versus text' is never a single decision—it is four decisions disguised as one. Naming all four stops one preference from silently settling the others.

§ 03 · 11 MIN READ

The axes you did not name are the ones that decide

A printed railway timetable and a live departure board carry the same facts under opposite policies. The timetable is eager: every train and every stop is resolved at press time. The departure board is lazy: it resolves only the next departures from a feed that may still change. A faxed signature and a notarised copy divide along a second seam—one is lossy, the other exact. You already reason this way about paper documents; the same discipline governs bytes.

Canonical against permissive. A canonical format admits exactly one byte string for each logical value; a permissive format admits many spellings and asks readers to treat them as equal. Canonical encoding buys deterministic hashes, verifiable signatures, content deduplication, and plain byte-equality checks—at the cost of strict encoder discipline. Permissive encoding tolerates diverse serializers, sacrificing the guarantee that two equal values produce identical bytes.

Eager against lazy. Eager decoding materialises the entire input into an in-memory object tree before the caller touches a field: simple control flow, no random access, and memory proportional to input size. Lazy decoding leaves bytes in place and resolves fields on demand, trading startup speed and random access for the obligation to validate—or trust—every access as it happens.

Exact against lossy. Exact formats preserve every distinction the writer encoded. Lossy formats discard information irreversibly—acceptable when a human eye or ear is the final consumer, poisonous when the bytes feed arithmetic or a cryptographic signature.

Human against machine. Human-first text stays debuggable, greppable, and diffable, but requires escaping rules, grammar parsing, and a character encoding. Machine-first binary is compact and fixed in width, yet opaque without a decoder or a hex dump.

Wire against storage. A wire format models transit: one message at a time, streaming forward, with no indexes. A storage format answers for disk pages, crash durability, and finding one record among billions. The same logical data routinely requires both, and the two encodings rarely look alike.

None of these axes acts in isolation. Canonical versus permissive is empty until you specify exactly what is canonicalised, and eager versus lazy is largely a decoder policy rather than a property stamped into the file. When a format advertises a single headline virtue—"human-readable", "compact", "fast"—it is telling you which axis it wants you to inspect first, and which ones it would rather leave unnamed.

Place real formats on these five axes and familiar production bugs stop looking mysterious. JSON is text, permissive, eager in most parsers, lossy for large integers (values above 2^53 lose precision once decoded into IEEE 754 doubles), and human-first. Engineers routinely try to make JSON signable by sorting object keys alphabetically and stripping whitespace—and still watch signature checks fail across services in production.

The culprit is permissive text's hidden degrees of freedom. 1, 1.0, 1e0, and -0.0 all parse to the same number; "\u0061" and "a" (like "\/" and "/") decode to the same string; Unicode characters can arrive in composed (NFC) or decomposed (NFD) form; and a single trailing newline scrambles every bit of a SHA-256 digest. Until every spelling rule is pinned identically across every language runtime, a hash signs a serializer's dialect, not the underlying value.

DER—Distinguished Encoding Rules, from ASN.1—sits at the opposite pole: binary, canonical, eager, exact within its type system, and machine-first. By admitting strictly one binary byte sequence per value, DER eliminates decimal formatting and whitespace ambiguity altogether, which is why X.509 certificates and content-addressed protocols such as deterministic CBOR sign canonical binary profiles rather than permissive text. A gzip archive occupies a third spot: exact about its decompressed content yet permissive about its wire bytes, since embedded timestamps, header flags, and compressor choices allow the same file compressed twice to yield different hashes.

The decision procedure is to name the deciding axis before arguing over brands. "Should we use JSON or binary?" has no principled answer. "Do we need exactly one byte string per value so signatures verify across independent runtimes?" has a crisp answer—and settles half the candidate list immediately.

EXHIBIT 03 · CANONICALISATION & THE FIVE DEEPER AXES

Six Spellings of One JSON Value — Six Unrelated SHA-256 Digests

Every row below parses to the identical object (a=1, b=2). Change one byte of spelling and roughly half of all 256 digest bits flip.

PART A · SHA-256 AVALANCHE SHATTER LEDGER — ALL SIX SPELLINGS AT ONCE
Spelling & Wire Bytes SHA-256 Digest (first 64b bold) 64-Bit XOR vs A Hamming Diff
A · Canonical 13 B
{"a":1,"b":2}
43258cff783fe7036d8a43033f830adfc60ec037382473548ac742b888292777 0 / 256 baseline
B · Swapped keys 13 B
{"b":2,"a":1}
3fb75453225c732a76b7899ea2096dda1455189c89817239732182f73fe5a09f 131 / 256 51.2% flipped
C · Pretty spaces 18 B
{ "a": 1, "b": 2 }
dff00ea25fe8c50e7aa5c8990614ad8f4ede53b61b821eb029993ada4a58aca3 122 / 256 47.7% flipped
D · Trailing \n 14 B
{"a":1,"b":2}\n
e8d38819d39f705646bfb643368eca78f7db476c16471dbc33b941b27326410d 129 / 256 50.4% flipped
E · Float 1.0 15 B
{"a":1.0,"b":2}
3a5fc11441293773f44e7207ddf4783fdcfc50b78e63e3e484cfcbfe61a8508c 116 / 256 45.3% flipped
F · Unicode \u0061 18 B
{"\u0061":1,"b":2}
d59d2dc570dbbd6d4d7afa4afdc3a9f24cf4c5425dc68038b377f570757dbd57 119 / 256 46.5% flipped

ASN.1 BER vs DER (X.690): BER permits multiple byte spellings per value; X.509 certificates sign DER because one value maps to exactly one byte sequence.

MATCHES CANONICAL A
Bytes 13 B SHA-256 43258cff783fe703… XOR 64b Diff vs A 0 / 256 bits
PART B · FIVE DEEPER AXES — PARALLEL-COORDINATES SPINE
JSON (RFC 8259) ASN.1 DER (X.690) gzip (RFC 1952) CANONICALITY Canonical (1:1) one value, one encoding Permissive many byte spellings PARSE MODEL Random-access seek by byte offset Eager scan parse / inflate from 0 FIDELITY Exact types lossless bytes & ints Lossy (>2⁵³) float64 coercions READERSHIP Machine-first opaque binary wire Human-first inspectable UTF-8 LIFECYCLE Storage / Archive at-rest compression Wire & Certs transit, RPCs, X.509 JSON (RFC 8259) JSON (RFC 8259) JSON (RFC 8259) JSON (RFC 8259) JSON (RFC 8259) ASN.1 DER (X.690) ASN.1 DER (X.690) ASN.1 DER (X.690) ASN.1 DER (X.690) ASN.1 DER (X.690) gzip (RFC 1952) gzip (RFC 1952) gzip (RFC 1952) gzip (RFC 1952) gzip (RFC 1952) COUPLED AXES Every advertised virtue (“human-readable”, “signable”, “compressed”) silently pins your neighbours on the other axes.
FIG. 03 · HASH AVALANCHE & DEEP-AXIS PROFILES A hash signs a spelling, never a meaning — until canonicalisation collapses many spellings to one.
Principle · Insight

A hash is a statement about bytes, never about meaning. To make it testify about meaning, you must collapse every equivalent spelling into one—and that collapse is a design decision, not a library call.

§ 04 · 12 MIN READ

Read a format as a position, not a precedent

A street address is a position: a house number tells you where to look without walking the block. A library shelf mark works the same way—823.914 SMI locates a volume without scanning the stacks because the coordinate scheme, not the neighbouring books, defines its place. Directions, by contrast, are precedents: "the third house past the church" works only from one starting point, and "the book after the atlas" breaks the moment a clerk reshelves a volume. Data formats are addresses. Reading one as a precedent—"do what the winner shipped"—copies a solution stripped of its problem.

Read PNG as a set of coordinates. It is binary, big-endian, chunk-framed, self-describing by chunk type, lossless, parse-on-read, and used on both wire and disk. None of those is a virtue in isolation; each buys one capability and pays a specific bill. Binary buys pixel density; big-endian pins one byte order across CPU architectures; chunk framing enables skipping and resynchronisation; self-describing chunk types allow safe extension; lossless preserves exact pixels; and parse-on-read tolerates compression and unaligned payloads at the cost of CPU on every access.

Its eight-byte file signature is the clearest miniature portrait of design-as-position:

89 50 4E 47 0D 0A 1A 0A

The leading byte, 0x89, has its high bit set so any 7-bit channel that strips bit 7 corrupts the signature visibly. The next three bytes spell ASCII PNG for anyone inspecting a dump. The 0D 0A pair catches transfers that translate DOS CRLF line endings to Unix LF. Byte 0x1A halts a DOS TYPE command from spewing binary noise across a terminal, and the final 0x0A detects Unix-to-DOS LF expansion. Not a single byte is decoration; each is a concrete bet against a transmission failure the designers expected to meet.

Immediately at offset 8 begins the first chunk, IHDR: a four-byte length, a four-byte type, thirteen bytes of image metadata, and a four-byte CRC-32 covering type and data. That twelve-byte envelope is a deliberate framing bet. Any decoder that understands the envelope can skip an unknown chunk in O(1) time—stepping cleanly past length, type, payload, and checksum without interpreting a byte inside—while a mangled signature still causes rejection within the first eight bytes.

Every framing bet also draws a trust boundary. A four-byte length prefix is an untrusted claim until the reader bounds it against both the remaining file size and a hard memory limit. If an attacker sends a 64-byte file whose chunk length reads 0xFFFFFFFF (4 GB) and a naive reader allocates or seeks blindly, O(1) chunk skipping collapses immediately into memory exhaustion or an out-of-bounds read.

The trailing CRC-32 marks a second boundary: it defends against accidental transmission bit-flips, never against a deliberate adversary. Anyone who alters the payload bytes can trivially recompute a matching CRC-32 trailer. Integrity against channel noise is a checksum's job; authenticity against tampering requires a cryptographic MAC or signature.

Now read a Git object the same way. Its uncompressed bytes carry a minimal header—"blob", a space, the decimal byte count (such as blob 12), and a NUL byte—followed by the file content, then zlib-deflated for disk storage. Object identity is the hash of the uncompressed header plus content. Its coordinates: binary on disk, minimally self-describing (the header names the object type), canonical enough for content addressing, storage-oriented, and parse-on-read because the reader must inflate before hashing. The NUL terminates the header; the decimal length gives the reader a bound it can check.

Set both beside an older ancestor at the opposite corner of the design space. ASN.1 is binary, tag-length-value, and schema-bound, pairing one abstract syntax with multiple concrete wire encodings—BER, CER, and DER. That coordinate bought extraordinary generality across telecommunications and security protocols, yet paid in a specification surface so wide that compliant implementations routinely disagreed. None of these formats is a template to imitate blindly. Each is a coordinate you can locate—and its location predicts exactly which workloads it will serve.

EXHIBIT 04 · ARCHITECTURAL BYTE CUTAWAY

The First 33 Bytes of a PNG — Every Byte Answers a Threat

A 1920×1080 8-bit RGBA PNG header laid flat. Read the bytes as deliberate coordinates, not historic precedent.

Exploded 33-byte PNG architectural cutaway blueprint Bytes 00 to 07 form the 8-byte PNG magic signature encoding five transmission traps; bytes 08 to 32 form the self-framed IHDR chunk with 4-byte length, 4-byte type, 13-byte payload for a 1920 by 1080 8-bit RGBA image, and 4-byte CRC-32 checksum with trust-boundary annotations. DECK I · BYTES 00–07 · 8-BYTE MAGIC SIGNATURE 5 transmission traps in 8 bytes 00 01 02 03 04 05 06 07 89 50 4E 47 0D 0A 1A 0A bit7=1 'P' 'N' 'G' CR LF Ctrl-Z LF 01–03 (50 4E 47) · ASCII “PNG” Visibly identifies the file in raw hex dumps without a decoder. 04–05 (0D 0A) · DOS CRLF detector Text-mode DOS→Unix collapses 0D 0A→0A; shifts offsets, fails byte 4. 00 (89) · 7-bit channel trap High bit set (>0x7F); a 7-bit channel strips it to 0x09 (TAB), caught immediately on byte 0. 06 (1A) · DOS EOF stop Halts legacy TYPE file.png console dumps before binary garbage hits the screen. 07 (0A) · Unix LF detector — Catches Unix→DOS text transfer expanding 0A → 0D 0A. DECK II · BYTES 08–32 · FIRST SELF-FRAMED CHUNK (IHDR · 25 B) 1920×1080 · 8-bit RGBA CRC-32 checksum scope · TYPE + DATA (offsets 12–28, 17 B) 08–11 · 4 B LENGTH 00 00 00 0D = 13 B payload O(1) chunk skip 12–15 · 4 B TYPE 49 48 44 52 “IHDR” case: crit. & copy 16–28 · 13 B DATA · IHDR PAYLOAD 00 00 07 80 W = 1920 BE 16–19 00 00 04 38 H = 1080 BE 20–23 08 06 00 00 00 8-bit RGBA · deflate filter 0 · no interlace 29–32 · 4 B CRC-32 E8 D3 C1 43 over 12–28 noise check Letter case encodes criticality & copy-safety 24–28: depth 8, color 6 (RGBA), deflate, filter 0, non-interlaced TRUST BOUNDARY · UNTRUSTED LENGTH CLAIM A hostile 33 B file writing FF FF FF FF (4 GB) triggers OOM or out-of-bounds seek unless bounded against remaining bytes & memory budget before allocating. NOISE CHECK ≠ AUTHENTICITY CRC-32 catches an accidental 1-bit flip (1920→1921), never an adversary: an attacker rewriting width simply recomputes a valid CRC. Authenticity requires a MAC or signature.
CONTRAST POSITION · GIT BLOB OBJECT (20 UNCOMPRESSED BYTES, ZLIB-DEFLATED ON DISK)
20-byte uncompressed Git blob byte schematic Bytes 00 to 06 store ASCII blob 12, byte 07 is a 00 NUL terminator, and bytes 08 to 19 store hello world newline. SHA-1 hashes all 20 uncompressed bytes. SHA-1 content identity covers all 20 uncompressed bytes (00–19) 00–06 · 7 B · HEADER 62 6C 6F 62 20 31 32 “blob 12” · type + decimal length 07 · 1 B 00 NUL 08–19 · 12 B · PAYLOAD 68 65 6C 6C 6F 20 77 6F 72 6C 64 0A “hello world\n” · raw content bytes ASCII variable-width framing terminator exact 12 bytes claimed by header; zlib-deflated on disk
ID = SHA-1(all 20 uncompressed bytes) = 3b18e512dba79e4c8300dd08aeb37f8e728b8dad
Reader must inflate before hashing; NUL separates framing from payload.
FIELD TRIAGE · SIX QUESTIONS TO PLACE ANY UNSEEN FORMAT IN TEN MINUTES
  1. 01Shape

    Self-describing or schema-bound? Fixed layout, tagged fields, or length-framed chunks?

    Read the opening 32 bytes for a magic signature, version coordinate, and whether sizes live inline (PNG chunks, Git ASCII length) or in an external schema.

  2. 02Atomicity

    What survives a crash mid-write?

    Whole-file temp-and-rename (PNG, Git, safetensors) or an append-only log with an explicit commit marker? A checksum alone never guarantees crash recovery.

  3. 03Random Access

    Can a reader jump to record k without scanning bytes 0..k−1?

    Look for a header offset table (safetensors O(1)) or chunk length chains (PNG skip). Outer stream compression (Git zlib) forces sequential inflate first.

  4. 04Canonical Form

    Does one logical value map to one exact byte sequence?

    Mandatory whenever bytes are hashed or signed (Git uncompressed blob). Key ordering, padding, whitespace, and gap rules decide whether two writers match.

  5. 05Concurrency

    Single writer, immutable object, or multi-writer coordination?

    Content-addressed immutable files (Git objects) need zero read locks; mutable containers require external locks, snapshots, or copy-on-write replacement.

  6. 06Trust Boundary

    What breaks when an attacker controls every byte?

    Validate every length prefix and offset against remaining bytes and memory limits before allocating. Checksums catch random noise; authenticity demands a MAC or signature.

60-second test — safetensors: 8-byte header length + JSON offset map + raw tensor buffer with no gaps and no overlaps → self-describing, O(1) random access by offset, canonical by construction, bounds-validated on untrusted input, file-atomic, single-writer.
FIG. 04 · DESIGN AS COORDINATE POSITION Memorising a format copies its accidents; reading its coordinates predicts its failures.
Principle · Insight

A format becomes legible the moment you can state what it bought and what it paid in the same sentence. If you can recite only what it is, you have memorised a precedent, not read a position.

§ 05 · 12 MIN READ

Local best practice is a global trap

A factory standardises on inches because its machines were milled in inches. A city lays tram tracks at the gauge of the fleet it already owns. Both choices are locally rational and globally expensive: the bill arrives years later when a new machine, supplier, or connecting line turns up. Data formats accumulate the exact same sediment.

Teams walk into that trap in three predictable ways. The first is designing for the demo, where the only constraint visible is the one in the README and every operational constraint arrives as an incident. The second is copying the winner's accidents—adopting a ubiquitous format and inheriting its number semantics, escaping rules, and evolution limits without inheriting the environment that made them cheap. The third is picking tools before naming constraints: choosing a library first and letting its default format silently dictate durability, framing, and schema policy.

The way out is arithmetic, not taste. Write down the workload: records per second, bytes per record, retention horizon, reader population, read frequency, and what must never be lost. Then multiply. You do not need a benchmark to learn that 45 bytes per row and 14 bytes per row differ by a factor of three; you need one multiplication.

Run the numbers for a single sensor logging once per second for five years (ignoring leap days): 157,680,000 rows. At 45 bytes per row, the archive consumes 7.1 GB; at 14 bytes per row, it shrinks to 2.2 GB. The packed encoding is 3.21 times smaller—a 69% reduction. That ratio is a mathematical property of the encoding, completely independent of hardware.

Whether a 69% reduction should drive your architecture depends entirely on the binding constraint. Across 10,000 internal configuration rows, the exact same ratio saves just 310 KB (0.45 MB versus 0.14 MB)—invisible on any modern disk or link—while charging you schema distribution, cross-language decoders, and the ability to inspect or diff a broken config at 2 AM.

Now scale that identical 1 Hz logger across 50,000 cellular field sensors. The exact same 3.21x ratio drops five-year volume from 354.8 TB down to 110.4 TB, saving 244 TB of storage and radio battery life. Nothing about either encoding changed; the binding constraint simply flipped from engineer-hours to bandwidth and energy.

The reason JSON keeps winning in small and medium systems is not that engineers stopped caring about bytes. It is that the global constraint is coordination: parsers already exist in every runtime, a human can open and diff the file in a text editor, and onboarding a new consumer takes minutes rather than a schema negotiation. That is a real engineering advantage, priced in engineer-hours instead of gigabytes. The mistake is never choosing JSON; the mistake is believing you chose it for its bytes, or quoting a percentage reduction without multiplying it by your actual row count.

Before importing any best practice, restate the constraint it was built to solve. "Always use text" solved debugging and universal tooling in a world of modest record counts. "Always use binary" solved bandwidth and footprint in a world of controlled readers. Neither rule travels safely without its world.

EXHIBIT 05 · SCALE REGIME CROSSOVER

Same 3.21× Ratio Across Ten Orders of Magnitude — Where the Binding Constraint Flips

Packing cuts 45 B/row to 14 B/row (−68.9%) at every scale. Whether that ratio should decide your format depends on what dominates the bill.

Log-log scale crossover chart comparing JSON (45 B/row), TLV binary (22 B/row), and Packed binary (14 B/row) from 1,000 to 10 trillion rows Three parallel diagonal lines with a constant 3.21x vertical ratio across ten orders of magnitude, overlaid on three regime bands: Coordination Dominates, Inflection Zone, and Bytes and Physics Dominate, with anchors at 10,000 rows, 157.7 million rows, and 7.88 trillion rows. I · COORDINATION KB saved; grep & diffs win II · INFLECTION ZONE Weigh GB vs schema; TLV / Protobuf bridges III · BYTES & PHYSICS Hundreds of TB & radio battery pay for binary SIZE 100 KB 10 MB 1 GB 100 GB 10 TB 1 PB 10³ 1K 10⁵ 100K 10⁷ 10M 10⁹ 1B 10¹¹ 100B 10¹³ 10T TOTAL ROWS WRITTEN (LOG SCALE) JSON45 B TLV22 B Packed14 B 3.21× (−68.9%) constant ratio at every scale 10K rows · Config 0.45 → 0.14 MB −310 KBinvisible 157.7M rows · 1 Hz × 5 yr 7.10 → 2.21 GB −4.89 GB· TLV 3.47 GB 7.88T rows · 50K sensors 354.8 → 110.4 TB −244.4 TB· disk & radio
WORKED ARITHMETIC · THREE REAL SCALES (45 B JSON · 22 B TLV · 14 B PACKED)
REGIME I · COORDINATION
10,000 rowsConfig / Dashboard
JSON (45 B)
0.45 MB
TLV (22 B)
0.22 MB
Packed (14 B)
0.14 MB
Saved
−310 KB (−68.9%)

Pick JSON/CSV — engineer-hours dominate; 310 KB is invisible.

REGIME II · INFLECTION
157.7M rows1 Hz × 5 yr (1 node)
JSON (45 B)
7.10 GB
TLV (22 B)
3.47 GB
Packed (14 B)
2.21 GB
Saved
−4.89 GB (−68.9%)

Inflection — TLV/Protobuf (3.47 GB) trades size for evolution.

REGIME III · PHYSICS & FLEET
7.88T rows50K Cellular Sensors
JSON (45 B)
354.8 TB
TLV (22 B)
173.4 TB
Packed (14 B)
110.4 TB
Saved
−244.4 TB (−68.9%)

Pick framed binary — radio battery & storage dominate.

WHAT THE BYTE COUNT LEAVES OUT
  • External schema & version registry — every packed reader must hold the exact layout version.
  • Cross-language decoder maintenance — each runtime pays a permanent parsing & test bill.
  • 2 AM incident inspection in year six — no human can open or grep packed bytes in an editor.
Physics & Fleet Regime
Rows1.00B
JSON (45 B)45.0 GB
TLV (22 B)22.0 GB
Packed (14 B)14.0 GB
Saved (−68.9%)−31.0 GB
FIG. 05 · ARITHMETIC OVER TASTE A 69% reduction means nothing until you multiply it by your row count — and price the decoder.
Principle · Insight

Best practice is a local solution to someone else's constraint. Before you import it, restate the constraint it solved and verify that you actually share it.

Next: The Burn →
Burn 01 · Post-Mortem Note · What this cost in practice

The zero-copy bet that won its argument and lost the market

WHAT BROKE

Cap'n Proto set out to eliminate the parse step: the wire buffer is the in-memory object graph, fields sit at fixed offsets, and a reader follows pointers without copying or decoding. It delivered exactly that—yet adoption stayed narrow, leaving the format a textbook reference for a trade-off rather than an industry default. The costs it accepted were real: larger padded messages, a rigid layout, schema-coupled evolution, and an ergonomics bill paid by every caller. Systems optimising for wire density, untrusted inputs, or loose schema flexibility went elsewhere. Nothing crashed; the loss was the opportunity cost of perfecting a local optimum.

THE ARCHITECTURAL LESSON

A format succeeds by fitting its adopters' binding constraints, not by winning on elegance. Zero-copy is a bet on read-heavy, trusted, memory-mappable data; most systems face untrusted boundaries, transform payloads, and copy anyway.

SOURCE https://capnproto.org/ — the project's own description of the zero-copy design and its trade-offs. No adoption statistic is claimed; the absence of a default slot is observable, not measured.
GRADED PRACTICE · CLUES & RATIONALE, NO VERBATIM SPOILERS

Five Drills to Lock the Axes In

0 / 5 passed

Every drill grades your reasoning against concrete architectural checkpoints. Missed points return targeted clues — never verbatim answer dumps — alongside why each check is suggested in practice.

DRILL 01 · COMPARE UNGRADED · 4 CHECKS
DIFF 2/5

Three records describe one order: a 23-byte fixed-width line, a 23-byte CSV line, and a 45-byte JSON document. For each, name one promise the reader may rely on without checking, and one promise the reader must verify itself.

Ctrl/Cmd + Enter to grade
DRILL 02 · COMPARE UNGRADED · 4 CHECKS
DIFF 2/5

Place CSV, JSON, PNG and Protocol Buffers on four axes: text/binary, fixed/variable, delimited/framed, schema-bound/self-describing. Which pair is closest, and on which axis do they differ most?

Ctrl/Cmd + Enter to grade
DRILL 03 · PREDICT UNGRADED · 3 CHECKS
DIFF 3/5

A team signs JSON documents by hashing the bytes. Their encoder emits object keys in insertion order and includes a trailing newline only when the writer's template happens to end with one. Predict what breaks when a second service verifies the signature, and name the property the format is missing.

Ctrl/Cmd + Enter to grade
DRILL 04 · DESIGN UNGRADED · 3 CHECKS
DIFF 4/5

Design a format for 200-byte sensor readings taken once per second for eight years in the field. Readers are low-power devices that sometimes need only the timestamp and sometimes the whole reading. State your position on fixed/variable, schema-bound/self-describing, and parse-on-read/zero-copy, and name the cost you accept.

Ctrl/Cmd + Enter to grade
DRILL 05 · PREDICT UNGRADED · 3 CHECKS
DIFF 4/5

A team cuts its storage by about 40% by moving a 10-million-row table from CSV to a packed binary record. Six months later analysts cannot inspect files, a new field is needed, and one downstream team has no decoder. Predict the two costs that were not in the byte count, and name one design change that would have reduced both.

Ctrl/Cmd + Enter to grade
Newsletter · Dispatches

Get Part 02 by email.

Next in this series: Byte Craft—what a single byte can promise, alignment walls, endianness, and framing invariants. One illustrated dispatch when it finishes; no filler, no third-party trackers.

Prefer plain Markdown? Fetch /format-coordinates.md or /llms.txt.

Direct Correspondence · Email Me

Write straight to Femi.

Spotted a corner case in one of the five exhibits, disagreed with a drill checkpoint, or want to discuss wire format architecture for your stack? Email goes straight to me.

Editorial, reader notes & corrections admin@mostlyquantized.com
Direct to Femi · systems audits & research femi@omenworks.dev
Subject topic
Open in mail app ↗ To: admin@mostlyquantized.com