package routing import ( "crypto/sha256" "encoding/binary" ) // CanonicalHash returns a deterministic 64-bit hash of (system, user). // Used to make sample-band routing decisions reproducible: identical input // strings produce the same hash on every call, independent of process state. // // Inputs are joined with a 0x00 byte separator before hashing — distinguishes // (system="ab", user="cd") from (system="abcd", user=""). func CanonicalHash(system, user string) uint64 { h := sha256.New() h.Write([]byte(system)) h.Write([]byte{0}) h.Write([]byte(user)) sum := h.Sum(nil) return binary.BigEndian.Uint64(sum[:8]) }