computeContentHash function

String computeContentHash(
  1. UiNode tree
)

Computes a stable content hash for a UiNode tree (FR-008).

Pure-Dart — no package:crypto dependency required. Uses a deterministic stringification (canonical ordering of map entries) then a 64-bit FNV-1a hash formatted as hex. Good enough for replay/audit trace deduplication.

Implementation

String computeContentHash(UiNode tree) {
  final canonical = _canonicalize(tree);
  // 64-bit FNV-1a.
  var hash = 0xcbf29ce484222325;
  for (final byte in canonical.codeUnits) {
    hash ^= byte;
    hash = (hash * 0x100000001b3) & 0xFFFFFFFFFFFFFFFF;
  }
  return hash.toRadixString(16).padLeft(16, '0');
}