0188. Binary fingerprints cover wire schemas
- Status: Accepted
- Date: 2026-11-08
- Plan: M9.6,
R02 - Review: Data, schemas and wire formats
Context
Binary placed eight bytes of the target's reflected API signature digest before the payload. API identity intentionally hides newtype representations (ADR-0075). Changing a direct or nested newtype from i64 to u64 therefore allowed old bytes to decode as a different value under the same header.
Decision
Supersede the Binary header clause of ADR-0083. The Binary generator hashes the reflected target and its full reachable wire schema. It uses the deduplicated reference table and the deterministic postorder named table described in ADR-0081. The ordered tables include primitive widths, container arguments, qualified type names, ordered fields and variants, and each newtype's representation. Visibility, derive flags and API signatures are excluded.
FNV-1a-64 starts at the standard offset basis and consumes the
length-prefixed domain harness-binary-schema-1, the
target index, and the length-prefixed reference and named tables
in that order. Shape and reference kinds have explicit one-byte
tags in binary.tn.
Counts and indices are little-endian u64 words. Strings are
prefixed by their byte length. The wire header is the resulting
u64 in big-endian order. Named children continue to encode only
their payloads within the parent.
Alternatives considered
- Change the API hash — exposes opaque representation in compatibility checks and changes consumers unrelated to serialization.
- Add a compiler-provided reflection digest — changes the generator ABI and freshness keys for generators that have no wire schema.
- Accept old headers as a fallback — the old header cannot distinguish the representations that caused the incorrect decode.
Consequences
Regenerate companions. Read retained payloads with the original codec and write them with the regenerated codec. The header detects schema mismatches and supplies no authentication. Public signatures and the payload grammar stay the same.