Skip to Content
DocsLanguageDeterminism Guarantees

Determinism Guarantees

LODE provides deterministic behavior at every level of the pipeline. This is not a feature flag — it is a design invariant.

Encoding Determinism

Given the same source object and schema, compile always produces the identical Uint8Array. This is guaranteed by:

  1. Field order follows schema order — Fields are encoded in the order they appear in the schema, not the order of keys in the source object
  2. Map key sortingmap<string,string> entries are sorted by key before encoding
  3. Fixed-width integers — All lengths use big-endian uint16, no variable-length encoding
  4. No padding or alignment — Fields are packed contiguously with no gaps

Fingerprint Determinism

Given the same logical object (regardless of key order or array order), fingerprint always produces the same SHA-256 hash. This is guaranteed by:

  1. Deep cloning — The original object is never modified
  2. Recursive key sorting — All object keys at every depth are sorted alphabetically
  3. String array sorting — Arrays where all elements are strings are sorted
  4. Compact serializationJSON.stringify with no whitespace or replacer
  5. Consistent hashing — SHA-256 with hex output

What Breaks Determinism

These will cause different fingerprints for “similar” objects:

  • Different values — Obviously, { a: 1 } and { a: 2 } produce different hashes
  • Different types{ count: "5" } and { count: 5 } produce different hashes (string vs number)
  • Non-string array order[1, 2, 3] and [3, 2, 1] produce different hashes (not all strings, so order is preserved)
  • Extra fields{ a: 1 } and { a: 1, b: 2 } produce different hashes

Verification Determinism

verify(vein, hash, schema) is deterministic: same inputs always produce the same boolean result. It combines decode (deterministic binary parsing) and fingerprint (deterministic hashing).

Last updated on