Replace DJB2 with FNV-1a hash and enhance CRDT merge#44
Open
Conversation
…5 tests) - Replace DJB2 with FNV-1a (offset=14695981039346656037, prime=1099511628211) in both interpreter (interp.rs) and C backend (emit.rs) - Add pair/tuple hashing support with tag byte separation - Make nested ContentHash idempotent (hash of hash = same hash) - Extend CRDTMerge: strings (lexicographic max), pairs (componentwise) - Extract fnv1a_feed/fnv1a_hash_value and crdt_merge_values helper functions - Add 15 new tests: pair hashing, idempotency, string merge, pair merge, associativity, commutativity, FNV constants in C output, crdt_merge in C https://claude.ai/code/session_0152RhmcLYA5zwBLumJ9U1Nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor hashing and CRDT merge operations to use industry-standard FNV-1a algorithm instead of DJB2, add support for hashing and merging composite types (Pairs, Strings), and make content hashing idempotent.
Changes
fnv1a_feed()to handlePairandHashvalues with tag bytes (0x01, 0x02) for disambiguationValue::is_hash()check sohash(hash(x)) == hash(x)for all valuesPairtypes and add lexicographic max forStringvalues (LWW-Register semantics)fnv1a_hash_value(),crdt_merge_values()) for reusabilityType
Testing
Checklist
unsafewithout justificationhttps://claude.ai/code/session_0152RhmcLYA5zwBLumJ9U1Nr