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:
- 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
- Map key sorting —
map<string,string>entries are sorted by key before encoding - Fixed-width integers — All lengths use big-endian uint16, no variable-length encoding
- 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:
- Deep cloning — The original object is never modified
- Recursive key sorting — All object keys at every depth are sorted alphabetically
- String array sorting — Arrays where all elements are strings are sorted
- Compact serialization —
JSON.stringifywith no whitespace or replacer - 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