Crate ifc_lite_diff

Crate ifc_lite_diff 

Source
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:

  1. 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].
  2. ECMAScript number formatting is not Rust’s Display. 1e21 renders as 1e+21, not 1000000000000000000000. Handled by ryu-js.
  3. JSON.stringify preserves key order; stableSerialize sorts. 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§

DocumentValue

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.