AITrace.Hash (AITrace v0.2.0)

Copy Markdown View Source

Deterministic content hashing helpers for trace compatibility.

These helpers are intentionally value-oriented. They normalize maps, atoms, lists, tuples, numbers, and binaries before SHA-256 hashing, so callers can produce stable refs without depending on runtime map ordering.

Summary

Functions

Hashes raw binary content as lowercase SHA-256 hex.

Hashes a transcript represented as role/content maps.

Hashes trace metadata maps.

Normalizes a value into the deterministic shape used by term/1.

Hashes any term with deterministic normalization and serialization.

Hashes text or response payloads.

Types

hash()

@type hash() :: String.t()

Functions

bytes(binary)

@spec bytes(binary()) :: hash()

Hashes raw binary content as lowercase SHA-256 hex.

messages(messages)

@spec messages([map()]) :: hash()

Hashes a transcript represented as role/content maps.

metadata(map)

@spec metadata(map()) :: hash()

Hashes trace metadata maps.

normalize_for_hash(value)

@spec normalize_for_hash(term()) :: term()

Normalizes a value into the deterministic shape used by term/1.

term(value)

@spec term(term()) :: hash()

Hashes any term with deterministic normalization and serialization.

text(value)

@spec text(String.t()) :: hash()

Hashes text or response payloads.