Expand description
Store-agnostic entity diff engine for IFC models.
A Rust port of @ifc-lite/diff, carrying the same contract: pure, no I/O,
no parser, no geometry kernel. Callers extract fingerprints from whatever
store they have and this crate compares them.
§Byte-exactness is the contract, not just equal verdicts
The fingerprints this crate produces must be identical strings to the
TypeScript engine’s, not merely consistent within Rust. @ifc-lite/merge
consumes stableHash for its component snapshots, so a hash that differed
would surface as spurious merge conflicts rather than as a test failure.
That is harder than it looks, because the hash is taken over
JSON.stringify output and the digest consumes UTF-16 code units. Three
places where the obvious Rust is wrong, each measured against V8 rather
than assumed:
- UTF-16 code-unit order is not codepoint order.
"\u{E000}"sorts after"\u{10000}"in JavaScript and before it in Rust. See [utf16::cmp_code_units]. - ECMAScript number formatting is not Rust’s
Display.1e21renders as1e+21, not1000000000000000000000. Handled byryu-js. JSON.stringifypreserves key order;stableSerializesorts. Both are used, for different purposes. See [js_json].
Canonical encoding, fingerprints, keyed comparison, content matching,
split/merge, successors, lineage and sidecar wire records are implemented.
The composed comparison entry point is engine::diff_models.
Re-exports§
pub use fingerprint::build_component_fingerprint_entries;pub use fingerprint::build_component_fingerprints;pub use fingerprint::build_data_fingerprint;pub use input::DataFingerprintInput;pub use input::PropertyEntryInput;pub use input::PropertySetInput;pub use input::PropertyValue;pub use input::QuantitySetInput;pub use input::TypeAssignmentInput;
Modules§
- class_
families - columns
- Columnar transport for precomputed fingerprints. JsString dictionaries and numeric buffers cross once; opaque JS references remain in the caller.
- content_
match - Ordered content tiers: geometry+data, geometry-only, then residue/position.
- content_
types - document_
serde - Typed DTO transport over lossless documents. No string escape conventions.
- engine
- Ordered composition of the diff passes. Additive claims never retire keys.
- fingerprint
- Canonical, order-independent data fingerprinting for model diffing.
- geometry_
compare - Shared geometry comparison arithmetic, preserving JS evaluation order (#8042).
- identity_
map - input
- The input shapes an adapter fills in before hashing.
- key_
diff - The GlobalId classification pass, before optional content matching (#8042).
- lineage
- model
- Store-independent comparison inputs and key-pass results (#8042).
- mutual_
nearest - sidecar
- Typed sidecar wire records. Validation and normalization are separate from serialization, as in the TypeScript API.
- sidecar_
document - Creation, parsing, validation and serialization of lossless sidecar documents.
- sidecar_
validation - Structural validation of untrusted sidecar JSON. The host supplies its date parser predicate: the JS facade uses Date.parse, including legacy formats.
- sparse_
collection - Fingerprint collection slots. Absent array indices are content (#8042).
- split_
evidence - Volume evidence for additive split/merge claims (#8042).
- split_
geometry - Box predicates for split/merge evidence (#8042).
- split_
grid - Bounded uniform-grid candidate lookup and deterministic proximity clusters.
- split_
merge - split_
types - successor
- Additive replacement-in-place claims, after content and split/merge (#8042).
- transport_
options - transport_
result - Result transport contains row indices, never copied adapter references.
Structs§
- JsHash
- Pass-through hashing for maps keyed by
JsString(#8351): its digest is already keyed, so a second keyed round per probe buys nothing. - JsString
- JavaScript strings are UTF-16 sequences, including unpaired surrogates. Keep a scalar view only when it exists; equality, hashing and ordering use the original code units, never a replacement-character projection.
Enums§
Functions§
- stable_
hash - 64-bit FNV-1a over the string’s UTF-16 code units, rendered as 16 lowercase hex digits, zero-padded.
- stable_
hash_ units - Hash raw JS code units, including unpaired surrogates without lossy UTF-8 conversion.